akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

bool isp[2000];
int x,ans;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for(int b=1;b<=32;b++){
        int sum = b;
        for(int i=2;i<=10;i++){
            sum *= b;
            if(sum<=1000)isp[sum]=true;
            else break;
        }
    }
    cin>>x;
    for(int i=x;i>=1;i--){
        if(isp[i]){ans=i;break;}
    }
    cout<<ans<<newl;
}


Measured memory_bytes: 256
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a,b;
  cin >> a >> b;
  if(b<=9) a = a*10;
  else if(b<=99) a = a*100;
  else a = a*1000;
  int sum = a + b;
  int flag=0;
  for(int i=0;i<=100000;i++){
    if(sum == i * i) flag=1;
  }
  if(flag==1) cout << "Yes"<<endl;
  else cout << "No"<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
a = ["" for _ in range(n)]
for i in range(n):
    a[i] = int(input())
    
#print(a)

count = 0
isOn = False
i = 0
for k in range(n):
#    print("pushed")
    count += 1
    if (i + 1) == 2:
        print(count-1)
        isOn = True
        break
    i = a[i] - 1
#    print("i",i)
if isOn:
    pass
else:
    print(-1)


Measured memory_bytes: 7080
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int X,N;
    cin >> X >> N;
    unordered_set<int>us;
    for(int i=0;i<N;i++)
    {
        int t;
        cin>>t;
        us.insert(t);
    }
    for(int i=0;i<=N;i++)
    {
        if(us.find(X-i)==us.end())
            {cout<<X-i<<endl;break;}
        if(us.find(X+i)==us.end())
            {cout<<X+i<<endl;break;}
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>

typedef long long LL;
bool qry(LL v) {
	std::cout << "? " << v << std::endl;
	static char buf[10]; std::cin >> buf;
	return *buf == 'Y';
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	LL nx = 9999999999;
	int dd = 0;
	int l = 10, r = 0, c = 0;
	for (int i = 9; ~i; --i) {
		if (qry(nx) && qry((nx + 1) / 10)) {
			dd = i; l = std::min(l, i), r = std::max(r, i), ++c;
		}
		nx /= 10;
	}
	if (r - l + 1 == c && r == 9) dd = l; else dd = r;
	LL now = 0;
	for (int j = dd; j; --j) {
		int l = 0, r = 9; LL ans = 0;
		while (l <= r) {
			int mid = l + r >> 1;
			LL t = now * 10 + mid;
			if (!qry(t)) r = mid - 1;
			else ans = t, l = mid + 1;
		}
		now = ans;
	}
	now *= 100; now += 9; LL ans = 0;
	for (int j = dd == 0; j < 10; ++j)
		if (qry(now + j * 10)) {
			ans = now / 10 + j; break;
		}
	std::cout << "! " << ans << std::endl;
	return 0;
}


Measured memory_bytes: 596
# include <bits/stdc++.h>
# define int long long
using namespace std;
const int N = 2e5 + 100;
int f[N], a[N], ans;
main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		ans += f[a[i]];
		f[a[i]] ++;
	}
	for(int i = 1; i <= n; i++){
		f[a[i]] --;
		ans -= f[a[i]];
		cout << ans << endl;
		ans += f[a[i]];
		f[a[i]] ++;
	}
}

Measured memory_bytes: 4736
//广度优先搜索拓扑排序
#include <iostream>
#include <vector>
#include <queue>

using namespace std;


int n;//点数 

vector<int> *Graph; //图的邻接表 
bool *color;//标记顶点是否访问结束
int *indeg; //顶点的入度

vector<int> ans;


void bfs(int u) { //广度优先搜索实现的拓扑排序 
	queue<int> Q;
	Q.push(u);
	color[u] = true;
	while (!Q.empty()) {
		u = Q.front();
		ans.push_back(u);
		Q.pop();
		for (int i=0;i<Graph[u].size();i++) {
			int v = Graph[u][i];
			indeg[v]--;
			if (!color[v] && indeg[v] == 0) {
				Q.push(v);
				color[v] = true;
			}
		}
	}
}

void topSort() { //拓扑排序 
	for (int i=0;i<n;i++) {
		//入度为0的点即为起点 
		if (!color[i] && indeg[i] == 0) {
			bfs(i);
		}
	}
}

