akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i < n; ++i)

class dice {
  private:
    int f[6];
  public:
    dice(int *a){
      int i;
      rep(i, 6) f[i] = a[i];
    }
    void n(){
      int t;
      t = f[0];
      f[0] = f[1];
      f[1] = f[5];
      f[5] = f[4];
      f[4] = t;
    }
    void s() {
      int t;
      t = f[0];
      f[0] = f[4];
      f[4] = f[5];
      f[5] = f[1];
      f[1] = t;
    }
    void w() {
      int t;
      t = f[0];
      f[0] = f[2];
      f[2] = f[5];
      f[5] = f[3];
      f[3] = t;
    }
    void e() {
      int t;
      t = f[0];
      f[0] = f[3];
      f[3] = f[5];
      f[5] = f[2];
      f[2] = t;
    }
    void r() {
      int t;
      t = f[1];
      f[1] = f[2];
      f[2] = f[4];
      f[4] = f[3];
      f[3] = t;
    }
    void l() {
      int t;
      t = f[1];
      f[1] = f[3];
      f[3] = f[4];
      f[4] = f[2];
      f[2] = t;
    }
    int print(int num) {
      return f[num];
    }
};

int main(void) {
  int a[6], i, j, b[6];
  rep(i, 6) scanf("%d", &a[i]);
  rep(i, 6) scanf("%d", &b[i]);
  dice d1(a), d2(b);
  if(d1.print(1) == d2.print(0)) d1.n();
  else if(d1.print(2) == d2.print(0)) d1.w();
  else if(d1.print(3) == d2.print(0)) d1.e();
  else if(d1.print(4) == d2.print(0)) d1.s();
  else if(d1.print(5) == d2.print(0)) d1.n(), d1.n();
  if(d1.print(2) == d2.print(1)) d1.r();
  else if(d1.print(3) == d2.print(1)) d1.l();
  else if(d1.print(4) == d2.print(1)) d1.r(), d1.r();
  int s = 0;
  rep(i, 6) if(d1.print(i) != d2.print(i)) s = 1;
  if(s) printf("No\n");
  else printf("Yes\n");
  return 0;
}


Measured memory_bytes: 2616
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

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

pair<int, int> city[8];

void def(int n, int zero, int one)
{
	city[n].first = zero; city[n].second = one;
}

int main()
{
	//A:0  X:1  Y:2  Z:3  W:4  B:5
	//
	//0:first  1:second
	def(0, 1, 2);
	def(1,-1, 3);
	def(2, 1,-1);
	def(3, 4, 5);
	def(4, 5, 2);
	def(5, 2, 1);

	string a;
	while(cin >> a)
	{
		if(a == "#")
		{
			break;
		}

		int now = 0;

		for(int i = 0; i < a.size(); i++)
		{
			if(a[i] == '0')
			{
				now = city[now].first;
			}
			else if(a[i] == '1')
			{
				now = city[now].second;
			}
			if(now == -1)
			{
				break;
			}
		}
		cout << (now == 5? "Yes": "No") << endl;
	}
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
int n;
vector<vector<int>> capacity;
vector<vector<int>> adj;

int bfs(int s, int t, vector<int>& parent) {
    fill(parent.begin(), parent.end(), -1);
    parent[s] = -2;
    queue<pair<int, int>> q;
    q.push({s, 1e9});

    while (!q.empty()) {
        int cur = q.front().first;
        int flow = q.front().second;
        q.pop();
      //  debug(cur);

        for (int next : adj[cur]) {
            if (parent[next] == -1 && capacity[cur][next]) {
                parent[next] = cur;
                int new_flow = min(flow, capacity[cur][next]);
                if (next == t)
                    return new_flow;
                q.push({next, new_flow});
            }
        }
    }

    return 0;
}

int maxflow(int s, int t) {
    int flow = 0;
    vector<int> parent(n);
    int new_flow;

    while (new_flow = bfs(s, t, parent)) {
        flow += new_flow;
        int cur = t;
        while (cur != s) {
            int prev = parent[cur];
            capacity[prev][cur] -= new_flow;
            capacity[cur][prev] += new_flow;
            cur = prev;
        }
    }

    return flow;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    capacity.assign(250, vector<int>(250, 1));
    adj.resize(250);
    int h, w;cin >> h >> w;
    n = 250;
    char in; 
    FOR(i, h){
        FOR(j, w){
            cin >> in;
     //       debug(in);
            j += 100;
    //        cout << j << " " << i << endl;

            if(in == 'S'){
                adj[i].pb(202); 
                adj[j].pb(202);
                adj[i].pb(j);
                adj[j].pb(i);
                adj[202].pb(j);
                adj[202].pb(i);
                capacity[202][j]= 10000;
                capacity[202][i]= 10000;
                capacity[i][202]= 10000;
                capacity[j][202]= 10000;
            }else if(in == 'T'){
                adj[i].pb(201); 
                adj[j].pb(201);
                adj[i].pb(j);
                adj[j].pb(i);
                adj[201].pb(j);
                adj[201].pb(i);
                capacity[201][j]= 10000;
                capacity[201][i]= 10000;
                capacity[i][201]= 10000;
                capacity[j][201]= 10000;
            }else if(in == 'o'){
                adj[i].pb(j); 
                adj[j].pb(i);
            }
            j -= 100;
        }
    }
    int ans = maxflow(201, 202);
    if(ans >= 10000){
        cout << -1;
    }else cout << ans;
}




Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            switch (S)
            {
                case "Sunny":
                    Console.WriteLine("Cloudy");
                    break;
                case "Cloudy":
                    Console.WriteLine("Rainy");
                    break;
                case "Rainy":
                    Console.WriteLine("Sunny");
                    break;
            }
        }
    }
}


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

