akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def solve():
    MOD = 10**9 + 7

    N = int(input())
    ABs = [tuple(map(int, input().split())) for _ in range(N)]

    def gcd(a, b):
        while b:
            a, b = b, a%b
        return a

    cntPos = Counter()
    cntNeg = Counter()
    num00 = 0
    for A, B in ABs:
        if A == B == 0:
            num00 += 1
            continue
        if A == 0:
            cntNeg[(0, 1)] += 1
        elif B == 0:
            cntPos[(0, 1)] += 1
        else:
            isPN = A*B < 0
            A, B = abs(A), abs(B)
            g = gcd(A, B)
            A, B = A//g, B//g
            if isPN:
                cntNeg[(B, A)] += 1
            else:
                cntPos[(A, B)] += 1

    numPoss = []
    numNegs = []

    numIso = 0
    for key in set(cntPos.keys()) | set(cntNeg.keys()):
        if cntPos[key] > 0 and cntNeg[key] > 0:
            numPoss.append(cntPos[key])
            numNegs.append(cntNeg[key])
        else:
            numIso += cntPos[key] + cntNeg[key]

    M = len(numPoss)
    numAlls = [0] * M
    numOKs = [0] * M
    numNGs = [0] * M
    for i in range(M):
        numPos = numPoss[i]
        numNeg = numNegs[i]
        numAll = pow(2, numPos+numNeg, MOD)
        numOK = pow(2, numPos, MOD) + pow(2, numNeg, MOD) - 1
        numNG = numAll - numOK
        numAlls[i] = numAll
        numOKs[i] = numOK
        numNGs[i] = numNG

    acc = pow(2, numIso, MOD)
    accNumAlls = [acc]
    for i in reversed(range(M)):
        acc *= numAlls[i]
        acc %= MOD
        accNumAlls.append(acc)
    accNumAlls.reverse()

    N -= num00
    ans = pow(2, N, MOD) - 1
    accOK = 1
    for i in range(M):
        num = accOK * numNGs[i] * accNumAlls[i+1] % MOD
        ans -= num
        ans %= MOD
        accOK *= numOKs[i]

    print(ans + num00)


