akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long 
int mod;
vector<int> ar;
int expo(int a,int n)
{
		if(n<=0)
				return 1;
		if(n==1)
				return a;
		int tmp=expo(a,n/2);
		tmp=(tmp*tmp)%mod;
		if(n&1)
				tmp=(tmp*a)%mod;
		return tmp;
}
signed main()
{
		int n;
		cin>>n;
		ar.resize(n);
		int c=0;
		string str;
		cin>>str;

		for(int i=0;i<n;++i)
				ar[i]=str[i]=='1'?1:0,c+=ar[i]?1:0;
		mod=c;
		int br[3]={0};
		int dp[300000]={0};
		for(int i=1;i<=200000;++i)
		{
				int x=__builtin_popcount(i);
				dp[i]=1+dp[i%x];
		}
		for(int i=ar.size()-1;~i;--i)
		{
				if(mod>0)
						br[1]=(br[1]+ar[i]*expo(2,ar.size()-i-1))%mod;
				--mod;
				if(mod>0)
						br[0]=(br[0]+ar[i]*expo(2,ar.size()-i-1))%mod;
				mod+=2;
				if(mod>0)
						br[2]=(br[2]+ar[i]*expo(2,ar.size()-i-1))%mod;
				--mod;
		}

		for(int i=0;i<ar.size();++i)
		{
				if(ar[i]==0)
				{
						++mod;
						if(mod==0)
						{
								cout<<0<<endl;
								continue;
						}
						int x=expo(2,ar.size()-i-1);
						cout<<dp[(x+br[2])%mod]+1<<endl;
						--mod;
				}
				else
				{
						--mod;
						if(mod<=0)
						{
								cout<<0<<endl;
								++mod;
								continue;
						}
						int x=expo(2,ar.size()-i-1);
						int ne=(((br[0]-x)%mod)+mod)%mod;
						cout<<1+dp[ne]<<endl;
						++mod;
				}
		}










		return 0;
}



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

int main(){
	int n,x;
	while(cin>>n>>x && (n!=0)){
		int ans=0;
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				for(int k=j+1;k<=n;k++){
					if(i==j || j==k || k==i)continue;

					if(i+j+k == x)++ans;
				}
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, -1, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    vector<vector<int>> B(H, vector<int>(W, -1));
    rep(i, H) cin >> A[i];
    vector<pair<int, int>> Q;
    rep(i, H) rep(j, W) if(A[i][j] == '#') {
        B[i][j] = 0;
        Q.pb(mp(i, j));
    }
    vector<pair<int, int>> R;
    rep(c, 2222) {
        for(auto q: Q) {
            rep(d, 4) {
                if(q.first + dy[d] >= 0 && q.first + dy[d] < H && q.second + dx[d] >= 0 && q.second + dx[d] < W) {
                    if(B[q.first + dy[d]][q.second + dx[d]] < 0) {
                        B[q.first + dy[d]][q.second + dx[d]] = c + 1;
                        R.pb(mp(q.first + dy[d], q.second + dx[d]));
                    }
                }
            }
        }
        Q = R;
        R.clear();
    }
    
    int ans = 0;
    rep(i, H) rep(j, W) ans = max(ans, B[i][j]);
    output(ans);
    
    
    return 0;
}


Measured memory_bytes: 17768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[] seq = new int[n];
      for(int i=0; i!=n; i++)
        seq[i] = Integer.parseInt(br.readLine());

      int cnt = shellSort(seq, n);
      System.out.println(cnt);
      StringBuilder str = new StringBuilder();
      for (int i : seq) {
        str.append(i);
        System.out.println(str);
        str.setLength(0);
      }
    }
  }

  public static int shellSort(int a[], int n) {
    int cnt=0;
    int m = 0;
    int[] aG = new int[100];
    for (int i=0,d=1; d <= n; i++,d=(d*3+1)) {
      aG[i] = d; m++;
    }
    System.out.println(m);
    StringBuilder str = new StringBuilder(m*5);

    for(int i=(m-1); i!=-1; i--){
      cnt += insertionSort(a, n,aG[i]);
      str.append(aG[i]).append(" ");
    }

    str.setLength(str.length()-1);
    System.out.println(str);

    return cnt;
  }
  
  public static int insertionSort(int a[], int max, int g) {
    int cnt=0;

    for (int i=g,j=0,v=0; i < max; i++) {
      for( j=(i-g), v=a[i]; j>=0 && a[j]>v; j=j-g ) {
        a[j+g] = a[j];
        cnt++;
      }
      a[j+g] = v;
    }

    return cnt;
  }
}


Measured memory_bytes: 106028
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int gcd( int x, int y ){ return y ? gcd(y, x%y) : x; }
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
int a=0,b=0;
std::vector< pairint > v(6);
rep(i,10){
std::cin >> x;
y+=x;
}

