akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct Edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 10e-10;
const int MAX_V = 1000;

vector<int> G[MAX_V], rG[MAX_V], vs;
int component[MAX_V];
bool used[MAX_V];
ll dp[MAX_V][2];
int V,E;

void add_edge(int s, int t){
    G[s].push_back(t);
    rG[t].push_back(s);
}

void dfs(int node){
    used[node] = true;
    for(int next: G[node]){
        if(!used[next]) dfs(next);
    }
    vs.push_back(node);
}

void rdfs(int node, int k){
    used[node] = true;
    component[node] = k;
    for(int next: rG[node]){
        if(!used[next]) rdfs(next, k);
    }
}

void scc(){
    memset(used, false, sizeof(used));
    rep(V){
        if(!used[i]) dfs(i);
    }
    memset(used, false, sizeof(used));
    int k = 0;
    reverse(all(vs));
    for(int i: vs){
        if(!used[i]) rdfs(i, k++);
    }
}

vector<int> topological_sort(int N){
    vector<int> ret, indeg(N, 0);
    vector<bool> used(N, false);
    set<int> st;
    rep(N) for(int to: G[i]) indeg[to]++;
    rep(N) if(indeg[i] == 0) st.insert(i);

    while(!st.empty()){
        int node = *st.begin();
        st.erase(node);
        ret.push_back(node);
        used[node] = true;
        for(int next: G[node]){
            indeg[next]--;
            if(!used[next] && indeg[next] == 0) st.insert(next);
        }
    }

    return ret;
}

void rec(int node, int color){
    if(color == 0) dp[node][0] = 1;
    if(dp[node][color] > 0) return;

    dp[node][1] = 1LL;
    for(int next: rG[node]){
        dp[node][1] *= (dp[next][0] + dp[next][1]);
        dp[node][1] %= MOD;
    }
    return;
}

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);

    int s, d;
    cin >> V >> E;
    Pii edges[E];
    rep(E){
        cin >> s >> d;
        s--; d--;
        add_edge(s, d);
        edges[i] = Pii(s, d);
    }

    scc();

    rep(V){
        G[i].clear();
        rG[i].clear();
    }
    V = *max_element(component, component+V) + 1;
    rep(E){
        s = edges[i].first;
        d = edges[i].second;
        if(component[s] != component[d]){
            add_edge(component[s], component[d]);
        }
    }

    vector<int> sorted_v = topological_sort(V);
    fill(dp[0], dp[2], 0LL);
    for(int s: sorted_v){
        rec(s, 0); rec(s, 1);
    }
    ll ans = 1LL;
    for(int v: sorted_v){
        if(!G[v].size()) (ans *= ((dp[v][0]+dp[v][1]) % MOD)) %= MOD;
    }

    cout << ans << endl;
}



Measured memory_bytes: 3304
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

typedef long long ll;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

long long lcm(long long a, long long b)
{
    return a * b / gcd(a, b);
}

int main(void)
{
    long long x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
}


Measured memory_bytes: 3100
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();

		List<Double> A = new ArrayList<>();

		for(int i = 0; i < N; i++) {
			A.add(scan.nextDouble());
		}

		double ans = 0;
		for(int i = 0; i < N; i++) {
			ans += (1/A.get(i));
		}

		System.out.println(1/ans);
	}
}

Measured memory_bytes: 23120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int main() {
    
    map<char, int> ans;
    int n;
    cin >> n;
    rep(i, n) {
        map<char, int> mp;
        string s;
        cin >> s;
        rep(j, sz(s)) {
            mp[s[j]]++;
        }
        if (i == 0) ans = mp;
        else {
            for (auto e : ans) {
                ans[e.F] = min(e.S, mp[e.F]);
            }
        }
    }
    
    for (auto e : ans) {
        rep(j, e.S) cout << e.F;
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int h = 0;
	int m[10];
	for(int i = 0; i < 10; i++){
		scanf("%d",&m[i]);
	}

	for(int i = 0; i < 10; i++){
		int tmp = m[i];
		h = i;
		for(int j = i+1; j < 10; j++){
			if(tmp > m[j] ){
				tmp = m[j];
				h = j;
			}
		}
		
		int f = m[i];
		m[i] = m[h];
		m[h] = f;
	}

	for(int i = 9; i >= 7; i--){
		printf("%d\n",m[i]);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  set<int> s;
  int n,k;
  cin >> n >> k;
  rep(i,k){
    int d;
    cin >> d;
    vector<int> a(d);
    rep(j,d){
      cin >> a[j];
      s.insert(a[j]);
    }
  }

  cout << n - s.size() << endl;

  return 0;
    

}


Measured memory_bytes: 3652
import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))

    H.sort()
    if K == 0:
        ans = sum(H)
    else:
        ans = sum(H[:-K])

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31360
from networkx import*
(N,),*t=map(str.split,open(0))
G=Graph()
G.add_edges_from(t)
s=shortest_path_length
x=s(G,'1')
y=s(G,N)
print('FSennunkeec'[sum(x[k]>y[k]for k in x)*2>=int(N)::2])

