akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
int a[200005];
int mp[2100];
signed main()
{
	string s;
	cin>>s;
	reverse(all(s));
	int y=1;
	for (int i=0;i<sz(s);i++){
		a[i]=(y*(s[i]-'0'))%2019;
		y=(y*10)%2019;
	}
	y=0;
	for (int i=0;i<sz(s);i++){
		y=(y+a[i])%2019;
		mp[y]++;
	}
	int ans=0;
	for (int i=0;i<2019;i++){
		ans=ans+mp[i]*(mp[i]-1)/2;
	}
	ans+=mp[0];
	cout<<ans;
	re 0;
}

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

using namespace std;

long long a, b, n;

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

    cin >> a >> b >> n;

    long long x = min(b - 1, n);

    cout << (a * x / b) << "\n";
    
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 100100100;
using namespace std;

int main()
{
  char n[3];
  cin >> n;

  rep(i,3) {
    if(n[i]=='1') n[i]='9';
    else if(n[i]=='9') n[i]='1';
  }

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

  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

const int INF = 10010010;

int main()
{
    int A, B, ans = INF, Xa = 0, Xb = 0;
    cin >> A >> B;
    if(A % 2 == 0) Xa = A * 25 / 2;
    else Xa = A * 25 / 2 + 1;
    Xb = B * 10;
    //cout << Xa << " " << Xb <<endl;
    int aXb = 0, bXa = 0;
    aXb = 0.08 * Xb; 
    bXa = 0.1 * Xa;
    if(aXb == A) ans = Xb;
    if(bXa == B) ans = min(ans, Xa);
    if(ans != INF) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<char> C(N);
  int rc = 0;
  for (int i = 0; i < N; i++) {
    cin >> C[i];
    if (C[i] == 'R') rc++;
  }
  
  int ans = 0;
  for (int i = 0; i < rc; i++) {
    if (C[i] == 'W') ans++;
  }
   
  cout << ans;
 
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	if(n == 0)
	{
		cout<<endl;
		return 0;
	}
	char s[3] = {'~','~','~'};
	/*
	if(m == 0)
	{
		if(n>1)
			cout<<"-1"<<endl;
		else
			cout<<"0"<<endl;
		return 0;
	}
	*/
	for(int i=0;i<m;i++)
	{
		int n1;
		char m1;
		cin>>n1>>m1;
		n1--;
		if(n1 == 0&&m1 == '0'&&n>1)
		{
			cout<<"-1"<<endl;
			return 0;
		}
		if(s[n1] == '~')
			s[n1] = m1;
		else if(s[n1]!=m1)
		{
			cout<<"-1"<<endl;
			return 0;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(i == 0&&n>1&&!(s[i]>='1'&&s[i]<='9'))
			s[i] = '1';
		if(s[i] == '~')
			s[i] = '0';
	}
	if(s[0] == '0'&&n>1)
	{
		cout<<"-1"<<endl;
	} 
	else
		for(int i=0;i<n;i++)
			cout<<s[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int N;
ll M;
vector<vector<int>> edge;
vector<ll> dp, dp_rev;
vector<vector<ll>> dp_l, dp_r;

void dfs(int now, int par) {
    for (int nxt : edge[now]) {
        if (nxt == par) continue;
        dfs(nxt, now);
        dp[now] *= (dp[nxt]+1);
        dp[now] %= M;
    }
    int K = edge[now].size();
    if (K == 0) return;
    
    dp_l[now].resize(K, 1);
    if (edge[now][0] != par) dp_l[now][0] = dp[edge[now][0]]+1;
    for (int i = 1; i < K; i++) {
        dp_l[now][i] = dp_l[now][i-1];
        if (edge[now][i] != par) dp_l[now][i] = dp_l[now][i] * (dp[edge[now][i]]+1) % M;
    }
    
    dp_r[now].resize(K, 1);
    if (edge[now][K-1] != par) dp_r[now][K-1] = dp[edge[now][K-1]]+1;
    for (int i = K-2; i >= 0; i--) {
        dp_r[now][i] = dp_r[now][i+1];
        if (edge[now][i] != par) dp_r[now][i] = dp_r[now][i] * (dp[edge[now][i]]+1) % M;
    }
    return;
}

void dfs_rev(int now, int par) {
    int K = edge[now].size();
    for (int i = 0; i < K; i++) {
        int nxt = edge[now][i];
        if (nxt == par) continue;
        dp_rev[nxt] = dp_rev[now];
        if (i >= 1) {
            dp_rev[nxt] *= dp_l[now][i-1];
            dp_rev[nxt] %= M;
        }
        
        if (i <= K-2) {
            dp_rev[nxt] *= dp_r[now][i+1];
            dp_rev[nxt] %= M;
        }
        dp_rev[nxt]++;
        dfs_rev(nxt, now);
    }
    return;
}

int main() {
    scanf("%d %lld", &N, &M);
    edge.resize(N);
    dp.resize(N, 1);
    dp_rev.resize(N, 1);
    dp_l.resize(N);
    dp_r.resize(N);
    for (int i = 0; i < N-1; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        x--;y--;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    
    dfs(0, -1);
    dfs_rev(0, -1);
    for (int i = 0; i < N; i++) {
        printf("%lld\n", dp[i]*dp_rev[i]%M);
    }
    return 0;
}

Measured memory_bytes: 27700
slime_num = int(input())
slime_color = input()
color_list = []
for slime in slime_color:
    color_list.append(slime)
for slime in range(slime_num):
    if slime == slime_num - 1:
        break
    if color_list[slime]  == color_list[slime + 1]:
        color_list[slime] = ""
slime_color_ans = ""
for color in color_list:
    if color != "":
        slime_color_ans += color
print(len(slime_color_ans))

Measured memory_bytes: 4212
#include <cstdio>
#include <algorithm>

using namespace std;

const int kMax = 100 + 5;

int n;
int num[kMax], dp[kMax][kMax];

int main() {
    scanf("%d", &n);
    for(int i = 1;i <= n;++ i) scanf("%d%d", &num[i-1], &num[i]);
    for(int l = 2;l <= n;++ l) {
        for(int i = 1;i <= n - l + 1;++ i) {
            int j = i + l - 1;
            dp[i][j] = (1 << 30);
            for(int k = i;k < j;++ k) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + num[i-1] * num[k] * num[j]);
        }
    }
    printf("%d\n", dp[1][n]);
    return 0;
}

Measured memory_bytes: 2692
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	string s;
	int n;
	cin>>s>>n;
	string t;
	for(int i=0;i<s.size();i+=n){
		t.push_back(s[i]);
	}
	cout<<t<<endl;
}

Measured memory_bytes: 256
A, B = map(int, input().split())

import math


Alist = []
Blist = []


for i in range(2000):
    taxA = i*0.08
    taxA = math.floor(taxA)
    if taxA == A:
        # print(i, taxA, i*0.08)
        Alist.append(i)

# exit()

for i in range(2000):
    taxB = i*0.10
    taxB = math.floor(taxB)
    if taxB == B:
        Blist.append(i)

# print(Alist)
# print(Blist)
Aset = set(Alist)
Bset = set(Blist)
Res = Aset.intersection(Bset)
if not Res:
    print(-1)
    exit()
ans = sorted(Res)[0]
print(ans)


Measured memory_bytes: 3188
s=str(input())

a=s[0]
b=s[1]
c=s[2]
d=s[3]

if a==b and b==c and c==d:
  print("No")
elif a==b and c==d:
  print("Yes")
elif a==c and b==d:
  print("Yes")
elif a==d and b==c:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38256
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

int ck(int X,int N){
    if(X >= N){
        return 1;
    }else{
        return 0;
    }
}

int main(){
    int N,X,ans = 1,L,S=0;
    cin >> N >> X;
    for(int i =  0;i < N;i++){
        cin >> L;
        S = S + L;
        ans = ans + ck(X,S);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define PI 3.14159265
using namespace std;
int main() {
  int len, rot;
  float x, y, shita;
  x = y = shita = 0;
  while(1) {
    scanf("%d,%d", &len, &rot);
    if (len == 0 && rot == 0) {
      break;
    }
    x += len * cos(shita * PI / 180);
    y += len * sin(shita * PI / 180);
    shita += rot;
  }
  cout << (int)y <<  endl;
  cout << (int)x << endl;
  return 0;
}

Measured memory_bytes: 3400
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 3005; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


bool sieve[N]; int n, ans=0;

void solve()
{
    fill(sieve,sieve+N,true);
    sieve[0]=sieve[1]=false;
    for (int i=2; i<=N; i++) {
        if (sieve[i] && i*i<=N) {
            for (int j=i*i; j<=N; j+=i) sieve[j] = false;
        }
    }

    cin >> n;
    int i=11;
    while (n>0) {
        if (sieve[i]) {
            sout(i); n--;
        }i+=10;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, beg, end) for (int i = beg; i < end; i++)

int id[1000000+5];
int sz[1000000+5];
void ufinit(int n)
{
    for (int i = 1; i < n + 1; i++)
    {
        id[i] = i;
        sz[i] = 1;
    }
}

int root(int i)
{
    while (i != id[i])
    {
        id[i] = id[id[i]];
        i = id[i];
    }

    return i;
}

bool connected(int p, int q)
{
    return root(p) == root(q);
}

void link(int p, int q)
{
    int i = root(p);
    int j = root(q);
    if (i == j)
        return;
    if (sz[i] < sz[j])
    {
        id[i] = j;
        sz[j] += sz[i];
    }
    else
    {
        id[j] = i;
        sz[i] += sz[j];
    }
}

vector<set<int>> graph(1000000+5);
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    ufinit(n);
    rep(i, 0, m)
    {
        int p, q;
        cin >> p >> q;
        link(p, q);
        graph[p].insert(q);
        graph[q].insert(p);
    }
    rep(i, 0, k)
    {
        int p, q;
        cin >> p >> q;
        if (connected(p,q))
        {
            graph[p].insert(q);
            graph[q].insert(p);
        }
    }
    rep(i, 1, n + 1)
    {
        int ans = sz[root(i)] - graph[i].size() - 1;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 70912
#!/mnt/c/Users/moiki/bash/env/bin/python
H,W = map(int, input().split())
a = [ list(map(int, input().split())) for _ in range(H)]

diff = lambda a,b: abs(a[0]-b[0]) + abs(a[1]-b[1])

trainsition_list = []
for h in range(H):
    step = 1 if h%2==0 else -1
    for w in range(W)[::step]:
        trainsition_list.append( (h,w) )

ans_tuple = []
n = 0
for pos,next_pos in zip(trainsition_list, trainsition_list[1:]):
    h,w = pos
    if a[h][w] % 2 == 1:
        nh,nw = next_pos
        a[nh][nw] += 1
        ans_tuple.append( (h,w,nh,nw) )
        n += 1

print(n)
for atp in ans_tuple:
    print( *(map(lambda x: x+1, atp)))


Measured memory_bytes: 85916
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

double area_n(const vector<P> &v) {
    double ans = 0;
    double x, y, z;
    P init = v[0];
    rep(i,2,v.size()) {
        x = sqrt(norm(v[i] - init));
        y = sqrt(norm(v[i-1] - init));
        z = sqrt(norm(v[i] - v[i-1]));

        double s = (x + y + z) / 2;
        ans += sqrt(s * (s-x) * (s-y) * (s-z));
    }
    return ans;
}

int main() {
    vector<P> v;
    double a, b;
    while(~scanf("%lf,%lf", &a, &b)) v.pb(P(a,b));

    printf("%.8f\n",area_n(v));
    return 0;
}

Measured memory_bytes: 1256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
//const int MAX=;

int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}

int main(){
	int N;
	cin>>N;
	
	int m;
	cin>>m;
	rep(i,N-1){
		int a;
		cin>>a;
		m=gcd(m,a);
	}
	cout<<m;
}

Measured memory_bytes: 256
'use strict';
const main = input => {
  let x = parseInt(input[0]);
  for(let i=x;i<(2*x); i++) {
    let check = 0;
    for(let j=2; j<i-1; j++) {
      if (i%j == 0) {
        check = 1;
        break;
      }
    }
    if (!check) {
      return console.log(i);
    }
  }

}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 21064
#include <stdio.h>

int main(void)
{
	int a,b,c;
	int n[5];
	scanf("%d %d %d %d %d",&n[0],&n[1],&n[2],&n[3],&n[4]);
	for(a=0;a<5;a++){
		for(b=a;b<5;b++){
			if(n[a]<n[b]){
				c=n[a];
				n[a]=n[b];
				n[b]=c;
			}
		}
	}
	for(a=0;a<4;a++)
		printf("%d ",n[a]);
	printf("%d\n",n[4]);
	return 0;
}

Measured memory_bytes: 1804
#include <iostream>

using namespace std;
 
int a[305];
int b[305];

int main() {
    int n;
    
    while(cin >> n && n != 0) {
    	
        for(int i = 0; i <= n; i++) {
        	
            a[i] = 1;
            b[i] = 0;
            
        }
        
        for(int i = 2; i <= 17; i++) {
        	
            for(int j = 0; j <= n; j++) 
            	for(int k = 0; k+j <= n; k+=i*i)
					b[j+k] += a[j];
					
            for(int j = 0; j <= n; j++) {
            	
                	a[j] = b[j];
					b[j] = 0;
					
            }
            
        }
        
        cout << a[n] << "\n";
        
    }
    
    return 0;
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
string a,b;
int n;
bool cmp(char x,char y)
{
    return x>y;
}
int main()
{
    cin>>a>>b;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),cmp);
    if(a<b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
} 

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

const int MOD = 1e9+7;
void add(int &a,int b) { a = (a + b + MOD) % MOD; }

signed main(){

  int n,m; cin >> n >> m;
  vector<int> a(n,0);
  for(int i = 0; i < m; i++){
    int p; cin >> p;
    a[p] = 1;
  }

  vector<int> dp(n+3,0);
  dp[0] = 1;
  for(int i = 0; i < n; i++){
    if(a[i]) continue;
    add(dp[i+1],dp[i]);
    add(dp[i+2],dp[i]);
  }
  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 1792
class Node:
    def __init__(self, val):
        self.num = val
        self.val = val
        self.is_parent = True
        self.parent = None
        self.childs = []

    def show(self):
        print(self.num, end=" ")
        print(self.is_parent, end=" ")
        for child in self.childs:
            print(child.num, end=" ")

def root(node):
    depth = 0
    while node.parent != None:
        node = node.parent
        depth += 1
    return node, depth

N, M = map(int, input().split())

roots = [Node(i) for i in range(N)]
count = N

for i in range(M):
    x, y, z = map(int, input().split())
    x = roots[x-1]
    y = roots[y-1]
    if x.is_parent and y.is_parent:
            y.is_parent = False
            y.parent = x
            count -= 1
            x.childs.append(y)
    else:
        root_x, depth_x = root(x)
        root_y, depth_y = root(y)
        if root_x != root_y:
            if depth_x >= depth_y:
                root_y.is_parent = False
                root_y.parent = root_x
                count -= 1
                root_x.childs.append(root_y)
            else:
                root_x.is_parent = False
                root_x.parent = root_y
                count -= 1
                root_y.childs.append(root_x)

print(count)

Measured memory_bytes: 41460
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int A = nextInt();
      int B = nextInt();
      myout(A ^ B);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32860
# D - Teleporter
N,K = map(int,input().split())
A = [0]+list(map(int,input().split()))
s = {1:0}
l = [1]
i = 1
for j in range(1,10**10):
    i = A[i]
    if i in s:
        sigma = j-s[i]
        break
    s[i] = j
    l.append(i)
if K<s[i]:
    print(l[K])
else:
    K -= s[i]
    mod = l[s[i]:]
    print(mod[K%sigma])

Measured memory_bytes: 39944
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int cnt = 0;
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = n; i >= 1; i--) {
            int c = 0;
            for (int j = i; j <= n; j+= i) if (ans[j-1] == 1) c++;
            if (a[i-1] == c % 2) continue;
            cnt++;
            ans[i - 1] = 1;
        }
        System.out.println(cnt);
        for (int i = 1; i <= n; i++) {
            if (ans[i - 1] == 1) {
                System.out.print(i + " ");
            }
        }
        System.out.println();
    }

}


Measured memory_bytes: 81448
N, M, X = map(int, input().split())
C = [0] * N
A = [0] * N
AA = [list(map(int, input().split())) for i in range(N)]
for i in range(len(AA)):
    C[i] = AA[i][0]
    A[i] = AA[i][1:]
ans = sum(C) + 1
for p in range(2 ** N):
    Y = [0] * M
    cnt = 0
    for i, c in enumerate(C):
        if p % 2 == 1:
            cnt += c
            for j, a in enumerate(A[i]):
                Y[j] += a
        p //= 2
    ans = min(ans, cnt) if min(Y) >= X else ans
print(ans if ans <= sum(C) else -1)

Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e2+5;
int n, w, weight[A], val[A];
ll dp[A][100005];
ll build()
{
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= w; j++)
		{
			ll ret = dp[i-1][j];
			
			if (j - weight[i] >= 0)
				ret = max(ret, dp[i-1][j - weight[i]] + val[i]);
			
			dp[i][j] = ret;
		}
	}
	return dp[n][w];
}

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n >> w;
	for (int i = 1; i <= n; i++)
		cin >> weight[i] >> val[i];
	cout << build();
	return 0;
}
	/*

	states : indx , weight

	base case : dp[0][ay 7aga] = 0, dp[ay 7aga][0] = 0

	transitions : dp[i][j] = dp[i-1][j]  |  dp[i-1][j-w] + val

	0   0

	3   30
		
	4   50
	
	5   60
	
	
	 */


Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
string s;
long long int i,t, idx;
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin>>i>>t;
	priority_queue<long long int> it;
	for(long long int a = 0; a < i; a++){
	    long long int x;
	    cin>>x;
	    it.push(x);
	}

    while(t != 0){
        long long int aux = it.top();
        it.pop();
        long long int ans = aux;
        long long int tickets = 1;
        while(t != 0 && (aux >= it.top() || it.empty())){
            t--;
            aux = floor(ans/pow(2,tickets));
            tickets++;
        }
        it.push(aux);
    }
    long long int ans = 0;
    while(!it.empty()){
        ans+= it.top();
        it.pop();
    }
    cout<<ans<<"\n";
}
	


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