int main() {
	int e;
	cin >> n >> e;
	Graph = new vector<int>[n];
	color = new bool[n];
	indeg = new int[n];
	
	for (int i=0;i<n;i++) {
		color[i] = false;
		indeg[i] = 0;
	}
	
	for (int i=0;i<e;i++) {
		int s,t;
		cin >> s >> t;
		Graph[s].push_back(t);
		indeg[t]++; //t的入度加一 
	}
	topSort();
	
	for (int i=0;i<ans.size();i++) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int numX = Integer.parseInt(scanner.next());
		int numY = Integer.parseInt(scanner.next());
		int X = Integer.parseInt(scanner.next());
		int Y = Integer.parseInt(scanner.next());

		Integer[] x = new Integer[numX];
		Integer[] y = new Integer[numY];

		for (int i = 0; i < numX; i++) {
			x[i] = Integer.parseInt(scanner.next());
		}
		for (int i = 0; i < numY; i++) {
			y[i] = Integer.parseInt(scanner.next());
		}

		String isWar = "War";
		for (int z = X + 1; z <= Y; z++) {
			isWar = "No War";
			boolean isContinue = true;
			for (int j = 0; j < numX; j++) {
				if (z <= x[j]) {
					isContinue = false;
					isWar = "War";
					break;
				}
			}
			if (isContinue) {
				for (int i = 0; i < numY; i++) {
					if (z > y[i]) {
						isWar = "War";
						break;
					}
				}
			}
			if (isWar.equals("No War")) {
				break;
			}
		}
		System.out.println(isWar);
	}

}


Measured memory_bytes: 23764
n,K = map(int, input().split())
h = list(map(int, input().split()))
h = [0] + h
INF = 1001001001001
dp = [[INF] *(n+1) for _ in range(n+1)]  
dp[0][0] = 0
for j in range(n):
    for i in range(1,n+1):
        for k in range(i):
            dp[i][j+1] = min(dp[i][j+1],dp[k][j]+max(0,h[i]-h[k]))

ans = INF
for i in range(n+1):
    ans = min(ans,dp[i][n-K])

print(ans)





Measured memory_bytes: 43756
#include<bits/stdc++.h>
#define ll long long int 
#define w(x) int x; cin>>x; while(x--)
#define pb push_back
#define mp make_pair
using namespace std;
int main(){
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s;
	ll sum=0;
	cin>>s;
	ll l=s.length();
	for(ll i=0; i<l; i++){
		sum+=s[i]-'0';
	}
	if(sum%9==0)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<string> w(n);
	REP(i,n) cin>>w[i];
	set<string> s;
	s.insert(w[0]);
	FOR(i,1,n) {
		if(w[i-1][w[i-1].length()-1]!=w[i][0]) {
			cout<<"No"<<endl;
			return 0;
		}
		if(s.count(w[i])) {
			cout<<"No"<<endl;
			return 0;
		}
		s.insert(w[i]);
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: isize,
        a: isize,
        b: isize,
    }

    let m = 1000000007;

    let mut ans = repeat_squaring(2, n, m) - 1;
    //println!("repeat {}", ans);
    ans = (ans + m - combination(n, a, m)) % m;
    //println!("comb1 {}", ans);
    ans = (ans + m - combination(n, b, m)) % m;
    //println!("comb2 {}", ans);


    println!("{}", ans%m);
}

fn repeat_squaring(n: isize, p: isize, m: isize) -> isize {
    if p == 0 {
        return 1;
    }
    if p%2 == 0 {
        let t = repeat_squaring(n, p/2, m);
        //println!("t: {}", t);
        return (t%m)*(t%m) % m;
    }
    n * repeat_squaring(n, p-1, m) % m
}

fn combination(n: isize, a: isize, m: isize) -> isize {
    let mut child = n;
    let mut mother = 1;

    for i in 1..a {
        child = child * (n-i) % m;
        mother = mother * (i+1) % m;
    }

    //println!("child {}", child);
    //println!("mother {}", mother);
    child * repeat_squaring(mother, m-2, m) % m

}

Measured memory_bytes: 2180
#include "bits/stdc++.h"
using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  string s;
  cin>>s;
  int flag=1;
  for(int i=0;i<s.size();i++){
    if(i==a){
      if(s[i]!='-')flag=0;
    }else if(s[i]<'0'||s[i]>'9'){
      flag=0;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int n;
	cin >> n;
	if (n == 1)print("Hello World");
	else {
		int a, b;
		cin >> a >> b;
		print(a + b);
	}




	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		String Big = input.next();
		String Small = input.next();
		boolean bad = true;
		String ans = "";
		for (int R = Big.length(); R >= 0; R--) {
			int L = R-Small.length();
			if (L>=0) {
				String curString = Big.substring(L,R);
				boolean fit = true;
				for (int i = 0; i < curString.length(); i++) {
					if (curString.charAt(i)!='?') {
						if (Small.charAt(i)!=curString.charAt(i)) {
							fit=false; break;
						}
					}
				}
				if (fit) {
					bad=false;
					for (int i = 0; i < L; i++) {
						if (Big.charAt(i)=='?') ans+="a";
						else ans+=Big.substring(i,i+1);
					}
					ans+=Small;
					for (int i = R; i < Big.length(); i++) { //R is numbered in 1 based indexing, 
						//therefore including R in 0 based indexing works
						if (Big.charAt(i)=='?') ans+="a";
						else ans+=Big.substring(i,i+1);
					}
					break;
				}
			}
		}
		System.out.println(bad?"UNRESTORABLE":ans);
	}
}