namespace CSharpConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A_Poor();
        }
        static void A_Poor()
        {
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = int.Parse(str[2]);
            if((A == B && A != C) || (A == C && A != B) ||(B ==C && B != A))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int count = 0;
    while (A >= B) {
        count++;
        B *= 2;
    }
    while (B >= C) {
        count++;
        C *= 2;
    }

    if (count <= K) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = a; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n / x + (n % x != 0)) * t << endl;
}


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

int main()
{
    int n,a,b,c=0,x=0;
    cin>>n;
    while(n--){
       cin>>a>>b;
       if(a==b){
        c++;
       }else{
            c=0;
       }
       if(c==3){
        cout<<"Yes"<<"\n";
        x=1;
       }
    }
    if(x==0){
        cout<<"No"<<"\n";
    }
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const int N=100000;

struct edge{int to,cost;};
vector<edge> G[N];

int c[N]={}, d[N]={};
double pw[N];

void dfs(int now, int par, int depth)
{
    d[now] = depth;
    for(edge &e:G[now])
    {
        if(e.to == par) continue;
        
        c[e.to] = e.cost;
        dfs(e.to,now,depth+1);
    }
}

int main()
{
    double p;
    int n;
    scanf(" %lf %d", &p, &n);
    rep(i,n-1)
    {
        int a,b,x;
        scanf(" %d %d %d", &a, &b ,&x);
        --a;
        --b;
        G[a].pb(edge{b,x});
        G[b].pb(edge{a,x});
    }

    dfs(0,-1,0);

    pw[0]=1;
    for(int i=1; i<N; ++i) pw[i]=pw[i-1]*p;

    double A=0,B=1;
    rep(i,n)
    {
        A += c[i]*pw[d[i]];
        B += pw[d[i]];
    }

    printf("%.10f\n", A*B);
    return 0;
}

Measured memory_bytes: 14908
#include <bits/stdc++.h>
#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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);
llong n,c,k;

int main(){ _;
  cin>>n>>c>>k;
  V t(n);
  REP(i,n) cin>>t[i];
  VSORT(t);
  
  llong ans=1,crt=1;
  llong first=t[0];

  FOR(i,1,n){
    if (t[i]<=first+k && crt<c)
      ++crt;
    else{
      ++ans;
      first = t[i];
      crt=1;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include <fstream>
#include<string>
#include<cctype>
using namespace std;
string str;
string::iterator itr;
int main() {
	cin >> str;
	int p = str.size();
	itr = str.end();
	for (int i = 0; i < p; i++)
	{
		itr--;
		cout << *itr;
		
	}
	cout << endl;
			return 0;
}


Measured memory_bytes: 1176
import sys

s = input()

list = list(s)
n = len(list)

list_l = list[:n//2]
list_r = list[(n//2)+1:]

n_l = len(list_l)
n_r = len(list_r)

for i in range(n):
    if list[i] != list[-i-1]:
        print('No')
        sys.exit()

for i in range(n_l):
    if list_l[i] != list_l[-i-1]:
        print('No')
        sys.exit()

for i in range(n_r):
    if list_r[i] != list_r[-i-1]:
        print('No')
        sys.exit()

print('Yes')


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

int main() {
	int h, w;
	while(h+w){
		cin >> h >> w;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(i == 0 || i == h-1 || j == 0 || j == w-1) cout<<"#";
				else cout<< ".";
			}
			cout<<endl;
		}
		if(h+w) cout<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 1152
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){
    long long n;
    cin>>n;
    cout<<(n*(n-1))/2;
    return 0;
}

Measured memory_bytes: 3156
var
	s,t:double;
	i,n:longint;
	a:String;
begin
	readln(n);
	for i:=1 to n do begin
		readln(s,a);
		if a=' BTC'then s:=s*38e4;
		t:=t+s;
	end;
	writeln(t);
end.

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

  int A , B , C ;
  cin >> A >> B >> C ; 
  if  (A*C <= B) cout << C << endl ;
  else cout << B/A << endl;   
}

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

#define MAX_SIZE (1000)
#define MAX_DIGIT (1000)

using namespace std;

int only_num(char x[]);

int main()
{
    int   size;

    char** x = new char*[MAX_SIZE + 1];

    for (int i = 0; i < MAX_SIZE + 1; i++) {
         x[i] = new char[MAX_DIGIT + 1];
    }

    int* sum = new int[MAX_SIZE + 1];

    for (int i = 0; i < MAX_SIZE + 1; i++) {
         do {
             cin >> x[i];
         } while (strlen(x[i]) > MAX_DIGIT || only_num(x[i]) == 0);

         if (strcmp(x[i], "0") == 0) {
             size = i;
             break;
         } else {
             for (int j = 0; x[i][j] != '\0'; j++) {
                  sum[i] += x[i][j] - '0';
             }
         } 
    }

    for (int i = 0; i < size; i++) {
         cout << sum[i] << endl;
    }
    
    for (int i = 0; i < MAX_SIZE + 1; i++) {
         delete[] x[i];
    }

    delete[] x;

    delete[] sum;

    return (0);
}

int only_num(char x[])
{
    int i;

    for (i = 0; x[i] != '\0'; i++) {
         if (x[i] < '0' || x[i] > '9') {
             break;
         }
    }

    if (x[i] == '\0') {
        return (1);
    } else {
        return (0);
    }
}

Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
int input() {
	int r;
	scanf("%d", &r);
	return r;
}
int main() {
	int h, w;
	while (cin >> h >> w, h) {
		int x = 1, y = 1, d = 1;
		string s;
		while (cin >> s) {
			if (s[0] == 'S')break;
			if (s[0] == 'L')d++;
			if (s[0] == 'R')d += 3;
			d %= 4;
			if ((s[0] == 'F' && d == 1) || (s[0] == 'B' && d == 3)) {
				y += input(); y = min(y, w);
			}
			if ((s[0] == 'F' && d == 3) || (s[0] == 'B' && d == 1)) {
				y -= input(); y = max(y, 1);
			}
			if ((s[0] == 'F' && d == 0) || (s[0] == 'B' && d == 2)) {
				x += input(); x = min(x, h);
			}
			if ((s[0] == 'F' && d == 2) || (s[0] == 'B' && d == 0)) {
				x -= input(); x = max(x, 1);
			}
		}
		cout << x << ' ' << y << endl;
	}
}


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

string s;
string a = "CODEFESTIVAL2016";
int n;
int main() {
    ios::sync_with_stdio(false);
    cin >> s;
    
    for (int i = 0; i < a.length(); i++) {
        if (a[i] != s[i])
            n++;
    }
    cout << n << endl;
    

    
    return 0;
}



Measured memory_bytes: 256
## coding: UTF-8
import bisect

N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))


#Cum_A = []
Cum_B = []
yoryoku = [K]



na = K
for i in range(len(A)):
    na -= A[i]
    yoryoku.append(na)
    #Cum_A.append(na)

nb = 0
for j in range(len(B)):
    nb += B[j]
    Cum_B.append(nb)

#print(Cum_A)
#print(yoryoku)
#print(Cum_B)
    


ans = 0
for i in range(len(yoryoku)):
    r = yoryoku[i]
    if(r < 0):
        break
    #print(i + 1 + bisect.bisect_right(Cum_B, r))
    ans = max(ans , i+bisect.bisect_right(Cum_B, r))
print(ans)


Measured memory_bytes: 126588
//import java.io.*;
import java.util.*;
//import java.math.*;
public class Main {
 
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
        int n=0;
        while((n=scan.nextInt())!=0){
        	int [] data =new int[n];
        	for(int i=0;i<n;i++)
        		data[i]=scan.nextInt();
        	
        	int tch=0;
        	
        	while(true){
        		int ch=0;
        	for(int i=0;i<n-1;i++){
        		if(data[i]>data[i+1]){
        			data[i]^=data[i+1];
        			data[i+1]^=data[i];
        			data[i]^=data[i+1];
        			ch++;
        			
        		}
        	}
        	tch+=ch;
        	if(ch==0)break;}
        
        System.out.println(tch);
        }
    }
}

Measured memory_bytes: 12000
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template


def main():
    Q, H, S, D = mi()
    N = ii()
    N *= 4
    dp = [10**10] * 9
    dp[0] = 0
    for i in range(1, 9):
        dp[i] = min(dp[i - 1] + Q, dp[i])
    for i in range(2, 9):
        dp[i] = min(dp[i - 2] + H, dp[i])
    for i in range(4, 9):
        dp[i] = min(dp[i - 4] + S, dp[i])
    for i in range(8, 9):
        dp[i] = min(dp[i - 8] + D, dp[i])
    # print(dp)
    m = min(8 * Q, 4 * H, 2 * S, D)
    print(m * (N // 8) + dp[N % 8])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
int main()
{
    int t,i,j;
        string s,ss;
        int n,k;
        cin>>n;
        if(n%1000==0)cout<<0<<endl;
        else
        {
             k=n/1000;
            n-=(k*1000);
            cout<<1000-n<<endl;
        }
    return 0;
}


Measured memory_bytes: 3624
import java.util.* ;

class Main {
    static int dp[] = new int[100001] ; 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in) ;
        int n = sc.nextInt() ; 
        int arr[] = new int[n+1] ; 
        for(int i=1 ; i<=n ; i++){
            arr[i] = sc.nextInt() ; 
        }
        for(int i=0 ; i<=n ; i++){
            dp[i] = -1 ; 
        }
        System.out.println(path(arr, n)); 
    }

    static int path(int arr[],int n){
        if(n<=1){
            return dp[n] = 0  ; 
        }
        if(n==2){
            return dp[n]=Math.abs(arr[n]-arr[n-1]) ;
        }
        if(dp[n]!=-1){
            return dp[n] ; 
        }
        else {
            return dp[n]= Math.min(Math.abs(arr[n]-arr[n-1])+path(arr, n-1),Math.abs(arr[n-2]-arr[n])+path(arr, n-2)) ; 
        }
       
    
    }

    
}


Measured memory_bytes: 74480
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define S(s) (int)((s).size())
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,(v))
#define MA(a,v) a = max(a,(v))
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m; cin>>n>>m;
    int pref[n][m];
    bool here[m];
    F(j,m) here[j] = true;
    F(i,n) F(j,m) {
        cin>>pref[i][j];
        pref[i][j]--;
    }
    int best = n, rem = m;
    while (rem) {
        int cnt[m];
        F(i,m) cnt[i] = 0;
        F(i,n) F(j,m) {
            if (here[pref[i][j]]) {
                cnt[pref[i][j]]++;
                break;
            }
        }
        int ma=0;
        F(i,m) MA(ma,cnt[i]);
        MI(best, ma);
        F(i,m) if (cnt[i] == ma) {
            here[i] = false;
            break;
        }
        rem--;
    }
    P(best);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e5+5;
int dp[3][maxn], a[maxn], b[maxn], c[maxn];

int main(){
	int n; cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];
	for(int i = 1; i <= n; i++){
		dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + a[i];
		dp[1][i] = max(dp[0][i-1], dp[2][i-1]) + b[i];
		dp[2][i] = max(dp[1][i-1], dp[0][i-1]) + c[i];
	}
	int ans;
	ans = max(dp[0][n], max(dp[1][n], dp[2][n]));
	cout << ans << endl;
}