std::cout << y << '\n';
}



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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];

    int mi = 1145141919;
    for (int i = 0; i < n; i++) {
        int now = 0;
        for (int j = 0; j <= i; j++)now += v[j];
        for (int j = i + 1; j < n; j++)now -= v[j];
        mi = min(mi, abs(now));
    }

    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int main(void) {
 
	int a, b, c, sum;
	a = b = c = sum = 0;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);


	int Swater = b + c;

	if (Swater <= a) {
		sum = 0;
	}else{
		sum = Swater - a;
	}

	printf("%d", sum);
 
	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#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)

int main(){
	
	string s;cin >> s;
	
	rep(i,4) cout << s[i];
	cout<<" ";
	rep(i,8) cout << s[i+4];
	cout <<endl;
	
}

//cout << ans << endl;

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll mx =  a * c;
	mx = max(mx, a * d);
	mx = max(mx, b * c);
	mx = max(mx, b * d);
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#define ll long long
using namespace std;
ll n,m,k;
ll res=0;
ll a[30],b[30];
int main()
{
	cin >>n>>m>>k;
	for (int i=0;i<m;i++) cin >>b[i];
	for (int i=0;i<n;i++)
	{
		ll t=k;
		for (int j=0;j<m;j++)
		{
			ll x;
			cin >>x;
			t+=x*b[j];
		}
		if (t>0) res++;
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let (A, B): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = (A + B - 3) / (A - 1);

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


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    for(int i = 0; i < M; i++) {
        cin >> X[i];
    }
    sort(X.begin(), X.end());
    if(N >= M) {
        cout << 0 << endl; 
        return 0;
    }
    vector<int> distance(M-1);
    for(int i = 0; i < M-1; i++) {
        distance[i] = X[i + 1] - X[i];
    }
    sort(distance.begin(), distance.end(), greater<int>());
    distance.erase(distance.begin() + N - 1, distance.end());
    cout << (X[M-1] - X[0]) - accumulate(distance.begin(), distance.end(), 0) << endl;
    
    return 0;

}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    int s[m],c[m];
    int ans[n];
    rep(i,0,n) ans[i] = -1;
    rep(i,0,m){
        cin >> s[i] >> c[i];
        if(ans[s[i]-1] == -1)ans[s[i]-1] = c[i];
        else if(ans[s[i]-1] != c[i]){
            cout << "-1" << endl;
            return 0;
        }
        if(s[i] == 1 && c[i] == 0 && n != 1){
            cout << "-1" << endl;
            return 0;
        }
    }
    if(ans[0] == -1 && n==1){
        cout << "0" << endl;
        return 0;
    }
    if(ans[0] == -1) ans[0] = 1;
    rep(i,1,n){
        if(ans[i] == -1) ans[i] = 0;
    }
    rep(i,0,n) cout << ans[i];
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int score[2], in[2], n, t;
	
	while(scanf("%d",&n), n!=0){
		score[0]=0, score[1]=0;
		
		for(;n--;){
			scanf("%d %d",&in[0],&in[1]);
		
			if(in[0]!=in[1])
				t=(in[0]>in[1])?0:1,
				score[t]+=in[0]+in[1];
		
			else score[0]+=in[0], score[1]+=in[1];
		}
	
		printf("%d %d\n",score[0],score[1]);
	}
	
	return 0;
}

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

int X[10][10];
int N, D;

bool culc(int a, int b){
	double r=0;
	for(int i=0;i<D;i++){
		r += pow(X[a][i]-X[b][i], 2);
	}

	r = sqrt(r);

	return ceil(r)==floor(r);
}

int main(){
	cin >> N >> D;
	int ans=0;

	for(int i=0;i<N;i++){
		for(int j=0;j<D;j++){
			cin >> X[i][j];
		}
	}

	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			ans += culc(i, j);
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
  long long n, total=0, tmp = 0, x = 0, y = 0, tmpx = 0, tmpy = 0;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }

  for (int i=0; i<n; i++) {
    total += a[i];
  }

  for (int i=0; i<n-1; i++) {
    tmp += a[i];
    tmpx = tmp;
    tmpy = total - tmpx;
    if(i == 0){
      x = tmpx;
      y = tmpy;
    }else if(abs(tmpx-tmpy)<abs(x-y)){
      x = tmpx;
      y = tmpy;
    }
  }
  cout << abs(x-y) << endl;

  return 0;
}


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

#define int long long int
#define mp make_pair
using namespace std;

int32_t main() {
    int n;
    scanf("%lld", &n);
    if(n == 1){
        printf("Hello World");
        return 0;
    }
    int a,b;
    scanf("%lld", &a);
    scanf("%lld", &b);
    printf("%lld",a+b);
    return 0;
}

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