solve()


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if ( a >= b ){
     if ( a == 1 ){
      cout << b << endl;
     }
     else if ( a == 2 ){
      cout << 11*b << endl;
     }
     else if ( a == 3 ){
      cout << 111*b << endl;
     }
     else if ( a == 4 ){
      cout << 1111*b << endl;
     }
     else if ( a == 5 ){
      cout << 11111*b << endl;
     }
     else if ( a == 6 ){
      cout << 111111*b << endl;
     }
     else if ( a == 7 ){
      cout << 1111111*b << endl;
     }
     else if ( a == 8 ){
      cout << 11111111*b << endl;
     }
     else if ( a == 9 ){
      cout << 111111111*b << endl;
     }
  }
  else {
     if ( b == 1 ){
      cout << a << endl;
     }
     else if ( b == 2 ){
      cout << 11*a << endl;
     }
     else if ( b == 3 ){
      cout << 111*a << endl;
     }
     else if ( b == 4 ){
      cout << 1111*a << endl;
     }
     else if ( b == 5 ){
      cout << 11111*a << endl;
     }
     else if ( b == 6 ){
      cout << 111111*a << endl;
     }
     else if ( b == 7 ){
      cout << 1111111*a << endl;
     }
     else if ( b == 8 ){
      cout << 11111111*a << endl;
     }
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define mymalloc(p,n) {p = malloc((n)*sizeof(*p));if ((p)==NULL) {printf("not enough memory?\n"); exit(1);};}

typedef struct obj{
	struct obj **word;
	int isIn;
}words;

words *createObj(){
	int i;
	words *W;
	mymalloc(W,1);
	mymalloc(W->word,4);
	for(i=0;i<4;i++){
		W->word[i]=NULL;
	}
	W->isIn=0;
	return W;
}

int num(char w){
	if(w=='A'){
		return 0;
	}else{
	if(w=='T'){
		return 1;
	}else{
	if(w=='G'){
		return 2;
	}else{
	if(w=='C'){
		return 3;
	}}}}
}

void insert(words *W,char *key){
	int i,l;
	words *w;
	l=strlen(key);
	w=W;
	for(i=0;i<l;i++){
		if(w->word[num(key[i])]!=NULL){
			w=w->word[num(key[i])];
		}
		else{
			w->word[num(key[i])]=createObj();
			w=w->word[num(key[i])];
		}
	}
	w->isIn=1;
	
}

int find(words *W,char *key){
	int i,l;
	words *w;
	l=strlen(key);
	w=W;
	for(i=0;i<l;i++){
		if(w->word[num(key[i])]!=NULL){
			w=w->word[num(key[i])];
		}
		else{
			return 0;
		}
	}
	if(w->isIn==1){return 1;}
	else{return 0;}
}
		
main(){
	int i,n,mes;
	char com[7],str[14];
	words *W;
	W=createObj();
	scanf("%d ",&n);
	for(i=0;i<n;i++){
		scanf(" %s %s",com,str);
		if(strcmp(com,"find")==0){
			mes=find(W,str);
			if(mes==0){
				puts("no");
			}
			else{
				puts("yes");
			}
		}
		else{
			insert(W,str);
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

/// The definitions in this library are as below.
#define rI readInt
#define rL readLong
#define rC readChar
#define rC2 readChar2
#define rS readString

#define pb push_back

#define acc accumulate
namespace __library_79brue{
    /// This is a C++ library which improves the programming speed by \
        defining frequently used data structures or algorithms.       \
        This library can be freely used without any copyrights,       \
        but I recommend not to change the name of this library.       \
        Made by 79brue                                                \
        2019

    /// The functions or structures in this library are as below.
    /// quit()
    /// readInt() readLong() readChar() readChar2() readString()

    /// terminates the program
    inline void quit(){
        exit(0);
    }

    /// reads an integer
    inline void readInt(int& _x){
        scanf("%d", &_x);
    }

    /// reads a long-long integer
    inline void readLong(ll& _x){
        scanf("%lld", &_x);
    }

    /// reads a character
    inline void readChar(char& _x){
        scanf(" %c", &_x);
    }

    /// reads a character, the character may be space or line-break, etc...
    inline void readChar2(char &_x){
        scanf("%c", &_x);
    }

    inline void readString(char* _x){
        scanf("%s", _x);
    }
}
using namespace __library_79brue;

int n;
vector<int> link[202];
int num[202];
int dist[202][202];
int ans;

void makeNumbers(int x, int y){
    num[x] = y;
    for(auto &z: link[x]){
        if(num[z]){
            if(num[z] == y){
                printf("-1");
                quit();
            }
            continue;
        }

        makeNumbers(z, 3-y);
    }
}

int main(){
    rI(n);
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            dist[i][j] = 1e9;
            int x;
            scanf("%1d", &x);
            if(x){
                link[i].push_back(j);
                link[j].push_back(i);
                dist[i][j] = 1;
            }
        }
    }

    makeNumbers(1, 1);

    for(int k=1; k<=n; k++) for(int i=1; i<=n; i++) for(int j=1; j<=n; j++){
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }

    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            if(i==j) continue;
            ans = max(ans, dist[i][j]);
        }
    }

    printf("%d", ans+1);
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long 

using namespace std;
const int Inf = 1e15;
const int maxn = 207;

struct Edge
{
    int u, v, flow;
    Edge(){};
    Edge(int u, int v, int flow) :u(u), v(v), flow(flow) {}
};

struct MaxFlow
{
    const int maxr = 1e5 + 7;
    int source, sink, h[maxn];
    vector<Edge> e;
    vector<int> adj[maxn];
    vector<int>::iterator cur[maxn];
    void Reset(int u, int v)
    {
        source = u, sink = v;
        for(int i = source; i <= sink; i++) adj[i] = {};
        e = {};
    }
    void AddEdge(int u, int v, int flow)
    {
        adj[u].push_back(e.size());
        e.push_back(Edge(u, v, flow));
        adj[v].push_back(e.size());
        e.push_back(Edge(v, u, 0));

    }
    bool BFS()
    {
        for(int i = source; i <= sink; i++) h[i] = 1e9;
        h[sink] = 0;
        queue<int> q;
        q.push(sink);
        while(!q.empty())
        {
            int gau = q.front();
            q.pop();
            for(auto i: adj[gau])
            {
                i ^= 1;
                int meo = e[i].u;
                if(e[i].flow == 0 || h[meo] != 1e9) continue;
                h[meo] = h[gau] + 1;
                if(meo == source) return true;
                q.push(meo);
            }
        }
        return false;
    }
    int DFS(int u, int FlowIn)
    {
        if(u == sink) return FlowIn;
        int FlowOut = 0;
        for(; cur[u] != adj[u].end(); cur[u]++)
        {
            int i = *cur[u];
            int v = e[i].v;
            if(e[i].flow == 0 || h[v] + 1 != h[u]) continue;
            int maxFlow = DFS(v, min(e[i].flow, FlowIn));
            FlowIn -= maxFlow;
            FlowOut += maxFlow;
            e[i].flow -= maxFlow;
            e[i ^ 1].flow += maxFlow;
            if(FlowIn == 0) break;
        }
        return FlowOut;
    }
    int FindMaxFLow()
    {
        int ans = 0;
        while(BFS())
        {
            for(int i = source; i <= sink; i++) cur[i] = adj[i].begin();
            ans += DFS(source, Inf);
        }
        return ans;
    }
} Dinitz;
int n, m;
int32_t main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   if(fopen("test.inp", "r")) freopen("test.inp", "r" ,stdin);
   cin >> n >> m;
   Dinitz.Reset(0, n + m + 1);
   for(int i = 1; i <= n; i++)
   {
      for(int j = 1; j <= m; j++)
      {
         char s;
         cin >> s;
         if(s == '.') continue;
         if(s == 'S')
         {
            Dinitz.AddEdge(0, i, Inf);
            Dinitz.AddEdge(0, n + j, Inf);
         }
         else if(s == 'T') 
         {
            Dinitz.AddEdge(i, n + m + 1, Inf);
            Dinitz.AddEdge(n + j, n + m + 1, Inf);
         }
         else
         {
            Dinitz.AddEdge(i, n + j, 1);
            Dinitz.AddEdge(n + j, i, 1);
         }
      }
   }
   int ans = Dinitz.FindMaxFLow();
   if(ans >= Inf) cout << -1;
   else
   cout << ans;
}