Measured memory_bytes: 21972
Module Program
  Sub Main
    Dim s=GetInts()
    Array.Sort(s)
    Dim a=s(0),b=s(1),c=s(2)
    Dim ans=If(a=b,c,a)
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 22352
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

template <unsigned long long mod > class modint{
public:
    ll x;
    constexpr modint(){x = 0;}
    constexpr modint(ll _x) : x((_x < 0 ? ((_x += (LLONG_MAX / mod) * mod) < 0 ? _x + (LLONG_MAX / mod) * mod : _x) : _x)%mod){}
    constexpr modint operator-(){
        return x == 0 ? 0 : mod - x;
    }
    constexpr modint& operator+=(const modint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr modint operator+(const modint& a) const{
        return modint(*this) += a;
    }
    constexpr modint& operator-=(const modint& a){
        if((x -= a.x) < 0) x += mod;
        return *this;
    }
    constexpr modint operator-(const modint& a) const{
        return modint(*this) -= a;
    }
    constexpr modint& operator*=(const modint& a){
        (x *= a.x)%=mod;
        return *this;
    }
    constexpr modint operator*(const modint& a) const{
        return modint(*this) *= a;
    }
    constexpr modint pow(unsigned long long pw) const{
        modint res(1), comp(*this);
        while(pw){
            if(pw&1) res *= comp;
            comp *= comp;
            pw >>= 1;
        }
        return res;
    }
    //以下、modが素数のときのみ
    constexpr modint inv() const{
        return modint(*this).pow(mod - 2);
    }
    constexpr modint& operator/=(const modint &a){
        (x *= a.inv().x)%=mod;
        return *this;
    }
    constexpr modint operator/(const modint &a) const{
        return modint(*this) /= a;
    }
};
#define mod1 998244353
#define mod2 1000000007
using mint = modint<mod2>;

ostream& operator<<(ostream& os, const mint& a){
    os << a.x;
    return os;
}
using vm = vector<mint>;

int main() {
    cin>>N;
    vec a(N);
    vm sum(N + 1);
    sum[0] = 0;
    rep(i,N){
        cin>>a[i];
        sum[i + 1] = sum[i] + a[i];
    }
    mint res(0);
    rep(i,N) res += sum[i] * a[i];
    cout<<res<<endl;
}

Measured memory_bytes: 6424
//push(),pop():C++ではstackと統一されいる
//front():先頭の要素が何かを返す
//back():末尾の要素が何であるかを返す
//empty():キューが空であるかどうかを調べる
//size():要素数を調べる
#include<stdio.h>
#include <iostream>
#include <queue>
using namespace std;
#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2
static const int INFTY = (1<<21);

int G[MAX][MAX],color[MAX],d[MAX],num;

void bfs(int s){
  int u;
  queue<int> Q; //Qを使うことでエンキュー、デキューの操作が容易になる
  for(int i=1; i<=num; i++) {
    d[i] = INFTY;
  }
  Q.push(s);
  d[s] = 0;
  while(!Q.empty()){
    u = Q.front();
    Q.pop();
    for(int v=1; v<=num; v++){
      if(G[u][v] == 0) continue;
      if(d[v] != INFTY) continue;
      d[v] = d[u] + 1;
      Q.push(v);
    }
  }
}


int main(){
  int i,j,u,k,v;

  scanf("%d",&num);
  for(i=1; i<=num; i++){
    color[i] = WHITE;
    for(j=1; j<=num; j++){
      G[i][j] = 0;
    }
  }
  for(i=1; i<=num; i++){
    scanf("%d%d",&u,&k);
    for(j=1; j<=k; j++){
      scanf("%d",&v);
      G[u][v] = 1;
    }
  }

  bfs(1);

  for(i=1; i<=num; i++) {
    if(d[i] == INFTY) printf("%d -1\n",i);
    else printf("%d %d\n",i,d[i]);
  }

  return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(std::string S, std::string T){ 
    cout<<T<<S<<endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;

int main()
{ 
  int h, w ;
  cin >> h >> w ;
  vector<string> data(h) ;
  vector< vector<int> > answer( h + 2, vector<int>(w + 2) ) ;
  for(int i = 0 ; i < h ; i++)
  {
    cin >> data.at(i) ;
  }
  
  for(int i = 0 ; i < h ; i++)
  {
    for(int j = 0 ; j < w ; j++)
    {
      if(data.at(i).at(j) == '#')
      {
        int k = j - 1 ;
        if(k < 0)
        {
          k = 0 ;
        }
        answer.at(i + 1).at(j + 1) += 10 ;
        answer.at(i).at(j + 2) += 1 ;
        answer.at(i).at(j) += 1 ;
        answer.at(i).at(j + 1) += 1 ;
        answer.at(i + 1).at(j) += 1 ;
        answer.at(i + 1).at(j + 2) += 1 ;
        answer.at(i + 2).at(j + 2) += 1 ;
        answer.at(i + 2).at(j) += 1 ;
        answer.at(i + 2).at(j + 1) += 1 ;
      }
    }
  }

  for(int i = 0 ; i < h + 2 ; i++)
  {
    if(i == 0 || i == h + 1)
    {
      continue ;
    }
    for(int j = 0 ; j < w + 2 ; j++)
    {
      if(j == 0)
      {
        continue ;
      }
      if(j == w + 1)
      {
        cout << endl ;
        continue ;
      }
      //cout << i << " " << j << endl ;
      if(answer.at(i).at(j) >= 10)
      {
        cout << '#' ;
      }
      else
      {
        cout << answer.at(i).at(j) ;
      }
    }
  }
}


Measured memory_bytes: 256
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		out=new PrintWriter (new BufferedOutputStream(System.out));
		FastReader s=new FastReader();
		int n=s.nextInt();
		int[][] arr=new int[n][3];
		for(int i=0;i<n;i++) {
			arr[i][0]=s.nextInt();
			arr[i][1]=s.nextInt();
			arr[i][2]=s.nextInt();
		}
		for(int i=n-2;i>=0;i--) {
			arr[i][0]+=Integer.max(arr[i+1][1], arr[i+1][2]);
			arr[i][1]+=Integer.max(arr[i+1][0], arr[i+1][2]);
			arr[i][2]+=Integer.max(arr[i+1][0], arr[i+1][1]);
		}
		out.println(Integer.max(arr[0][0],Integer.max(arr[0][1], arr[0][2])));
		out.close();
	}	

	public static PrintWriter out;
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct 

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}
	
}


