akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main(void)
{
	int n,i,j,nagasa;
	while(scanf("%d",&n),n){
		char str[60000]={0},afstr[60000]={0};
		char after;
		char *p;
		int count=0,r=1;
		
		scanf("%s",str);
		for(i=0;i<n;i++){ 
		
			nagasa = strlen(str);
			
			for(j=0;j<nagasa;j++){
				after=str[j+1];
				if(after==str[j]){
					r++;
				}
				
				else {
					sprintf( afstr+count, "%d",r);
					if(r>=10)count++;
					r=1;
					count++;
					afstr[count]=str[j];
					count++;
				}
			}
			count=0;
			strcpy( str,afstr);
		}
		printf("%s\n",afstr);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vsort(x) sort(x.begin(),x.end())

using namespace std;

int main() {

	int i, j, k;
	int n, m;
	cin >> n >>  m;
	cout << (n - 1)*(m - 1) << endl;
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,C;
int A[404],B[404];
ll mo=1000000007;
ll ppow[404][404];
ll ppowS[404][404];

ll dp[404][404];

ll modpow(ll a, ll n = mo-2) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>C;
	FOR(i,N) cin>>A[i];
	FOR(i,N) cin>>B[i];
	
	ppow[0][0]=1;
	for(i=1;i<=400;i++) {
		ppow[i][0]=1;
		FOR(j,400) ppow[i][j+1]=ppow[i][j]*i%mo;
	}
	FOR(i,401) FOR(j,401)  (ppowS[j+1][i]=ppowS[j][i]+ppow[j][i])%=mo;
	
	
	dp[0][0]=1;
	FOR(i,N) FOR(x,C+1) for(y=0;x+y<=C;y++) {
		ll p=(ppowS[B[i]+1][y]-ppowS[A[i]][y])%mo;
		if(p<0) p+=mo;
		(dp[i+1][x+y] += dp[i][x] * p) %= mo;
	}
	cout<<dp[N][C]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 4096
N=int(input())
s=[list(map(int, input().split())) for i in range(N)]
d={}
for i in range(N-1):
    for j in range(i+1,N):
        a=s[i]
        b=s[j]
        t=(a[0]-b[0],a[1]-b[1])
        if t in d:
            d[t]+=1
        else:
            d[t]=1
        t=(b[0]-a[0],b[1]-a[1])
        if t in d:
            d[t]+=1
        else:
            d[t]=1
m=0
for i in d.values():
    if i>m:
        m=i
print(N-m)

Measured memory_bytes: 3444
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static int count = 0;

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

		int n,s;
		while(true){
			String info[] = br.readLine().split(" ");
			n = Integer.parseInt(info[0]);
			s = Integer.parseInt(info[1]);


			if(n == 0 && s == 0){
				break;
			}

			solve(n,s,0);
			System.out.println(count);
			count = 0;
		}
	}

	private static void solve(int n,int s,int num){

		if(num > 9 || n == 0 || num > s){
			return;
		}

		if(n == 1 &&  s == num){
			count++;
		}

		solve(n - 1,s - num, num + 1);
		solve(n,s,num + 1);
	}

}

Measured memory_bytes: 24136
#include<iostream>
#include<string>
#include<algorithm>
#include <cmath>

using namespace std;

int main(){
 int a;
  cin >> a ;
  int b[a] ;
  for(int i =0; i < a; i++){
   cin >>  b[i];
  }
  bool c=true;
  int count=0;
  while(c){
    for(int j= 0; j< a; j++){
     	 if(b[j]%2 ==0){
    		b[j]=b[j] /2 ;
         }else{
          c=false;
         }
    }
    if(c== true)
     ++count;

  }
    
  cout << count << endl;
 
  return 0;
}

Measured memory_bytes: 256
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, m;
  rd(n, m);
  struct E {
    int u, v;
  }

  auto edges = new E[](m);
  foreach (i; 0 .. m) {
    rd(edges[i].u, edges[i].v);
    edges[i].u--;
    edges[i].v--;
  }

  int b = 0;
  foreach (i; 0 .. m) {
    auto g = new int[][](n);
    foreach (j; 0 .. m) {
      if (i != j) {
        g[edges[j].u] ~= edges[j].v;
        g[edges[j].v] ~= edges[j].u;
      }
    }
    auto vis = new bool[](n);
    void f(int i) {
      vis[i] = true;
      foreach (j; g[i]) {
        if (!vis[j]) {
          f(j);
        }
      }
    }

    f(0);
    if (!reduce!((res, v) => (res && v))(true, vis)) {
      b++;
    }
  }
  writeln(b);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 380
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using static System.Console;

class Program
{
    static int[] hw;
    static char[,] s;
    static void Main()
    {
        hw = ReadLine().Split().Select(int.Parse).ToArray();
        s = new char[hw[0], hw[1]];
        for (int i = 0; i < hw[0]; i++)
        {
            var line = ReadLine();
            for (int j = 0; j < hw[1]; j++)
            {
                s[i, j] = line[j];
            }
        }
        visited = new bool[hw[0], hw[1]];
        q.Enqueue(new[] { 0, 0 });
        pp = new int[hw[0], hw[1]][];
        BFS();
        if (pp[hw[0] - 1, hw[1] - 1] == null) WriteLine(-1);
        else
        {
            var c = 0;
            for (int i = 0; i < hw[0]; i++)
            {
                for (int j = 0; j < hw[1]; j++)
                {
                    if (s[i, j] == '.') c++;
                }
            }
            var r = 1;
            var np = new[] { hw[0] - 1, hw[1] - 1 };
            while (np[0] != 0 || np[1] != 0)
            {
                np = new[] { pp[np[0], np[1]][0], pp[np[0], np[1]][1] };
                r++;
            }
            WriteLine(c - r);
        }

    }

    static Queue<int[]> q = new Queue<int[]>();
    static bool[,] visited;
    static int[,][] pp;
    static void BFS()
    {
        while (q.Count != 0)
        {
            var p = q.Dequeue();
            if (!visited[p[0], p[1]])
            {
                visited[p[0], p[1]] = true;
                if (p[0] == hw[0] - 1 && p[1] == hw[1] - 1) break;

                if (canmove(p, 'u'))
                {
                    pp[p[0] - 1, p[1]] = new[] { p[0], p[1] };
                    q.Enqueue(new[] { p[0] - 1, p[1] });
                }
                if (canmove(p, 'r'))
                {
                    pp[p[0], p[1] + 1] = new[] { p[0], p[1] };

                    q.Enqueue(new[] { p[0], p[1] + 1 });
                }
                if (canmove(p, 'd'))
                {
                    pp[p[0] + 1, p[1]] = new[] { p[0], p[1] };
                    q.Enqueue(new[] { p[0] + 1, p[1] });
                }
                if (canmove(p, 'l'))
                {
                    pp[p[0], p[1] - 1] = new[] { p[0], p[1] };
                    q.Enqueue(new[] { p[0], p[1] - 1 });
                }
            }
        }
    }
    static bool canmove(int[] p, char d)
    {
        if (d == 'u' && 0 <= p[0] - 1 && s[p[0] - 1, p[1]] == '.' && !visited[p[0] - 1, p[1]]) return true;
        if (d == 'r' && p[1] + 1 < hw[1] && s[p[0], p[1] + 1] == '.' && !visited[p[0], p[1] + 1]) return true;
        if (d == 'd' && p[0] + 1 < hw[0] && s[p[0] + 1, p[1]] == '.' && !visited[p[0] + 1, p[1]]) return true;
        if (d == 'l' && 0 <= p[1] - 1 && s[p[0], p[1] - 1] == '.' && !visited[p[0], p[1] - 1]) return true;
        return false;
    }
}

Measured memory_bytes: 13780
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
#define fi first
#define se second
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vvi;
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string s;
	cin>>s;
	int cnt=11111110;
	for(int i=0;i<s.size()-2;i++){
		int num=100*(s[i]-'0')+10*(s[i+1]-'0')+s[i+2]-'0';
		cnt=min(cnt,abs(num-753));
	}
	cout<<cnt<<endl;
    return 0;
}

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