Measured memory_bytes: 2220
#include<bits/stdc++.h>
#pragma GCC optimize("inline,Ofast",3)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;
#define gc getchar()
#define lowbit(x) (x&(-x))
//register
//inline
//i=-~i
inline int read(){
	int sum=0,f=1;
	char ch=gc;
	while(!isdigit(ch)){
		if(ch=='-')f=-1;
		ch=gc;
	}
	while(isdigit(ch)){
		sum=(sum<<1)+(sum<<3)+(ch^48);
		ch=gc;
	}
	return f*sum;
}
int n;
int a[10],b[10];
string aa,bb;
long long ans;
char aaa[10],bbb[10];
bool ck(){
	for(register int i=1;i<=n;i=-~i)if(aaa[i]!=bbb[i])return 1;
	return 0;
}
int main(){
	n=read();
	for(register int i=1;i<=n;i=-~i)a[i]=read(),aa+=char(a[i]+48);
	for(register int i=1;i<=n;i=-~i)b[i]=read(),bb+=char(b[i]+48);
	if(aa<bb){
		swap(aa,bb);
	}
	for(register int i=1;i<=n;i=-~i)bbb[i]=bb[i-1],aaa[i]=aa[i-1];
	while(ck()){
		next_permutation(bbb+1,bbb+1+n);
		ans++;
	}
	printf("%lld",ans);
	return 0;
}


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

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    int a,b,c,d;
    cin>>a>>b>>c>>d;

    bool flag = true;
    while(a>0 && c>0){
        if(!flag){
            a -= d;
            flag = true;
        }
        else{ 
            c -= b;
            flag = false;
        }
    }
    if(a>0) cout<<"Yes";
    else cout<<"No";
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3636
import std.stdio;
import std.string;
import std.conv;
import std.bigint;
import std.typecons;
import std.algorithm;
import std.array;
import std.math;
import std.range;
 
void main() {
    auto N = readln.chomp.to!int;
    auto A = sort(readln.split.to!(ulong[]));
    auto B = sort(readln.split.to!(ulong[]));
    auto C = sort(readln.split.to!(ulong[]));
    writeln(sum(B.map!(b => A.lowerBound(b).length * C.upperBound(b).length)));
}


Measured memory_bytes: 12372
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;


int main(){
   int t=1 ;
   //cin>>t ;
   while(t--){
     string s ;
     cin>>s;
     int ans=0 ;
     for(char c:s){
        ans+=(int)c - (int)'0' ;
        ans%=9 ;
     }
     if(ans==0) cout<<"Yes" ;
     else cout<<"No" ;
    }


}



Measured memory_bytes: 3688
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n; cin >> n;
    vector<int> nums;
    for(int i = 0; i < n; ++i){
    	int x; cin >> x;
    	nums.pb(x);
    }
    sort(nums.begin(), nums.end());
    int y = nums[n - 1];
    int sum = 0;
    for(int i = 0; i < n - 1; ++i) sum += nums[i];
    if(sum > y) cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
} 

Measured memory_bytes: 256
# Problem https://atcoder.jp/contests/abc064/tasks/abc064_a
yes = "YES"
no = "NO"

r,g,b = gets.chomp('\n').split(' ').map(&:to_i)
allNumber = r*100 + g*10 + b
amari = allNumber % 4
if amari == 0
    puts(yes)
else
    puts(no)
end


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

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

string S, T;

int main()
{
  cin >> S >> T;
  int change = 0, ans = 1000;
  FOR( i, 0, S.size()-T.size()+1 ) {
    change = 0;
    REP( j, T.size() ) {
      if( S[j+i] != T[j] ) change++;
    }
    ans = min(ans, change);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>

int main(){
  int n;
  int cards[4][13];
  char suit;
  int number;

  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 13; j++){
      cards[i][j] = 0;
    }
  }

  std::cin >> n;

  for(int i = 0; i < n; i++){
    std::cin >> suit >> number;
    switch(suit){
    case 'S':
      cards[0][number - 1] = 1;
      break;
    case 'H':
      cards[1][number - 1] = 1;
      break;
    case 'C':
      cards[2][number - 1] = 1;
      break;
    case 'D':
      cards[3][number - 1] = 1;
      break;
    }
  }

  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 13; j++){
      if(cards[i][j] == 0){
	switch(i){
	case 0:
	  std::cout << 'S' << ' ' << j + 1 << std::endl;
	  break;
	case 1:
	  std::cout << 'H' << ' ' << j + 1 << std::endl;
	  break;
	case 2:
	  std::cout << 'C' << ' ' << j + 1 << std::endl;
	  break;
	case 3:
	  std::cout << 'D' << ' ' << j + 1 << std::endl;
	  break;
	}
      }

    }
  }

  return 0;
}

