akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace std;
    using namespace __gnu_pbds; 
    #define lli long long int
    #define fr(i,a,b) for(lli i=a;i<b;i++)
    #define bfr(i,a,b) for(lli i=a;i>=b;i--)
    #define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
    #define tc int t;cin>>t;while(t--)
    #define mod 1000000007LL
    #define mod2 998244353LL
    #define all(vec) vec.begin(),vec.end()  
    #define ld long double
    #define pb push_back

    #define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 



    int main()
    {
                           
             

                        
              fio

              lli n,sum=0;
              cin>>n;
              fr(i,1,n+1)
              fr(j,1,n+1)
              fr(k,1,n+1)
              sum+=__gcd(i,__gcd(j,k));
              cout<<sum;
return 0;}

Measured memory_bytes: 3652
#include<stdio.h>
int i,j,k;
int n,a[5000],b,ans=0;
int main(){
	while(scanf("%d",&n)){
		if(n==0)break;
		a[0]=a[1]=0;
		ans=-100001;
		for(i=1;i<=n;i++){
			scanf("%d",&b);
			a[i]+=b;
			a[i+1]=a[i];
		}
		for(i=0;i<=n-1;i++){
			for(j=i+1;j<=n;j++){
				if(a[j]-a[i]>ans)ans=a[j]-a[i];
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

ll n, k;

int main() {
  cin>>n>>k;
  ll a[n];
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  sort(a, a+n);
  ll ans=0;
  for (int i=0; i<k; i++) {
    ans+=a[i];
  }
  cout<<ans<<endl;
}

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

int cnt = 0;
char S[1024];
bool at[12];

bool count(char c){
  if( S[cnt] == c ) cnt++;
  else return false;
  return true;
}

bool get(char c){
  return at[c-'a'];
}

bool calc( bool a, bool b, char c ){
  if( c == '*' ) return a&b;
  if( c == '+' ) return a|b;
  return 1-(a&(1-b));
}

bool formula(){
  if( count('-') ){
    return 1-formula();
  } else if( count('T') ){
    return true;
  } else if( count('F') ){
    return false;
  } else if( count('(') ){
    bool a = formula();
    char c;
    if( count( '*' ) ) c = '*';
    else if( count('+') ) c = '+';
    else if( count('-') && count('>') ) c='>';
    else assert(false);
    bool b = formula();
    bool r = calc( a, b, c );
    count( ')' );
    return r;
  } else {
    char c = S[cnt];
    assert( 'a' <= c && c <= 'k' );
    count(c);
    return get(c);
  }  
}

bool equation(){
  cnt=0;
  bool a = formula();
  count( '=' );
  bool b = formula();
  return a==b;
}

int main(){
  while( cin >> S ){
    if( S[0] == '#' ) break;
    bool ret = true;
    for(int i=0;i<(1<<11);i++){
      for(int j=0;j<11;j++) at[j] = i&(1<<j);
      if( !equation() ){ ret = false; break;}
    }
    if( ret ) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<P>edge[100005];
int n,m;
ll dist[100005];
void dfs(int v,ll val){
	if(dist[v] > -1e17) return;
	dist[v] = val;
	for(int i=0;i<edge[v].size();i++){
		dfs(edge[v][i].fi,val+edge[v][i].sc);
	}
}
int main(){
	cin>>n>>m;
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		edge[a].pb(mp(b,c));
		edge[b].pb(mp(a,-c));
	}
	fill(dist,dist+100005,-1e18);
	for(int i=1;i<=n;i++){
		if(dist[i] > -1e17) continue;
		dfs(i,0);
	}
	for(int i=1;i<=n;i++){
		rep(j,edge[i].size()){
			ll x = dist[i];
			ll y = dist[edge[i][j].fi];
			if(x+edge[i][j].sc != y){
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    int l=s.size();
    string s1="s", s2="es";
    if(s[l-1]=='s') {s.append(s2); cout<<s<<endl; return 0;}
    else s.append(s1); cout<<s<<endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int dx[2] = {0, 1};
  int dy[2] = {1, 0};
  int sum[110] = {0};
  vector<vector<int>> A;
  
  for(int i=0;i<2;++i){
    vector<int> row;
    for(int j=0;j<N;++j){
      int Aij;
      cin >> Aij;
      row.push_back(Aij);
    }
    A.push_back(row);
  }
  
  for(int i=0;i<N;++i){
    for(int j=0;j<=i;++j){
      sum[i] += A[0][j];
    }for(int k=i;k<N;++k){
      sum[i] += A[1][k];
    }
  }
  
  sort(sum, sum+N, greater<int>());
  cout << sum[0] << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
s = int(input())

def gusu_fanc(num):
    ans = int(num / 2)
    return ans

def kisu_fanc(num):
    ans = int(3 * num + 1)
    return ans

num_list = [s]
hantei = 0
numbers = s

while hantei == 0:
    #次の項を追加
    if numbers % 2 == 0:
        numbers = gusu_fanc(numbers)
    else:
        numbers = kisu_fanc(numbers)
    num_list.append(numbers)
    #チェック
    for i in range(len(num_list)-1):
        if num_list[i] == numbers:
            hantei = 1
print(i+2)


Measured memory_bytes: 3064
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	long n, c, k;
	{
		long[] tmp = readln.chomp.split.map!(to!long).array;
		n = tmp[0], c = tmp[1], k = tmp[2];
		}
	
	long[] ts;
	foreach(i; 0 .. n){
		ts ~= readln.chomp.to!long;
		}
	
	ts.sort!("a < b")();
	
	long u = -1;
	long buscount = 0;
	long mancount = 0;
	foreach(t; ts){
		if(u < t || mancount >= c){
			buscount += 1;
			mancount = 0;
			u = t + k;
			}
		mancount += 1;
		debug writeln([t, u, buscount, mancount]);
		}
	
	buscount.writeln;
	
	}

Measured memory_bytes: 3836
n,a,b=map(int,input().split())
sa=b-a
if sa%2==0:
	print(sa//2)
else:
	ans1=0
	ans2=0
	ans1+=a
	ans1+=(b-a-1)//2
	ans2+=n-b+1
	ans2+=(n-(a+n-b+1))//2
	print(min(ans1,ans2))

Measured memory_bytes: 3060
from collections import defaultdict
import heapq

n = int(input())
s_dic = defaultdict(int)
max_count = 0
for _ in range(n):
    s = input()
    s_dic[s] += 1
    max_count = max(s_dic[s], max_count)

ans = []
for key in s_dic.keys():
    if s_dic[key] == max_count:
        heapq.heappush(ans, key)
for _ in range(len(ans)):
    print(heapq.heappop(ans))

Measured memory_bytes: 32448
def pat(K,count,keta,num):
    #print(str(num)+":"+str(count)+":"+str(keta))
    if count == -1:
        return -1
    elif keta == 1:
        if count == K-1:
            print(num)
            return -1
        else:
            return (count+1)
    else:
        if (int(num[-1])) -1 >= 0:
            count = pat(K,count,keta-1,num+str(int(num[-1])-1))
        count = pat(K,count,keta-1,num+num[-1])
        if (int(num[-1])+1) <= 9:
            count = pat(K,count,keta-1,num+str(int(num[-1])+1))
            
    return count


K = int(input())
count = 0
ans = list()
keta = 0

while True:
    keta += 1
    for i in range(1,10):
        count = pat(K,count,keta,str(i))
        #print(count)
        if count  == -1:
            break
    if count == -1:
        break
        



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

#define ll long long
#define N 500010
#define M 2000010
const ll p = 1e9 + 7;
ll qmod(ll base, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1) {
			res = res * base % p;
		}
		base = base * base % p;
		n >>= 1;
	}
	return res;
}
int n, a[N], b[N];
vector < vector <int> > vec;

int main() {
	while (scanf("%d", &n) != EOF) {
		vec.clear();
		int Max = 0;
		for (int i = 1; i <= n; ++i) {
			scanf("%d", a + i);
			a[i] ^= a[i - 1]; 
			Max = max(Max, a[i]);
			//printf("%d%c", a[i], " \n"[i == n]);
		}
		vec.resize(Max + 1);
		for (int i = 1; i <= n; ++i) {
			vec[a[i]].push_back(i);
		}
		for (int i = 1; i <= n; ++i) {
			b[i] = (a[i] == 0);
			b[i] += b[i - 1];
		}
		ll res = 0;
		if (a[n] == 0) {
			res = qmod(2, (int)vec[a[0]].size() - 1);
			for (int i = 1; i <= Max; ++i) if (!vec[i].empty()) {
				ll base = 0;
				ll tot = 0;
				int pre = 0;
				ll tmp = 0;
				for (auto it : vec[i]) {
					ll zero = b[it] - b[pre];
					pre = it;
					(tot += zero * base % p) %= p;
					tmp = (tot + 1) % p;
					(base += tmp) %= p;
					(res += tmp) %= p;
				}
			}
		} else {
			ll base = 0;   
			ll tot = 0; 
			int pre = 0;
			for (auto it : vec[a[n]]) {
				ll zero = b[it] - b[pre]; 
				pre = it;
				(tot += zero * base % p) %= p;
				res = (tot + 1) % p;
				(base += res) %= p;
			}	
		}
		printf("%lld\n", res); 
	}
	return 0;
}


Measured memory_bytes: 38388
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int n;cin>>n;
	string s;cin>>s;
	int cnt=0;
	for(int i=0;i<n-2;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int i;
	double x[1000],y[1000],a;
	x[0]=1.0;y[0]=0.0;
	for(i=1;i<1000;i++){
		a=atan2(y[i-1],x[i-1])+atan(1.0)*2;
		x[i]=x[i-1]+cos(a);
		y[i]=y[i-1]+sin(a);
	}
	while(1){
		scanf("%d",&i);
		if(i<0)break;
		printf("%lf\n%lf\n",x[i-1],y[i-1]);
	}
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	bool isAC = s[0] == 'A';

	int n = s.size(), c = 0;
	for (int i = 2; i < n - 1; i++) {
		if (s[i] == 'C')
			c++;
	}

	for (int i = 1; i < n; i++) {
		if (s[i] != 'A' && s[i] != 'C' && (s[i] < 'a' || s[i] > 'z')) {
			isAC = 0;
			break;
		}
	}

	cout << (isAC && c == 1 ? "AC" : "WA") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second



int main() {
	ll sum = 0;
	string s;
	cin >> s;
	for (int i = 0;i < s.size();i++) {
		sum += s[i] - '0';
	}
	cout << max(sum, (ll)(s[0] - '0' - 1 + (s.size() - 1) * 9)) << endl;
	return 0;
}

Measured memory_bytes: 764
import java.io.*;
import java.util.*;
public class   Main      {
	public static void main(String[] args) 
	{
		InputReader in = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		Scanner sc = new Scanner(System.in);
		int n = in.nextInt();
		int arr[] = new int[200001];
		arr=in.nextIntArray(n);
		long sum=0;
		for(int i=0;i<n;i++)
			sum+=arr[i];
		long ans=100000000000000L;
		long temp=0;
		for(int i=0;i<n;i++)
		{
			temp+=arr[i];
			if(i+1<	n)
				ans=Math.min(ans,Math.abs(sum-2*temp));
		}
		w.println(ans);
		w.close();
	}
	static class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		public InputReader(InputStream st) {
			this.stream = st;
		}
		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}
		
		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		
		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		
		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
		
		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}
		
		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}
		
		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
		
		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
		
	}
	
}

Measured memory_bytes: 24760
# C When I hit my pocket
k,a,b = map(int,input().split())

bis = 1

if k <= 1 or b <= a + 2 or k < a + 1:
    print(1 + k)
    exit()
else:
    bis = b
    k = k - ( a + 1)
    if not k == 0:
        bis += int(k / 2) * (b - a) + k % 2

print(bis)

Measured memory_bytes: 3060
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int N;
int left_c[64], right_c[64];

int pre[64], in[64], idx[64];
int recon(int& x, int l, int r){
  if(l >= r) return -1;
  int i = pre[x++];
  int mid = idx[i];

  if(r - l == 1){
	left_c[i] = right_c[i] = -1;
	return i;
  }

  left_c[i] = recon(x, l, mid);
  right_c[i] = recon(x, mid+1, r);
  return i;
}

bool first = true;
void print_post(int i){
  if(i <= 0) return;
  print_post(left_c[i]);
  print_post(right_c[i]);
  if(!first)
	cout << " ";
  cout << i;
  first = false;
}

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

  cin >> N;
  REP(i,N) cin >> pre[i];
  REP(i,N){
	cin >> in[i];
	idx[in[i]] = i;
  }

  int i = 0;
  recon(i, 0, N);
  //FOR(i,1,N+1) cout << i << ": " << left_c[i] << ", " << right_c[i] << endl;
  
  print_post(pre[0]);
  cout << endl;

  return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>

using namespace std;
#define SAY_YES cout<<"YES"<<endl;
#define SAY_Yes cout<<"Yes"<<endl;
#define SAY_NO cout<<"NO"<<endl;
#define SAY_No cout<<"No"<<endl;
#define IFYES(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} 
#define IFYes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} 
#define IFyes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"yes"<<endl;}else{cout<<"no"<<endl;} 
#define DEBUG_OUTPUT_ARRAY(XXX,ONE) for(int i=0;i<(ONE);i++){cout<<"DEBUG: i = "<<i<<" -> "<<XXX[i]<<endl;}
#define DEBUG_OUTPUT_ARRAY2(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<"<<< i = "<<i<<" >>>"<<endl;for(int j=0;j<(TWO);j++){cout<<"DEBUG: j = "<<j<<" -> "<<XXX[i][j]<<endl; } }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<i<<"  ";for(int j=0;j<(TWO);j++){cout<<XXX[i][j]<<" "; } cout<<endl;}

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


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int N,K,a[105],res=INF,cou=0;
pair<long double,long double> xy[15];
int main() {
	cout << fixed << setprecision(18);
    cin>>N;
    long double res=0,tmp=0;
    for(int i=0;i<N;i++){
        cin>>xy[i].first>>xy[i].second;
    }
    sort(xy,xy+N);
    do{
        tmp=0;
        for(int i=1;i<N;i++){
            tmp+=sqrt((xy[i].first-xy[i-1].first)*(xy[i].first-xy[i-1].first)+(xy[i].second-xy[i-1].second)*(xy[i].second-xy[i-1].second));
        }
        res+=tmp;
        //cout<<cou<<endl;
        cou++;
    }while(next_permutation(xy,xy+N));
    cout<<res/cou<<endl;

} 


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

int main(){
	int n,a,b,temp=0,gokei=0,soukei=0;cin>>n>>a>>b;
  	for(int i=1;i<=n;i++){
    	temp=i;
      	while(temp>0){
        	gokei+=temp%10;
          	temp/=10;
        }
      if(a<=gokei && gokei<=b) soukei+=i;
      gokei=0;
    }
  cout<<soukei<<endl;
}    

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

double dist(double x, double y, double z){
	return sqrt(x*x + y*y + z*z);
}

struct UnionFind{
	vl p;
	vl rank;
	vl cnt;

	UnionFind(ll n){
		rank.resize(n,0);
		p.resize(n,0);
		cnt.resize(n,0);
		rep(i,n){
			p[i] = i;
			rank[i] = 0;
			cnt[i] = 1;
		}
	}

	ll find(ll x){
		if(x != p[x]) p[x] = find(p[x]);
		return p[x];
	}

	bool same(ll x, ll y){
		return find(x) == find(y);
	}

	void unite(ll x, ll y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rank[x] > rank[y]){
			p[y] = x;
			cnt[x] += cnt[y];
		}else{
			p[x] = y;
			cnt[y] += cnt[x];
			if(rank[x] == rank[y]) rank[y]++;
		}
	}

	ll size(ll x){
		return cnt[find(x)];
	}
};

int main(){
	while(1){
		int n; cin >> n;
		if(!n) break;
		vd x(n),y(n),z(n),r(n);
		rep(i,n) cin >> x[i] >> y[i] >> z[i] >> r[i];
		vector<tuple<double,int,int>> v;
		rep(i,n){
			REP(j,i+1,n){
				double d = dist(x[i]-x[j], y[i]-y[j], z[i]-z[j]) - (r[i]+r[j]);
				v.emplace_back(max(d,0.0),i,j);
			}
		}
		double ans = 0.0;
		UnionFind uf(n);
		sort(all(v));
		for(auto i : v){
			int u,v; double d;
			tie(d,u,v) = i;
			if(uf.same(u,v)) continue;
			ans += d;
			uf.unite(u,v);
		}
		printf("%.3f\n",ans);
	}
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,k,l,c,f;
	cin>>n;c=0;
	for(i=1;i<=n;i++)
	{
	    cin>>k;
	    if((i&1)&&(k&1))
	        c++;
	}
	cout<<c;
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 1e18+7;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/



int main(){
  int n,a,x,y,ans=0;
  cin>>n;
  vector<vector<P>> s;
  rep(i,n){
    cin>>a;
    s.resize(n);
    for(int j=0;j<a;j++){
      cin>>x>>y;
      s[i].push_back({x-1,y});
    }
  }
  for(int i=0;i<(1<<n);i++){
    bool flag=true;
    for(int j=0;j<n;j++){
      if(((i>>j)&1)==0){
        continue;
      }
      for(auto k:s[j]){
        if(((i>>k.first)&1)!=k.second){
          flag=false;
          break;
        }
      }
    }
    if(flag){
      ans=max(ans,__builtin_popcount(i));
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int pow(int x,int y)
{
    ll res=1;
    while(y>0){
        if(y&1){
            res=res*x;
        }
        y>>=1;
        x=x*x;
    }
    return res;
}
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans=INT_MIN;
    //ll ans=a+b+c+max(a,max(b,c))*(pow(2,k)-1);
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k-x;y++){
            ans=max(ans,pow(2,x)*a+pow(2,y)*b+pow(2,k-x-y)*c);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

sss = []
for _ in range(M):
    k, *ss = map(lambda x: int(x) - 1, input().split())
    sss.append(ss)
ps = list(map(lambda x: x == '0', input().split()))

# print(ps)

# 全てのスイッチのパターンをチェック
cnt = 0
for i in range(2 ** N):
    lights = ps[:]
    # print(bin(i))
    for j, ss in enumerate(sss):
        for s in ss:
            if i >> s & 1:
                lights[j] = not lights[j]
    # print(ps)
    if all(lights):
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  var len = parseInt(input[0]);
  var tmp = input.slice(1, input.length - 1);
  
  var moti = tmp.filter(function(x, i, self){
  	return self.indexOf(x) === i;
  });
  
  console.log(moti.length);
  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
  int n,fx;
  cin >> n;
  vector<int> f(10001);
  rep(i,100) {
    rep(j,100) {
      rep(k,100) {
        fx = i * i + j * j + k * k + i * j + j * k + k * i;
        if(fx <= 10000) f[fx]++;
        else break;
      }
    }
  }
  rep(i,n) cout << f[i] << endl;
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int num=1e9+7;

ll ex(ll x,ll n){
  if(n==0)return 1;
  else if(n%2==1)return ex(x,n-1)*x%num;
  else return ex(x*x%num,n/2)%num;
};

ll nikou(ll n,ll k){
    ll dived=1,div=1;
    for(int i=0; i<k; i++){
        dived*=(n-i)%num;
        dived%=num;
        div*=(i+1)%num;
        div%=num;
    }
    div=ex(div,num-2);
    return dived*div%num;
}

int main(){
    int x,y;
    cin >> x >> y;
    bool flag=true;
    int num_r,num_u;
    if(x%2==0){
        int pre_h=x/2;
        if(pre_h>y)flag=false;
        int h;
        if((y-pre_h)%3==0)h=(y-pre_h)/3;
        else flag=false;
        num_r=x/2-h;
        if(num_r<0)flag=false;
        num_u=h*2;
    }
    else{
        int pre_h=x/2+2;
        if(pre_h>y)flag=false;
        int h;
        if((y-pre_h)%3==0)h=(y-pre_h)/3;
        else flag=false;
        num_r=x/2-h;
        if(num_r<0)flag=false;
        num_u=h*2+1;
    }
    if(flag)cout << nikou(num_r+num_u,min(num_r,num_u));
    else cout << 0;
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main(){
    char s[100002];
    scanf("%s",s);
    long int n;
    n=strlen(s);
    int i;
    int g=0,p=0;
    for(i=0;i<=n-1;i++){
        if(s[i]=='g'){
            g++;
        }else if(s[i]=='p'){
            p++;
        }
    }
    
    if(n%2==0){
        printf("%ld",(n/2-p));
    }else if(n%2==1){
        printf("%ld",((n-1)/2-p));
    }
    
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
t=int(input())
lst=[]
for _ in range(t):
	lst.append(input())
lst=Counter(lst)
if 'AC' in lst.keys():
	print("AC x",lst['AC'])
else:
	print("AC x 0")
if 'WA' in lst.keys():
	print("WA x",lst['WA'])
else:
	print("WA x 0")
if 'TLE' in lst.keys():
	print("TLE x",lst['TLE'])
else:
	print("TLE x 0")
if 'RE' in lst.keys():
	print("RE x",lst['RE'])
else:
	print("RE x 0")



Measured memory_bytes: 16608
-- maximum-sum.hs --- Maximum Sum

-- author: Seong Yong-ju <sei40kr@gmail.com>

solve a b c k = (max a (max b c)) * (2 ^ k - 1) + a + b + c

main :: IO ()
main = do
  [a, b, c] <- map (read :: String -> Int) . words <$> getLine
  k <- (read :: String -> Int) <$> getLine
  print $ solve a b c k


Measured memory_bytes: 508
readline = open(0).readline
writelines = open(1, 'w').writelines
H, W = map(int, readline().split())
S = []; T = []
for i in range(H):
    for j, a in enumerate(readline().strip()):
        if a == "#":
            S.append("#"); T.append("#")
        else:
            if j == 0:
                S.append("#"); T.append(".")
            elif j == W-1:
                S.append("."); T.append("#")
            elif i % 2 == 0:
                S.append("#"); T.append(".")
            else:
                S.append("."); T.append("#")
    S.append("\n")
    T.append("\n")
S.append("\n")

writelines(S)
writelines(T)

Measured memory_bytes: 8204
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		String[] a = new String[100];
		int[] c = new int[100];
		char[] cha = new char[100];
		int[] into = new int[100];
		int[] z = new int[100];
		String[] str = new String[100];
		char[][] x = new char[100][13];
		char[] chab = new char[100];
		int[] intb = new int[100];
		int flag = 1;
		
		int n = scan.nextInt();
		
		for(int i=0; i<n; i++){
			str[i] = scan.next();
			
			char[] b = str[i].toCharArray();
			cha[i] = b[0];
			into[i] = Character.getNumericValue(b[1]);
			chab[i] = b[0];
			intb[i] = Character.getNumericValue(b[1]);
			
			x[into[i]][z[into[i]]] = b[0];
			z[into[i]]++;
		}
		
		while(flag==1){
			flag = 0;
			for(int j=n-1; j>0; j--){
				if(intb[j] < intb[j-1]){
					int kari = intb[j];
					intb[j] = intb[j-1];
					intb[j-1] = kari;
					char kar = chab[j];
					chab[j] = chab[j-1];
					chab[j-1] = kar;
					flag = 1;
				}
			}
		}
		
		for(int i=0; i<n; i++){
			System.out.print(chab[i]+""+intb[i]);
			if(i!=n-1){
				System.out.print(" ");
			}
			else{
				System.out.print("\n");
			}
		}
		
		System.out.println("Stable");
		
		for(int i=0; i<n; i++){
			int min = i;
			for(int j=i; j<n; j++){
				if(into[j] < into[min]){
					min = j;
				}
			}
			int kari = into[min];
			into[min] = into[i];
			into[i] = kari;
			char kar = cha[min];
			cha[min] = cha[i];
			cha[i] = kar;
		}
		
		for(int i=0; i<n; i++){
			System.out.print(cha[i]+""+into[i]);
			if(i!=n-1){
				System.out.print(" ");
			}
			else{
				System.out.print("\n");
			}
		}
		
		for(int i=0; i<12; i++){
			z[i] = 0;
		}
		
		int NN = 0;
		
		for(int i=0; i<n; i++){
			if(x[into[i]][z[into[i]]] != cha[i]){
				NN = 1;
				break;
			}
			z[into[i]]++;
		}
		
		if(NN==1){
			System.out.println("Not stable");
		}
		else{
			System.out.println("Stable");
		}
	}
}


Measured memory_bytes: 26220
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n , k ;
	cin >> n >> k ;
	string s ;
	cin >> s ;
	k-- ;
	for(int i = 0 ; i < n ; i++){
		if(i == k){
			if(s[i] == 'A')
				cout <<'a' ;
			if(s[i] == 'B')
				cout <<'b' ;
			if(s[i] == 'C')
				cout <<'c' ;
		}
		else
			cout << s[i] ;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100000

int CC[N] = {0};

void init() {
  int i;
  for (i = 0; i < N; ++i) {
    CC[i] = i;
  }
}

int find(int a) {
  if (a == CC[a]) {
    return a;
    
  }

  return CC[a] = find(CC[a]);
  
}


int isSame(int a, int b) {

  if (find(a) == find(b)) {
    return 1;
  } else {
    return 0;
  }
  
}


void unite(int a, int b) {
  a = find(a);
  b = find(b);

  if (a == b) return;

  CC[b] = a;
  
}


int main() {
  int n, m, l, i, j, k;
  init();
  scanf("%d %d", &n, &m);

  for (i = 0; i < m; ++i) {
    scanf("%d %d", &j, &k);
    unite(j, k);
  }

  scanf("%d", &l);

  for (i = 0; i < l; i++) {
    scanf("%d %d", &j, &k);
    if (isSame(j, k)) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return 0;
}



Measured memory_bytes: 2104
from itertools import groupby

n, m = list(map(int, input().split()))
a = []
for i in range(m):
  p,y = list(map(int, input().split()))
  a.append((i,p,y))

a.sort(key=lambda x: x[1])
r = []
for k, g in groupby(a, key=lambda x: x[1]):
  pre ='{0:06d}'.format(k)
  for j, (i, _, _) in enumerate(sorted(g, key=lambda x: x[2])):
    r.append((i, pre + '{0:06d}'.format(j+1)))
r.sort()
for _, s in r:
  print(s)

Measured memory_bytes: 37040
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;

int main() {
	int m = 0;
	int f = 0;
	int r = 0;
	while (1) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1)
			break;
		if (m == -1 && f != 0) {
			cout << "F" << endl;
		}
		else if (m != 0 && f == -1) {
			cout << "F" << endl;
		}
		else if (m + f >= 80) {
			cout << "A" << endl;
		}
		else if (m + f < 80 && m + f >= 65) {
			cout << "B" << endl;
		}
		else if (m + f < 65 && m + f >= 50) {
			cout << "C" << endl;
		}
		else if (m + f < 50 && m + f >= 30) {
			if (r >= 50) {
				cout << "C" << endl;
			}
			else
				cout << "D" << endl;
		}
		else if (m + f < 30 && m != -1) {
			cout << "F" << endl;
		}
	}
}


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

int main()
{
    int n;
    cin >> n;
    if(n==25) cout << "Christmas" << endl;
    else if(n==24) cout << "Christmas Eve" << endl;
    else if(n==23) cout << "Christmas Eve Eve" << endl;
    else if(n==22) cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define ll	long long
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007

int main() {
	ios;
	/*int t;
	cin>>t;
	while (t--) {
		
	}*/
	int s, w;
	cin>>s>>w;
	if (w >= s) cout<<"unsafe";
	else cout<<"safe";
	
	return 0;
}


Measured memory_bytes: 3640
<?php
fscanf(STDIN, "%d%d", $N, $M);
if(abs($N - $M)>=2){
    echo 0;
    exit;
}elseif(abs($N - $M) == 1){
    $max = max($N, $M);
    $min = $max - 1;
    $p = 1;
    for($i = 1; $i <= $max; $i++){
        $p = $p * $i;
        $p %= 10**9 + 7;
    }
    for($i = 1; $i <= $min; $i++){
        $p = $p * $i;
        $p %= 10**9 + 7;
    }
    echo $p;
}else{
    $p = 2;
    for($i = 1; $i <= $M; $i++){
        $p = $p * $i;
        $p %= 10**9 + 7;
    }
    for($i = 1; $i <= $M; $i++){
        $p = $p * $i;
        $p %= 10**9 + 7;
    }
    echo $p;
}

Measured memory_bytes: 4728
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    res = []
    coef = 1
    while n:
        if n & 1:
            res.append('1')
            n -= coef
        else:
            res.append('0')
        coef *= -1
        n >>= 1
    res = ''.join(res[::-1]) if res else '0'
    print(res)
resolve()

Measured memory_bytes: 38384
#include<stdio.h>

int main()
{
    int n,ara[200000],count=0,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&ara[i]);
    }
    for(i=0,j=1;i<n;i++){
        if(ara[i]==j){
            count++;
            j++;
        }
    }
    if(count!=0)
    printf("%d",n-count);
    else printf("-1");
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()

int permutation(int n){
  int P=1;
  while(n>1){
    P*=n;
    n--;
  }

  return P;
}


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

  vector<ll> x(N);

  vector<ll> y(N);

  rep(i,N) cin >> x.at(i) >> y.at(i);//入力終了

  vector<vector<double>> d(N,vector<double>(N,0));//移動距離を定義する配列

  rep(i,N){
    rep(j,N){
      if(i==j) continue;
      double dist=sqrt((x.at(i)-x.at(j))*(x.at(i)-x.at(j))+(y.at(i)-y.at(j))*(y.at(i)-y.at(j)));
      d.at(i).at(j)=dist;
    }
  }//移動距離を入力

  vector<int> order(N);//初期順列の作成
  rep(i,N) order.at(i)=i;

  double ans=0;

  do{
    double temp_dist = 0;
    rep(i,N-1) temp_dist += d.at(order.at(i+1)).at(order.at(i));//順序orderについての移動距離を計算

    ans+=temp_dist;//答えに今回の順番での移動距離を加える

  }while(next_permutation(all(order)));

  int pattern=permutation(N);//パターン数を算出

  cout << fixed << setprecision(18);

  cout << ans/pattern << endl;//移動距離の合計を平均値に
  
  return 0;
}

Measured memory_bytes: 256
s = input()
K = int(input())
mj = []
for i in range(1,6):
    for j in range(0,len(s)-i+1):
        mj.append(s[j:j+i])
mj_uni = list(set(mj))
mj_stz = sorted(mj_uni)
print(mj_stz[K-1])

Measured memory_bytes: 5068
n = input()

if int(n[-1])==2 or int(n[-1])== 4 or int(n[-1]) == 5 or int(n[-1]) == 7 or int(n[-1]) == 9:
    print("hon")
elif int(n[-1]) == 0 or int(n[-1]) == 1 or int(n[-1]) == 6 or int(n[-1]) == 8:
    print("pon")
else:
    print("bon")



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

#define M 1000000
#define L 14

char H[M][L];

int getChar(char);
long long getKey(char *);
int h1(int);
int h2(int);
int find(char *);
int insert(char *);

int main(){
  int i, n, h;
  char str[L], com[9];

  for(i = 0; i < M; i++)
    H[i][0] = '\0';

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s %s", com, str);

    if(com[0] == 'i')
      insert(str);
      
      else{
      if(find(str))
        printf("yes\n");

      else
        printf("no\n");
    }
  }

  return 0;
}

int getChar(char c){
  if(c == 'A')
    return 1;

  else if(c == 'C')
    return 2;

  else if(c == 'G')
    return 3;

  else if(c == 'T')
    return 4;
}

long long getKey(char *str){
  long long sum = 0, p = 1, i;
  
  for(i = 0; i < strlen(str); i++){
    sum += p * (getChar(str[i]));
    p *= 5;
  }

  return sum;
}

int h1(int key){
  return key % M;
}

int h2(int key){
  return 1 + (key % (M - 1));
}

int find(char *str){
  long long key, i, result;

  key = getKey(str);

  for(i = 0;; i++){
    result = (h1(key) + i * h2(key)) % M;;

    if(strcmp(H[result], str) == 0)
      return 1;
    else if(strlen(H[result]) == 0)
      return 0;
  }
  
  return 0;
}

int insert(char *str){
  long long key, i, result;

  key = getKey(str);
  
  for(i = 0;; i++){
    result = (h1(key) + i * h2(key)) % M;

    if(strcmp(H[result], str) == 0)
      return 1;
      
      else if(strlen(H[result]) == 0){
      strcpy(H[result], str);
      return 0;
    }
  }

  return 0;
}
      


Measured memory_bytes: 15456
#include <stdio.h>

 
int main() {
    int n, g;
    int list[101][101];
    int i, a, v, u;
 
    for(i = 0; i <= 100; i++){
        for(a = 0; a <= 100; a++){
            list[i][a] = 0;
        }
    }
 
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d%d",&u,&v);
     
        for(a = 0; a < v; a++){
            scanf("%d", &g);
            list[i][g-1] = 1;
        }
    }
 
    for(i = 0; i < n; i++){
        for(a = 0; a < n-1; a++){
            printf("%d ", list[i][a]);
        }
        printf("%d\n", list[i][n-1]);
    }
    return 0;
}

Measured memory_bytes: 640
import java.io.PrintWriter

fun main() {
    val pw = PrintWriter(System.out)

    val mod = 2019
    val modDiv = 673

    val s = readInputLine().toCharArray()

    val cnt = LongArray(mod * 2)

    var ans = 0L

    repeat(s.size) {
        val digit = (s[it] - '0')

        for (i in 0 until modDiv) {
            cnt[(it % 2) * mod + i] = 0L
            cnt[(it % 2) * mod + modDiv + i] = 0L
            cnt[(it % 2) * mod + modDiv * 2 + i] = 0L
        }

        for (i in 0 until modDiv) {
            val locIndex = ((i * 10 + digit) % modDiv)
            cnt[(it % 2) * mod + (digit % 3) * modDiv + locIndex] = cnt[((it + 1) % 2) * mod + i]
            cnt[(it % 2) * mod + ((digit + 1) % 3) * modDiv + locIndex] = cnt[((it + 1) % 2) * mod + modDiv + i]
            cnt[(it % 2) * mod + ((digit + 2) % 3) * modDiv + locIndex] = cnt[((it + 1) % 2) * mod + modDiv * 2 + i]
        }

        ans += cnt[(it % 2) * mod]

        cnt[(it % 2) * mod + (digit % 3) * modDiv + digit]++
    }

    pw.println(ans)

    pw.flush()
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 40408
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<LL> a(n), b(n);
    for (auto& i : a) cin >> i;
    partial_sum(a.begin(), a.end(), b.begin());
    LL ans = 1e18;
    for (int i = 0; i < n - 1; i++) {
        ans = min(ans, abs(2 * b[i] - b.back()));
    }
    cout << ans << '\n';
}


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

using ll = long long;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    auto b = a;
    sort(begin(b), end(b));
    int wrong = 0;
    for(int i = 0; i < n; ++i) {
        wrong += a[i] != b[i];
    }
    int q; cin >> q;
    int ans = (a == b ? 0 : -1);
    for(int i = 0; i < q; ++i) {
        int x, y; cin >> x >> y;
        x--; y--;
        int px = a[x], py = a[y];
        swap(a[x], a[y]);
        if(px != b[x] && a[x] == b[x]) wrong--;
        if(px == b[x] && a[x] != b[x]) wrong++;
        if(py != b[y] && a[y] == b[y]) wrong--;
        if(py == b[y] && a[y] != b[y]) wrong++;
        if(wrong == 0 && ans == -1) {
            ans = i + 1;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 5228
/**                                                     **\
 *    created by:   Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
*                                                        */

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


using namespace std;
using namespace __gnu_pbds;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>new_data_set;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define pf push_front
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589


int power(int x, int y) {
    int r = 1, z = x;
    while (y) {
        if (y & 1)r *= z;
        z *= z; y = y >> 1;
    }
    return r;
}
int powerm(int x, int y, int p) {
    int r = 1;
    while (y) {
        if (y & 1)r = (r * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return r % p;
}
int modinv(int x, int m) {
    return powerm(x, m - 2, m);
}
int logarithm(int a, int b) {
    int x = 0;
    while (a > 1) {
        x++;
        a /= b;
    }
    return x;
}
int max3(int a, int b, int c) {
    return max(a, max(b, c));
}
int min3(int a, int b, int c) {
    return min(a, min(b, c));
}
int32_t main() {
    fast;
    int n;
    cin >> n;
    int N = 100005;
    int f[N];
    for (int i = 0; i < N; ++i) {
        f[i] = 0;
    }
    int tot = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        f[x]++;
        tot += x;
    }
    int q;
    cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        tot -= f[l] * l;
        tot += f[l] * r;
        f[r] += f[l];
        f[l] = 0;
        cout << tot << '\n';
    }
    return 0;
}

Measured memory_bytes: 4392
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
ll bit[61]; 

int main(void){
    ll n;
    cin>>n;
    vector<ll>v(n);
    for(ll i=0;i<n;i++)cin>>v[i];
    for(ll i=0;i<61;i++){
        ll z=0;
        ll o=0;
        for(ll j=0;j<n;j++){
            ll x=1LL<<i;
            if(v[j]&x)o++;
            else z++;
        }
        bit[i]=o*z;
    }
    ll ans=0;
    for(ll i=0;i<61;i++){
        ll x=(1LL<<i)%N;
        ll y=bit[i]%N;
        ans=(ans+(x*y)%N)%N;
        ans=(ans+N)%N;
        //cout<<i<<" "<<ans<<" "<<bit[i]<<endl;
    }
    cout<<(ans+N)%N<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
	ll c[3][3];
	for (int i = 0; i < 3; i++)for (int j = 0; j < 3; j++)cin >> c[i][j];
	cout << (c[0][0] + c[1][1] + c[2][2] == c[0][1] + c[1][2] + c[2][0] && c[0][0] + c[1][1] + c[2][2] == c[0][2] + c[1][0] + c[2][1] ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;
    string s = to_string(n);

    string t = s;
    reverse(t.begin(), t.end());
    if (s == t) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3704
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // ?¨??????\??????????????????????????????????????????                                                         
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] values = new int[w];
        for (int i = 0; i < values.length; i++) { values[i] = i + 1;
        }
        for (int i = 0; i < n; i++) {
            String str = sc.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0]) - 1;
            int b = Integer.parseInt(ab[1]) - 1; // a??¨b????????£???values??????????????????                   
            int c = values[a];
            values[a] = values[b];
            values[b] = c;
        }

        // values??????????????????                                                                        
for(int i = 0; i < values.length;i++){
            System.out.println(values[i]);
                               }
    }
}

Measured memory_bytes: 26012
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using f32 = float;
using f64 = double;
using f80 = __float80;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<LL>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
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;
}
LL n, a, b, c;
int main()
{
    cin >> a>>b;
    for (LL i = -1000000; i <= 1000000;i++){
        if(b-a<i&&i<b+a){
        cout << i << ' ';}
}
}

Measured memory_bytes: 256