typedef long long ll;

int main() {        
	ll n;
	cin >> n;
	vector<ll> prime(n + 10);
    for (int i = 2; i <= n; ++i) {
		if (!prime[i]) {
			for (int j = i; j <= n; j += i) {
				prime[j] = i;
			}
		}
	}
	//cout << (int)prime.size();
	ll ans = 0;
	for (ll i = 2;  i <= n; ++i) {
		//int p = 1;
		map<int,int> m;
		ll x = i;
		while (x > 1) {
			m[prime[x]]++;
			x /= prime[x];
		}
		ll p = 1;
		for (auto it = m.begin(); it != m.end(); ++it) {
			p *= (it->second + 1);
		}
		ans += (p * i);
	}
	cout << ans + 1;
}








Measured memory_bytes: 81408
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

int N;
int P[200000];
int main(void){
    cin >> N;
    REP(i,N) cin >> P[i];

    int count = 0, m = 200001;
    REP(i, N){
        m = min(m, P[i]);
        if(m >= P[i]) count++;
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


// LRUD
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


int main(int argc, char**argv){
    int n, k;
    cin >> n >> k;

    if (k > (n-1) * (n-2) / 2){
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int, int> > ans;
    for (int i = 2; i <= n; i++){
        ans.push_back(make_pair(1, i));
    }

    int first = 2, second = 3;
    for (int i = 0; i < (n-1) * (n-2) / 2 - k; i++){
        ans.push_back(make_pair(first, second));
        if (second == n){
            first++;
            second = first + 1;
        }else{
            second++;
        }
    }

    cout << ans.size() << endl;
    for (auto p : ans){
        cout << p.first << " " << p.second << endl;
    }

    return 0;
}





















Measured memory_bytes: 384
n , m = map(int, input().split())
c = [[0]*n for i in range(n)]
for i in range(m):
    a , b = map(int, input().split())
    c[a-1][b-1]=1
    c[b-1][a-1]=1
ans = 0
for k in range(n):
    for i in range(n):
        if sum(c[i])==1:
            ans+=1
            for j in range(n):
                if c[i][j]==1:
                    c[i][j]=0
                    c[j][i]=0
print(ans)


Measured memory_bytes: 9168
# ACのインデックスを求める
# インデックスから、含まれる個数を求める(2分探索)
from bisect import bisect_left
N,Q = map(int, input().split())
S = input()
tmp = ''
ac_count = []
for i, c in enumerate(S):
	if tmp + c == 'AC':
		ac_count.append(i-1)
	tmp = c
ac_count.sort()

for i in range(Q):
	l, r = map(int, input().split())
	print(len(S[bisect_left(ac_count, l-1) : bisect_left(ac_count, r-1)]))


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

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int n = Integer.parseInt(sl[0]);

    int a[] = new int[101];

    s = r.readLine();
    sl = s.split(" ");
    for(int i = 0; i < n; i++)
    {
    	a[i + 1] = Integer.parseInt(sl[i]);
    }

    int v = 0;
    int c = 0;
    for(int i = 0; i <= n; i++)
    {
        if(c < a[i])
        {
        	v += a[i] - c;
        }
        c = a[i];
    }

    System.out.println(v);
  }

}

Measured memory_bytes: 23252
/*
   Created by Rahul Goel.
*/
/*******************************************************************************/
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
/*******************************************************************************/
using namespace std;
using ll = long long;
using ld = long double;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
/*
.-.. . -. -.- .- / .. ... / .-.. --- ...- . -.-.--
 */
/* For PBDS */
/*Two new methods X.order_of_key() and X.find_by_order()*/
/*
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*******************************************************************************/
ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_prod() { return 1LL; }
template<typename T, typename... Args>
T mod_prod(T a, Args... args) { return (a*mod_prod(args...))%mod; }
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/

/*
    Code begins after this.
*/


ll solve(){
    ll a;
    cin >> a;
    ld b;
    cin >> b;
    ll x = round(b * 100);
    cout << a*x/100 << endl;
    return 0;
}


signed main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}

