akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int a, b, c;
int main(){
	scanf("%d%d", &a, &b);
	c = b - a;
	printf("%d\n", c * (c + 1) / 2 - b);
	return 0;
} 

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		String s = sc.next();

		int ans = 0;
		for (int i=0; i<N; i++){
			String s_l = s.substring(0, i);
			char[] s_l_array = s_l.toCharArray();
			HashSet<Character> s_l_set = new HashSet<Character>();
			for (int j=0; j<s_l_array.length; j++){
				s_l_set.add(s_l_array[j]);
			}
			ArrayList<Character> s_l_arrayList = new ArrayList<Character>(s_l_set);

 			String s_r = s.substring(i);
 			char[] s_r_array = s_r.toCharArray();
			HashSet<Character> s_r_set = new HashSet<Character>();
			for (int j=0; j<s_r_array.length; j++){
				s_r_set.add(s_r_array[j]);
			}

			int tmp = 0;
			for (int j=0; j<s_l_arrayList.size(); j++){
				if (s_r_set.contains(s_l_arrayList.get(j))){
					tmp += 1;
				}
			}

			if (tmp > ans){
				ans = tmp;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22608
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
 
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
struct node{
    int pc,g,l,r;
    node(int a,int b,int c,int d):pc(a),g(b),l(c),r(d){}
    node(){pc=g=l=r=-1;}
};
node e;
inline node add(const node &a,const node &b){
    if(a.pc==-1)return b;
    if(b.pc==-1)return a;
    node c;
    c.pc=a.pc+b.pc;
    c.g=a.g+b.g+a.r*b.l;
    c.l=a.l;
    c.r=b.r;
    return c;
}
 
struct segtree{
    static const int SEG=1<<17;
    vector<node>dat;
    vector<int>put;
    segtree(string &s):dat(SEG*2),put(SEG*2,-1){
        for(int i=0;i<s.size();i++){
            node d;
            int a=s[i]-'0';
            d.pc=a;
            d.g=0;
            d.l=d.r=a;
            dat[i+SEG-1]=d;
        }
        for(int i=SEG-2;i>=0;i--){
            dat[i]=add(dat[i*2+1],dat[i*2+2]);
        }
    }
    inline void push(int k,int l,int r){
        if(put[k]==-1)return;
        dat[k].pc=(r-l)*put[k];
        dat[k].g=(r-l-1)*put[k];
        dat[k].l=dat[k].r=put[k];
 
        if(k<SEG-1){
            put[k*2+1]=put[k*2+2]=put[k];
        }
        put[k]=-1;
    }
    void update(int a,int b,int x,int k=0,int l=0,int r=SEG){
        push(k,l,r);
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
            put[k]=x;
            push(k,l,r);
            return;
        }
        update(a,b,x,k*2+1,l,(l+r)/2);
        update(a,b,x,k*2+2,(l+r)/2,r);
        dat[k]=add(dat[k*2+1],dat[k*2+2]);
    }
    node query(int a,int b,int k=0,int l=0,int r=SEG){
        push(k,l,r);
        if(r<=a||b<=l)return e;
        if(a<=l&&r<=b)return dat[k];
        return add(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
    }
};
 
signed main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
 
    int N;
    string S;
    cin>>N>>S;
    segtree seg(S);
 
     int Q;cin>>Q;
     while(Q--){
        int l,r,b;
        cin>>l>>r>>b;
        l--;
        seg.update(l,r,b);
        node d=seg.query(0,N);
        cout<<d.pc-d.g<<endl;
     }
    return 0;
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m1 = sc.nextInt();
        int d1 = sc.nextInt();
        int m2 = sc.nextInt();
        int d2 = sc.nextInt();

        if (m1 != m2) {
            System.out.println(1);
        } else {
            System.out.println(0);
        }

        sc.close();
    }

}