Measured memory_bytes: 45560
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, cnt = 0;
    cin >> n;
    string s[200000];
    map<string, int> m;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        if (m[s[i]] == 0) {
            m[s[i]] = 1;
            ++cnt;
        }
    }
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 25440
#include <iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *parent, *left;
};

Node* root;
Node* NIL;

Node* treeMinimum(Node* x)
{
    while (x->left != NIL) {
        x = x->left;
    }
    return x;
}

Node* find(Node* u, int x)
{
    while (u != NIL && u->key != x) {
        if (u->key < x) {
            u = u->right;
        } else {
            u = u->left;
        }
    }
    return u;
}

Node* treeSuccessor(Node* x)
{
    if (x->right != NIL) {
        return treeMinimum(x->right);
    }

    Node* y = x->parent;
    while (y != NIL && x == y->right) {
        x = y;
        y = y->parent;
    }

    return y;
}

void treeDelete(Node* z)
{
    Node* y; // 削除対象のノード
    Node* x; // y の子

    if (z->left == NIL || z->right == NIL) {
        y = z;
    } else {
        y = treeSuccessor(z);
    }

    if (y->left != NIL) {
        x = y->left; // x has a left child
    } else {
        x = y->right; // x has a right child, or no child
    }

    if (x != NIL) {
        x->parent = y->parent;
    }

    if (y->parent == NIL) {
        root = x;
    } else {
        if (y == y->parent->left) {
            y->parent->left = x;
        } else {
            y->parent->right = x;
        }
    }

    if (y != z) {
        z->key = y->key;
    }

    free(y);
}

void insert(int k)
{
    Node* y = NIL;
    Node* x = root; // 走査用
    Node* z;

    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (x->key > z->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else if (y->key > z->key) {
        y->left = z;
    } else {
        y->right = z;
    }
}

void inorder(Node* u)
{
    if (u == NIL)
        return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node* u)
{
    if (u == NIL)
        return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    int n, i, x;
    string com;
    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if (com == "find") {
            scanf("%d", &x);
            if (find(root, x) != NIL)
                printf("yes\n");
            else
                printf("no\n");
        } else if (com == "delete") {
            scanf("%d", &x);
            treeDelete(find(root, x));
        }
    }

    return 0;
}



Measured memory_bytes: 22020
# -*- coding: utf-8 -*-

W, H, N = map(int, input().split())
HW = [[0 for i in range(W)] for j in range(H)]

aN = [list(map(int, input().split())) for i in range (N)]