using namespace std;
using ll = long long;

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

int main() {
  int n, m;
  cin >> n >> m;
  cout << (n == m ? "Yes" : "No") << endl;
  return 0;
}


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

typedef long long ll;

int main()
{
  ll n;
  cin >> n;
  for (int h = 1; h <= 3500; h++)
  {
    for (int w = 1; w < 3500; w++)
    {
      ll x = 4 * h * w - n * (w + h);
      if (x > 0 && (n * h * w) % x == 0)
      {
        ll y = (n * h * w) / x;
        cout << h << " " << w << " " << y << endl;
        return 0;
      }
    }
  }
}


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

int main(void){
  char b; cin >> b;
  if(b == 'A') cout << "T" << endl;
  else if(b == 'T') cout << "A" << endl;
  else if(b == 'G') cout << "C" << endl;
  else cout << "G" << endl;
  return 0;
}


Measured memory_bytes: 256
/*
        Author: Prokash
                CSE48, JU

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int ara[2005];
int main()
{
    FAST;
    ll k;
    string n;
    cin>>n>>k;
    ll j;
    for(ll i=0,j=1;i<n.size()&&j<=k;i++,j++)
    {
        if(n[i]!='1')
        {
            cout<<n[i]<<endl;
            return 0;
        }
    }
    cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  int N, T;
  cin >> N >> T;
  vector<int> t;
  rep(i, N) {
    int ti;
    cin >> ti;
    t.pb(ti);
  }

  int sum = 0;
  int i = 0;

  while (i < (N - 1)) {
    if((t[i + 1] - t[i]) < T) {
      sum += (t[i + 1] - t[i]);
    } else {
      sum += T;
    }
    i++;
  }
  sum += T;

  cout << sum << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main() {
    int N; cin>>N;
    int cmp=0;
    int i;
    for (i = 1; cmp<N ; i++) {
        cmp+=i;
    }
    --i;
    if(cmp>N){
        cout<<"No"<<endl;
        return 0;
    }

    vector<vector<int>> S(i+1,vector<int>(i,-1));
    int cnt=1;
    for (int j = 0; j < i + 1; ++j) {
        int k = 0;
        for ( ; k < j; ++k) {
            S[j][k]=S[k][j-1];
        }
        for( ; k<i;++k){
            S[j][k]=cnt;
            ++cnt;
        }
    }

    cout<<"Yes\n"<<i+1<<endl;

    for (int l = 0; l < i + 1; ++l) {
        cout<<i<<" ";
        for (int m = 0; m < i-1; ++m) {
            cout<<S[l][m]<<" ";
        }
        cout<<S[l][i-1]<<endl;
    }

    return 0;
}


Measured memory_bytes: 2176
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from decimal import Decimal 
from math import floor
def main():
    a, b = map(Decimal, input().split())
    ans = a*b
    print(floor(ans))
if __name__ == '__main__':
    main()


Measured memory_bytes: 71460
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    int ans = 0;
    cin >> s;
    rep(i, 0, 6) if(s[i] == '1') ans++;
    cout << ans << endl;
}

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

int main(){
  int n;
  cin >>n;
  vector<int> a(n);
  int num[n] = {0};
  rep(i,n) {
    cin >>a[i];
    a[i]--;
    num[a[i]]++;
  }
  rep(i,n){
    cout << num[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4820
#include <stdio.h>
#include <math.h>

int main(void)
{
	double a[1000];
	double b , c ;
	int n, i;

	while (1)
	{
		scanf("%d", &n);
		if (n == 0)
		{
			break;
		}
		for (i = 0,b=0;i < n;i++)
		{
			scanf("%lf", &a[i]);
			b += a[i];
		}
		scanf("\n");

		b /= n;
		for (i = 0,c=0;i < n;i++)
		{
			c += ((a[i] - b)*(a[i] - b));
		}
		c /= n;
		printf("%.8f\n", sqrt(c));
	}
	return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int ret=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return w*ret;
}
int h,w;
bitset<25610> s[85][85];
int a[85][85];
int b[85][85];
int main()
{
	cin>>h>>w;
	for(register int i=1;i<=h;i++)
	for(register int j=1;j<=w;j++) a[i][j]=read();
	for(register int i=1;i<=h;i++)
	for(register int j=1;j<=w;j++) b[i][j]=read();
	s[0][1][12800]=1;
	for(register int i=1;i<=h;i++)
	for(register int j=1;j<=w;j++)
	{
		int x=abs(a[i][j]-b[i][j]);
		for(register int k=-12800;k<=12800;k++)
		{
			if(k-x>=-12800) s[i][j][k+12800]=s[i][j][k+12800]|s[i-1][j][k-x+12800],s[i][j][k+12800]=s[i][j][k+12800]|s[i][j-1][k-x+12800];
			if(k+x<=12800) s[i][j][k+12800]=s[i][j][k+12800]|s[i-1][j][k+x+12800],s[i][j][k+12800]=s[i][j][k+12800]|s[i][j-1][k+x+12800];
		}
	}
	for(register int i=0;i<=12800;i++)
	if(s[h][w][12800+i]||s[h][w][12800-i])
	{
		cout<<i<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 22912
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(S) cout << "S" << endl

   int main(){
      int N;
      cin >> N;
     vector <int> vec(N);
       vector <int> vec1(N);
       
     for(int i=0;i<N;i++){
       cin >> vec[i];
         vec1[i] = vec[i];
     }
       sort(vec.begin(),vec.end());
       int max = vec[N-1];
       int second = vec[N-2];
       rep(i,N){
           if(vec1[i] == max){
               cout << second << endl;
           }
           else intput(max);
    }
   }


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ll long long
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a-1) * (b-1) << "\n";
}

Measured memory_bytes: 3568
x, y = map(int, input().split())

kame_num = x
turu_num = x - kame_num

for i in range(x):
  if kame_num * 4 + turu_num * 2 == y:
    print("Yes")
    break
  else:
    kame_num -= 1
    turu_num += 1
    if i == x - 1:
      if kame_num * 4 + turu_num * 2 == y:
        print("Yes")
      else:
        print("No")



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

int main(){
  int n;
  cin>>n;
  vector<int>arr(n);
  for(int i=0; i<n; i++) cin>>arr[i];
  sort(arr.begin(),arr.end());
  int ret = 0;
  for(int i=0; i<n; i++){
  	for(int j=i+1; j<n; j++){
  		for(int k=j+1; k<n; k++){
  			if(arr[i]==arr[j] || arr[j]==arr[k]) continue;
  			if(arr[i]+arr[j]>arr[k]) ret++;
		  }
	  }
  }
  cout<<ret;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(void){
    int H,W;
    int moji;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
        }
        for(int row=0;row<H;row++){
            if(row%2==0){//縦列が偶数の時はmoji=0
                moji=0;
            }else{//奇数はmoji=1
                moji=1;
            }
            for(int col=0;col<W;col++){
                if(moji==1){//mojiが1の時は'.'が出る。mojiを0に変える
                    printf(".");
                    moji=0;
                }
                else if(moji==0){//mojiが0の時は'#'が出る。mojiを1に変える
                    printf("#");
                    moji=1;
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2588
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;

int gcd(int a, int b){
	if(a < b) swap(a,b);
	if(a == 0 || b == 0) return max(a,b);
	else return gcd(b, a % b);
}

int main(){
	int n, tmp;
	vector<int> v;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> tmp;
		v.push_back(tmp);
	}
	int ans = v[0];
	for(int i = 1; i < n; i++)
		ans = ans * v[i] / gcd(ans, v[i]);
	cout << ans << endl;
}

Measured memory_bytes: 1212
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int res = 0;
    for(int r = 0; r * R <= N; r++) {
        for(int g = 0; g * G + r * R <= N; g++) {
            if((N - G * g - R * r) % B == 0)
                res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split(' '))
count = [0 for i in range(N)]

for _ in range(K):
    d = int(input())
    A = list(map(int, input().split(' ')))
    for a in A:
        count[a - 1] += 1

ans = sum([c == 0 for c in count])
print(ans)

Measured memory_bytes: 9140
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007
const int N = 501031;

long long cnt[1000];
string st;
long long ans;

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>st;
	for (int i=0;i<st.size();i++)
	{
		cnt[st[i]]++;
	}

	for (int i='a';i<='z';i++)
	{
		for (int j=i+1;j<='z';j++)
		{
			ans+=1ll*cnt[i]*cnt[j];
		}
	}

	cout<<ans+1<<endl;

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 720
#include<stdio.h>

int main(){
  int n,M[100][100],a[100][100];
  int i,j,k,c,d;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }

  for(i=0;i<n;i++){
    for(j=0;j<2;j++){
      scanf("%d",&a[i][j]);
    }
    for(j=2;j<(a[i][1]+2);j++){
      scanf("%d",&a[i][j]);
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<a[i][1];j++){
      c=a[i][0];
      d=a[i][j+2];
      M[c-1][d-1]=1;
    }
  }
  
  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      printf("%d ",M[i][j]);
    }
    printf("%d\n",M[i][j]);
  }
  return 0;
}



Measured memory_bytes: 2108
using System;
using System.Linq;

class MainClass{
        public static void Main(string[] args){
            var N    = int.Parse(Console.ReadLine());
            var nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();

            for (int n = 0; n < N - 1; n++)
            {
                Console.Write("{0} ", nums[n]);
            }
            Console.Write("{0}\n", nums[N - 1]);


            for (int i = 1; i < nums.Count(); i++){
                var temp = nums[i];
                var j = i - 1;

                while (j >= 0 && nums[j] > temp){
                    nums[j + 1] = nums[j];
                    j--;
                }

                nums[j + 1] = temp;

                for (int n = 0; n < N - 1; n++){
                    Console.Write("{0} ", nums[n]);
                }
                if (i != N - 1)
                    Console.Write("{0}\n", nums[N - 1]);
                else
                    Console.WriteLine("{0}", nums[N - 1]);
            }
        }
            
    }

Measured memory_bytes: 9612
#B
N = int(input())
T , A = map(int, input().split())
H = list(map(int, input().split()))
Temp = [0]*N

for i in range(N):
    Temp[i] = abs((T - 0.006 * H[i]) - A )

print(Temp.index(min(Temp))+1)

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

const int Maxn = 300005;

int n;
int a[Maxn];
int res[Maxn];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int ind; scanf("%d", &ind); ind--;
        a[ind]++;
    }
    sort(a, a + n);
    int pos = 0;
    for (int i = 0; i < n; i++) {
        res[i] = a[i];
        if (i + 1 < n)
            while (a[i] > 0) {
                if (pos <= i) {
                    pos = i + 1;
                    while (pos + 1 < n && a[pos] == a[pos + 1]) pos++;
                }
                a[i]--; a[pos]++; pos--;
            }
    }
    for (int i = n - 1; i >= 0; i--)
        printf("%d\n", res[i]);
    return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		int count=0;
		for(int i=1;i<=N-K+1;i++) {
			if(i+K-1>N) {
				break;
			}else {
				count++;
			}
			
		}
		System.out.println(count);
	}
	
		
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define mod 1000000007
#define inf 1e9
#define endl '\n'
#define zeros(x) ((x)&(-x))

using namespace std;

typedef long long ll;
typedef long double ld;

ll n, g, dp[3005][6010];
pair<ll, ll> V[3005];

int main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>g;
    for (int i=1; i<=n; i++)
    {
        cin>>V[i].first>>V[i].second;
    }

    sort(V+1, V+n+1);

    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=g+3005; j++)
        {
            dp[i][j] = -inf;
        }
    }

    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=g+3005; j++)
        {
            dp[i][j] = max(dp[i][j-1], dp[i-1][j]);

            if (j>=V[i].first && j-V[i].first < g)
                dp[i][j] = max(dp[i][j], dp[i-1][j-V[i].first] + V[i].second);
        }
    }

    cout<<dp[n][g + 3005];
    return 0;
}

Measured memory_bytes: 141184
count = int(input().rstrip())
shops = [input().split() for i in range(count)]
gain = [input().split() for i in range(count)]

 
max = -1000000000
for k in range(1,1024):
    tmp = format(k,'b').zfill(10)
    tmp_sum = 0
    for N in range(count):
        shop_count = 0
        for l in range(10):
            if tmp[l] == shops[N][l] and tmp[l] =='1':
                shop_count +=1
        tmp_sum += int(gain[N][shop_count]) 
    if max < tmp_sum:
        max = tmp_sum
 
print(max)

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;

    if (a >= 13) {
        cout << b << endl;
    }
    else if (a <= 12 && a >= 6) {
        cout << b/2 << endl;
    }
    else {
        cout << "0" << endl;
    }
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  vector<string> ans = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  rep(i,0,7) {
    if (ans[i] == s) {
      cout << 7-i << endl;
    }
  }
  return 0;
}


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

r = 0
for j in range(W):
    if map[0][j] == "#":
        r = j
for i in range(1,H):
    flag = 1
    for j in range(W):
        if flag and map[i][j] == "#":
            if r != j:
                print('Impossible')
                exit()
            flag = 0
        elif map[i][j] == "#":
            r = j

print('Possible')


Measured memory_bytes: 3060
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#define pii pair<int,int>
#define f first
#define s second
using namespace std;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
queue<pii>q;
queue<int>qq;
int n,m,ans;
string s[22];
bool vis[22][22];
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(s[i][j]=='#')
			{
				continue;
			}
			for(int x=0;x<n;x++)
			{
				for(int y=0;y<m;y++)
				{
					vis[x][y]=false;
				}
			}
			q.push(pii(i,j));
			qq.push(0);
			vis[i][j]=true;
			int mx=0;
			while(!q.empty())
			{
				pii p=q.front();
				int st=qq.front();
				q.pop();
				qq.pop();
				int x=p.f,y=p.s;
				for(int d=0;d<4;d++)
				{
					int nx=x+dx[d],ny=y+dy[d];
					if(nx<0 || ny<0 || nx>=n || ny>=m)
					{
						continue;
					}
					if(vis[nx][ny])
					{
						continue;
					}
					if(s[nx][ny]=='#')
					{
						continue;
					}
					mx=max(mx,st+1);
					q.push(pii(nx,ny));
					qq.push(st+1);
					vis[nx][ny]=true;
				}
			}
			ans=max(ans,mx);
		}
	}
	cout<<ans<<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++)

int main(){
    int k;cin>>k;
    int check[k];
    rep(i,k)check[i]=0;
    int i=1,j=7,ans;
    while(1){
        j%=k;
        if(j==0){ans=i;break;}
        if(check[j]==1){ans=-1;break;}
        check[j]=1;
        j=j*10+7;
        i++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7532
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii;
import std.typecons, std.functional;
import std.algorithm, std.container;

void scanValues(TList...)(ref TList list)
{
    auto lit = readln.splitter;
    foreach (ref e; list)
    {
        e = lit.fornt.to!(typeof(e));
        lit.popFront;
    }
}

T[] scanArray(T = long)()
{
    return readln.split.to!(long[]);
}

void scanStructs(T)(ref T[] t, size_t n)
{
    t.length = n;
    foreach (ref e; t)
    {
        auto line = readln.split;
        foreach (i, ref v; e.tupleof)
        {
            v = line[i].to!(typeof(v));
        }
    }
}

T scanElem(T = long)()
{
    string res;
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        res ~= cast(char) c;
        c = getchar;
    }
    return res.strip.to!T;
}

template fold(fun...) if (fun.length >= 1)
{
    auto fold(R, S...)(R r, S seed)
    {
        static if (S.length < 2)
        {
            return reduce!fun(seed, r);
        }
        else
        {
            import std.typecons : tuple;

            return reduce!fun(tuple(seed), r);
        }
    }
}

struct Factor
{
    long n;
    long c;
}

Factor[] factors(long n)
{
    Factor[] res;
    for (long i = 2; i ^^ 2 <= n; i++)
    {
        if (n % i != 0)
            continue;

        int c;
        while (n % i == 0)
        {
            n = n / i;
            c++;
        }
        res ~= Factor(i, c);
    }
    if (n != 1)
        res ~= Factor(n, 1);

    return res;
}

bool isPrime(long n)
{
    if (n <= 1)
        return false;
    if (n == 2)
        return true;
    if (n % 2 == 0)
        return false;
    for (long i = 3; i ^^ 2 <= n; i += 2)
        if (n % i == 0)
            return false;
    return true;
}

void main()
{
    auto N = scanElem;
    auto M = scanElem;
    long[] aList = scanArray;
    long sum;
    long[long] map;
    map[0]++;
    foreach(n; aList)
    {
        sum += n;
        map[sum%M]++;
    }
    long res;
    foreach(k, e; map)
    {
        foreach(i; 1..e)
        {
            res+=i;
        }
    }
    writeln(res);
}


Measured memory_bytes: 5072
using System;
using System.Collections.Generic;

public class Hello{
    public static void Main(){
        var lineSplited = new List<string>();

        string line;
        while ((line=Console.ReadLine()) != null) {
            lineSplited.Add(line);
        }
        string ans = "Yay!";
        if(int.Parse(lineSplited[4]) - int.Parse(lineSplited[0]) > int.Parse(lineSplited[5])) ans = ":(";
        System.Console.WriteLine(ans);
    }
}


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

#define LL long long
#define ULL unsigned long long

#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) (((l)+(r))>>1)

const int MOD = (int) 1e9 + 7;
const double eps = (double) 1e-8;
const int maxn = (int) 2e5 + 20;
const double pi = (double) acos(-1.0);

LL po[maxn], inv[maxn];

LL fp(LL a, LL n, LL m)
{
    LL res = 1;
    while(n)
    {
        if(n & 1) res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
}

LL C(int n, int m)
{
    return po[n] * inv[m] % MOD * inv[n - m] % MOD;
}

int n, m, k;

void work()
{
    po[0] = 1;
    for(int i = 1; i < maxn; i++) po[i] = po[i - 1] * i % MOD;
    inv[maxn - 1] = fp(po[maxn - 1], MOD - 2, MOD);
    for(int i = maxn - 2; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % MOD;

    cin >>n >>m >>k;

    LL ans = 0;

    LL mm = (LL) m * m % MOD;
    LL nn = (LL) n * n % MOD;
    for(int i = 1; i < n; i++)
    {
        LL tmp = (LL) i * (i + 1) / 2 % MOD;
        tmp = tmp * mm % MOD;
        ans += tmp;
    }
    for(int i = 1; i < m; i++)
    {
        LL tmp = (LL) i * (i + 1) / 2 % MOD;
        tmp = tmp * nn % MOD;
        ans += tmp;
    }
    ans %= MOD;
    ans = ans * C(n * m - 2, k - 2) % MOD;
    cout <<ans <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r" ,stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416

    int tc = 1;
//    scanf("%d", &tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 3328
n = int(input())

def factorize(N):
    arr = []
    for x in range(2, int(pow(N, 0.5) + 1)):
        cnt = 0
        while N % x == 0:
            cnt += 1
            N = N // x

        if cnt > 0:
            arr.append((x, cnt))

    if N != 1:
        arr.append((N, 1))

    return arr

euler = 1
for p, m in factorize(n):
    euler *= pow(p,m) - pow(p,m-1)

print(euler)


Measured memory_bytes: 5640
#include<iostream>

using namespace std;

int n,m;
long int p[501][501];
int cp[501];

void invit(int a){
	int b;
	for(b=1;b<=n;b++){
		if(p[a][b]==1 && cp[b]==0)cp[b]=a;
	}
}

int main(){
	int a,b;
	int ans=0;
	while(1){
		ans=0;
		for(a=0;a<=500;a++)for(b=0;b<=500;b++)p[a][b]=0,cp[a]=0;
		cp[1]=1;
		cin >> n;
		cin >> m;
		if(n==0 && m==0)break;
		for(a=0;a<m;a++){
			int c,d;
			cin >> c >> d;
			p[c][d]=1;
			p[d][c]=1;
		}
		for(a=1;a<=n;a++)if(cp[a]==1)invit(a);
		for(a=2;a<=n;a++)if(cp[a]>0)ans++;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll ans=0;
  rep(i,n-1){
    if(a[i]==a[i+1]){
      a[i+1]=-1;
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>

using std::list;
using std::max;
using std::min;
using std::vector;

int main()
{
  int ncontest;
  scanf("%d", &ncontest);
  if(1000 <= ncontest) {
    puts("ABD");
  } else {
    puts("ABC");
  }
  return 0;
}


Measured memory_bytes: 760