Measured memory_bytes: 2560
N=int(input())

sieve= [0]*(N+1)
sieve[0]=-1
sieve[1]=-1
for i in range(2,N+1):
    if sieve[i] != 0:
        continue
    sieve[i] = i
    for j in range(i*i, N+1, i):
        if sieve[j] ==0:
            sieve[j] = i
            
def G(x):
    t=[]
    a = x
    while a!=1:
        if len(t) != 0 and t[-1][0] == sieve[a]:
            t[-1][1] += 1
        else:
            t.append([sieve[a],1])
        a //= sieve[a]
    result = 1
    for _,n  in t:
        result *= n+1
    return result

sum = 0
for i in range(1, N+1):
    sum += i*G(i)
print(sum)            

Measured memory_bytes: 152788
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(usize);
    let mut aa = get!(String).split_whitespace().map(|i| i.parse::<i32>().unwrap()).collect::<Vec<_>>();
    aa.sort();
    let bb = get!(String).split_whitespace().map(|i| i.parse::<i32>().unwrap()).collect::<Vec<_>>();
    let mut cc = get!(String).split_whitespace().map(|i| i.parse::<i32>().unwrap()).collect::<Vec<_>>();
    cc.sort();

    let mut s = 0;
    for b in bb.into_iter() {
        let mut l;
        let mut r;
        let x = if aa[0] >= b {
            0
        } else {
            l = 0;
            r = n;
            while l+1 < r {
                let m = (l+r)/2;
                if aa[m] < b {
                    l = m;
                } else {
                    r = m;
                }
            }
            r
        };
        let y = if cc[0] > b {
            n
        } else {
            l = 0;
            r = n;
            while l+1 < r {
                let m = (l+r)/2;
                if cc[m] <= b {
                    l = m;
                } else {
                    r = m;
                }
            }
            n - r
        };
        s += x * y;
    }
    println!("{}", s);
}