Measured memory_bytes: 3076
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    int q;
    cin >> s >> q;
    deque<char> st;
    F0R(i,sz(s))
        st.pb(s[i]);
    bool rev=0;
    while(q--)
    {
        int t;
        cin >> t;
        if(t==1)
            rev=!rev;
        else
        {
            int f;
            char c;
            cin >> f >> c;
            if(rev)
            {
                if(f==1)
                    st.pb(c);
                else
                    st.push_front(c);
            }
            else
            {
                if(f==1)
                    st.push_front(c);
                else
                    st.pb(c);
            }
        }
    }
    if(rev)
        REV(st);
    F0R(i,sz(st))
        cout << st[i];

    return 0;
}


Measured memory_bytes: 976
#include<iostream>
#include<map>
#include<string>
#include<algorithm>

int main() {
	int n, m;
	std::cin >> n;

	std::map<std::string, int> mp;

	for (int i{}; i < n; ++i) {
		std::string t;
		std::cin >> t;
		if (mp.count(t) == 0)
			mp.emplace(t, 1);
		else
			++mp[t];
	}
	std::cin >> m;
	for (int i{}; i < m; ++i) {

		std::string t;
		std::cin >> t;
		if (mp.count(t) == 0)
			mp.emplace(t, -1);
		else
			--mp[t];
	}

	int ans{-100};
	for (auto&e : mp)
		ans = std::max(ans, e.second);

	std::cout << std::max(ans,0) << "\n";

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int a, b;
  while (cin >> a >> b) {
    if (a == 0 && b == 0) break;
    int n;
    cin >> n;
    int dp[20][20];
    bool ng[20][20];
    REP(i, 20) REP(j, 20) {
      dp[i][j] = 0;
      ng[i][j] = false;
    }
    REP(i, n) {
      int x, y;
      cin >> x >> y;
      x--, y--;
      ng[y][x] = true;
    }
    dp[0][0] = 1;
    REP(i, b) REP(j, a) {
      if (ng[i][j]) continue;
      dp[i + 1][j] += dp[i][j];
      dp[i][j + 1] += dp[i][j];
    }
    cout << dp[b - 1][a - 1] << endl;
  }
  return 0;
}


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

using namespace std;
const int N = 8;
int _w;

int n, m, a[N][N], k, b[N][N];

bool check( int s ) {
	memset(b, 0, sizeof b);
	b[0][0] = 1;
	int x = 0, y = 0;
	for( int i = 0; i < k; ++i ) {
		int d = (s>>i)&1;
		d ? ++x : ++y;
		if( x == n || y == m ) return false;
		b[x][y] = 1;
	}
	for( int i = 0; i < n; ++i )
		for( int j = 0; j < m; ++j )
			if( a[i][j] != b[i][j] )
				return false;
	return true;
}

int main() {
	cin >> n >> m, k = n+m-2;
	for( int i = 0; i < n; ++i )
		for( int j = 0; j < m; ++j ) {
			char ch;
			_w = scanf( " %c", &ch );
			a[i][j] = ch == '#';
		}
	for( int i = 0; i < (1<<k); ++i )
		if( check(i) )
			return puts("Possible"), 0;
	return puts("Impossible"), 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(),ans1 = 0,ans2 = 0;
        List<Integer> list = new ArrayList<>();
        for(int i = 0;i < A; i++){
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        if(A % 2 == 0) {
            while (A >= 1) {
                ans1 += list.get(A - 1);
                ans2 += list.get(A - 2);
                A -= 2;
            }
        }else{
            while(A >= 0){
                ans1 += list.get(A-1);
                if(A == 1){
                    break;
                }
                ans2 += list.get(A-2);
                A -= 2;
            }
        }
        System.out.println(ans1-ans2);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll ans[110][110];
bool flag[2][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	ll ans = 0;
	ll res = 0;
	rep(i, n) {
		cin >> a[i];
		if (a[i]) {
			res += a[i];
		}
		else {
			ans += res / 2;
			res = 0;
		}
	}
	ans += res / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) {
        PrintWriter pw = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String read1 = null;
        String read2 = null;
        try {
            read1 = br.readLine();
            read2 = br.readLine();
            br.close();
        } catch (IOException e){
            e.printStackTrace();
        }
        String str[] = read1.split(" ", 0);
        String at[] = read2.split(" ", 0);
        int h = Integer.parseInt(str[0]);
        int n = Integer.parseInt(str[1]);
        for (int i = 0; i < n; i++) {
            h = h - Integer.parseInt(at[i]);
        }
        if (h <= 0) {
            pw.println("Yes");
        }else {
            pw.println("No");
        }
        pw.flush();
    }
}

Measured memory_bytes: 35152
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>

// #include <stack>
// #include <queue>
// #include <deque>
// #include <set>
// #include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

// #include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;
typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';

/*
Edge cases:


*/

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


    string s; cin>>s;

    if (s[2]==s[3] && s[4]==s[5]) {
        cout<<"Yes";
    } else {
        cout<<"No";
    } cout<<el;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)