int main()
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int ans = 0;
    if (A + B >= 2*C) {
        if (X < Y) {
            ans += X*2*C;
            int nokori = Y - X;
            if (B > 2*C) { ans += 2*C*nokori; }
            else { ans += B*nokori; }
        }
        else
        {
            ans += Y*2*C;
            int nokori = X - Y;
            if (A > 2*C) { ans += 2*C*nokori; }
            else { ans += A*nokori; }
        }
    }
    else {
        ans += A*X;
        ans += B*Y;
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n, cnt;
int main() {
	while (true) {
		cnt = 0;
		cin >> n;
		if (!n) { break; }
		while (n > 1) {
			if (n % 2 == 1) { n = n * 3 + 1; }
			else { n /= 2; }
			cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;

int h, w, ans = 0;
char _;
queue<pair<int, int>> q;
vector<vector<int>> moves = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } };

int main() {
  cin >> h >> w;
  vector<vector<int>> memo(h, vector<int>(w, -1));
  REP(i, h) REP(j, w) {
    cin >> _;
    if (_ == '#') {
      q.push(make_pair(i, j)); memo[i][j] = 0;
    }
  }
  while(!q.empty()) {
    auto front = q.front();
    q.pop();
    int x = front.first, y = front.second;
    for (auto move: moves) {
      int nx = x + move[0], ny = y + move[1];
      if (nx < 0 || ny < 0 || nx >= h || ny >= w || memo[nx][ny] >= 0) continue;
      memo[nx][ny] = memo[x][y] + 1;
      q.push(make_pair(nx, ny));
    }
  }
  REP(i, h) REP(j, w) ans = max(ans, memo[i][j]);
  cout << ans << "\n";
}

Measured memory_bytes: 12432
import java.util.Scanner;
public class Main {
    static LCS lcs;
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int q = Integer.parseInt(scan.nextLine());
	String x, y;
	for (int i = 0; i < q; i++) {
	    x = scan.nextLine();
	    y = scan.nextLine();
	    lcs = new LCS(x, y);
	    lcs.runFindlcs();
	}
    }
}
class LCS {
    String x;
    String y;
    int[][] lcs;
    LCS (String x, String y) {
	this.x = x;
	this.y = y;
	lcs = new int[x.length()+1][y.length()+1];
    }
    void runFindlcs () {
	for (int i = 0; i < x.length(); i++) {
	    for (int j = 0; j < y.length(); j++) {
		if (x.charAt(i) == y.charAt(j)) {
		    lcs[i+1][j+1] = lcs[i][j] + 1;
		} else {
		    lcs[i+1][j+1] = Math.max(lcs[i][j+1], lcs[i+1][j]);
		}
	    }
	}
	System.out.println(lcs[x.length()][y.length()]);
    }
    
}

Measured memory_bytes: 72456
public class Main {
	
		
		public static void main(String[] args) {
			java.util.Scanner scan = new java.util.Scanner(System.in);
		int a = scan.nextInt();
		int h;
		int m;
		int s;
		h = a/3600;
		m = (a-h*3600)/60;
		s = (a-h*3600)%60;
		if(0<=a  && a<=86400){;
		System.out.println(h+":"+m+":"+s);
		// System.out.println(2*a+2*b);// TODO ?????????????????????????????????????????????
		}
		}	
			
		
	
	}
	

Measured memory_bytes: 26164
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from copy import deepcopy
#import heapq
#import math
#import string

setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
a=[int(i) for i in input().split()]

ans=0
for i in range(n-1):
    for j in range(i+1,n):
        ans+=a[i]*a[j]
print(ans)

Measured memory_bytes: 38512
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        int[] a = {1, 3, 5, 7, 8, 10, 12};
        int[] b = {4, 6, 9, 11};
        if (x == 2 || y == 2) {
            System.out.println("No");
        } else {
            int b1 = Arrays.binarySearch(a, x);
            int b2 = Arrays.binarySearch(a, y);
            if ((b1 >= 0 && b2 >= 0) || (b1 < 0 && b2 < 0)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}

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

int main()
{
    int n, l;
    cin >> n >> l;
    int sum = 0;
    int mini = 10000000;
    int a = 0;
    for(int i=0;i<n;i++){
        if(l == 0){
            a++;
        }
        else if(abs(l) < abs(mini)){
            mini = l;
        }

        sum = sum + l;
        l++;
    }
    if(a == 1){
        cout << sum << endl;
    }
    else{
        cout << sum - mini << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = (int)(1e6) + 5;
vector < pii > G[N];
int color[N];
vi vv;
void dfs(int node)
{
    vv.pb(node);
    for (auto it : G[node])
        if (color[it.fi] == -1)
            color[it.fi] = (color[node] + it.se) % 3,dfs(it.fi);
}
int main(void)
{
    int n,m;
    ll answer = 0;
    cin>>n>>m;
    while (m --)
    {
        int a,b;
        cin>>a>>b;
        G[a].pb(mp(b,1));
        G[b].pb(mp(a,2));
    }
    for (int i = 1;i <= n;++i)
        color[i] = -1;
    for (int i = 1;i <= n;++i)
        if (color[i] == -1)
        {
            color[i] = 0;
            vv.clear();
            dfs(i);
            int ok = 1;
            for (auto u : vv)
                for (auto v : G[u])
                    if (((color[u] + v.se) % 3) != color[v.fi])
                        ok = 0;
            if (!ok)
            {
                answer += 1ll * vv.size() * vv.size();
                continue;
            }
            int e = 0;
            for (auto u : vv)
                e += G[u].size();
            e /= 2;
            int cnt[3] = {0,0,0};
            for (auto u : vv)
                cnt[color[u]] += 1;
            if (*min_element(cnt,cnt+3) == 0)
                answer += e;
            else
            for (int i = 0;i < 3;++i)
                answer += 1ll * cnt[i] * cnt[(i + 1) % 3];
        }
    cout << answer << '\n';
    return 0;
}


Measured memory_bytes: 34296
import sys
N = int(input())
A = list(map(int, input().split()))
 
ans = 1

if A.count(0) != 0:
    print(0)
    sys.exit()

for i in A:

    ans = ans*i
    if ans > int(10**18):
        print(-1)
        sys.exit()
 
if ans > int(10**18):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 21640
#include <stdio.h>
int main(void) {
    int num,pm,pe,pj,i,ave;
    while (1) {
        scanf("%d",&num);
        if (num==0) break;
        for (i=0; i<num; i++) {
            scanf("%d %d %d",&pm,&pe,&pj);
            ave=(pm+pe+pj)/3;
            if (pm==100||pe==100||pj==100||(pm+pe)/2>=90||ave>=80) {
                printf("A\n");
            } else if (ave>=70||(ave>=50&&(pm>=80||pe>=80))) {
                printf("B\n");
            } else {
                printf("C\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 584
import sys

a, b, c, d = map(int, sys.stdin.readline().split())

def main():
    ans = 'No'
    if abs(c - a) <= d: ans = 'Yes'
    elif abs(b - a) <= d and abs(c - b) <= d: ans = 'Yes'
    print(ans)

if __name__ ==  '__main__':
    main()

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main (String args[]) {
	Scanner scan = new Scanner(System.in);
	int count = 0;

	while (scan.hasNext()) {
	    int n = scan.nextInt();

	    for (int a=0; a<10; a++) {
		for (int b=0; b<10; b++) {
		    for (int c=0; c<10; c++) {
			for (int d=0; d<10; d++) {
			    if (a+b+c+d == n) count++;
			}
		    }
		}
	    }
	    System.out.println(count);
	    count = 0;
	}
    }
}

Measured memory_bytes: 26560
def myAnswer(A:int,B:int,S:list) -> str:
   hun = S.pop(A)
   if(hun != "-" or A+B!=len(S)): return "No"

   for s in S:
      asc = ord(s)
      if(asc < 48 or asc > 57): return 'No'
   return "Yes"

def modelAnswer():
   tmp=1
def main():
   A,B = map(int,input().split())
   S = list(input())
   print(myAnswer(A,B,S))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
import Control.Applicative
import Control.Monad

makeLine :: [Int] -> String
makeLine [h, w] = unlines . replicate h $ replicate w '#' 

addReturn :: String -> String
addReturn x = x ++ "\n"

shapingData :: String -> [[Int]]
shapingData = map (map read . words) . takeWhile ( /= "0 0") . lines
main = do
    line <- getContents
    let shapedData = shapingData line 
    putStr $ shapedData >>= addReturn . makeLine 


Measured memory_bytes: 4136
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, ans;
ll A[200010];
std::map<ll, ll> mp;

int main()
{
  std::cin >> N;

  rep( i, N )
    std::cin >> A[i];

  rep( j, N )
  {
    ans += mp[j+1-A[j]];
    
    ++mp[j+1+A[j]];
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 27464
S = input()
p = ["+", ""]

count = 0
for i in range(2 ** (len(S) - 1)):
    t = S[0]
    for j in range(len(S) - 1):
        t += p[i >> j & 1] + S[j + 1]
    #print(t)
    count += eval(t)
print(count)

Measured memory_bytes: 3060
n = gets.chomp.to_i
v = gets.chomp.split(" ").map(&:to_i)
c = gets.chomp.split(" ").map(&:to_i)
sum = 0
n.times do |i|
    if v[i]-c[i] > 0
      sum += v[i]-c[i]
    end
end
puts sum

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

using namespace std;

int main(){
  string s;
  cin>>s;
  int count=0; 
  if(s.size()==1 &&s.at(0)=='?') {
    s.at(0)='D';
  }
  for(int i=0;i<s.size()-1;i++){
    if(s.at(i)=='D'){
      count++;
    }
    else if((s.at(i)=='P') && (s.at(i+1)=='D')) {
      count++;
    }
    else if(s.at(i)=='P' && s.at(i+1)=='?') {
      count+=2;
      s.at(i+1)='D';
    }
    else if(s.at(i)=='?' && s.at(i+1)=='D') {
      count++;
      s.at(i)='D';
    }
    else if(s.at(i)=='?' && s.at(i+1)=='?') {
      count++;
      s.at(i)='D';
      s.at(i+1)='D';
    }
  }
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='?') {
      s.at(i)='D';
 
    }
  }
  cout<<s<<endl;        
  return 0;
}


Measured memory_bytes: 3684
from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd,numbers)


N,K = map(int,input().split())
A = list(map(int,input().split()))
gcd = gcd_list(A)
if K % gcd == 0 and K <= max(A):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 16280
#include <stdio.h>
#define REP(i,n) for (int i=0;i<(n);++i)
const int INF = 1e9;

int A,B;

int main(){
    scanf("%d%d",&A,&B);
    printf("%d\n",A*B - A - B + 1);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node {
  int p, l, r;
};

struct Node T[MAX];
int n;

void preParse(int u) {
  if (u == NIL) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u) {
  if (u == NIL) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u) {
  if (u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main() {
  int v, l, r, root;

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    T[i].p = NIL;
  }

  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if (l != NIL) T[l].p = v;
    if (r != NIL) T[r].p = v;
  }

  for (int i = 0; i < n; i++) {
    if (T[i].p == NIL) {
      root = i;
    }
  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2048
eval'A,B,*C=#'+`tr ' ' ,`
z=0
i=45
i=C.inject(A^B,:^)[i]>0?(z+=t=[A[0,i],(~B)[0,i]].min+1
A-=t
B+=t
45):i-1until(i|A)<0
p A>0?z:-1

Measured memory_bytes: 14492
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#include <map>
#include <random>
/* All our base are belong to AC */
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<int,int>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;};
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
ll adad(ll x) {return x*(x+1)/2;} // 1～xの総和

namespace r {
    random_device rd;
    mt19937 mt(rd());
    //mt19937 mt(time(NULL));
    int nd(int max) {return mt() % max + 1;}
    int nd2(int min, int max) {return mt() % (max - min + 1) + min;}
}

int d;
ll c[26], s[365][26], t[365];
set<int> v[26];
ll an;

void solve0() {
  an=0;
  for(int i=0;i<d;i++) {
    an+=s[i][t[i]];
  }
  for(int i=0;i<26;i++) {
    int bf = -2;
    ll su = 0;
    for(int x : v[i]) {
      su+=adad(x-bf-1);
      bf=x;
    }
    an-=su*c[i];
  }
}

void solve1(int h, int k) {
  int bf = t[h];
  an-=s[h][bf];
  an+=s[h][k];

  auto s1 = v[bf].lower_bound(h);
  auto s2 = v[bf].upper_bound(h);
  s1--;
  //cout<<*s1<<" "<<h<<" "<<*s2<<endl;

  an+=adad((*s2) - h - 1) * c[bf];
  an+=adad(h - (*s1) - 1) * c[bf];
  an-=adad((*s2) - (*s1) - 1) * c[bf];
  v[bf].erase(h);
  
  auto t1 = v[k].lower_bound(h);
  auto t2 = v[k].upper_bound(h);
  t1--;
  //cout<<*t1<<" "<<h<<" "<<*t2<<endl;

  an-=adad((*t2) - h - 1) * c[k];
  an-=adad(h - (*t1) - 1) * c[k];
  an+=adad((*t2) - (*t1) - 1) * c[k];
  v[k].insert(h);
  t[h]=k;
}

int main() {
  cin>>d;
  for(int i=0;i<26;i++) {
    cin>>c[i];
  }
  for(int i=0;i<d;i++) {
    for(int j=0;j<26;j++) {
      cin>>s[i][j];
    }
  }
  for(int i=0;i<26;i++) {
    v[i].insert(-1);
    v[i].insert(d);
  }
  for(int i=0;i<d;i++) {
    cin>>t[i]; t[i]--;
    v[t[i]].insert(i);
  }
  solve0();
  int m; cin>>m;
  int f[m],g[m];
  for(int i=0;i<m;i++) {
    cin>>f[i]>>g[i];
    f[i]--; g[i]--;
  }
  for(int i=0;i<m;i++) {
    solve1(f[i],g[i]);
    cout<<an<<endl;
    //solve0();
    //cout<<an<<endl;
  }
}


Measured memory_bytes: 4436
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 15;

string s[N];

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

	int h, w, k;
	cin >> h >> w >> k;

	for(int i = 0; i < h; i++) cin >> s[i];
	
	int ans = 1e9;

	for(int i = 0; i < (1 << (h - 1)); i++) {
		vector<int> bts;
		for(int j = 0; j < (h - 1); j++) {
			if(i>>j&1) bts.push_back(j + 1);
		}
		if(bts.size()) assert(bts.back() < h);
		bts.push_back(h);
		int a = 0;
		// last total sum of each component
		vector<int> sums(bts.size(), 0);
		bool ok = true;
		for(int col = 0; col < w; col++) {
			// sum of each component
			vector<int> go(bts.size(), 0);
			int last = 0;
			int pos = 0;
			for(int x : bts) {
				int sum = 0;
				for(int row = last; row < x; row++) {
					if(s[row][col] == '1') sum++;
				}
				go[pos] = sum;
				last = x;
				pos++;
			}
			
			for(int j = 0; j < go.size(); j++) {
				if(go[j] > k) {
					ok = false;
					break;
				}
			}

			if(!ok) break;

			bool div = false;
			for(int j = 0; j < go.size(); j++) {
				if(sums[j] + go[j] > k) {
					div = true;
					break;
				}
			}
			if(div) {
				a++;
				for(int j = 0; j < go.size(); j++) {
					sums[j] = go[j];
				}
			}
			else {
				for(int j = 0; j < go.size(); j++) {
					sums[j] += go[j];
				}
			}
		}

		if(ok) ans = min(ans, a + (int)bts.size() - 1);
	}

	cout << ans;

	
	return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int N=2e6+1;
int n,q;
int c[N];
int p[N];
int f[N];
int ans[N];
int lz[N];
vector<pair<int,int> >qr[N];
void push(int id){
	lz[id*2]+=lz[id];
	lz[id*2+1]+=lz[id];
	lz[id]=0;
}
void upd(int id,int l,int r,int ql,int qr,int v){
	if(l>qr || r<ql) return;
	if(ql<=l && r<=qr){
		lz[id]+=v;return;
	}
	push(id);
	int mid=(l+r)/2;
	upd(id*2,l,mid,ql,qr,v);
	upd(id*2+1,mid+1,r,ql,qr,v);
}
int qry(int id,int l,int r,int p){
	if(l==r) return lz[id];
	push(id);
	int mid=(l+r)/2;
	if(p<=mid) return qry(id*2,l,mid,p);
	else return qry(id*2+1,mid+1,r,p);
}
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> q;
	for(int i=1; i<=n ;i++){
		cin >> c[i];
		p[i]=f[c[i]];
		f[c[i]]=i;
	}
	for(int i=1; i<=q ;i++){
		int l,r;cin >> l >> r;
		qr[r].push_back({l,i});
	}
	for(int i=1; i<=n ;i++){
		upd(1,1,n,p[i]+1,i,1);
		for(auto c:qr[i]){
			ans[c.se]=qry(1,1,n,c.fi);
		}
	}
	for(int i=1; i<=q ;i++){
		cout << ans[i] << '\n';
	}
	
}

Measured memory_bytes: 72612
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e6+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}


ll fa[MAX], rf[MAX];

ll C(ll n, ll k) {
  if(n==0) return 1;
  if(n==k) return 1;
  return fa[n]*rf[k]%MOD*rf[n-k]%MOD;
}

ll moP(ll x, ll n) {
  ll res=1;
  while(n>0) {
    if(n&1) moC(res, *, x);
    moC(x, *, x);
    n>>=1;
  }
  return res;
}

int main(void) {
  ll x, y;
  cin >> x >> y;
  
  if((x+y)%3) {
    pt(0);
    return 0;
  }
  
  ll N=(x+y)/3;
  if(x<N || y<N) {
    pt(0);
    return 0;
  }
  
  fa[0]=rf[0]=1;
  for(ll i=1; i<=N; i++) {
    fa[i]=fa[i-1]*i%MOD;
    rf[i]=moP(fa[i], MOD-2);
  }
  
  ll K=min(x, y)-N;
  
  pt(C(N, K));
  
  
  
  
}


Measured memory_bytes: 14592
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

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

lint H, W;

void step(vector<string> &S, vector<vector<bool>> &flag, lint x, lint y, P &p) {
  char current = S[x][y];
  char target = S[x][y] == '#' ? '.' : '#';
  //  cout << "x: " << x << " y: " << y << " " << current <<"\n";
  
  if(current == '#') {
    p.first++;
  } else {
    p.second++;
  }
  flag[x][y] = true;

  if(x+1 < H) {
    if(!flag[x+1][y] && target == S[x+1][y]) {
      step(S, flag, x+1, y, p);
    }
  }
  
  if(x-1 >= 0) {
    if(!flag[x-1][y] && target == S[x-1][y]) {
      step(S, flag, x-1, y, p);
    }
  }
  if(y+1 < W) {
    if(!flag[x][y+1] && target == S[x][y+1]) {
      step(S, flag, x, y+1, p);
    }
  }
  if(y-1 >= 0) {
    if(!flag[x][y-1] && target == S[x][y-1]) {
      step(S, flag, x, y-1, p);
    }
  }
}

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

    vector<string> S(H);
    vector<vector<bool>> flag(H, vector<bool>(W, false));

    REP(i, H) {
      string s; cin >> s; S[i] = s;
    }

    lint res = 0;

    REP(x, H) {
      REP(y, W) {
        if(flag[x][y]) continue;
        P p(0,0);
      //      if(S[x][y] == '#') {
      //        p.first++;
      //      } else {
      //        p.second++;
      //      }

        step(S, flag, x, y, p);
        
        res += p.first*p.second;
        //        cout << "x: " << x << " y: " << y << "\n";
        //        cout << p.first << " " << p.second << "\n";
      }
    }

    PRINT(res);

    return 0;
}


Measured memory_bytes: 25472
import sys
import math
from fractions import gcd
# import queue
from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N = int(sys.stdin.readline())

L = [int(sys.stdin.readline()) for _ in range(N)]

Lc = Counter(L)

ans = 0
for v in Lc.values():
    if v % 2 == 1:
        ans += 1

print(ans)

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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
bool is_prime (int x){
  if (x<=1) return false ;
  for (int i=2 ; i*i<=x ; i++){
    if (x%i==0) return false ;
  }
   return true;
}
string alpha = "abcdefghijklmnopqrstuvwxyz" ;
 
/*CODE START HERE*/
int main() {
  string w ;
  cin >> w ;
  vector<int> count ( 26,0);
  forn(i,w.size()){
    forn(j,26){
      if ( w.at(i) == alpha.at(j)){
        count.at(j)++;
      }
    }
  }
  bool ans = true;
   forn(j,26){
      if ( count.at(j)%2==1){
        ans = false;
      }
    }
  cout << (ans ? "Yes" : "No" ) << endl;
}

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

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

//---main---------------------------------------------
int main(){
    //main
    int N;
    cin >> N;

    for(int n=1; n<=N ; n++){
        int fn=0;
        for(int x = 1; x*x<n; x++){
            for(int y = x; y*y<n; y++){
                for(int z = y; z*z<n; z++){
                    if(x*x+y*y+z*z+x*y+y*z+z*x == n){
                        //cout << n << " : " << x << y << z << endl;
                        if(x==y && y==z){
                            fn += 1;
                        }else if( x==y || y==z || z==x ){
                            fn += 3;
                        }else{
                            fn += 6;
                        }
                    }
                
                
                }
            }
        }
        cout << fn << endl;
    }
   return 0;
}

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

int md[12] = {0,31,29,31,30,31,30,31,31,30,31,30};
char* day[7] = {"Mon","Tues","Wednes","Thurs","Fri","Satur","Sun"};

int main()
{
	int m,d;
	while(cin >> m >> d, m||d)
	{
		for(int i=0; i<m; i++)
		{
			d+=md[i];
		}
		cout << day[(d+2)%7] << "day" << endl;

	}
}

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

using namespace std;

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

  int N; cin>>N;
  string S; cin>>S;

  if (S[0] != 'B' or S.back() != 'B') {
    cout << 0 << endl;
    return 0;
  }

  long cl = 0;
  long cr = 0;
  const long MOD = 1e9+7;
  long pat = 1;
  bool d = false;
  for (int i = 0; i < S.size(); i++) {
    if (i > 0) {
      if (S[i] == S[i-1])
        d = !d;
    }
    if (d == true) {
      pat *= cl - cr;
      pat %= MOD;
    }
    if (d == false) {
      cl++;
    } else {
      cr++;
    }
  }
  if (cl != cr) {
    cout << 0 << endl;
    return 0;
  }

  for (long i = 1; i <= N; i++) {
    pat = pat * i % MOD;
  }

  cout << pat << endl;

  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long mod = 1000000007;
const int INF = 1001001001;

int main(){
  int n;
  cin >> n;
  vector<vector<int>> G(n,vector<int>(0));
  vector<pair<int,int>> vp(n-1);
  for(int i=0;i<n-1;i++){
    int a,b;
    cin >> a >> b;
    a--;b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
    vp.at(i) = make_pair(a,b);   
  }
  int K=0;
  map<pair<int,int>,int> I;//辺のラベルを管理
  vector<int> cs(n,-1);//親との辺が何番になっているか？初期値は-1
  vector<bool> flag(n,false);//頂点をcheckしたか
  queue<int> q;//BFS用
  q.push(0);
  flag.at(0) = true;
  while(!q.empty()){
    //v->uの辺を考える
    int v = q.front(); q.pop();
    int label = 1;
    K = max(K,(int)G.at(v).size());
    for(auto u:G.at(v)){//vの行先を全て調査
      if(flag.at(u) == true) continue;
      if(cs.at(v) == label) label++;
      cs.at(u) =label;
      I[make_pair(v,u)] = label;
      I[make_pair(u,v)] = label;
      label++;
      q.push(u);
      flag.at(u) = true;
    }
  }
  cout << K << endl;
  for(auto p:vp){
    cout << I.at(p) << endl;      
  }

}

Measured memory_bytes: 19712
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
 
int main()
{
    int n,y;
    cin >> n >> y;

    for(int i = 0; i <= n; i++){
        for(int j = 0; i + j <= n; j++){
            if(10000*i+5000*j+1000*(n-i-j) == y){
                cout << i << ' ' << j << ' ' << n-i-j << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
	long n;
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    long ans = 0;
    for (int i = 1; i <= n; i++){
		 ans += i * (n - i + 1);
	}
    for (long i = 1, x, y; i < n; i++) {
        cin >> x >> y;
        if (x > y) swap(x, y);
        ans -= x * (n - y + 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        Integer N=sc.nextInt();
        Integer[] t=new Integer[N+1];
        Integer[] x=new Integer[N+1];
        Integer[] y=new Integer[N+1];
        Boolean b=true;
        t[0]=x[0]=y[0]=0;

        for(int i=1;i<=N;i++){
            t[i]=sc.nextInt();
            x[i]=sc.nextInt();
            y[i]=sc.nextInt();
            Integer d=Math.abs(t[i]-t[i-1])-Math.abs(x[i]-x[i-1])-Math.abs(y[i]-y[i-1]);
            if(d<0||d%2>0){
                b=false;
            }
        }

        System.out.println(b?"Yes":"No");

	}
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   int n, r;
   while (1) {
      // 初期化
      cin >> n >> r;
      vec<int> v(n);
      rep (i, n) { v[i] = n-i; }
      if (n == 0 && r == 0) return 0;

      // 実体
      while (r--) {
         int p, c;
         cin >> p >> c;
         vec<int> next;
         p--;
         repp (i, p, p+c) {
            next.push_back(v[i]);
         }
         rep (i, n) {
            if (i >= p && i < p+c) continue;
            next.push_back(v[i]);
         }

         v = next;
      }
      cout << v[0] << endl;
   }

   return 0;
}


Measured memory_bytes: 3040
A,B,C,D = (int(x) for x in input().split())
f = True
while True:
    if f:
        C = C - B
        f = False
    else:
        A = A - D
        f = True
    if A <= 0:
        print('No')
        break
    elif C <= 0:
        print('Yes')
        break
    else:
        continue


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

using namespace std;
typedef long long ll;


int n, k;
int h[100100];
int dp[100100];

int main()
{
    memset(dp, 0x3f, sizeof dp);
    dp[0] = 0;

    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; ++i)
        scanf("%d", &h[i]);

    for (int i = 1; i < n; ++i)
    {
        for (int j = 1; j <= k; ++j)
            if (i-j > -1)
                dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
    }
    printf("%d\n", dp[n-1]);

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

class Main {


  

  public static void main(String[] args) {
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int N = in.nextInt();
    int K = in.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {a[i] = in.nextInt();}
    boolean[] dp = new boolean[K + 1]; // dp[i]: True if who are making the move now wins when there are i stones left
    dp[0] = false;
    for (int i = 1; i <= K; i++) {
      dp[i] = false;
      for (int j = 0; j < N; j++) {
        if (i >= a[j]) {
          if (dp[i - a[j]] == false) {
            dp[i] = true;
            break;
          }
        } else {
          break;
        }
      }
    }



    System.out.println(dp[K] ? "First" : "Second");
  }

}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
const char sp = ' ';

int N, A;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A;
		if (A % 2 == 0) {
			if (A % 3 != 0 && A % 5 != 0) {
				puts("DENIED");
				return 0;
			}
		}
	}
	puts("APPROVED");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) x.begin(),x.end()
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, n, m) for(int i = n; i >= m; i--)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;

int main(){

  int K,X;
  cin >> K>>X;

  reps(i,-(K-1),K){
  cout << X+i<<" ";
}
  return 0;
}


Measured memory_bytes: 256
import numpy as np
n = int(input())
towns = []
for _ in range(n):
    x,y = map(int,input().split())
    towns.append((x,y))
dist = []
for i in range(n-1):
    for j in range(i+1,n):
        x1,y1 = towns[i]
        x2,y2 = towns[j]
        dist.append(np.sqrt((x1-x2)**2+(y1-y2)**2))
print((sum(dist)/len(dist)) * (n-1))

Measured memory_bytes: 12504