Measured memory_bytes: 5708
#include<bits/stdc++.h>
#define ll long long
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
ll get(ll n)
{
    return (n*(n+1))/2;
}

main()
{
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=k;i<=n+1;i++)
    {
        ll f=get(i-1);
        ll first=get(n)-get(n-i);
        //cout<<first<<' '<<f<<' '<<first-f+1<<endl;
        ans+=first-f+1;
        ans%=M;
    }
    cout<<ans;



}



Measured memory_bytes: 3596
def get_indices_of_letter(string, letter):
    indices_of_min_letter = []
    for i, c in enumerate(string):
        if c == letter:
            indices_of_min_letter.append(i)

    return indices_of_min_letter


def solve(s, k):
    letters_in_s = sorted(set(s))

    min_letter = letters_in_s[0]
    if k == 1:
        return min_letter

    indices_of_min_letter = get_indices_of_letter(s, min_letter)

    substrings_seen = set([min_letter])

    for i in indices_of_min_letter:
        for j in xrange(i + 1, i + 6):
            substrings_seen.add(s[i:j])

    if len(substrings_seen) >= k:
        return sorted(substrings_seen)[k - 1]

    second_smallest_letter = letters_in_s[1]

    substrings_seen.add(second_smallest_letter)
    if len(substrings_seen) == k:
        return second_smallest_letter

    indices_of_second_letter = get_indices_of_letter(s, second_smallest_letter)

    for i in indices_of_second_letter:
        for j in xrange(i + 1, i + 6):
            substrings_seen.add(s[i:j])

    if len(substrings_seen) >= k:
        return sorted(substrings_seen)[k - 1]

    return letters_in_s[2]