int main() {
    int N; cin >> N;
    using P = pair<int, int>;
    vector<P> ans;
    rep(i, 1, N) rep(j, i+1, N+1) {
        if(i + j == N + 1 - N%2) continue;
        ans.emplace_back(i, j);
    }
    cout << ans.size() << '\n';
    for(auto p : ans) cout << p.first << " " << p.second << '\n';
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
    if(i>=k)
    {
      if(arr[i]>arr[i-k])
        cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4472
//A smoothe sea never made a skilled sailor.
//KEEP IT SIMPLE STUPID
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define print(o) for(auto it=(o).begin();it!=(o).end();it++) cout<<*it<<" ";
#define vll vector<ll>
#define pb push_back
#define FOR(n) for(ll i=0;i<n;i++)

int main()
{
    ll x;
    cin>>x;
  ll h=0;
  while(x>=500)
  {
    x-=500;
    h+=1000;
  }
  while(x>=5)
  {
    x-=5;
    h+=5;
  }
  cout<<h;
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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

template<class T>
class SqrtDecomposition {
    using Func = function<T(T, T)>;
    const Func f;
    const T def;
    const int cap = 512;
    int N, K;
    vector<T> data, bucket;
public:
    SqrtDecomposition(int n, T _def, const Func f);
    void update(int x, T y);
    T query(int x, int y);
};

template<class T>
inline SqrtDecomposition<T>::SqrtDecomposition(int n, T _def, const Func f) : N(n), def(_def), f(f) {
    K = (N + cap - 1) / cap;
    data.assign(K * cap, def);
    bucket.assign(K, def);
}

template<class T>
inline void SqrtDecomposition<T>::update(int x, T y) {
    int k = x / cap;
    T val = data[x] = y;
    for(int i = k * cap; i < (k + 1) * cap; ++i) {
        val = f(val, data[i]);
    }
    bucket[k] = val;
}

template<class T>
inline T SqrtDecomposition<T>::query(int x, int y) {
    T val = def;
    for(int k = 0; k < K; ++k) {
        int l = k * cap, r = (k + 1) * cap;
        if(r <= x || y <= l) continue;
        if(x <= l && r <= y) {
            val = f(val, bucket[k]);
        } else {
            for(int i = max(x, l); i < min(y, r); ++i) {
                val = f(val, data[i]);
            }
        }
    }
    return val;
}

int main() {
    int n, q;
    cin >> n >> q;
    SqrtDecomposition<int> sd(n, numeric_limits<int>::max(), [](int a, int b) { return min(a, b); });
    while(q--) {
        int c, x, y;
        cin >> c >> x >> y;
        if(c) cout << sd.query(x, y + 1) << '\n';
        else sd.update(x, y);
    }
    return 0;
}



Measured memory_bytes: 3352
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int, S: "List[int]", C: "List[int]"):
    if N == 1:
        mn, mx = 0, 9
    if N == 2:
        mn, mx = 10, 99
    if N == 3:
        mn, mx = 100, 999
    for v in range(mn, mx + 1):
        val = str(v)
        found = True
        for i in range(M):
            if int(val[S[i] - 1]) != C[i]:
                found = False
        if found:
            print(v)
            return
    print(-1)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, s, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

lint p=1000*1000*1000+7;
lint S[200000];

lint pow_mod(lint a,lint b,lint p){
  if(b==0)return 1;
  if(b%2==0){
    lint d=pow_mod(a,b/2,p);
    return (d*d)%p;
  }else{
    return (a*pow_mod(a,b-1,p))%p;
  }
}

//x / a mod p=x * inv_mod(a,p)
lint inv_mod(lint a,lint p){
  return pow_mod(a,p-2,p);//(a^(p-2))mod p
}

lint calc(lint h,lint w){
  lint ans=S[h+w-2];
  lint div=S[h-1];
  div*=S[w-1];
  div%=p;
  ans*=inv_mod(div,p);
  ans%=p;
  return ans;
}


int main(){
  S[0]=1;
  FOR(i,1,200000){
    S[i]=i*S[i-1];
    S[i]%=p;
  }
  lint H,W,A,B;
  cin>>H>>W>>A>>B;
  lint ans=0;
  REP(i,H-A){
    ans+=(calc(B,i+1)*calc(W-B,H-i))%p;
    ans%=p;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int N,h[105],hmax,hmin,high,count=0,i;
  char str[500],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  h[0]=0;
  h[1]=atoi(p);
  hmax=hmin=h[1];
  
  for(i=2;i<N+1;i++){
    p=strtok(NULL," \n");
  	h[i]=atoi(p);
    if(hmax<h[i]){
      hmax=h[i];
    }
    if(hmin>h[i]){
      hmin=h[i];
    }
  }
  
  count+=hmin;
  
  for(high=hmin+1;high<hmax+1;high++){
    for(i=1;i<N+1;i++){
      if(h[i]<high){
        
      }else if(h[i-1]<high && h[i]>=high){
        count++;
      }
    }
  }
  
  printf("%d\n",count);
  
  return 0;
}

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

int main() {
	string s;
	cin >> s;
	string k = "No";
	if(s.at(2) == s.at(3)&&s.at(4)==s.at(5))
	{
		k = "Yes";
	}
	cout << k << endl;
	return 0;
}


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

using namespace std;

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const int MOD = 1000000007;
const int INF = INT_MAX;

int main(int argc, char const *argv[])
{
    int k, x;
    cin >> k >> x;

    if (500*k >= x){
        puts("Yes");
    }
    else {
        puts("No");
    }
    

    return 0;
}




//              g++ -std=c++1z  

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }else if(a==b){
        printf("a == b\n");
    }
}



Measured memory_bytes: 2608
N = int(input())
A = list(map(int,input().split()))

s = [0]*(N+1)
for i in range(N):
    s[i+1] = s[i] + A[i]
    
cnt = 0
for j in range(N):
    cnt =  (cnt + (A[j]*(s[N] - s[j+1])))%(10**9+7)
print(cnt)

Measured memory_bytes: 104992
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
/*int main()
{
	int n; cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
//	for(int i=0;i<n;i++) cout<<a[i];
	int sum=0;
	for(int i=n-1;i>1;i--)
	{
		for(int j=i-1;j>0;j--)
		{
			if(a[i]==a[j]) continue;
			for(int k=j-1;k>=0;k--)
			{
				if(a[k]!=a[i] and a[k]!=a[j] and a[i] < (a[k] + a[j])) 
				{
					sum++;
				}
				
				if(a[k]!=a[i] and a[k]!=a[j] and a[i] >= (a[k] + a[j])) 
				{
					break;
				}
				
			}
		}
	}
	
	cout<<sum;
}

int main()
{
	int n,d,ans=0;
	cin>>n>>d;
	while(n--)
	{
		int a,b; cin>>a>>b;
		long long int fl=a*a + b*b;
		float sum=sqrt(fl);
		if(sum<=d) ans++;
		
	}
	cout<<ans;
}
int main()
{
	int n,k; cin>>n>>k;
	int a[n],sum=0;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<k;i++) sum+=a[i];
	cout<<sum; 
}

int main()
{
	int n,k; cin>>n>>k;
	k%2==0 and k>=2*n and k<=4*n ? cout<<"Yes" : cout<<"No";
}

int main()
{
	int n; cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	unsigned long long ans=1,ANS;
	vector<int>v;
	for(int i=0;i<n;i++)
	{
		ans*=a[i];
		ANS=ans;
		while(ANS)
		{
			v.push_back(ANS%10);
			ANS/=10;
		}
		if(v.size()>1000000000000000000)
		{
			cout<<"HRE";
			cout<<"-1";
			return 0;
		}
		v.clear();
	}
	cout<<ans;
}*/

int main()
{
	int n; cin>>n;
	string s; cin>>s;
	if(s.size()<=n) cout<<s;
	else {
		
	for(int i=0;i<n;i++) cout<<s[i];
	cout<<"...";
}}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <limits>
using namespace std;
 
#define int int64_t
#define pr(x) cout << x << endl;
#define vi vector<int>
#define vii vector< vector<int> >
#define mp make_pair
#define f(i,n) for(i =0 ; i< n ; i++)
#define ii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define INF 1e9
#define SIZE 200001
#define mod 1000000007
#define int_max 1e12
int dr[]={0,0,1,1,1,-1,-1,-1};
int dc[]={1,-1,0,1,-1,0,1,-1};
 
void solve();
 
int power(int a, int b)
{
    if(b==0) return 1;
    else if(b&1) return a*power(a*a,b/2);
    else return power(a*a, b/2);
}
 
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}  
 