Measured memory_bytes: 21844
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	string s;
	getline(cin,s);
	for(int i=0;i<s.length();i++){
		if(s[i]=='C'){
			for(int j=i+1;j<s.length();j++){
				if(s[j]=='F'){
					printf("Yes\n");
					return 0;
				}
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"



int main() {
	string s;
  cin>>s;
	sort(s.begin(),s.end());
	if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2])
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

struct Edge{
    int from,to;
    ll d;
    Edge(int from,int to,ll d)
    :from(from),to(to),d(d){}
};

int N;
vector<Edge> G[100001];
ll dis[100001];

void dfs(int from,ll d,int parent){
    rep(i,G[from].size()){
        if(parent!=G[from][i].to){
            ll next=dis[G[from][i].to]=G[from][i].d+d;
            dfs(G[from][i].to,next,from);
        }
    }
}

int main(){
    cin>>N;
    rep(i,N-1){
        int u,v,w;
        cin>>u>>v>>w;
        G[u].push_back(Edge(u,v,w));
        G[v].push_back(Edge(v,u,w));
    }

    dfs(1,0,-1);

    repn(i,N){
        int ans=dis[i]&1;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 11008
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int numofbits(long bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main(){
    int N;
    cin >> N;
    vector<vector<pair<int,int> > > vvp;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        vector<pair<int,int> > vp;
        for(int j = 0; j < A; j++){
            int x,y;
            cin >> x >> y;
            vp.push_back(make_pair(x,y));
        }
        vvp.push_back(vp);
    }
    vector<int> A(N);

    ll ans=0;
    for( ll i = 0; i < pow(2,N); i++){//全パターン試す
        
        //値設定
        
        for(ll j = 0; j < N; j++){
            ll X = pow(2,j);
            if( (X&i) == X ) 
                A[j] = 1;
            else 
                A[j] = 0;
        }
        ll tmpans=numofbits(i);
        //cout << "i" << i << endl;
        //cout << "tmpans" << tmpans << endl;

        //チェック
        bool OK = true;
        for(ll j = 0; j < N; j++){
            if(A[j] == 1){
                for(ll k = 0; k < vvp[j].size(); k++){
                    if( A[vvp[j][k].first -1] == vvp[j][k].second ){
                        //OK
                    }else{
                        OK = false;//このパターンは違うことがわかる
                    }
                }
            }
        }
        if(!OK) tmpans = 0;
        ans = max(ans,tmpans);
        //cout << "OK" << OK << endl;
        //cout << "ans" << ans << endl;
    }
    cout << ans << endl;



    /*
    for(int i = 0; i < N; i++){
        cout << vvp[i].size() << endl;
        for(int j = 0; j < vvp[i].size(); j++){
            cout << vvp[i][j].first  << vvp[i][j].second << endl;
        }

    }
    */


}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    ll k;
    cin >> s >> k;
    rep(i,min(k,(ll)s.size())){
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << "1" << endl;
    return 0;
}


Measured memory_bytes: 3640
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import deque

# 入力
n = ni()
graph = [[] for _ in range(n*n)]

# グラフを構築
ins = [0]*(n*n)
for i in range(n):
    jlist = list(li_())
    for j1, j2 in zip(jlist[:-1], jlist[1:]):
        node1 = max(i, j1)*n + min(i, j1)
        node2 = max(i, j2)*n + min(i, j2)
        graph[node1].append(node2)
        ins[node2] += 1

# 最長経路
visited = [False]*(n*n)
for i in range(n):
    visited[i*n + i] = True

# 入次数0をqueに詰める
que = deque()
for i, insi in enumerate(ins):
    if insi == 0:
        que.append((i, 1))

# queがなくなるまで距離を記録
dist = [0]*(n*n)
while que:
    cur, d = que.popleft()

    visited[cur] = True
    dist[cur] = d
    for nex in graph[cur]:
        if not visited[nex]:
            ins[nex] -= 1
            if ins[nex] == 0:
                que.append((nex, d+1))

# 訪れてないノードがあれば-1
ok = True
for vi in visited:
    if not vi:
        ok = False


ans = 0
for di in dist:
    ans = max(ans, di)

print(-1 if not ok else ans)

Measured memory_bytes: 146532
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
using namespace std;

#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

void sout(string* a, string* b) {
	if (*a > * b) {
		string c = *a;
		*a = *b;
		*b = c;
	}
}

int combination(int n, int k) {
	if (n > k && k > 0) {
		return (combination(n - 1, k) + combination(n - 1, k - 1));
	}
	else
		return 1;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (a.at(i) >= k) {
			count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int n,m;cin>>n>>m;
    char a[n][m];
    for(int i = 0;i<n;i++){
      string b;cin>>b;
      for(int j = 0;j<m;j++) {
       a[i][j] = b[j];
      }
    }
    for(int i = 0;i<n;i++){
      bool kesu = true;
      for(int j = 0;j<m;j++){
        if(a[i][j] == '#'){
          kesu = false;
          break;
        }
      }
      if(kesu){
        for(int o = 0;o<m;o++){
          a[i][o] = 'a';
        }
      }
    }
    for(int i = 0;i<m;i++){
      bool kesu = true;
      for(int j = 0;j<n;j++){
        if(a[j][i] == '#'){
          kesu = false;
          break;
        }
      }
      if(kesu){
        for(int o = 0;o<n;o++){
          a[o][i] = 'a';
        }
      }
    }
    for(int i = 0;i<n;i++){
      int kita = 0;
      for(int j = 0;j<m;j++) {
        if(a[i][j] != 'a'){
          cout<<a[i][j];
          kita +=1;
        }
      }
      if(kita>0)cout<<""<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>

using namespace std;

int main()
{
  int h, w;

  while(true)
  {
    cin	>> h >> w;
    if(!h && !w)
      break;
    for(int i = 0; i < h; i++)
    {
      for(int j = 0; j < w; j++)
      {
	if(i % 2 == j % 2)
          cout << "#";
	else
          cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(ll i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n,ma,mb;
  cin >> n >> ma >> mb;
  vector<int> a(n),b(n),c(n);
  rep(i,n){
    cin >> a[i] >> b[i] >> c[i];
  }
  vector<vector<vector<int>>> dp(50, vector<vector<int>>(450, vector<int>(450,inf)));
  dp[0][0][0]=0;
  rep(i,n){
    rep(j,410)rep(k,410){
      dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
      dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k] + c[i]); 
    }
  }

  int ans = inf;
  for(int i=1; i*ma<410 && i*mb<410; i++){
    ans = min(ans, dp[n][i*ma][i*mb]);
  }
  if(ans==inf) ans = -1;
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 44440
#include<stdio.h>
#include<stdlib.h>
#define N 100001
 
typedef struct{
  int parent;
  int left;
  int right;
} Tree;
  
Tree T[N];
  
int sibilings(int);
int degree(int);
int depth_c(int);
int hight(int);
void print(int);
 int sibilings(int a){
  if(T[a].parent == -1){
    return -1;
  }
  else if(T[T[a].parent].left == a){
    return T[T[a].parent].right;
  }
  else return T[T[a].parent].left;
}
  
int degree(int b){
  if(T[b].left ==-1 && T[b].right == -1){
    return 0;
  }
  else if(T[b].left !=-1 && T[b].right != -1){
    return 2;
  }
  else
    return 1;
}
  
int depth_c(int c){
  int count = 0;
  if(T[c].parent == -1){
    return 0;
  }
  else{
    count = depth_c(T[c].parent) + 1;
    return count;
  }
}
  
int hight(int z){
  int ah = 0, bh = 0;
  if(T[z].left != -1){
    ah = hight(T[z].left) + 1;
  }
   if(T[z].right != -1){
    bh = hight(T[z].right) + 1;
  }
   if(ah < bh){
     return bh;
   }
   else
     return ah;
}
  
void print(int f){
  printf("node %d: parent = %d, sibling = %d, degree = %d, ",f, T[f].parent, sibilings(f),degree(f));
  printf("depth = %d, height = %d, ",depth_c(f),hight(f));
  if(T[f].parent == -1){
    printf("root\n");
  }
  else if(T[f].left == -1 && T[f].right == -1){
    printf("leaf\n");
  }
  else
    printf("internal node\n");
}
 
main(){
  int i,j,p,l,r,n;
  scanf("%d", &n);
  for(i=0; i<n; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }
  for(i=0; i<n; i++){
    scanf("%d%d%d",&p,&l,&r);
    T[l].parent = p;
    T[r].parent = p;
    T[p].left = l;
    T[p].right = r;
   }
  for(i=0; i<n; i++){
    print(i);
   }
  return 0;
}

Measured memory_bytes: 612
import math
ans=0
a,b=map(int,input().split())
for i in range(b*20):
    ans1=i*0.08
    ans2=i*0.1
    if math.floor(ans1)==a and math.floor(ans2)==b:
        ans=i
        break
    else:
        ans=-1
print(ans)

Measured memory_bytes: 3060
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
n, z, w = gi
a = gi
if n >= 2
  puts max (a[n-1]-w).abs, (a[n-1] - a[n - 2]).abs
else
  puts (a[0] - w).abs
end


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

int main() {
  int64_t N,A,B;
  cin >> N;
  cin >> A;
  cin >> B;
  int64_t x;
  x=N/(A+B);
  int64_t ans;
  ans=x*A;
  int64_t y;
  y=N-(A+B)*x;
  if (y < A) ans=ans+y;
  else ans=ans+A;
  cout << ans << endl; 
}

Measured memory_bytes: 256
def main():
    # 入力
    n = int(input())
    s = input()

    set1 = set()
    set2 = set()
    set3 = set()
    for x in s:
        for x2 in set2:
            _x2 = x2+x
            if x2+x not in set3:
                set3.add(_x2)
        for x1 in set1:
            _x1 = x1+x
            if x1+x not in set2:
                set2.add(_x1)
        if x not in set1:
            set1.add(x)

    print(len(set3))


main()


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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  string s;
  while(cin >> s && !cin.eof()){
    int joi = 0, ioi = 0;
    rep(p, s.size()){
      if(s[p+1] != 'O' || s[p+2] != 'I') continue;
      if(s[p] == 'J') joi++;
      if(s[p] == 'I') ioi++;
    }
    printf("%d\n%d\n", joi, ioi);
  }
  return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    char z; cin >> z;

    cout << (char)(z + 1) << endl;
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    a = list(map(int, input().split()))
    d = dict()
    ans = list()

    for i, ai in enumerate(a, 1):
        d[i] = ai

    for j, di in sorted(d.items(), key=lambda x: x[1]):
        ans.append(j)

    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


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

int N, M;
vector<int> G[100010];
int A[100010], B[100010];
int used[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
    G[A[i]].emplace_back(B[i]);
    G[B[i]].emplace_back(A[i]);
  }  
  int p = A[0], q = B[0];
  vector<int> a{p}, b{q};
  used[p] = used[q] = 1;
  int update = 1;
  while (update) {
    update = 0;
    for (int nxt : G[a.back()]) {
      if (used[nxt]) continue;
      used[nxt] = 1;
      a.emplace_back(nxt);
      update = 1;
      break;
    }
  }
  update = 1;
  while (update) {
    update = 0;
    for (int nxt : G[b.back()]) {
      if (used[nxt]) continue;
      used[nxt] = 1;
      b.emplace_back(nxt);
      update = 1;
      break;
    }
  }
  cout << a.size() + b.size() << endl;
  reverse(a.begin(), a.end());
  for (int i = 0; i < a.size(); i++) {
    cout << a[i] + 1 << " ";
  }
  for (int i = 0; i < b.size(); i++) {
    cout << b[i] + 1 << " ";
  }


  return 0;
}

Measured memory_bytes: 8056
#include<iostream>

using namespace std;

int main(){
 int x,buf;
 int H[3];

 for(int i = 0; i < 3; i++){
  H[i] = 0;
 }
 
 for(int i = 0; i < 10; i++){
  cin >> x;
  
  if(x > H[2]){
  
   H[2] = x;
   
   for(int j = 2; j > 0; j--){
  
    if(H[j] > H[j-1]){
     buf = H[j];
     H[j] = H[j-1];
     H[j-1] = buf;
    }
   }
  }
 }
 
 for(int i = 0; i < 3; i++)
    cout << H[i] << endl;
 
  return 0;
}
    

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

int main(){
  int n,r;
  cin >> n >> r;
  if( n >= 10 ){
    cout << r << endl;
  }else{
    cout << r + 100*(10-n) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <utility>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef pair<int,int> p;
int cen[]={1,4,7};
int main()
{
    int n;
	cin>>n;
	while(n--){
		int a[9][9];
		bool cor[9][9];
		
		for(int i=0;i<9;i++)
			for(int j=0;j<9;j++){
				cin>>a[i][j];
				cor[i][j]=true;
			}
		for(int i=0;i<9;i++){
			int check[9]={};
			for(int j=0;j<9;j++)check[a[i][j]-1]++;
			for(int j=0;j<9;j++)if(check[a[i][j]-1]!=1)cor[i][j]=false;
		}
		for(int i=0;i<9;i++){
			int check[9]={};
			for(int j=0;j<9;j++)check[a[j][i]-1]++;
			for(int j=0;j<9;j++)if(check[a[j][i]-1]!=1)cor[j][i]=false;
		}
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++){
				int check[9]={};
				for(int kx=-1;kx<=1;kx++)
					for(int ky=-1;ky<=1;ky++){
						int nx=cen[i]+kx,ny=cen[j]+ky;
						check[a[nx][ny]-1]++;
					}
				for(int kx=-1;kx<=1;kx++)
					for(int ky=-1;ky<=1;ky++){
						int nx=cen[i]+kx,ny=cen[j]+ky;
						if(check[a[nx][ny]-1]!=1)cor[nx][ny]=false;
					}
			}
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				printf(cor[i][j]?" %d":"*%d",a[i][j]);
			}
			cout<<endl;
		}
		if(n!=0)cout<<endl;
	}
    return 0;
}

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

int main() {
  int n, r;
  cin >> n >> r;

  int ans = 0;
  if(n < 10){
    ans = r + (100 * (10 - n));
  }else{
    ans = r;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itc ll t;cin>>t;while(t--)
#define otc ll t=1;while(t--)
#define ll long long int
#define ld long double
#define pb push_back
#define gcd(a,b) __gcd(a,b)
#define fi first
#define se second
#define ull unsigned long long int
#define memset(arr) memset(arr, 0, sizeof(arr));
bool sortinrev(const pair<ll, ll> &a, const pair<ll, ll> &b)
{return (a.fi > b.fi);}//sort by first in descending order
bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b)
{ return (a.se < b.se); }//sort by second in ascending order
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	ll n;
	cin >> n;
	ll ar[n + 1];
	for (ll i = 1; i <= n; i++)cin >> ar[i];

	ll dp[n + 1] = {0};

	dp[1] = 0;
	dp[2] = abs(ar[2] - ar[1]);
	dp[3] = min((abs(ar[3] - ar[2]) + dp[2]), abs(ar[3] - ar[1]) + dp[1]);

	for (ll i = 4; i <= n; i++)
	{
		dp[i] = min((abs(ar[i] - ar[i - 1]) + dp[i - 1]), abs(ar[i] - ar[i - 2]) + dp[i - 2]);
	}
	cout << dp[n] << endl;

	/*for (ll i = 1; i <= n; i++)
	{
		cout << dp[i] << " ";
	}*/



	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////
ll printNcR(ll n, ll r) 
{ 
    if(n==r)
    return 1;
    if(n<r)
    return 0;
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            long long m = __gcd(p, k); 
            p /= m; 
            k /= m; 
  
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
        return p;
} 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    ll n;
    cin>>n;
    ll v[n];
    ll ans[200005]={0};
    
    REP(i,n)
    {
        ll x;
        cin>>x;
        v[i]=x;
        ans[x]++;
    }
    ll ini=0;
    for(ll i=0;i<200001;i++)
    {
        if(ans[i]>=2)
        ini+=printNcR(ans[i],2);
    }
    for(ll i=0;i<n;i++)
    {
        if(ans[v[i]]>=3)
        {
            cout<<ini - printNcR(ans[v[i]],2) + printNcR(ans[v[i]]-1,2)<<"\n";
        }
        else if(ans[v[i]]==2)
        {
            cout<<ini-1<<"\n";
        }
        else cout<<ini<<"\n";
    }
  }  
  return 0;
}

Measured memory_bytes: 5760
import java.util.*;
public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int t = 0;
        while(n > 0) {
          n /= k;
          t++;
        }
        System.out.println(t);
    }
}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

int main(){
    vector<int> lis(3);
    REP(i, 0, 3){cin >> lis[i];}
    sort(ALL(lis), greater<>());
    int ans = lis[0] - lis[1];
    int cc = lis[2] + ans;
    if((lis[0] - cc) % 2 == 0){
        ans += (lis[0] - cc) / 2;
    }else{
        ans += ((lis[0] - cc + 1) / 2) + 1;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    int n;  cin >> n;
    string s;   cin >> s;
    int ans = 0;
    for (int i = 0; i < n;) {
        int j = i;
        while (j < n && s[i] == s[j])    j++;
        ans++;
        i = j;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#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	endl			'\n'

typedef long long		ll;
typedef unsigned long long	ull;
typedef unsigned char	 	byte;
typedef vector<int>		vi;
typedef pair<int, int>		pii;
typedef pair<ll, ll>		pll;
typedef vector<pii>		vpii;

const int MX = 25;

int main(int argc, char *argv[])
{
#ifdef	HTRINH_UNIT_TEST
	freopen(argv[1],"r",stdin);
	ifstream cin(argv[1]);
#endif
#if 0
	ofstream cout(argv[2]);
#endif
	ios :: sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	int h1,h2,cst1,cst2,cur;
	cin >> h1;
	cst1 = 0;
	cin >> h2;
	cst2 = abs(h2-h1);
	FOR(i,2,n) {
		int h;
		cin >> h;
		cur = min(cst1+abs(h-h1),cst2+abs(h-h2));
		h1 = h2;
		h2 = h;
		cst1 = cst2;
		cst2 = cur;
	}
	cout << cst2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using arr = vector<ll>;
constexpr ll mod = 1000000007;
constexpr ll inf = 1LL << 60;
constexpr int max = 110000;

string a;
ll s[2020], now;

int main()
{
  cin >> a;
  reverse(a.begin(), a.end());

  ll ans = 0;
  ll ten = 1;
  s[0] = 1;
  for(int i = 0 ; i < a.size(); ++i) {
    now = (now + (a[i] - '0') * ten) % 2019;
    ans += s[now];
    s[now]++;
    ten = ten * 10 % 2019;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

typedef long long ll;
string itos(ll x){stringstream ss;ss<<x;return ss.str();};

int main(void)
{
  ll x;

  while(cin>>x,x)
  {
    bool flg = false;
    if(x < 0)
	{
      flg = true;
      x = -x;
    }
    string s = itos(x);
    ll ans = 0;
    ll p = 1;

    //ºÊ©çÔÉ©Ä¢­
    for(int i=0;i<s.length();i++,p*=10)
	{
      ll digit = s[s.length()-i-1] - '0';

      //0Í³
      if(digit == 0) continue;

      if(i % 2 == 0 && !flg || i % 2 == 1 && flg)
	  {
        ans += digit * p;

        //Jèã°
        if(ans >= p*10)
		{
          ll tmp = ans / (p*10);
          ans = ans % (p*10) + (20 - tmp) * p * 10;
        }
      }
      else
	  {
        ans += (20 - digit) * p;

        //Jèã°
        if(ans >= p*20)
		{
          ans -= p*20;
        }
      }
    }
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ss(x) (int) x.size()
#define cat(x) cerr << #x << " = " << x << endl

using ll = long long;

using namespace std;

const int N = 4000005;

int n, s, a;
bitset <N> B;

int main() {
	B[0] = 1;
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf ("%d", &a);
		s += a;
		B |= (B << a);
	}
	for (int i = (s + 1) / 2; true; ++i)
		if ((int) B[i] == 1) 
			return printf ("%d\n", i), 0;
	return 0;
}


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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    char c;
    cin >> c;
    if ((int)(c-'A')>=0 && (int)(c-'A') < 26) cout << "A" << "\n";
    else cout << "a" << "\n";
}

Measured memory_bytes: 3608
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [int(input()) for _ in range(m)]
ans = [0 for _ in range(n)]
for i in range(n):
    for j in range(m):
        ans[i] += a[i][j]*b[j]
print("\n".join(map(str, ans)))


Measured memory_bytes: 6020
n = int(input())
A = [int(input()) for x in range(5)]
B = []
cnt=0
for i in range(5):
    if A[i]>=n:
        B.append(1)
        cnt+=1
    else:
      if A[i]==1:
        B.append(n)
      else:
        B.append(int(n/A[i])+1)
if cnt==5:
    print(5)
else:
    print(max(B)+4)

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"os"
)

func main() {
	count := 0
	var n int
	fmt.Scan(&n)
	var a int
	var array []int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		array = append(array, a)
	}
	for {
		for i := 0; i < n; i++ {
			if array[i]%2 != 0 {
				fmt.Println(count)
				os.Exit(0)
			} else {
				array[i] = array[i] / 2
			}
		}
		count++
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int n;
	cin >> n;
	cout << n * (n + 1) / 2 << endl;
}

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

int main(void){
    int a, b;
    vector<int> c = {0,1,2,3};
    cin >> a >> b;
    c.at(a) = 0;
    c.at(b) = 0;
    
    for(auto i : c) {
        if (i != 0) cout << i << endl;
    }
    
}


Measured memory_bytes: 3576
s = list(input())
ss = set(s)
ans = 100
for i in ss:
  cnt = 0
  nexts = s[:]
  while len(set(nexts)) > 1:
    nexts = [i if i in nexts[j:j+2] else nexts[j] for j in range(len(nexts)-1)]
    cnt += 1
  ans = min(ans, cnt)
print(ans)
    

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] iArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            string result = "APPROVED";
            for (long p = 0;p<N;p++)
            {
                if (iArray[p] % 2 == 0)
                {
                    if((iArray[p] % 3 != 0 && iArray[p] % 5 != 0))
                    {
                        result = "DENIED";
                    }
                }
            }
            Console.WriteLine(result);

        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0'; ch=getchar();} while ('0'<=ch&&ch<='9');t*=f;
}
typedef long long ll;
const ll mod=(1e9)+7;
const int maxn=5005;
int n,sz[maxn];
ll dp[maxn][maxn],f[maxn],t[maxn];
vector<int> g[maxn];
void dfs(int u,int p) {
	sz[u]=1;
	dp[u][1]=1;
	for (int i=0;i<g[u].size();i++) {
		int v=g[u][i];
		if (v==p) continue;
		dfs(v,u);
		for (int j=0;j<=sz[u];j++) t[j]=dp[u][j],dp[u][j]=0;
		for (int j=0;j<=sz[u];j++)
		for (int k=0;k<=sz[v];k++)
			dp[u][j+k]=(dp[u][j+k]+t[j]*dp[v][k]%mod)%mod;
		sz[u]+=sz[v];
	}
	for (int i=0;i<=sz[u];i++)
		if (i%2==0) dp[u][0]=(dp[u][0]+(mod-1)*dp[u][i]%mod*f[i]%mod)%mod;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<n;i++) {
		int x,y; read(x); read(y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	f[0]=1;
	for (int i=2;i<=n;i++)
		f[i]=f[i-2]*(i-1)%mod;
	dfs(1,0);
	printf("%lld\n",(mod-1)*dp[1][0]%mod);
	return 0;
}

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

int a, b;
int main() {
	cin >> a >> b;
	if(a==1) a = 14;
	if(b==1) b = 14;
	if(a>b){
      cout <<"Alice" << endl;
    }
    else if(a<b){
      cout << "Bob" << endl;
    }
	else {
      cout << "Draw" << endl;
    }
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

int main() {
	int n, m;
	cin >> n >> m;
	vll ppp(n), ppm(n), pmp(n), mpp(n);
	vll pmm(n), mmp(n), mpm(n);
	rep(i, 0, n) {
		i64 x, y, z;
		cin >> x >> y >> z;
		ppp[i] = x + y + z;
		ppm[i] = x + y - z;
		pmp[i] = x - y + z;
		mpp[i] = -x + y + z;
		pmm[i] = x - y - z;
		mmp[i] = -x - y + z;
		mpm[i] = -x + y - z;
	}
	sort(rall(ppp));
	sort(rall(ppm));
	sort(rall(pmp));
	sort(rall(mpp));
	sort(rall(pmm));
	sort(rall(mmp));
	sort(rall(mpm));
	vll sum(7, 0);
	rep(i, 0, m) {
		sum[0] += ppp[i];
		sum[1] += ppm[i];
		sum[2] += pmp[i];
		sum[3] += mpp[i];
		sum[4] += pmm[i];
		sum[5] += mmp[i];
		sum[6] += mpm[i];
	}
	i64 ans = abs(sum[0]);
	rep(i, 1, 7) {
		ans = max(ans, abs(sum[i]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>
#include <algorithm>

int arr[100010];

int main()
{
	int n, r = 0, i;
	scanf("%d", &n);
	for(i = 1; i<=n; i++)
		scanf("%d", &arr[i]);
	for(i = 1; i<=n; i++)
	{
		if(arr[arr[i]]==i)
			r++;
	}
	printf("%d\n", r/2);
	return 0;
}

Measured memory_bytes: 640
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
     int n;cin>>n;
     int a[n];
     a[0] = 1;
     map<int,int> m;
     for(int i=1;i<n;i++)
     {
         cin>>a[i];
         m[a[i]]++;
     }
     int res[n+1];
     memset(res,0,sizeof res);
     for(auto it:m)
     {
         res[it.first] = it.second;
     }
     for(int i=1;i<=n;i++)
     {
         cout<<res[i]<<endl;
     }

}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 14592
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
int siz[200010];
int par[200010];
int depth[200010];
void init(int n){
  for(int i=0;i<=n;i++){
      par[i]=i;
      depth[i]=0;
  }
  rep(i,n+1){
      siz[i]=1;
  }
}
int root(int x){
  return par[x]==x?x:par[x]=root(par[x]);
}
bool same(int x,int y){
  return root(x)==root(y);
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  ll sx=siz[x];
  ll sy=siz[y];
  if(x==y)return;
  if(depth[x]<depth[y]){
      par[x]=y;
  }else{
      par[y]=x;
      if(depth[x]==depth[y])depth[x]++;
  }
  siz[root(x)]=sx+sy;
}
int main(){
    ll n;cin>>n;
    vector<ll>x(n),y(n);
    rep(i,n){
        cin>>x[i]>>y[i];
    }
    init(n);
    vector<set<ll> >cx(n),cy(n);
    vector<ll>cnt(n);
    vector<vector<ll> >cnx(100010),cny(100010);
    rep(i,n){
        cnx[x[i]].pb(i);
        cny[y[i]].pb(i);
    }
    rep(i,100010){
        ll s=cnx[i].size();
        s--;
        rep(j,s){
            unite(cnx[i][j],cnx[i][j+1]);
        }
    }rep(i,100010){
        ll s=cny[i].size();
        s--;
        rep(j,s){
            unite(cny[i][j],cny[i][j+1]);
        }
    }
    rep(i,n){
        cx[root(i)].insert(x[i]);
        cy[root(i)].insert(y[i]);
        cnt[root(i)]++;
    }
    ll ans=0;
    rep(i,n){
        if(cx[i].size()>1&&cy[i].size()>1){
            ans+=cx[i].size()*cy[i].size()-cnt[i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 26120
#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 ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

const int MAX_K = 5;

set<string> ss;

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

    REP (i, (int)s.length())
    {
        FOR (j, i + 1, i + MAX_K + 1)
        {
            string tmp = s.substr(i, j - i);
            ss.insert(tmp);
        }
    }

    set<string>::iterator itr = ss.begin();
    cout << *next(itr, K - 1) << endl;

    return 0;
}


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

using namespace std;

typedef vector<int> V;

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    V b = V(m);
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    int d = 0;
    for (int j = 0; j < n; j++) {
        int a ;
        int s = c;
        for (int i = 0; i < m; i++) {
            cin >> a;
            s += a * b[i];
        }
        if (s > 0) {
            d++;
        }
    }
    cout << d << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n;
string s;

int32_t main(){_

   cin>>s;

   n = sz(s);

   map<char, int> M;

   for (int i = 0; i < n; ++i)
   {
      M[s[i]]++;
   }

   if(sz(M) != 2){
      cout<<"No";
   }

   else{
      if(M.begin()->S != M.rbegin()->S){
         cout<<"No";
      }
      else{
         cout<<"Yes";
      }
   }

   return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define endl '\n'
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x, y) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << (y) << "\n"
#define watch3(x, y, z) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << (y) << " and " << (#z) << " is " << (z) << "\n"
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define rep(i, a, b) for (ll i = a; i < (b); ++i)
#define reb(i, a, b) for (ll i = a; i >= (b); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
int main()
{
fast;
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
		string s;
		ll sum=0;
		cin>>s;
		rep(i,0,sz(s))
		{
			sum+=s[i]-'0';
		}
		if(sum%9==0)
		cout<<"Yes"<<endl;
		else
		{
			cout<<"No"<<endl;
		}
		
	}
	return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define loop(i,L,R) for(int i=(L);i<=(R);i++)
const int maxn=1e5+5;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((c>=b&&c<=a)||(c>=a&&c<=b))
        printf("Yes\n");
    else printf("No\n");
}


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

s, t = 0, 1
max_len = -1
while s < N:
    t = s + 1
    while t < N and H[t] <= H[t - 1]:
        t += 1
    max_len = max(max_len, t - s)
    s = t
print(max_len - 1)

Measured memory_bytes: 15020
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      long a = sc.nextLong();
      long b = sc.nextLong();
      long c = sc.nextLong();
      long k = sc.nextLong();
      long x = 0;
      if(k%2==0)x = a-b;
      else x = b-a;
      System.out.println(x);
    }
}


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

int main() {
  string t;
  cin >> t;
  int a = t.size();
  for(int i=0;i<t.size();i++){
  if(t.at(i) == '?'){
  	t.at(i) = 'D';
  }
  }
    cout << t << endl;
}

Measured memory_bytes: 3712
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] line = sc.nextLine().split(" ");
		ArrayList<Integer> distantList = new ArrayList();
		for(int i = 0;i<line.length;i++) {
			distantList.add(Integer.parseInt(line[i]));
		}
		Collections.sort(distantList);
		System.out.println(distantList.get(0) + distantList.get(1));
		
	}
}
	
	

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>

typedef long long ll;

using namespace std;

const int MAX = 50;
char a[MAX][MAX], b[MAX][MAX];

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            cin >> a[i][j];
            }
    }
    for (int i = 0; i < m; i++){
        for (int j = 0; j < m; j++) {
            cin >> b[i][j];
        }
    }

    bool included = false;
    for (int ay = 0; ay < n; ay++){
        for (int ax = 0; ax < n; ax++){
            if ((ay + m > n) || (ax + m > n)) continue; //はみ出たら

            bool match = true; //一致するか判定
            for (int by = 0; by < m; by++){
                for (int bx = 0; bx < m; bx++){
                    if(a[ay + by][ax + bx] != b[by][bx]){
                        match = false; //違うときだけ変更
                    }
                }
            }
            if(match == true) included = true;
        }
    }
    if(included == true) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256