s = raw_input()
k = int(raw_input())

print solve(s, k)

Measured memory_bytes: 2820
#include<bits/stdc++.h>
#define n 200005
using namespace std;
vector<long long >v(n,0);
vector<long long >prime;
long long i,j;
void sieve()
{
    for(i=3; i*i<=n; i+=2)
    {
        for(j=i*i; j<=n; j+=(i+i))
        {
            v[j-1]=1;
        }
    }
    prime.push_back(2);
    for(i=3; i<n; i+=2)
    {
        if(v[i-1]==0)
        {
            //cout<<i<<endl;
            prime.push_back(i);
        }
    }
}
int main()
{
    sieve();
    long long num,t;
    cin>>num;
    for(i=0;i<n;i++)
    {
        if(prime[i]>=num)
        {
            cout<<prime[i]<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2176
A = [[],[],[]]
b = []

for i in range(0,3):
    A[i] = [int(x) for x in input().split(" ")]
N = int(input())
for i in range(0,N):
  b.append(int(input()))

for i in range(0,3):
  for j in range(0,3):
    for n in range(0,N):
      if A[i][j] == b[n]:
        A[i][j] = 0

if A[0] == [0,0,0] or A[1] == [0,0,0] or A[2] == [0,0,0]:
  print("Yes")
elif [A[0][0],A[1][0],A[2][0]] == [0,0,0]:
  print("Yes")
elif [A[0][1],A[1][1],A[2][1]] == [0,0,0]:
  print("Yes")
elif [A[0][2],A[1][2],A[2][2]] == [0,0,0]:
  print("Yes")
elif [A[0][0],A[1][1],A[2][2]] == [0,0,0]:
  print("Yes")
elif [A[2][0],A[1][1],A[0][2]] == [0,0,0]:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define get ch=getchar()
#define is isdigit(ch)
using namespace std;
const int maxm=100001;
inline ll read(){
	char get;
	ll r=0;
	while(!is)get;
	while(is){
		r=(r<<3)+(r<<1)+(ch^48);
		get;
	}
	return r;
}
ll n,a,b,pos[maxm],dis[maxm-1],costs;
int main(){
	n=read();a=read();b=read();
	for(ll i=1;i<=n;i++){
		pos[i]=read();
		if(i>1){
			dis[i-1]=pos[i]-pos[i-1];
			dis[i-1]*=a;
		}
	}
	for(ll i=1;i<=n-1;i++){
		if(dis[i]<b)costs+=dis[i];
		else costs+=b;
	}
	printf("%lld",costs);
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int H, W, h, w;

	while (1)
	{
		scanf("%d %d", &H, &W);

		if ((H == 0) && (W == 0))
		{
			break;
		}
		for (h = 0; h<H; h++)
		{
			for (w = 0; w<W; w++)
			{
				if ((h + w) % 2 == 0)
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
			}	printf("\n");
		}   printf("\n");
	}   


    return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
#include <string.h>

int main(){
	int n,i,j,data;
	int sum[11],sum2[11];

	while(1){
		scanf("%d",&n);
		if(n == 0){
			break;
		}

		memset(sum,0,sizeof(sum));
		memset(sum2,0,sizeof(sum2));

		for(i = 0;i < n;i++){
			for(j = 0;j < n;j++){
				scanf("%d",&data);
				printf("%5d",data);
				sum[j] += data;
				sum2[i] += data;
			}
			printf("%5d\n",sum2[i]);
			sum[n] += sum2[i];
		}
		for(i = 0;i <= n;i++){
			printf("%5d",sum[i]);
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n;
  cin >> n;
  vector<string> vs(n);
  for(auto &s: vs) cin >> s;
  int answer = 0;
  int ba = 0;
  int bx = 0;
  int xa = 0;
  for(auto s: vs) {
    for(auto ite = s.begin(); ite+1 != s.end(); ++ite) {
      if(string(ite,ite+2)=="AB") ++answer;
    }
    if(s.front() == 'B' && s.back() == 'A') ++ba;
    if(s.front() == 'B') ++bx;
    if(s.back() == 'A') ++xa;
  }
  if(ba && ba == bx && ba == xa) --bx;
  answer += min(bx,xa);
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 768
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	k := nextInt(sc)
	var t uint
	for i := 0; i < k; i++ {
		t |= (1 << uint(nextInt(sc)))
	}
	wtr := bufio.NewWriter(os.Stdout)
	for bits := uint(0); bits < (1 << uint(n)); bits++ { // Uの要素を全列挙
		if (bits & t) == t { // TはUの部分集合(bits)に含まれる
			fmt.Fprint(wtr, bits, ":")
			for j := 0; j < n; j++ {
				if (bits & (1 << uint(j))) != 0 {
					fmt.Fprint(wtr, " ", j)
				}
			}
			fmt.Fprintln(wtr)
		}
	}
	wtr.Flush()
}



Measured memory_bytes: 6148
use std::io::{self, BufRead, BufWriter, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let n: i32 = lines.next().unwrap().unwrap().parse().unwrap();

    let odd = if n % 2 == 0 { n / 2 } else { (n + 1) / 2 };

    let ans = odd as f64 / n as f64;

    writeln!(&mut writer, "{}", ans).unwrap();
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
//         (
//             br"4", br"0.5000000000
// ",
//         ),
//         (
//             br"5", br"0.6000000000
// ",
//         ),
//         (
//             br"1", br"1.0000000000
// ",
//         ),
    ];

    #[test]
    fn test_a() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 4352
import math
N, A , B = map(int, input().split())

ans = 0

for x in range(1, N + 1):
    SUM = 0
    num = x
    while x > 0:
        SUM += (x % 10)
        x //= 10
    if A <= SUM <= B:
        ans += num

print(ans)  

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int main(){
  ll h;
  cin >> h;

  int k = 0;
  while(h){
  	h /= 2;
  	++k;
  }

  ll ans = 1;
  for(int i = 0; i < k; ++i)ans *= 2;
  --ans;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define EPS 0.00000000001
using namespace std;

int main()
{
  double x1,x2,x3,x4,y1,y2,y3,y4;
  double dx1,dy1,dx2,dy2;
  int n;
  int i;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
    dx1=x2-x1;
    dy1=y2-y1;
    dx2=x4-x3;
    dy2=y4-y3;

    if(abs(dx1)<EPS && abs(dx2)<EPS)
      cout<<"YES"<<endl;
    else if(abs(dx1)<EPS || abs(dx2)<EPS)
      cout<<"NO"<<endl;
    else if(abs(dy1/dx1-dy2/dx2) < EPS)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 1224
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum = 0;
        long total = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            if (x == 0) {
                total += sum / 2;
                sum = 0;
            } else {
                sum += x;
            }
        }
        total += sum / 2;
     System.out.println(total);
    }
}


Measured memory_bytes: 48900
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


int main(void) {
  ll X, Y;
  cin >> X >> Y;

  ll ans = 1;
  ll now = X;
  while (now <= Y) {
    ll next = now * 2;
    if (next > Y) break;
    ++ans;
    now = next;
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a==b) printf("Draw");
  else if(a==1) printf("Alice");
  else if(b==1) printf("Bob");
  else if(a>b) printf("Alice");
  else printf("Bob");
  return 0;
}

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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
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; }

int main() {
    string S;
    cin >> S;
    int x,y;
    cin >> x >> y;
    
    int tnum = 0;
    int xnum = 0, ynum = 0;
    vector<int> xv,yv;
    REP(i,S.size()){
        if ( S[i] == 'F' ) {
            if ( tnum == 0 ) {
                --x;
            } else {
                if ( tnum % 2 == 0 ) ++xnum;
                else ++ynum;
            }
        } else {
            if ( tnum % 2 == 0 ) {
                if( xnum != 0 ) xv.push_back(xnum);
                xnum = 0;
            } else {
                if( ynum != 0 ) yv.push_back(ynum);
                ynum = 0;
            }
            ++tnum;
        }
    }
    if ( tnum % 2 == 0 ) {
        if( xnum != 0 ) xv.push_back(xnum);
        xnum = 0;
    } else {
        if( ynum != 0 ) yv.push_back(ynum);
        ynum = 0;
    }
    
    set<int> xst,yst,nxst,nyst;

    
    xst.insert(0);
    REP(i,xv.size()){
        for ( auto itr = xst.begin(); itr != xst.end(); ++itr){
            int xx = *itr;
            nxst.insert(xx+xv[i]);
            nxst.insert(xx-xv[i]);
        }
        xst = nxst;
        nxst.clear();
    }
    
    yst.insert(0);
    REP(i,yv.size()){
        for ( auto itr = yst.begin(); itr != yst.end(); ++itr){
            int yy = *itr;
            nyst.insert(yy+yv[i]);
            nyst.insert(yy-yv[i]);
        }
        yst = nyst;
        nyst.clear();
    }
    
    if ( xst.find(x) != xst.end() and yst.find(y) != yst.end() ) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    
    return 0;
}

Measured memory_bytes: 4116
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N],d[N],f[N], tt;


void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for(v = 0; v < n; v++ ){
    if( M[u][v] == 0 ) continue;
    if( color[v] == WHITE ){
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs(){
  int u;
  
  for( u = 0; u < n; u++ ) color[u] = WHITE;
  tt = 0;
  
  for( u = 0; u < n; u++ ){
    if( color[u] == WHITE ) dfs_visit(u);
  }
  for( u = 0; u < n; u++ ){
    printf("%d %d %d\n", u + 1, d[u], f[u]);
  }
}


int main(){
  int u,v,k,i,j;
  
  scanf("%d", &n);
  for( i = 0; i < n; i++ ){
    for( j = 0; j < n; j++ ) M[i][j] = 0;
  }
  
  for( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    u--;
    for( j = 0; j < k; j++ ){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }
  
  dfs();
  
  return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
     long double n;
     cin >> n;
    long double d;
    cin >> d;
    long double ans = d * n;
    ll a = ans;
    cout << a ;
    
}









Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

const ll inf = 1e18L + 5;

vector < vector < int > > a;
vector < ll > group_value;
vector < ll > dp;

void f (int mask, int i, vector < int > & not_selected, int group, ll value) {
	if (i == (int) not_selected.size()) {
		dp[mask] = max (dp[mask], value + group_value[group]);
		return;
	}
	
	f (mask, i + 1, not_selected, group, value);
	f (mask ^ (1 << not_selected[i]), i + 1, not_selected, group ^ (1 << not_selected[i]), value);
}
	

int main() {
	int n; scanf ("%d", &n);
	a.resize (n, vector < int > (n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <n; j++) {
			scanf ("%d", &a[i][j]);
		}
	}
	group_value.resize (1 << n);
	for (int state = 0; state < (1 << n); state++) {
		vector < int > members;
		for (int i = 0; i < n; i++) {
			if ((state >> i) & 1) {
				members.push_back (i);
			}
		}
		for (int i = 0; i < (int) members.size(); i++) {
			for (int j = i + 1; j < (int) members.size(); j++) {
				group_value[state] += a[members[i]][members[j]];
			}
		}
	}
	dp.resize (1 << n, -inf);
	dp[0] = 0;
	for (int taken = 0; taken < (1 << n); taken++) {
		vector < int > not_taken;
		for (int i = 0; i < n; i++) {
			if (!((taken >> i) & 1)) {
				not_taken.push_back (i);
			}
		}
		f (taken, 0, not_taken, 0, dp[taken]);
	}
	printf ("%lld\n", dp[(1 << n) - 1]);
	return 0;
}



Measured memory_bytes: 1280
N=int(input())
S=list(map(int,input().split()))
S.sort()
S.reverse()

count=0
le=len(S)
S.append(-100000)
for i in range(le-2):
    for j in range(i+1,le-1):
        if S[i]<S[j]+S[j+1]:
            left=j+1
            right=le
            while left<=right:
                mid=(left+right)//2
                if S[i]<S[j]+S[mid] and S[i]>=S[j]+S[mid+1]:
                    count+= mid-(j+1)+1
                    
                    break
                elif S[i]<S[j]+S[mid]:
                    left=mid+1
                elif S[i]>=S[j]+S[mid]:
                    right=mid-1
                else:
                    print("イレギュラーな例につかまりました")
                    exit()
                
print(count)


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

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * n

    def sum(self, i):
        s = 0
        i -= 1
        while i >= 0:
            s += self.tree[i]
            i = (i & (i + 1)) - 1
        return s

    def add(self, i, x):
        while i < self.size:
            self.tree[i] += x
            i |= i + 1

a = ord('a')

def make_index(s):

    index = [[] for _ in range(26)]
    for i, ch in enumerate(s):
        index[ord(ch) - a].append(i)

    return index

def solve(s):

    n = len(s)
    index = make_index(s)

    odd = None
    for code, char_pos in enumerate(index):
        if len(char_pos) % 2 == 1:
            if odd is not None:
                return -1
            odd = code

    bit = Bit(n)

    ans = 0
    cnt = 0
    for i in range(n):
        if bit.sum(i + 1) - bit.sum(i) == 1:
            continue
        code = ord(s[i]) - a
        if code == odd and index[code][-1] == i:
            continue
        cnt += 1
        j = index[code].pop()
        ans += n - cnt - (j - bit.sum(j))
        bit.add(j, 1)
        if n // 2 <= cnt:
            break

    if odd is not None:
        j = index[odd][-1]
        ans += abs(n // 2 - (j - bit.sum(j)))

    return ans


def main():
    s = input()

    print(solve(s))


if __name__ == '__main__':
    main()



Measured memory_bytes: 15320
#include<bits/stdc++.h>
#define re register
#define M 1000000007
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0'){
		t=(t<<3)+(t<<1)+v-48;
		v=getchar();
	}
	return t;
}
using namespace std;
int n,head[2000002],cnt,ans[2000002],fa[2000002],f[2000002],jc[2000002],num[2000002],inv[2000002],siz[2000002],siz1[2000002];
struct edge{
	int to,next;
}e[2000002];
inline int C(re int x,re int y){
	return 1ll*jc[x]*inv[y]%M*inv[x-y]%M;
}
inline void add(re int x,re int y){
	e[++cnt].to=y;
	e[cnt].next=head[x];
	head[x]=cnt;
}
inline void dp(re int x,re int y){
	ans[x]=1;fa[x]=y;siz[x]=1;
	for(re int i=head[x];i;i=e[i].next)
	if(e[i].to^y){
	dp(e[i].to,x);
	ans[x]=1ll*ans[x]*ans[e[i].to]%M*C(siz[x]-1+siz[e[i].to],siz[e[i].to])%M;siz[x]+=siz[e[i].to];}
}
inline int ksm(re int x,re int y){
	re int ans=1;
	while(y){
		if(y&1)ans=1ll*ans*x%M;
		x=1ll*x*x%M;
		y>>=1;
	}
	return ans;
}
inline void dp1(re int x,re int y){
	if(x!=1)ans[x]=1ll*ans[x]*y%M*C(siz[x]-1+n-siz[x],n-siz[x])%M;
	for(re int i=head[x];i;i=e[i].next)if(e[i].to^fa[x])dp1(e[i].to,1ll*ans[x]*ksm(ans[e[i].to],M-2)%M*ksm(C(n-1,siz[e[i].to]),M-2)%M);
}
signed main(){
	n=read();
	jc[0]=1;n*=2;
	for(re int i=1;i<=n;++i)jc[i]=1ll*jc[i-1]*i%M;
	inv[n]=ksm(jc[n],M-2);inv[0]=1;
	for(re int i=n-1;i;--i)inv[i]=1ll*(i+1)*inv[i+1]%M;n/=2;
	for(re int i=1,x,y;i<n;++i){
		x=read();y=read();
		add(x,y);
		add(y,x);
	}
	dp(1,1);
	dp1(1,1);
	for(re int i=1;i<=n;++i)printf("%d\n",ans[i]);
}


Measured memory_bytes: 22656
import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String s = sc.next();
      int total = 0;
      int i;
      for(i=0;i<n-2;i++){
        if(s.charAt(i)=='A'){
          if(s.charAt(i+1)=='B'){
            if(s.charAt(i+2)=='C'){
              total += 1;
            }
          }
        }
      }
      System.out.println(total);
      
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> T(N);
    rep(i, N) cin >> T[i];
    
    int Sum = 0;
    rep(i, N) Sum += T[i];
    int M;
    cin >> M;
    rep(i, M) {
        int P, X;
        cin >> P >> X;
        cout << Sum - T[P - 1] + X << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
char t[101];

int main(){
	int N = 0;
	cin >> N;
	string input;
	cin >> input;
	string temp = input;
	

	int p = 0;

	for(int i = N-1; i >= 0; i--){
		if(input[i] == '(' && p == 0){
			temp = temp + ')';
		}
		else if(input[i] == ')'){
			t[p++] = input[i];
		}
		else if(input[i] == '(' && t[p-1] == ')'){
			p--;
		}
	}


	for(int i = 0; i < p; i++){
		temp = '(' + temp;
	}

	for(int i = 0; i < temp.length(); i++){
		cout << temp[i];
	}
	cout << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int x,y;
	cin>>x>>y;
	int ans=0;
	for(int i=x;i<=y;i*=2){
		ans++;
	}
	cout<<ans<<endl;
}


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

int main()
{


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

  if ( a > b )  swap (a,b);
  if ( b > c )  swap (b,c);
  if ( a > b )  swap (a,b);

  cout << a <<" "<< b <<" "<< c << endl; 
  
  return 0;
}

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

int main()
{
	int a[6];
	a[0]=9;
	cin >> a[1];
	cin >> a[2];
	cin >> a[3];
	cin >> a[4];
	cin >> a[5];
	int c=0;
	for(int i=1;i<6;i++){
		if(a[i]%10!=0){
			if(a[c]%10>=a[i]%10){
				a[c]=a[c]/10*10+10;
				c=i;
				
			}else{
				a[i]=a[i]/10*10+10;
			}
		}
	}
	cout << a[1]+a[2]+a[3]+a[4]+a[5];
	return 0;
}

Measured memory_bytes: 256
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define MOD 1000000007

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>

using namespace std;

// clang-format on

map<pair<int, int>, int> p;

main {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  int s = sum(a);
  if (s % n == 0) {
    int avg = s / n;
    int c = 0;
    rep(i, n) c += (avg - a[i]) * (avg - a[i]);
    cout << c << endl;
  } else {
    int ava = s / n, avb = (s + n - 1) / n;
    int c = 0, d = 0;
    rep(i, n) {
      c += (ava - a[i]) * (ava - a[i]);
      d += (avb - a[i]) * (avb - a[i]);
    }
    cout << min(c, d) << endl;
  }
  bye;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main()
{
	long long n;
	char pass[255] = {0};
	
	scanf("%lld", &n);
	--n;
	int i = 0;
	
	while(n >= 0){
		pass[i] = (n % 26) + 'a';
		n /= 26;
		++i;
		--n;
	}
	
	int len = strlen(pass);
	
	for(int i = len - 1 ; i >= 0; i--){
		printf("%c", pass[i]);
	}
	puts("");
}

Measured memory_bytes: 1660
import sys
sys.setrecursionlimit(10**8)
def line_to_int(): return int(sys.stdin.readline())
def line_to_each_int(): return map(int, sys.stdin.readline().split())
def line_to_list(): return list(map(int, sys.stdin.readline().split()))
def line_to_list_in_iteration(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
# def dp(init, i, j): return [[init]*i for i2 in range(j)]
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
# from itertools import accumulate #A = [0]+list(accumulate(A))
# import bisect #bisect.bisect_left(B, a), bisect.bisect_right(B,a)

a, b = line_to_each_int()
print(a*b)

Measured memory_bytes: 9048