int i, j, k, l, n, m, x, y, t;
void solve()
{ 
    // cin >> t; while(t--)
    {
        cin >> n;
        if(n==1) cout << 0;
        else
        {
            k = n*(n-1)/2;
            cout << k;
        }
        
    }
}

Measured memory_bytes: 256
import math

a,b = map(int,input().split())
 
ans_a = int(math.ceil(a/0.08))
ans_b = int(b/0.1)
 
if ans_a <= ans_b:
  if int(ans_b*0.08) == a:
    print(ans_b)
  else:
    print(-1)
elif ans_b < ans_a:
  if int(ans_a*0.1) == b:
    print(ans_a)
  else:
    print(-1)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int insertionSort(int n,int N[]);
int main(void){
    int n;//需要排序的数字个数
    cin>>n;
    int arr[n];

    for(int i=0;i<n;i++){
        cin>>arr[i];
    }//读入n个数字
    for(int i=0;i<n;i++){
        cout<<arr[i];
        if(i<n-1) cout<<" ";
    }
    cout<<endl;
    insertionSort(n,arr);
    return 0;
}
int insertionSort(int n,int N[]){
    //从小到大
    for(int i=1;i<n;i++){
        int key=N[i];
        int j=i-1;
        while(j>=0&&key<N[j]){
            N[j+1]=N[j];
            j--;
        }
        N[j+1]=key;
        for(int i=0;i<n;i++)
            {
                cout<<N[i];
                if(i<n-1) cout<<" ";
            }
        cout<<endl;
    }
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll


int n;


vector<int> dijkstra(vector<vector<P> >& g,int sp){
  vector<int> dir(n+1,INF);
  dir[sp]=0;
  priority_queue<P,vector<P>,greater<P> > q;
  q.push(P(0,sp));
  while(!q.empty()){
    int d=q.top().F;
    int p=q.top().S; q.pop();
    if(dir[p]!=d) continue;
    rep(i,g[p].size()){
      int np=g[p][i].F;
      int cost=g[p][i].S;
      if(dir[np]>d+cost){
        dir[np]=d+cost;
        q.push(P(dir[np],np));
      }
    }
  }
  return dir;
}



signed main(){

  cin>>n;
  vector<vector<P> > v(n+1);
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    v[a].PB(P(b,1));
    v[b].PB(P(a,1));
  }

  vector<int> a = dijkstra(v,1);
  vector<int> b = dijkstra(v,n);

  int s=0,t=0;
  FOR(i,1,n+1){
    if(a[i]>b[i]) s++;
    if(a[i]<=b[i]) t++;
  
  }

  if(s<t){
    cout<<"Fennec"<<endl;
  }
  else{
    cout<<"Snuke"<<endl;
  }


}