Measured memory_bytes: 189764
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 
 using namespace std;
 
 int main()
 {
   int n,m;
   while(cin>>n>>m&&(n||m))
   {
     list<int> mm;
     list<int>::iterator iter;
     list<int>::iterator iter2;
     for(int i=1;i<=n;i++) mm.push_back(i);
     while(mm.size()>1)
     {
       for(int i=1;i<=m-1;i++)
       {
         mm.push_back(mm.front());
         mm.pop_front();
       }   
       mm.pop_front(); 
       //cout<<mm.front()<<endl;            
     }
     iter=mm.begin();
     cout<<(*iter)<<endl;                
   }
   //while(1);
   return 0; 
 }

 

Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int n;cin >> n;
    vector<int> vec(3*n);
    for(int i=0;i<3*n;i++){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end(),greater<int>());
    long long count=0;
    for(int i=0;i<n;i++){
        count += vec[2*(i+1)-1];
    }
    cout<<count<<endl;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C___Maximum_Volume
{
    class Program
    {
        static void Main(string[] args)
        {
            var L = int.Parse(Console.ReadLine());

            Console.WriteLine(Math.Pow((double)L / 3, 3));
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <memory.h>
int main(void){
	int n,m,t,p[100][101],k,l[100],i,j,ans,f;
	while(1){
		scanf("%d",&n);
		if(!n)
			break;
		memset(p,0,sizeof(p));
		f=1;
		ans=-1;
		for(i=0;i<n;i++){
			scanf("%d",&m);
			for(j=0;j<m;j++){
				scanf("%d",&t);
				p[i][t]++;
			}
		}
		scanf("%d",&k);
		for(i=0;i<k;i++)
			scanf("%d",&l[i]);
		for(i=0;i<n;i++){
			for(j=0;j<k;j++){
				if(!p[i][l[j]])
					break;
			}
			if(j==k&&f){
				ans=i+1;
				f=0;
			}
			else if(j==k&&!f)
				ans=-1;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 648
#include<iostream>
#include<math.h>
#include<cmath>
#include<iomanip>
#include<string.h>
#include<stdio.h>
#include <algorithm>
using namespace std;
char num[105];
long long int n[105];
int main()
{
	ios::sync_with_stdio(false);
	int i;
	long long u;
	while(cin>>num>>u)
	{
		for(i=0;i<strlen(num);i++)
		{
			n[i]=num[i]-'0';
		}
		int flag=0;
		for(i=0;i<strlen(num);i++)
		{
			if(n[i]!=1)
			{
				if((u-1)<i)
				{
					cout<<1<<endl;
					flag=1;
					break;
				}
				else
				{
					cout<<n[i]<<endl;
					flag=1;
					break;
				}
			}
		}
		if(flag==0)
		{
			cout<<1<<endl;
		}
	}
	return 0;
}


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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define repl(n) for (int l = 0; l < (n); l++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
ll modpow(ll a, ll b, ll m) {
  ll re = 1, k = 1;
  while (k <= b) {
    if (b & k) {
      re *= a;
      re %= m;
    }
    k = k << 1;
    a *= a;
    a %= m;
  }
  return re;
}
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  vector<int> ls, rs;
  char pre = s[0];
  int prelen = 0;
  repi(n) {
    if (s[i] == pre) {
      prelen++;
    } else {
      (pre == 'L' ? ls : rs).push_back(prelen);
      pre = s[i];
      prelen = 1;
    }
  }
  (pre == 'L' ? ls : rs).push_back(prelen);
  int ll = ls.size(), rl = rs.size();
  if (s[0] == s[n - 1]) {  // XYX...YX
    cout << n - 1 - max((s[0] == 'L' ? rl : ll) - k, 0) * 2 << endl;
  } else {  // XYXY...X
    cout << n - max((ll - k) * 2, 1) << endl;
  }
}


Measured memory_bytes: 1020
N = int(input())
arr = list(map(int,input().rstrip().split()))
dparr= [-1 for i in range(N)]
dparr[0] = 0
dparr[1] = abs(arr[0]-arr[1])
for num in range(2,N):
  dparr[num] = min(dparr[num-2]+ abs(arr[num]-arr[num-2]), dparr[num-1]+ abs(arr[num]-arr[num-1]))
print(dparr[-1])





Measured memory_bytes: 20624
from fractions import gcd
a,b,c,d=map(int,input().split())
ans=(b-a+1)-(b//c-(a-1)//c)+(b-a+1)-(b//d-(a-1)//d)
lc=(c*d)//gcd(c,d)
ans-=(b-a+1)-(b//lc-(a-1)//lc)
print(ans)



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

int main()
{
  int n,count=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<s.length()-2;i++)
  {
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')count++;
  }
  cout<<count<<endl;
  return 0;
}	

  

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    char c;
    cin >> c;
    if('a' <= c && c <= 'z') cout << 'a' << endl;
    if('A' <= c && c <= 'Z') cout << 'A' << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
 
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

#define int long long
#define pb push_back
#define pii pair<int,int>
#define ppii pair<pii,pii>
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define ccM 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
long double pi = 3.14159265358979323;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int max(int b,int a){if(b>a)return b;else return a;}
int min(int b,int a){if(b<a)return b;else return a;}
int Abs(int b){return max(b,-b);}
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){return a.second<b.second;}

int32_t main()
{
    int n;
    cin>>n;
    int sum=0;
    sum+=(n/500)*1000;
    n%=500;
    sum+=(n/5)*5;
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

const int Z = 1e9+7;

int main() {
    int n, k;
    cin >> n >> k;

    int sqn = sqrt(n);

    int dp0[k+1][sqn+1], dp1[k+1][sqn+1];
    memset(dp0, 0, sizeof(dp0));
    memset(dp1, 0, sizeof(dp1));
    for (int i = 1; i <= sqn; i++) {
        dp0[0][i] = dp1[0][i] = 1;
    }

    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= sqn; j++) {
            dp0[i][j] = (dp0[i][j-1] + dp1[i-1][j]) % Z;
        }

        int s = dp0[i][sqn], lj = sqn;
        for (int j = sqn; j >= 1; j--) {
            s = (s + 1ll * (n / j - lj) * dp0[i-1][j]) % Z;
            dp1[i][j] = s;
            lj = n / j;
        }
    }

    cout << dp1[k][1] << endl;

    return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0)
#define fori(x,a,b) for (int x=a;x<=b;++x)
#define ford(x,a,b) for (int x=a;x>=b;x--)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define mp make_pair
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define getbit(x,i) ((x>>(i-1))&1)
#define batbit(x,i) (x|(1ll<<(i-1)))
#define tatbit(x,i) (x&~(1<<(i-1)))
#define gg exit(0);

const int maxn = 1e5 + 10;
int n,x,y,mod;
int f[maxn],g[maxn];
int ans[maxn];
vector<int> ke[maxn];
void dfs(int u,int pr)
{
    f[u] = 1;
    forv(v,ke[u]) if (v!=pr)
    {
        dfs(v,u);
        f[u] = (f[u]*(f[v]+1))%mod;
    }
}

void dfs1(int u,int pr)
{
    vector<int> a,l,r;
    int cnt = 0;
    forv(v,ke[u]) if (v!=pr) ++cnt;
    a.resize(cnt+5,0);
    l.resize(cnt+5,0);
    r.resize(cnt+5,0);

    int m = 0;
    forv(v,ke[u]) if (v!=pr) a[++m] = v;

    l[0] = 1,r[m+1] = 1;
    fori(i,1,m) l[i] = l[i-1]*(f[a[i]]+1)%mod;
    ford(i,m,1) r[i] = r[i+1]*(f[a[i]]+1)%mod;

    fori(i,1,m)
    {
       int v = a[i];
       g[v] = (g[u]*l[i-1]%mod*r[i+1]%mod+1);
       dfs1(v,u);
    }
}

main()
{
     fasty;
    cin>>n>>mod;
    fori(i,1,n-1)
    {
        cin>>x>>y;
        ke[x].pb(y);
        ke[y].pb(x);
    }
    fori(i,1,n) f[i] = g[i] = 1;
    dfs(1,0);
    dfs1(1,0);
    fori(i,1,n)
    {
        cout<<f[i]*g[i]%mod<<"\n";
    }
}


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

int main(){
  int R,G;
  
  cin >> R;
  cin >> G;
  
  if (0 <= R, G<= 4500){
    cout << 2*G-R << endl;
  }
  else {
    cout << "error" << endl;
  }
}

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

int main() {
  int N, ans = 0;
  cin >> N;
  for(int i=0; i<N; i++){
    int a, count = 0;
    cin >> a;
    while(a%2 == 0){
      a /= 2;
      count++;
    }
    if(i==0)
      ans = count;
    else if(ans > count)
      ans = count;
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

int n, m;
int swapped = 0;
int arr[1050][1050];

int main() {
	scanf("%d%d",&n,&m);
	if (n<m) swap(n,m), swapped=1;
	for (int i=0;i<m;i++) {
		for (int j=0;j<(1<<m);j++) {
			if (j>>i&1) {
				for (int k=0;k<(1<<n);k++) {
					if (k>>i&1) arr[k][j]^=1;
				}
			}
		}
	}
	if (swapped) swap(n,m);
	for (int i=1;i<(1<<n);i++) {
		for (int j=1;j<(1<<m);j++) {
			printf("%d",swapped?(arr[j][i]^arr[j-1][i]^arr[j][i-1]^arr[j-1][i-1]):(arr[i][j]^arr[i-1][j]^arr[i][j-1]^arr[i-1][j-1]));
		}
		puts("");
	}

	return 0;
}


Measured memory_bytes: 5504
#include <iostream>

int main() {
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;
  int t_c, a_c;
  t_c = (c + b - 1) / b;
  a_c = (a + d - 1) / d;
  if (t_c <= a_c) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long N, A, B, C, D, E;
	cin >> N >> A >> B >> C >> D >> E;
	cout << max({ (N - 1) / A, (N - 1) / B, (N - 1) / C, (N - 1) / D, (N - 1) / E }) + 5 << endl;
	return 0;
}

Measured memory_bytes: 256
import sys


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


def check(G, n):
    for a in range(n):
        for b in range(a+1, n):
            if G._root(a) != G._root(b):
                return True
    return False


def main():
    n, m = map(int, sys.stdin.buffer.readline().split())
    ab = [list(map(int, x.split())) for x in sys.stdin.buffer.readlines()]
    ans = 0
    for i in ab:
        G = UnionFind(n)
        for j in ab:
            if i != j:
                G.union(j[0]-1, j[1]-1)
        if check(G, n):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    string ans;
    int nx=tx-sx,ny=ty-sy;
    if(nx>=0 && ny>=0)
    {
        rep(i,nx)ans+="R";
        rep(i,ny)ans+="U";
        rep(i,nx)ans+="L";
        rep(i,ny)ans+="D";
        ans+="D";
        rep(i,nx+1)ans+="R";
        rep(i,ny+1)ans+="U";
        ans+="L";
        ans+="U";
        rep(i,nx+1)ans+="L";
        rep(i,ny+1)ans+="D";
        ans+="R";




    }
    else if(nx<0 && ny <0)
    {
        rep(i,abs(nx))ans+="L";
        rep(i,abs(ny))ans+="D";
        rep(i,abs(nx))ans+="R";
        rep(i,abs(ny))ans+="U";
        
    }
    else if(nx>=0 && ny <0)
    {
        rep(i,nx)ans+="R";
        rep(i,abs(ny))ans+="D";
        rep(i,nx)ans+="L";
        rep(i,abs(ny))ans+="U";

    }
    else if(nx<0 && ny >=0)
    {
        rep(i,abs(nx))ans+="L";
        rep(i,ny)ans+="U";
        rep(i,abs(nx))ans+="R";
        rep(i,ny)ans+="D";

    }
    cout<<ans;
}

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

int main()
{
    string a;
    char b;
    cin >> a;
    for (int i = 0; i < a.size() / 2; i++)
    {
        b = a[i];
        a[i] = a[a.size() - 1 - i];
        a[a.size() - 1 - i] = b;
    }
    cout << a << endl;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
using namespace std;
using ll = long long;

vector<vector<int>> dp(100005, vector<int>(3, 0));
// dp[i][j] := i日終了時点での最大の幸福度(最後の選択がj)

int main(void) {
  int n;
  cin >> n;
  int abc[n + 1][3];
  rep (i, n) cin >> abc[i + 1][0] >> abc[i + 1][1] >> abc[i + 1][2];

  dp[1][0] = abc[1][0];
  dp[1][1] = abc[1][1];
  dp[1][2] = abc[1][2];

  for (int i = 2; i <= n; i++) {
    rep (j, 3) {
      rep (k, 3) {
        if (j == k) continue;
        dp[i][j] = max(dp[i][j], dp[i - 1][k] + abc[i][j]);
      }
    }
  }
  
  cout << max({dp[n][0], dp[n][2], dp[n][1]}) << endl;
  return 0;
}

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

struct Sieve{
  int n;
  vector<int> f,primes;
  Sieve(int n=1):n(n),f(n+1){
    f[0] = f[1] = -1;
    for(ll i = 2; i<=n;++i){
      if(f[i]) continue; //素数でない場合continue
      primes.push_back(i);
      f[i] = i;
      for(ll j=i*i;j<=n;j+=i){
        if(!f[j]) f[j]=i;
      }
    }
  }
  bool isPrime(int x){
    return f[x]==x;
  }
  vector<int> factorList(int x){
    vector<int> res;
    while(x != 1){
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x){
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1,P(fl[0],0));
    for (int p:fl){
      if(res.back().first == p){
        res.back().second++;
      }else{
        res.emplace_back(p,1);
      }
    }
    return res;
  }
};




int main(){
    int n;
    cin >> n;
    Sieve s(55555);
    vector<int> ans;
    rep(i,s.primes.size()){
        if(s.primes[i]%5==1){
            ans.push_back(s.primes[i]);
        }
        if(ans.size()>=55){
            break;
        }
    }

    rep(i,n){
        cout << ans[i] << " ";
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N,M;
  cin >> N >> M;
  ll H[N];
  bool X[N];
  for (int i = 0; i < N; i++) {
    X[i] = true;
  }
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  ll A[M];
  ll B[M];
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
  }
    for (int j = 0; j < M; j++) {
      if (H[A[j] - 1] > H[B[j] - 1]) {
        X[B[j] - 1] = false;
      } else if (H[A[j] - 1] < H[B[j] - 1]) {
        X[A[j] - 1] = false;
      } else {
        X[B[j] - 1] = false;
        X[A[j] - 1] = false;
      }
    }
  ll ans = 0;
  for (int i = 0; i <N; i++) {
    if (X[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6064
#include<bits/stdc++.h> 
using namespace std;
int main(){
  int n; cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  cin>>arr[i]; 
  long long total_money=1000;
  long stokes=0;
  for(int i=0;i<n-1;i++){
     if(arr[i+1]>arr[i]){
       stokes+=total_money/arr[i];
       total_money=total_money%arr[i];
     }
    else{
       long long temp=stokes*arr[i];
       stokes=0;
       total_money+=temp;
      }
    }
    total_money+=stokes*arr[n-1];
  cout<<total_money<<endl;
    return 0;
}


Measured memory_bytes: 3628
package main

import (
	"fmt"
)

const maxUint = ^uint(0)
const maxInt = int(maxUint >> 1)
const minInt = -maxInt - 1

func main() {
	var n int
	fmt.Scanf("%d", &n)

	var sched [][]bool
	for i := 0; i < n; i++ {
		var shop []bool
		for j := 0; j < 10; j++ {
			var k int
			fmt.Scanf("%d", &k)
			shop = append(shop, k == 1)
		}
		sched = append(sched, shop)
	}

	var rewards [][]int
	for i := 0; i < n; i++ {
		var r []int
		for j := 0; j <= 10; j++ {
			var c int
			fmt.Scanf("%d", &c)
			r = append(r, c)
		}
		rewards = append(rewards, r)
	}

	best := minInt
	for p := 1; p < 1 << 10; p++ {
		var plan []bool
		for j := 0; j < 10; j++ {
			plan = append(plan, p & (1 << uint(j)) != 0)
		}
		total := 0
		for i := 0; i < n; i++ {
			cnt := 0
			for j := 0; j < 10; j++ {
				if plan[j] && sched[i][j] {
					cnt++
				}
			}
			total += rewards[i][cnt]
		}
		if total > best {
			best = total
		}
	}

	fmt.Println(best)
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(void){

  int N;  cin >> N;
  int tmp = N;
  int fx = 0;
  while(N != 0){
    fx += N%10;
    N /= 10;
  }

  if(tmp % fx == 0) puts("Yes");
  else puts("No");
  
return 0;
}


Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int dp[202020];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  int n;
  cin >> n;
  vpi v;
  for(int i=1;i<=n;i++){
    int x,l;
    cin >> x >> l;
    v.pb({x-l,x+l});
  }
  sort(all(v));
  dp[0] = 1;
  int ans = 0;
  for(int i=0;i<v.size();i++){
    if(i!=0){
      dp[i] = max(dp[i],dp[i-1]);
    }
    int r = v[i].sc;
    pi p  = {r,0};
    int nxt = lower_bound(all(v),p)-v.begin();
    dp[nxt] = max(dp[nxt],dp[i]+1);
    ans = max(ans,dp[i]);
  }
  cout << ans << endl;

return 0;
}
///....


Measured memory_bytes: 2800
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int A, B;

int C = 0;


int main()
{
	cin >> A >> B;

	for (int i = 0; i < 2; i++)
	{
		C += max(A, B);
		if (A > B) A--;
		else B--;
	}

	cout << C << endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
s = [list(input()) for _ in range(H)]

bre = False
for h in range(H):
    for w in range(W):
        if s[h][w] == "#":
            if h>0 and s[h-1][w]=="#":
                continue
            elif h<H-1 and s[h+1][w]=="#":
                continue
            elif w>0 and s[h][w-1]=="#":
                continue
            elif w<W-1 and s[h][w+1]=="#":
                continue
            else:
                #print(h,w)
                print("No")
                bre = True
                break
    if bre:
        break
else:
    print("Yes")

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

# 人数
psn_cnt = int(input())

# 日数と最終日の余り
date_amari = input()
# 分割
da_list = date_amari.split()
date = int(da_list[0])
amari = int(da_list[1])

# 人数分の入力値を取得
psn_list = []
for i in range(psn_cnt):
	psn_list.append(int(input()))

choco_cnt_list = []
# 人数分のループ
for i in range(psn_cnt):
	# チョコ数の初期化
	choco_cnt = 0
	# 日数+1のループ
	for j in range(date + 1):
		# 条件に当てはまる数値が日数を超えていなければその人のチョコを+1
		if date >= psn_list[i] * j + 1:
#			print(str(i) + "add")
			choco_cnt += 1
		# 条件に当てはまる数値が日数を超えたところでその人のチョコ数をリストに詰めて次の人へ
		else:
			choco_cnt_list.append(choco_cnt)
#			print(str(i) + "added" + str(choco_cnt))
			break
# 全員のチョコ数を合計して余りも足す
choco_sum = 0
for choco_cnt in choco_cnt_list:
	choco_sum += choco_cnt
choco_sum += amari

print(choco_sum)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>

typedef struct{
	int to, cost;
} Edge;

typedef std::pair<int, int> P;	//<cost, pos>

const int kMaxSize	= 32;
const int kMaxField = kMaxSize*kMaxSize;
const int kCostFriendlyInk = 1;
const int kCostShot = 2;
const int kCostBlank = 2;
const int kShotRange = 3;

const char kWall = '#';
const char kFriend = 'o';
const char kEnemy = 'x';
const char kStart = 'S';
const char kGoal = 'G';
const char kBlank = '.';

char field[kMaxField];
int way[4] = { -1, 1, -kMaxSize, kMaxSize };

const int kInf = 1 << 16;
int d[kMaxField];
std::vector<Edge> cost[kMaxField];
int R, C;

inline int xy2pos(const int x, const int y){
	return x + y*kMaxSize;
}

void initCost(){
	for (int y = 1; y <= R; y++){
		for (int x = 1; x <= C; x++){
			int pos = xy2pos(x, y);
			if (field[pos] == kWall) continue;
			for (int i = 0; i < 4; i++){
				for (int j = 1; j <= kShotRange; j++){
					int newpos = pos + j*way[i];
					if (field[newpos] == kWall) break; //?£?????????????????????????
					if (j == 1){
						if (field[newpos] == kFriend) cost[pos].push_back({ newpos, kCostFriendlyInk });
						else if (field[newpos] == kEnemy) cost[pos].push_back({ newpos, kCostShot + kCostFriendlyInk });
						else cost[pos].push_back({ newpos, kCostBlank });
					}else{
						int newcost;
						if (field[newpos] == kFriend)
							newcost = std::min(kCostShot + kCostFriendlyInk * j, cost[pos].back().cost + kCostFriendlyInk);
						else if (field[newpos] == kEnemy)
							newcost = kCostShot + kCostFriendlyInk * j;
						else
							newcost = std::min(kCostShot + kCostFriendlyInk * j, cost[pos].back().cost + kCostBlank);
						cost[pos].push_back({ newpos, newcost });
					}
				}
			}
		}
	}
}

void dijkstra(int spos){
	std::priority_queue<P, std::vector<P>, std::greater<P>> q;
	std::fill(d, d + kMaxField, kInf);
	d[spos] = 0;
	q.push({ 0, spos });

	while (!q.empty()){
		P p = q.top(); q.pop();
		if (d[p.second] < p.first) continue;
		for (unsigned int i = 0; i < cost[p.second].size(); i++){
			Edge e = cost[p.second][i];
			if (d[e.to] > d[p.second] + e.cost){
				d[e.to] = d[p.second] + e.cost;
				q.push({ d[e.to], e.to });
			}
		}
	}
}

int main(){
	int start, goal;

	std::fill(field, field + kMaxField, '#');

	std::scanf("%d %d", &R, &C);
	for (int y = 1; y <= R; y++)
		for (int x = 1; x <= C; x++){
			int pos = xy2pos(x, y);
			std::scanf(" %c", &field[pos]);
			if (field[pos] == kStart) start = pos;
			else if (field[pos] == kGoal) goal = pos;
		}
	initCost();
	dijkstra(start);
	printf("%d\n", d[goal]);
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

int main()
{
    long long S;
    cin >> S;

    if(S == 1e+18){
        cout << "0 0 1000000000 0 0 1000000000" << endl;
        return 0;
    }
    
    vector<long long> X(3), Y(3);
    X[0] = Y[0] = 0;
    X[1] = 1e+9;
    Y[1] = 1;
    X[2] = 1000000000 - S%1000000000;
    Y[2] = S/1000000000 + 1;

    REP(i, 3) cout << X[i] << " " << Y[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main()
{
    std::string in;
    std::cin >> in;
    int sum = 0;
    for (const auto& v : in)
    {
        sum += v - '0';
        sum %= 9;
    }
    if (sum == 0)
    {
        std::cout << "Yes";
    }
    else
    {
        std::cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

            long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

            if (a[0] <= a[1])
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }



        }
}

Measured memory_bytes: 28044
package main

/**
 * -100 <= A,B int <= 100
 * A + B, A - B, A * Bの中で最大の数を出力
 */

import (
	"fmt"
	"bufio"
	"os"
	"strings"
	"strconv"
)

func main() {

	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	s := sc.Text()
	sl := strings.Split(s, " ")
	a, _ := strconv.Atoi(sl[0])
	b, _ := strconv.Atoi(sl[1])

	calcs := []int{
		a + b,
		a - b,
		a * b,
	}

	var max int

	for i, val := range calcs {
		if i == 0 {
			max = val
			continue
		}
		if val > max {
			max = val
		}
	}
	fmt.Println(max)
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;

int main(){
	ll T = 1;
	//cin >> T;
	while (T--){
	 int k; int x;
	 cin >> k >> x;
      if (k == x) {
		  cout << "Yes" << endl;
	  } else {
		  cout << "No" << endl;
	  }
	}
}


Measured memory_bytes: 3588
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;

import org.omg.Messaging.SyncScopeHelper;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new Test_100().doIt();
	}
	class Test_100{
		void doIt() {
			String str[] = sc.next().split("/");
			System.out.println("2018/"+str[1]+"/"+str[2]);
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main(){
    string s; cin >> s;
    if(s == "a")print("vowel");
    else if(s == "i")print("vowel");
    else if(s == "u")print("vowel");
    else if(s == "e")print("vowel");
    else if(s == "o")print("vowel");
    else print("consonant");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0;i<n;i++) cin >> h[i];
  sort(h.begin(),h.end());
  long long ans=0;
  for(int i=0;i<n-k;i++){
    ans+=h[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int N,M;
vector<int> v;
vector<int> w;

int main(){
    cin >> N >> M;
    v.resize(M);
    if(N>=M){
        cout << 0 << endl;
        return 0;
    }
    for(int i=0;i<M;i++) cin >> v[i];
    sort(v.begin(),v.end());
    for(int i=0;i<M-1;i++){
        w.push_back(v[i+1]-v[i]);
    }
    sort(w.begin(),w.end(),greater<int>());
    int ans = v[M-1]-v[0];
    for(int i=0;i<N-1;i++){
        ans -= w[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main(void)
{
    int x, y;
    int buf = 0;
    
    for (int i = 0; i < 3000; i++) {
        cin >> x >> y;
        if (x == 0 && y == 0){
            break;
        }
        if (x > y) {
            buf = x;
            x = y;
            y = buf;
        }
        cout << x << " " << y << endl;
    }
}


Measured memory_bytes: 2980
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    int n;
    string buhin[100];
    int bup[100];
    int m;
    int o;
    string buren[100];
    
    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin>>buhin[i]>>bup[i];
    }
    cin>>m;
    for(int i=0;i<m;i++){
      string rnk;
      int rnkp;
      int hikaku=0;
      cin>>rnk>>o;
      for(int j=0;j<n;j++){
	if(rnk==buhin[j]){
	  rnkp=bup[j];
	}
      }
      for(int j=0;j<o;j++){
	cin>>buren[j];
	for(int k=0;k<n;k++){
	  if(buren[j]==buhin[k]){
	    hikaku+=bup[k];
	  }
	}	
      }
      
      if(hikaku<rnkp){
	for(int j=0;j<n;j++){
	  if(rnk==buhin[j]){
	    bup[j]=hikaku;
	  }
	}
      }
    }
    string c;
    cin>>c;
    for(int i=0;i<n;i++){
      if(c==buhin[i]){
	cout<<bup[i]<<endl;
      }
    }
  }
}

Measured memory_bytes: 1212
import Data.List
import Data.Tuple
main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  xs <- map (\[a,b] -> (a,b)) . map (map read . words) . lines <$> getContents :: IO [(Int,Int)]
  print $ step n (xs ++ map swap xs) 1 []

step :: Int -> [(Int,Int)] -> Int -> [Int] -> Int
step n path dest arrived
  | sort (dest:arrived) == [1..n] = 1
  | dest `elem` arrived =  0
  | otherwise = 
      let 
        ns = map snd $ filter (\(a,_) -> a==dest) path
      in
       sum $ [r | next<-ns, let r = step n path next (dest:arrived)]

Measured memory_bytes: 892
N = int(input())
a = [int(x) for x in input().split()]
ans = []
li = [0]*N
x = 0
for ind,i in enumerate(a[N//2:]):
    if(i==1):
        ans.append(ind+1+N//2)
        li[ind+N//2] = 1
for ind,i in enumerate(a[:N//2][::-1]):
    n = N//2-ind
    if(sum(li[n-1::n])%2!=i):
        li[n-1]=1
        ans.append(n)
ans.sort()
print(len(ans))
if(len(ans)!=0):
    print(*ans)


Measured memory_bytes: 14268
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

string S;
cin >> S;

rep(i,3){
	cout << S[i-1];
}











	return 0;

}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
/*iamsorry*/
 
#define thegamebegins   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fileio          freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define int             long long
#define float           long double
#define test            int t; cin>>t; while(t--)
#define in(a,n)         for(int i=0; i<n; ++i)  cin>>a[i]
#define r0              return 0
#define E               "\n"
#define S               " "
#define elif            else if 
#define M               1000000007
#define fi(i,x,y)       for(int i=x; i<y; ++i)
#define fa(i,s)         for(auto i:s)
#define fp(i,s)         for(auto i=(s).begin(); i!=(s).end(); ++i)
#define vi              vector <int>
#define vpii            vector <pair <int,int> >
#define mii             map <int,int>
#define pii             pair <int,int>
#define seti            set <int>
#define setd            set <int,greater <int> >
#define all(s)          (s).begin(),(s).end()
#define sortd(a,n)      sort(a, a+n, greater<int>())
#define pb              push_back
#define mp              make_pair
#define fr              first
#define sc              second
#define lb              lower_bound
#define ub              upper_bound
#define er              equal_range
 
const int INF = 0x3f3f3f3f;

signed main()
{
    thegamebegins

    int n;  cin>>n;
    int ans=(n/500)*1000;
    n%=500;
    ans+=(n/5)*5;
    cout<<ans;
    r0;
}

Measured memory_bytes: 384
import sys
n=int(input())
p=list(map(int,input().split()))
q=sorted(p)
for i in range(n-1):
  for j in range(i,n):
    s=p[i]
    p[i]=p[j]
    p[j]=s
    if p==q:
      print("YES")
      sys.exit()
    s=p[i]
    p[i]=p[j]
    p[j]=s
      
print("NO")

      
      
    
    

Measured memory_bytes: 9124
N,M=map(x->parse(Int,x),split(readline()," "))
Ai=map(x->parse(Int,x),split(readline()," "))


sn=sum(Ai)
m_num=sum(4M*(Ai).>=sn)
if m_num >= M
	print("Yes")
else
  print("No")
end

Measured memory_bytes: 111820
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int n, d;
	cin >> n >> d;

	vector<vector<int>> x(n, vector<int>(d));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}

	int cnt = 0;
	for (int i = 0; i < n; i++) {

		for (int j = i + 1; j < n; j++) {
			int sum = 0;
			for (int k = 0; k < d; k++) {
				int num = x[i][k] - x[j][k];
				sum += num * num;
			}

			for (int k = 0; k * k <= sum; k++) {
				if (k * k == sum) {
					cnt++;
				}
			}
			
		}


	}

	cout << cnt << endl;
}


Measured memory_bytes: 3516
n,x,y=map(int,input().split())
ans=[0]*(n-1)
for i in range(1,n):
  for j in range(i+1,n+1):
    ans[min(j-i,abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(x-j))-1]+=1
for i in ans:
  print(i)

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

int main(){
  string s;
  char p[2] = { '0' , '1' };
  int a=0,b=0;
  
  cin >> s;
  
  
  
  for(int i=0; i<s.size(); i++){
    if( s[i] == p[i%2] ) a++;
  }
  
  for(int i=0; i<=s.size(); i++){
    if( s[i] == p[(i+1)%2] ) b++;
  }
  
  cout << min(a,b) << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

void solve(void){
    string s;
    cin >> s;
    ll num = 0; //0num

    rep(i,0,s.size()){
        if(s[i] == '0')num++;
    }
    cout << min((ll)s.size() - num,num)*2<< endl;

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}

Measured memory_bytes: 512
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

using namespace std;


int main(int argc, char* argv[]){
    long long N;
    cin >> N;

    while(N > 0){
        if(N % 10 == 7){
            cout << "Yes";
            return 0;
        }
        N /= 10;
    }

    cout << "No";
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    int ans=0;
    if(a>b){
      ans+=a;
      a--;
    }else{
      ans+=b;
      b--;
    }
    if(a>b){
      ans+=a;
      a--;
    }else{
      ans+=b;
      b--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 892
def solve( i, t )
	$isExist[ t ] = true
	if i < $n
		solve( i+1, t-$arrA[i] )
		solve( i+1, t )
	end
end


$isExist = Array.new( 2000, false );

$n = gets.to_i
$arrA = gets.split( " " ).map { |val| val.to_i }
s = 0
for val in $arrA
	s += val
end
q = gets.to_i
arrM = gets.split( " " ).map { |val| val.to_i }

solve( 0, s )
for i in ( 0 ... q )
	if $isExist[ arrM[i] ]
		puts( "yes" )
	else
		puts( "no" )
	end
end

Measured memory_bytes: 6124