for i in range(N):

    if aN[i][2] == 1:
        for j in range(H):
            for k in range(aN[i][0]):
                HW[j][k] = 1

    elif aN[i][2] == 2:
        for j in range(H):
            for k in range(aN[i][0], W):
                HW[j][k] = 1

    elif aN[i][2] == 3:
        for j in range(aN[i][1]):
            for k in range(W):
                HW[j][k] = 1

    elif aN[i][2] == 4:
        for j in range(aN[i][1], H):
            for k in range(W):
                HW[j][k] = 1

ans = 0
for i in range(H):
    ans += HW[i].count(0)
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
typedef long long ll;

const int N=2e5+7;

int n,h[N],A,B;
bool pan(int t){
	ll cnt=0;
	rep(i,1,n){
		ll res;
		if((res=1ll*h[i] - 1ll*t*B) > 0){
			cnt+=(res-1)/A + 1;
		}
	}
	return cnt<=t;
}
int main(){
	scanf("%d%d%d",&n,&A,&B);A-=B;
	rep(i,1,n){
		scanf("%d",&h[i]);
	}
	int l=1,r=1e9+7;
	while(l<r){
		int mid=(l+r)>>1;
		if(pan(mid))r=mid;
		else l=mid+1;
	}
	printf("%d\n",l);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    
    N %= 10;

    if(N == 3){
        cout << "bon" << endl;
    }
    else if(N == 0 || N == 1 || N == 6 || N == 8){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, x, i;
  cin >> N >> x;
  vector<int> a(N);
  for (i = 0; i < N; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  int id = 0;
  for (i = 0; i < N; i++) {
    if (x < a.at(i)) break;
    else if (i == N - 1 && x > a.at(i)) break;
    x -= a.at(i);
    id++;
  }
  
  cout << id << endl;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define mx 100005
ll ar[mx+10],memo[mx+10];
ll n;
ll dp(ll ind){
    if(ind>n) return INT_MAX;
    if(ind==n) return 0;
    if(memo[ind]!=-1) return memo[ind];
    ll x=abs(ar[ind]-ar[ind+1])+dp(ind+1);
    ll y=abs(ar[ind]-ar[ind+2])+dp(ind+2);
    return memo[ind]=min(x,y);
}

int main()
{
    memset(memo,-1,sizeof(memo));
    cin>>n;
    for(ll i=1;i<=n;i++) cin>>ar[i];
    cout<<dp(1)<<endl;
    return 0;
}


Measured memory_bytes: 9856
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<complex>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000
#define PI  acos(-1.0)
////////////////////////////////////////////////
struct Rect{int h;int p;};
int lgstrec(int size,int buffer[])
{
	stack<Rect> S;
	int maxv=0;
	buffer[size]=0;
	for(int i=0;i<=size;i++)
	{
		Rect rect;
		rect.h=buffer[i];
		rect.p=i;
		if(S.empty())
		{
			S.push(rect);
		}
		else
		{
			if(S.top().h<rect.h)
			{
				S.push(rect);
			}
			else if(S.top().h>rect.h)
			{
				int tgt=i;
				while(!S.empty()&&S.top().h>=rect.h)
				{
					Rect pre=S.top();S.pop();
					int area=pre.h*(i-pre.p);
					maxv=max(maxv,area);
					tgt=pre.p;
				}
				rect.p=tgt;
				S.push(rect);
			}
		}
	}
	return maxv;
}
int H,W;
int buffer[1400][1400];
int T[1400][1400];
int lgstrec()
{
	REP(j,W)
	{
		REP(i,H)
		{
			if(buffer[i][j])
			{
				T[i][j]=0;
			}
			else
			{
				T[i][j]=(i>0)?T[i-1][j]+1:1;
			}
		}
	}
	int maxv=0;
	REP(i,H)
	{
		maxv=max(maxv,lgstrec(W,T[i]));
	}
	return maxv;
}
int main()
{
	scanf("%d%d",&H,&W);
	REP(i,H)
	{
		REP(j,W)
		{
			scanf("%d",&buffer[i][j]);
		}
	}
	cout<<lgstrec()<<endl;
	return 0;
}

Measured memory_bytes: 18472
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int A, B;
	char o;
	cin >> A >> o >> B;
	if (o == '+'){
		cout<<A+B<<endl;
	}
	else {
		cout << A - B << endl;
	}
}


Measured memory_bytes: 256
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    sum = 0
    for i in range(1,10**6):
        if i**2 >= n:
            break
        if n%i == 0:
            if i < n//i-1:
                sum += n//i-1
            else:
                break
    print(sum)
    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 9620
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	a := make([]int, 4)
	for i := 0; i < 4; i++ {
		a[i] = strings.Count(s, s[i:i+1])
	}
	if a[0] == 2 && a[1] == 2 && a[2] == 2 && a[3] == 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long int lli;
using namespace std;
// #define int long long int

inline void swap(int &a, int &b) {
    int tmp = a;
    a = b;
    b = tmp;
}

signed main() {
    int N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>

#define ll long long

using namespace std;

const int mod = (int)1e9 + 7;
const int N = (int)5e5 + 7;

int mul(int a, int b) {
  return (a * 1ll * b) % mod;
}

int add(int a, int b) {
  return (a + b) % mod;
}

int binpow(int a, int n) {
  int res = 1;
  while (n) {
    if (n & 1)
      res = mul(res, a);
    a = mul(a, a);
    n >>= 1;
  }
  return res;
}

int n, m;
int fact[N], rfact[N];

void precalc() {
  fact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = mul(fact[i - 1], i);
  }
  rfact[N - 1] = binpow(fact[N - 1], mod - 2);
  for (int i = N - 2; i >= 0; i--) {
    rfact[i] = mul(rfact[i + 1], i + 1);
  }
}

int cnk(int n, int k) {
  if (k > n) return 0;
  return mul(fact[n], mul(rfact[k], rfact[n - k]));
}

main() {
  precalc();
  scanf("%d %d", &n, &m);
  int ans = 0;
  for (int i = 0, res; i <= n; i++) {
    res = 1;
    res = mul(res, cnk(n, i));
    res = mul(res, cnk(m - i, n - i));
    res = mul(res, fact[n - i]);
    res *= ((i & 1) ? -1 : 1);
    if (res < 0) res += mod;
    ans = add(ans, res);
  }
  cout << mul(ans, mul(cnk(m, n), fact[n])) << '\n';
}


Measured memory_bytes: 7556
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

li n, a[100007], mn;

int main () {
    fastIO;
    cin >> n;
    for(li i = 0; i < n; i ++) cin >> a[i];
    mn = 1e9;
    for(li i = n-1; i >= 0; i --) {
        if(a[i]<mn) mn = a[i];
        else {
            if(a[i] == mn) continue;
            if(a[i]-1>mn) { cout << "No"; return 0; }
            mn = a[i]-1;
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cmath>
using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  
  if ((A - B) % 2 == 0){
    cout << (A + B) / 2 << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def X(): return list(input())
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0

S = X()
T = X()
for i in range(len(S)):
    if S[i] != T[i]:
        count+=1
    else:
        pass
print(count)


Measured memory_bytes: 13124
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
 int n, temp, min, ans2;
 cin>>n;
 vector<int> a(n);
 for(int i=0; i<n; i++)cin>>a[i];
 sort(a.begin(), a.end());
 min=a[n-1]-a[0]*2;
 ans2=a[0];
 for(int i=0; i<n-1; i++){
  temp=abs(a[n-1]-a[i]*2);
  if(min>temp){
   min=a[n-1]-a[i]*2; ans2=a[i];
  }
 }
 cout<<a[n-1]<<" "<<ans2<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

template <class T>
class WeightedUnionFind
{
    vector<int> par;
    vector<T> dist;

public:
    WeightedUnionFind(int n) : par(n, -1), dist(n, 0) {}

    int root(int x)
    {
        if (par[x] < 0)
            return x;
        else
        {
            //rootから降りて足していく
            int r = root(par[x]);
            //親までの累積和は計算し終わっている
            dist[x] += dist[par[x]];
            return par[x] = r;
        }
    }

    //d[y] = d[x] + w
    bool merge(int x, int y, T w)
    {
        //par[y] = x
        w += weight(x) - weight(y);
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (par[x] > par[y])
        {
            w = -w;
            swap(x, y);
        }
        par[x] += par[y];
        par[y] = x;
        dist[y] = w;
        return true;
    }

    T weight(int x)
    {
        root(x);
        return dist[x];
    }

    T dis(int x, int y) { return weight(y) - weight(x); }

    int size(int x) { return -par[root(x)]; }
};

int main(void)
{
    int n, q, c;
    cin >> n >> q;
    WeightedUnionFind<long> wuf(n);
    while (q--)
    {
        cin >> c;
        if (c)
        {
            int x, y;
            cin >> x >> y;
            if (wuf.root(x) == wuf.root(y))
            {
                cout << wuf.dis(x, y) << '\n';
            }
            else
            {
                cout << "?\n";
            }
        }
        else
        {
            int x, y;
            long z;
            cin >> x >> y >> z;
            wuf.merge(x, y, z);
        }
    }
    return 0;
}


Measured memory_bytes: 3796
from collections import defaultdict
K = int(input())
if K % 2 == 0:
    print(-1)
    exit()
c = 1
d = 7 % K
D = defaultdict(int)
while True:
    if d == 0:
        print(c)
        exit()
    if D[d] == 1:
        print(-1)
        exit()
    D[d] += 1
    c += 1
    d = (d * 10 + 7)%K

Measured memory_bytes: 170136
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
  ll n; cin>>n;
  if(n%2==0)cout<<n<<endl;
  else cout<<2*n<<endl; 
}

Measured memory_bytes: 256
n,W=map(int,input().split())
wv=[list(map(int,input().split()))]
w0=wv[0][0]-1
wv[0][0]=1
# すべてのwからw0を引く
for _ in range(n-1):
  w,v=list(map(int,input().split()))
  wv.append([w-w0,v])
import numpy as np
dp=np.full((n+1,401),0,int)
# dp[k][w]:k個で重さwでの最大価値
dp[0]=0
for w,v in wv:
  for i in range(n):
    dp[n-i][w:]=np.maximum(dp[n-i][w:],dp[n-i-1][:-w]+v)
ans=0
for i in range(1,n+1):
  if W-i*w0<=0:break
  ans=max(ans,dp[i][min(W-i*w0,400)])
print(ans)



Measured memory_bytes: 14444
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define vii vector<int>
#define vll vector<ll>
#define vip vector<pair<int,int> >
#define pb push_back
ll const mod=1e9+7;

ll mod_pow(ll a, ll n,ll mod=1e9+7) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x,ll mod=1e9+7){
    return mod_pow(x, mod - 2);
}

ll nCr(ll n, ll r,ll mod=1e9+7){
    ll ans=1;
    for(ll i=0;i<r;++i){
        ans=(ans*(n-i))%mod;
        ans=(ans*mod_inv(i+1, mod))%mod;
    }
    return ans;
}

ll MOD(ll val, ll m) {
    ll res = val % m;
    if (res < 0) res += m;
    return res;
}


int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //#ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w",stdout);
    //#endif

    ll n=1000000000,a,b,ans=0;
    cin>>n>>a>>b;
    ans=MOD(MOD(mod_pow(2,n)-1-nCr(n,a),mod)-nCr(n,b),mod);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
#include <string.h>

typedef long long ll;

int main() {
	int n;
	scanf("%d", &n);
	
	ll ans = 0;
	for (int a = 1; a < n; a++)
	{
		int b0 = n / a;
		if (n % a != 0)
		{
			ans += b0;
		}
		else
		{
			ans += (b0 - 1);
		}
		
	}
	printf("%lld", ans);
	
	
	return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n;
 
int main() {
	cin>>n;
	ll a[n], b[n], ans[n];
	for (int i=0; i<n; i++) {
		cin>>a[i];
	}
	for (int i=0; i<n; i++) {
		if (i==n-1) b[i]=(a[i]^a[0]);
		else b[i]=(a[i]^a[i+1]);
	}
	ans[0]=a[1];
	for (int i=2; i<n; i+=2) {
		ans[0]=(ans[0]^b[i]);
	}
	for (int i=1; i<n; i++) {
		ans[i]=(b[i-1]^ans[i-1]);
	}
	for (int i=0; i<n; i++) {
		if (i>0) cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
}



Measured memory_bytes: 8236
#include<stdio.h>

int main(void)
{
  int i,n,top,k,v[101];
  int a[101][101],j;
  
  for(i=0;i<101;i++)
    {
      for(j=0;j<101;j++)
	{
	  a[i][j]=0;
	}
    }
   
   
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d %d",&top,&k);
      for(j=0;j<k;j++)
	{
	  scanf("%d",&v[j]);
	  a[top-1][v[j]-1]=1;
	}
    }
   
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  printf("%d", a[i][j]);
	  if(j!=n-1)
	    {
	      printf(" ");
	    }
	}
      printf("\n");
    }
  
  return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long N;
    cin >> N;
    vector<long long> A(N), left(N), right(N), hcf(N);
    for(long long i = 0; i < N; i++)
        cin >> A[i];
    left[0] = A[0];
    right[N-1] = A[N-1];
    for(long long i = 1; i < N; i++){
        left[i] = __gcd(left[i-1], A[i]);
        right[N-1-i] = __gcd(right[N -i], A[N-i-1]);
    }
    hcf[0] = right[1];
    hcf[N-1] = left[N-2];
    long long ans = hcf[0];
    for(long long i = 1; i < N-1; i++){
        hcf[i] = __gcd(left[i-1], right[i+1]);
        ans = max(ans, hcf[i]);
    }
    ans = max(ans, hcf[N-1]);
    cout << ans << "\n";
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int n; cin >> n;
    vector<double> v(n); rep(i, 0, n) cin >> v[i];
    sort(v.begin(), v.end());
    double ans = v[0];
    rep(i, 1, n) ans = (ans + v[i]) / 2.0;
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main (string[] args) {

        var p = Console.ReadLine().Split(' ');
        long D = long.Parse(p[0]);
        long N = long.Parse(p[1]);


        long basen = (long)Math.Pow(100,D);
        long num = basen * N;
        if (N==100){
            num = basen * (N+1);
        }

        Console.WriteLine(num);

        
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;

/// Defining variable types.
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

/// Defining usable key words
#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

/// Defining constant variables.
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

/// Defining some useful lines.
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);


/// Code of debugger.
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}

const int mx=2e5+123;
int dp[mx];
int h[mx],k,n;

int solve(int i)
{
    if(i==n)
        return 0;

    if(dp[i]!=-1)
        return dp[i];

    int ret=inf;

    for(int j=1; j<=k; j++)
    {
        if(i+j<=n)
        {
            ret=min(ret,abs(h[i]-h[i+j])+solve(i+j));
        }
    }

    dp[i]=ret;

    return dp[i];

}

int main()
{
    optimize();

    cin>>n>>k;

    for(int i=1; i<=n; i++)
        cin>>h[i];

    mem(dp,-1);

    cout<<solve(1)<<endl;


    return 0;
}


Measured memory_bytes: 12548
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n,b,max;
  std::cin >> n;
  int a[n];
    b=0;
    max=0;
  for(int i=0; i<n; i++) std::cin >> a[i];
  if(n==1){
    cout<<"Yes"<<endl;
  }else{
    for(int i=0; i<n; i++){
      if(a[i]-1>max){
        max=a[i]-1;
      }
        if(max<=a[i]){
          b+=1;
        }
      
    }
    if(b==n){
    cout<<"Yes"<<endl;
        
    }else{
    cout<<"No"<<endl;
    }
}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll (i)=(0);(i)<(ll)(n);++(i))
typedef pair<int, int> P;
typedef long long ll;

const int mod=1e9+7;

int main() {
    ll n, m;
    cin >> n >> m;
    ll sa=0LL, sb=0LL;

    rep(k, n) {
        ll x;
        cin >> x;
        sa += (x*(k-(n-1-k)));
        sa %= mod;
    }

    rep(k, m) {
        ll y;
        cin >> y;
        sb += (y*(k-(m-1-k)));
        sb %= mod;
    }

    cout << sa * sb % mod << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pq priority_queue
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define elif else if

using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using pll=pair<ll,ll>;
using pss=pair<string,string>;
using pdd=pair<ld,ld>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-9;

template<class T> void chmin(T &a, T b){a=min(a, b);}
template<class T> void chmax(T &a, T b){a=max(a, b);}

ll abs1(ll a){if(a>=0)return a;else return -a;}
ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1)ret*=a;
    a*=a;
    if(a>=p)a%=p;if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}
int digit(ll a,ll b=10){int i=0;while(a!=0){a/=b;i++;}return i;}
ll gcd1(ll a,ll b){
  if(a==0 || b==0)return 0;
  ll n;while(a%b!=0){n=a%b;a=b;b=n;}return b;
}
ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];a[0]=n;b[0]=m;int i=1;
  while(b[i-1]!=0){a[i]=b[i-1];b[i]=a[i-1]%b[i-1];i++;}
  n=i;if(c%a[n-1]!=0)return 0;
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){ll cnt=x;x=y;y=cnt-(a[n-i-1]/b[n-i-1])*y;}
  return x;
}
ll modRev(ll a,ll p=MOD){
  a%=p;ll n=solveLinear(a,p,1);
  n%=p;if(n<0)return n+p;
  return n;
}
ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  ll ret=1;
  for(int i=1;i<=n;i++){ret=ret*i;if(ret>=p)ret%=p;}
  return ret;
}
ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  ll ret=1;
  rep(i,k){ret=ret*(n-i);if(ret>=p)ret%=p;}
  return ret;
}
ll binom(ll n,ll k,ll p=MOD){
  return (perm(n,k,p)*modRev(fact(k)))%p;
}
int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j,k,cnt=0;
  int n,q;
  cin>>n>>q;
  int a[q],b[q];
  rep(i,q){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
  }
  set<int> s;
  s.insert(0);
  s.insert(1);
  int c[n];
  rep(i,n)c[i]=i;
  rep(i,q){
    swap(c[a[i]],c[b[i]]);
    if(c[a[i]]==0)cnt=a[i];
    if(c[b[i]]==0)cnt=b[i];
    if(cnt>1)s.insert(c[cnt-1]);
    if(cnt<n-1)s.insert(c[cnt+1]);
  }
  cout<<s.size()<<endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	vector<int>a(n,0);
	rep(i,k){
		int d;
		cin>>d;
		rep(i,d){
			int tmp;
			cin>>tmp;
			tmp--;
			a[tmp]++;
		}		
	}
	int ans=0;
	rep(i,n)if(a[i]==0)ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 3628