Measured memory_bytes: 9744
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;
 
void IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("test.txt","r",stdin);
    #endif
}
 
const int N=2e6+3,M=5e3+5,mod=1e9+7,dx[]={1,-1,0,0},
                                    dy[]={0,0,1,-1};
const double eps=1e-9;
 
int n,m,k,tc,ans,a[N];
 
int main(){
    scanf("%d",&n);
    if (n <= 599)
        printf("8\n");
    else if (n <= 799)
        printf("7\n");
    else if (n <= 999)
        printf("6\n");
    else if (n <= 1199)
        printf("5\n");
    else if (n <= 1399)
        printf("4\n");
    else if (n <= 1599)
        printf("3\n");
    else if (n <= 1799)
        printf("2\n");
    else
        printf("1\n");

}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int infint = 1e9;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e3 + 7;
ll n, a, b;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n >> a >> b;
	if(a > b)
		return cout << 0, 0;
	if(n == 1)
	{
		if(a == b)
			return cout << 1, 0;
		else
			return cout << 0, 0;
	}
	n -= 2;
	cout << (b - a) * n + 1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vi a(n+1),b(n+1,0),ans;
  rep(i,n)cin >> a[i+1];
  for(int i = n;i>=1;i--){
    int sum = 0;
    for(int j = i;j<=n;j+=i){
      sum+=b[j];
    }
    if(sum%2 != a[i]){
      b[i] = 1;
      ans.push_back(i);
    }
  }
  cout<<sz(ans)<<endl;
  rep(i,sz(ans))cout<<ans[i]<<" ";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 5472
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>


#define MOD 1000000007
#define INTMAX 0x7fffffff
#define INTMIN 0x80000000
#define LLMAX 0x7fffffffffffffffLL
#define LLMIN 0x8000000000000000LL

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define RINGO '@'
#define KAKI '#'
#define MIKAN '*'
#define CHECKED 'C'

using namespace std;
using ll = long long;

int H,W;
int map[100][100];

void dfs(int h, int w, int c){
    if (h < 0 || h >= H || w < 0 || w >= W)
        return;
    if (map[h][w] == CHECKED || map[h][w] != c) {
        return;
    }
    map[h][w] = CHECKED;

    dfs(h + 1, w, c);
    dfs(h, w + 1, c);
    dfs(h - 1, w, c);
    dfs(h, w - 1, c);
}

int main(){
    while (1) {
        cin >> H >> W;
        if (H == 0 && W == 0){
            break;
        }

        char c;
        rep(i, H) {
            rep(j, W) {
                cin >> c;
                map[i][j] = c;
            }
        }
        int n = 0;
        rep(i, H) {
            rep(j, W) {
                if (map[i][j] != CHECKED){
                    dfs(i, j, map[i][j]);
                    ++n;
                }
            }
        }
        cout << n << endl;
    }
}

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

struct edge{
	int to, cost;

	edge(int to, int cost){
		this->to = to;
		this->cost = cost;
	}
};