/*******************************************************************************/
// Remeber - In a custom comparator cmp(a, b) a==b must always return to false.


Measured memory_bytes: 3772
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    a,b,c,k=map(int,input().split())
    ans=0
    while True:
        if a>=k:
            ans=k
            break
        else:
            ans+=a
            k-=a
        if b>=k:
            break
        else:
            k-=b
        ans-=k
        break
    print(ans)







if __name__ == "__main__":

    main()

Measured memory_bytes: 68144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll = long long;
int main(){
  string s;
  cin >> s;
  int n;
  n=s.size();
  rep(i,n){
    cout << 'x';
  }
  cout << endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var S = cin.Read.ToCharArray();
            var T = cin.Read.ToCharArray();
            var ans = new char[S.Length * 2];
            for (int i = 0; i < S.Length; i++)
            {
                ans[2 * i] = S[i];
                ans[2 * i + 1] = T[i];
            }
            Console.WriteLine(new string(ans));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,d,a;cin>>n>>d>>a;
    vector<pair<ll,ll>> m;
    map<ll,ll> vals;
    rep(i,n) {
        ll tx,th;cin>>tx>>th;
        m.emplace_back(tx,th);
    }
    
    sort(all(m));
    ll cur = 0;
    ll sum = 0;
    ll res = 0;
    rep(i,n) {
        auto p = vals.lower_bound(cur);
        cur = m[i].first;
        while(p!=vals.end()&&p->first<cur) {
            sum -= p->second;
            p++;
        }
        ll rem = max(0LL, m[i].second - sum);
        ll cnt = (rem==0? 0 : (rem-1)/a + 1);
        if (rem==0) {
            continue;
        }
        vals[cur+2*d] = cnt * a;
        sum += cnt * a;
        res += cnt;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 15852
#include <iostream>
#include <vector>

using namespace std;

const int MAX_N=10000;

int S[MAX_N];
int w[MAX_N];

int getRoot(int x){
	//x???root?????¢???
	int r;
	for (r=x;r!=S[r];r=S[r]);
	return r;
}

void unite(int x,int y){
	//x??¨y?????????
	//root?????¢???
	int root1,root2;
	root1=getRoot(x);
	root2=getRoot(y);
	if (root1!=root2){
		if (w[root1]>=w[root2]){
			S[root2]=root1;
			w[root1]+=w[root2];
		}
		else{
			S[root1]=root2;
			w[root2]+=w[root1];
		}
	}
}

int same(int x,int y){
	//x??¨y??????????????????????????????1??????????????°0?????????
	int root1,root2;
	root1=getRoot(x);
	root2=getRoot(y);
	if (root1==root2){
		return 1;
	}
	else{
		return 0;
	}
}

int main(){
	int n,q;
	cin>>n>>q;
	for (int i=0;i<n;i++){
		S[i]=i;
		w[i]=1;
	}
	vector<int> out;
	for (int i=0;i<q;i++){
		int com,x,y;
		cin>>com>>x>>y;
		if (!com){
			//unite
			unite(x,y);
		}
		else{
			//same
			out.push_back(same(x,y));
		}
	}
	for (int i=0,l=out.size();i<l;i++){
		cout<<out[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x,n,mind=1000,ans=100; cin>>x>>n;
  vector<int> p(n); for(int i=0; i<n; i++) cin>>p[i];
  for(int i=0; i<=101; i++){
    if(count(p.begin(),p.end(),i)==0){
      int d=abs(x-i);
      if(mind>d){
        mind=d; ans=i;
      }
      else if(mind==d){
        ans=min(ans,i);
      }
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N, Q;
vector<int> G[200005];
ll val[200005];
ll add[200005];

void dfs(int v, int p, ll sum){
  sum += add[v];
  val[v] = sum;
  rep(i,G[v].size()){
    if(G[v][i] == p) continue;
    int nv = G[v][i];
    dfs(nv, v, sum);
  }
}

int main(){
  cin >> N >> Q;
  rep(i,N-1){
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rep(i,Q){
    int p, x;
    cin >> p >> x;
    add[p] += x;
  }

  dfs(1, -1, 0);

  REP(i,1,N+1){
    if(i>1) cout << " ";
    cout << val[i];
  }
  cout << endl;
  
  return 0;
}



Measured memory_bytes: 31872
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

struct Node {
  ll parent, left, right;
};

Node t[100000];
ll n, d[100000], h[100000];

void setDepth(ll u, ll dep) {
  if (u == -1) return;
  d[u] = dep;
  setDepth(t[u].left, dep+1);
  setDepth(t[u].right, dep+1);
}

ll setHeight(ll u) {
  ll h1=0, h2=0;
  if (t[u].left != -1) h1 = setHeight(t[u].left) + 1;
  if (t[u].right != -1) h2 = setHeight(t[u].right) + 1;
  return h[u] = (h1 > h2 ? h1 : h2);
}

ll getSibling(ll u) {
  if (t[u].parent == -1) return -1;
  if (t[t[u].parent].left != u && t[t[u].parent].left != -1)
    return t[t[u].parent].left;
  if (t[t[u].parent].right != u && t[t[u].parent].right != -1)
    return t[t[u].parent].right;
  return -1;
}

void print(ll u) {
  printf("node %lld: ", u);
  printf("parent = %lld, ", t[u].parent);
  printf("sibling = %lld, ", getSibling(u));
  ll deg = 0;
  if (t[u].left != -1) deg++;
  if (t[u].right != -1) deg++;
  printf("degree = %lld, ", deg);
  printf("depth = %lld, ", d[u]);
  printf("height = %lld, ", h[u]);

  if (t[u].parent == -1) {
    printf("root\n");
  } else if (t[u].left==-1 && t[u].right==-1) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main() {
  ll root;
  scanf("%lld", &n);
  REP(i, n) t[i].parent = -1;
  REP(i, n) {
    ll v, l, r; cin >> v >> l >> r;
    t[v].left = l;
    t[v].right = r;
    if (l != -1) t[l].parent = v;
    if (r != -1) t[r].parent = v;
  }
  REP(i, n) if (t[i].parent == -1) root = i;

  setDepth(root, 0);
  setHeight(root);

  REP(i, n) print(i);
  return 0;
}



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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if ((x - r >= 0) && (y - r >= 0) && (x + r <= W) && (y + r <= H))
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3112
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<cmath>
using namespace std;
typedef vector<int> vi;
set<string> cands;
int dy[]={-1,-1,-1,0,0,1,1,1};
int dx[]={-1,0,1,-1,1,-1,0,1};
int maxlength=0,h,w;
string ans="";

int main()
{
  while(1) 
    {
      int n,m,a;
      int amida[1005][105];
      cin >> n >> m >> a;
      if(n==0) break;
      memset(amida,0,sizeof(amida));
      for(int i=0;i<m;i++)
	{
	  int h,p,q;
	  cin >> h >> p >> q;
	  amida[h][p]=q;
	  amida[h][q]=p;
	}
      int now=a;
      for(int i=1000;i>=1;i--)
	{
	  if(amida[i][now]!=0)
	    {
	      now=amida[i][now];
	    }
	}
      cout << now << endl;
    }
}



Measured memory_bytes: 3548
package main

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

var writer = bufio.NewWriter(os.Stdout)

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	ret := make([]int, M+1)
	for i := 0; i < N; i++ {
		var K int
		fmt.Scan(&K)
		for j := 0; j < K; j++ {
			var A int
			fmt.Scan(&A)
			ret[A]++
		}
	}

	cnt := 0
	for i := 0; i < M+1; i++ {
		if ret[i] == N {
			cnt++
		}
	}

	fmt.Fprintf(writer, "%d\n", cnt)
	writer.Flush()
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define int long long
#define mod 1000000007
#define DEBUG cout<<"Hello1\n";
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))
#define deb(...) debug(#__VA_ARGS__, __VA_ARGS__);
const int N = 1e6 + 5;
const double pi =  acosl(-1);
const long long inf = 1e18 + 5;
using namespace std;
template<typename T> void debug(string s, T x)
{
	cout << s << " = " << x << "\n";
}
template<typename T, typename... Args> void debug(string s, T x, Args... args)
{
	cout << s.substr(0, s.find(',')) << " = " << x << " | ";
	debug(s.substr(s.find(',') + 2), args...);
}
template<class T> void print_container(T &container)
{
	for (auto &t : container)
	{
		cout << t << " ";
	}
	cout << endl;
}
template<class T> void print_pair_container(T &container)
{
	for (auto &t : container)
	{
		cout << t.first << " " << t.second << endl;
	}
	cout << endl;
}
template<class T> void printArr(T &a, int n)
{
	for (int i = 0; i < n; i++)
	{
		cout << a[i] << " ";
	}
	cout << endl;
}
typedef long long ll;
typedef pair<int, int> pii;

//Template Ends
int n;

string s, t;
void solve()
{
	int ans = 10000;
	cin >> s >> t;
	n = s.length();
	int m = t.length();

	for (int i = 0; i <= n - m; i++) {
		int curr = 0;
		for (int j = i; j < i + m; j++) {
			curr += s[j] != t[j - i];
		}
		ans = min(ans, curr);
	}
	cout << ans << endl;
}

int32_t main()
{
	IOS;
	solve();

	return 0;
}




Measured memory_bytes: 3652
import os, sys, re, math

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

d = math.ceil(math.log2(1e+12))
ones = [0 for _ in range(d)]

for a in A:
    s = bin(a)[::-1]
    for i in range(len(s)-2):
        if s[i] == '1':
            ones[i] += 1

X = 0
for di in range(d-1,-1,-1):
    if X + 2 ** di <= K and ones[di] <= N * 0.5:
        X += 2 ** di

ret = 0
for a in A:
    ret += X ^ a

print(ret)


Measured memory_bytes: 14876
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string> 
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g;}
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int main()
{
	int n, k;
	cin >> n >> k;
	vi a(n);
	rep(i, n)
	{
		cin >> a[i];
		if (a[i] == k)
		{
			co("POSSIBLE");
			return 0;
		}
	}
	sort(all(a));
	int g = 0;
	rep(i, n - 1)g = gcd(g, a[i + 1] - a[i]);
	if (g==1 || (k<a[n-1] &&(k - a[0]) % g == 0))co("POSSIBLE");
	else co("IMPOSSIBLE");
	return 0;
}


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

int main(){
	int n,m,a,mh;
	mh=0;
	while(1){
		cin>>n>>m>>a;
		if(n==0&&m==0&&a==0) break;
		vector<vector<int> > h;
		h.resize(m);
		for(int i=0;i<m;i++){
			h[i].resize(3);
		}
		for(int i=0;i<m;i++){
			cin>>h[i][0]>>h[i][1]>>h[i][2];
			if(h[i][0]>mh) mh=h[i][0];
		}
		for(int i=mh;i>0;i--){
			for(int j=0;j<m;j++){
				if(h[j][0]==i){
					if(h[j][1]==a) a=h[j][2];
					else if(h[j][2]==a) a=h[j][1];
				}
			}
		}
		cout<<a<<endl;
	}
	return 0;
}


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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i,j,k,a[201]={0},t,s=0,n;
	cin>>n;
	for (i=1;i<201;i++){
		t=1;
		for (j=1;2*j<=i;j++){
			if (i%j==0){
				t++;
			}
		}
		if (t==8&&i%2==1){
			s++;
		}
		a[i]=s;
	}
	cout<<a[n];
	return 0;
}

Measured memory_bytes: 256
mod = 10**9 + 7
_factorial = [1]
def fact(n):
    ''' n! % mod '''
    if n >= mod:
        return 0
    _size = len(_factorial)
    if _size < n+1:
        for i in range(_size, n+1):
            _factorial.append(_factorial[i-1]*i % mod)
    return _factorial[n]
    
_factorial_inv = [1]
def fact_inv(n):
    ''' n!^-1 % mod '''
    if n >= mod:
        raise ValueError('Modinv is not exist! arg={}'.format(n))
    _size = len(_factorial)
    if _size < n+1:
        for i in range(_size, n+1):
            _factorial.append(_factorial[i-1]*i % mod)
    _size_inv = len(_factorial_inv)
    if _size_inv < n+1:
        for i in range(_size_inv, n+1):
            _factorial_inv.append(modinv(_factorial[i]))
    return _factorial_inv[n]
    
def comb(n, r):
    ''' nCr % mod '''
    if r > n:
        return 0
    t = fact(n) * fact_inv(n-r) % mod
    t = t * fact_inv(r) % mod
    return t

def xgcd(a, b):
    x0, x1, y0, y1 = 0, 1, 1, 0
    while a != 0:
        (q, a), b = divmod(b, a), a
        y0, y1 = y1, y0 - q * y1
        x0, x1 = x1, x0 - q * x1
    return b, x0, y0

def modinv(n):
    g, x, _ = xgcd(n, mod)
    if g != 1:
        raise ValueError('Modinv is not exist! arg={}'.format(n))
    return x % mod        

x, y = sorted(map(int, input().split()))
q, r = divmod(x+y, 3)
if r != 0:
    print(0)
else:
    print(comb(q, y-q))


Measured memory_bytes: 48540
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);
typedef pair<int, int> pii;

const int maxn = 805;
int d[maxn][maxn];
char a[maxn][maxn];
int n, m, k;

int main() {
    #ifdef LOCAL
    assert(freopen("c.in", "r", stdin));
    #else
    #endif
    cin >> n >> m >> k;
    int sx = -1, sy = -1;
    forn (i, n) {
        cin >> a[i];
        forn (j, m) {
            d[i][j] = inf;
            if (a[i][j] == 'S') {
                sx = i, sy = j;
                d[sx][sy] = 0;
            }
        }
    }
    assert(sx != -1);
    vector<pii> o;
    o.emplace_back(sx, sy);
    int res = inf;
    forn (ii, sz(o)) {
        int x, y;
        tie(x, y) = o[ii];
        if (d[x][y] <= k) {
            int f = min(x, y);
            f = min(f, n - x - 1);
            f = min(f, m - y - 1);
            res = min(res, 1 + (f + k - 1) / k);
        }
        const int dx[] = {-1, 0, 1, 0};
        const int dy[] = {0, -1, 0, 1};
        forn (dir, 4) {
            int nx = x + dx[dir];
            int ny = y + dy[dir];
            if (nx < 0 || nx >= n || ny < 0 || ny >= m)
                continue;
            if (a[nx][ny] == '#')
                continue;
            if (d[nx][ny] != inf)
                continue;
            d[nx][ny] = d[x][y] + 1;
            o.emplace_back(nx, ny);
        }
    }
    cout << res << '\n';
}


Measured memory_bytes: 13164
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
ll calc(ll a , ll d, ll l)
{
    return (l-a)/d;
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    ll m,d;
    cin>>m>>d;
    ll ans=0;
    for(ll i=1;i<=m;i++)
    {
        
        for(ll j=22;j<=d;j++)
        {
            ll tmp=j;
            ll l=tmp%10;
            if(l<2)
                continue;
            ll f=tmp/10;
            if(f*l==i)
                ans++;
        }
        
    }
    cout<<ans;
     
	return 0;
}

Measured memory_bytes: 256
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int N; cin >> N;
    vector<pair<int, int>>A(N); rep(i, N)cin >> A[i].first >> A[i].second;
    bool b = false;
    rep(i, N - 2) {
        if (A[i].first == A[i].second && A[i + 1].first == A[i + 1].second && A[i + 2].first == A[i + 2].second) {
            b = true;
            break;
        }
    }
    if (b)puts("Yes");
    else puts("No");
}




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

int main() {
    long long N; cin >> N;
    long long res = 1001001001001001001;
    for(long long i=1; i*i<=N; ++i) {
        if(N % i == 0) {
            res = min(res, i + (N / i) - 2);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
    int n, k, q;
    int x, y;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> q;
    }
    x = n - k;
    y = x / (k-1);
    if (x % (k-1) != 0) {
        y += 1;
    }

    cout << y+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
 
 
int main(){
   
    int x,t;
    cin >> x >> t;
    int ans;
    if (x < t){
      ans = 0;
    }
    else{
      ans = x - t;
    }

    cout << ans << endl;
  }
 

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	int flag = (N&1);
	deque<int> ans;
	for(int i=1;i<=N;++i){
		int A;
		cin >> A;
		if( flag == (i&1) ){
			ans.push_front( A );
		}else{
			ans.push_back( A );
		}
	}
	for(int i=0;i<N;++i){
		if( i != 0 ) cout << " ";
		cout << ans[i];
	}
	cout << endl;
	
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


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

public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String in = "";

		try {
			while (null != (in = br.readLine())) {
				int a = Integer.parseInt((in.split(" ")[0]));
				int b = Integer.parseInt((in.split(" ")[1]));
				int fig = (int) (Math.floor(Math.log10(a + b))) + 1;
				System.out.println(fig);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 17076
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

vector<string> samesplit(string s) {
	vector<string> ret;
	rep(i,s.size()) {
		stringstream ss;
		ss << s[i];
		REP(j,i+1,s.size()) {
			if(s[i] == s[j]) {
				ss << s[j];
				i++;
			}
			else break;
		}
		ret.push_back(ss.str());
	}
	return ret;
}

int main() {
	string s;
	cin >> s;

	vector<string> ret = samesplit(s);
	int ans = 0;

	if(ret.size() <= 2) {
		cout << 0 << endl;
		return 0;
	}

	rep(i, ret.size()-2) {
		if(ret[i][0] == 'J' && ret[i+1][0] == 'O' && ret[i+2][0] == 'I' && ret[i].size() >= ret[i+1].size() && ret[i+2].size() >= ret[i+1].size()) {
			ans = max(ans, (int)ret[i+1].size());
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 57616
h = 1
w = 1
while not(h == 0 and w == 0):
    z = input()
    h,w = [ int(a) for a in z.split()]
    pre = h
    while pre > 0:
        if pre == h or pre == 1:
            print ("#" * w)
            pre = pre - 1
        else:
            print ("#" + "." * (w - 2) + "#")
            pre = pre - 1
    if not(h == 0 and w == 0):
        print ()


Measured memory_bytes: 5620
# coding:utf-8

import sys
from collections import defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7
dy, dx = (0, -1, 0, 1), (1, 0, -1, 0)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    MA = defaultdict(int)
    # 目標値をO(1)で見つけるために辞書に格納
    for a in A:
        MA[a] += 1

    key_n = list(MA.keys())
    key_n.sort()
    key_n.reverse()

    res = 0
    p = 30
    for x in key_n:
        # すでにペアを作るために使用してしまっている時はパス
        if not MA[x]:
            continue

        # 残っているボールの中で一番大きな値xを選ぶと，そのボールを使って表せる2べきの値x + yは1つに定まる
        # x + 1 <= x + y < 2x
        # 2べきの比は2であるのに対して，x + 1と2xの比は2未満だから
        while 2 * x < 2 ** p:
            p -= 1

        if x + 1 <= 2 ** p:
            y = 2 ** p - x
            if not MA[y]:
                continue

            if x == y:
                _add = MA[x] // 2
            else:
                _add = min(MA[x], MA[y])

            res += _add
            MA[x] -= _add
            MA[y] -= _add

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 55900
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;


  
int main(){
  int n;cin>>n;
  vector<int>a(n+2);
  a[0]=0,a[n+1]=0;
  ll sum=0,dis[n];
  for (int i = 1; i <= n; i++)
  {
    cin>>a[i];
    sum += abs(a[i]-a[i-1]);
  }
  sum += abs(a[n+1]-a[n]);
  for (int i = 1; i <=n; i++)
  {
    ll ans=0;
    ans = sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);
    cout<<ans<<endl;
  }
  
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   pii;
typedef vector<int>     vi;
typedef long double     ld;
#define MOD         1000000007
#define pb          push_back
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        '\n'
#define PI          3.14159265359d
#define sz(x)       (int)x.size()
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,x;
    bool flag;
    cin>>n;
    if(n%2)
        flag=false;
    else
        flag=true;
    deque<int> q;
    while(n--)
    {
        cin>>x;
        if(flag)
            q.push_back(x);
        else
            q.push_front(x);
        flag=!flag;
    }
    while(!q.empty())
    {
        cout<<q.front()<<" ";
        q.pop_front();
    }
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000009
const long long INF = 1LL<<60;

int main() {
    string s;
    cin>>s;
    ll n=s.length();

    vector<ll> cnt(26,0);
    rep(i,n) cnt[s[i]-'a']++;
    ll ans=n*(n-1)/2;
    rep(i,26){
        if(cnt[i]>=2) ans-=cnt[i]*(cnt[i]-1)/2;
    }
    cout<<ans+1<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

using P = pair<int, int>;

int main() {
    int n, m; cin >> n >> m;
    vector<P> ab(m);
    rep(i, m) {
        int a, b; cin >> a >> b; a--; b--;
        ab[i] = make_pair(b, a);
    }
    sort(all(ab));
    rep(i, m) ab[i] = make_pair(ab[i].second, ab[i].first);
    int cnt = 0, bb = -1;
    rep(i, m) {
        if(1 <= cnt && ab[i].first <= bb) continue;
        cnt++;
        bb = ab[i].second - 1;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
class team {
public:
	char name;
	int win;
	int lose;
	team() :win(0), lose(0) {}
};

bool compare(team &a, team &b) {
	return a.win > b.win || (a.win == b.win&&a.lose < b.lose);
}
using namespace std;

int main() {
	int num;
	while (cin >> num&&num != 0) {
		vector<team> line(num);
		for (int i = 0; i < num; ++i) {
			cin >> line[i].name;
			for (int j = 0, nmax = num - 1; j < nmax; ++j) {
				int result;
				cin >> result;
				if (result == 0) {
					++line[i].win;
				}
				else if (result == 1) {
					++line[i].lose;
				}
			}
		}
		sort(line.begin(), line.end(), compare);
		for (int i = 0; i < num; ++i) {
			cout << line[i].name << endl;
		}
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int>data(N);
  int M=0;
  int m=1000000000;
  for(int i;i<N;i++){
    cin >> data.at(i);
    if(data.at(i)>M) M=data.at(i);
    if(data.at(i)<m) m=data.at(i);
  }
  cout << M-m << endl;
}


Measured memory_bytes: 256