pair<int, int> diameter(vector<vector<edge>> &v, int now = 0, int dist = 0, int par = -1){
	pair<int, int> r(dist, now);
	for(auto &next:v[now]) if(next.to != par){
		pair<int, int> d = diameter(v, next.to, dist + next.cost, now);
		if(r.first < d.first) r = d;
	}
	return r;
}

int main(){
	int n;
	cin >> n;
	vector<vector<edge>> v(n);
	for(int i = 0; i < n - 1; i++){
		int from, to, cost;
		cin >> from >> to >> cost;
		v[from].emplace_back(edge(to, cost));
		v[to].emplace_back(edge(from, cost));
	}
	cout << diameter(v, diameter(v).second).first << endl;
}

Measured memory_bytes: 17608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<string> s(n);
    vector<ll> t(n);
    REP(i, n) cin >> s[i] >> t[i];
    string x;
    cin >> x;

    ll ret = 0;
    bool turn = false;
    REP(i, n) {
        if(s[i] == x) {
            turn = true;
            continue;
        }
        if(turn) ret += t[i];
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
'use strict'

function main(input) {
    input = input.split('\n')
    const troops = input[1].split('')
    const n = troops.length
    let min, cnt = 0
    let ary = []
    let a, b;

    //EとW、それぞれの累積和を用意しておく
    let countsE = [0] //カウントの関係で0を入れておく
    let countsW = [0]
    for (let i = 1; i <= n; i++) {
        countsW[i] = (troops[i - 1] == 'W') ? countsW[i - 1] + 1 : countsW[i - 1];
        countsE[i] = (troops[i - 1] == 'E') ? countsE[i - 1] + 1 : countsE[i - 1];
    }

    for (let i = 0; i < n; i++) {

        cnt = parseInt(countsW[i]) // 0 からiまでのW >の累積和から
        cnt += countsE[n] - countsE[i + 1] // i+1からnまでのEの累積和から

        min = (min < cnt) ? min : cnt
    }

    console.log(min)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32924
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const long long inf = 1LL << 58;
vector<long long> a;
long long solve(int depth, vector<long long> v) {
	if (depth == 3) return 0;
	long long ans = inf;
	for (int i = 1; i < 1 << v.size(); ++i) {
		vector<long long> nxtv;
		long long sum = 0; int cut = 0;
		for (int j = 0; j < v.size(); ++j) {
			if (!((i >> j) & 1)) nxtv.push_back(v[j]);
			else sum += v[j], ++cut;
		}
		long long res = solve(depth + 1, nxtv);
		ans = min(ans, res + 10 * (cut - 1) + abs(sum - a[depth]));
	}
	return ans;
}
int main() {
	int N;
	cin >> N;
	a = vector<long long>(3);
	for (int i = 0; i < 3; ++i) cin >> a[i];
	vector<long long> L(N);
	for (int i = 0; i < N; ++i) cin >> L[i];
	long long ans = solve(0, L);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        String s = scanner.next();
        System.out.println(s.substring(0, k - 1) + Character.toLowerCase(s.charAt(k - 1)) + s.substring(k));
    }
}

Measured memory_bytes: 20564
#入力部
n,m,x = map(int,input().split())
a = []
c = []
for s in range(n):
	c_tmp,*a_tmp = list(map(int,input().split()))
	c.append(c_tmp)
	a.append(a_tmp)
#ビット全探索処理
c_ans = []
for i in range(2**n):
	ans_box = [0]*m
	c_box = 0
	for j in range(n):
		if(i>>j)&1 == 1:
			for p in range(m):
				ans_box[p] += a[j][p]
			c_box += c[j]
	if min(ans_box) >= x:
		c_ans.append(c_box)
#出力部
print(min(c_ans) if len(c_ans)>0 else -1)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n){
        int a;
        cin >> a;
        mp[a]++;
    }

    int ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if(itr->second % 2 == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4864
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    int q;
    scan(q);

    while (q--) {
        long ai, bi;
        scan(ai, bi);
        solve(ai, bi);
    }
}

void solve(long ai, long bi) {
    long l = sqrt(ai*bi);
    debug {
        writefln("l:%s", l);
    }
    long ans;

    if (l*(l+1) < ai*bi) {
        ans = 2*l - 1;
    }
    else {
        ans = 2*l - 2;
    }

    if (ai == bi) ans++;

    writeln(ans);
}

long sqrt(long x) {
    long btm = 0, top = x;

    while (top - btm > 1) {
        long mid = (top + btm) / 2;

        if (mid < (x+mid-1)/mid) {
            btm = mid;
        }
        else {
            top = mid;
        }
    }

    return btm;
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
package main
  
import (
    "fmt"
)

func main() {
    var n int
    fmt.Scan(&n)

    var sum float64
    for i := 0; i < n; i++ {
        var x float64
        var u string
        fmt.Scan(&x, &u)

        var money float64
        switch u {
        case "JPY":
            money = x
        case "BTC":
            money = 380000 * x
        }
        sum += money
    }

    fmt.Println(sum)
}


Measured memory_bytes: 512