akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(x) scanf("%d",&x)
#define sc(x) scanf(" %c",&x)
#define sll(x) scanf("%I64d",&x)
#define f(i,n,k) for(int i=k;i<n;i++)
#define pi(x) printf("%d ",x);
#define pll(x) printf("%I64d ",x);
int arr[1000000],brr[1000000],crr[1000000];
int main()
{
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    f(i,a,0)
    cin>>arr[i];
    f(i,b,0)
    cin>>brr[i];
    f(i,c,0)
    cin>>crr[i];
    ll sum=0;
    int ax=0;
    sort(arr,arr+a);
    sort(brr,brr+b);
    sort(crr,crr+c);
    while(x!=0)
    {
        if(arr[a-1]>crr[c-1] && (a>0 && c>0))
        {
            sum+=arr[a-1];
            a--;
            x--;
        }
        else if(c>0)
        {
            sum+=crr[c-1];
            c--;
            x--;
            ax++;
        }
        else
        {
            sum+=arr[a-1];
            a--;
            x--;
        }
    }
    int j=0;
    for(int i=b;i<(b+c);i++)
    {
       brr[i]=crr[j++];
    }
    j=a-1;
    b=b+c;
    for(int i=b;i<(b+ax);i++)
    {
        brr[i]=arr[j--];
    }
    b=b+ax;
    sort(brr,brr+b);
    for(int i=b-1;i>=0;i--)
    {
        if(y==0)
            break;
        else
        {
            sum+=brr[i];
            y--;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 8832
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

const int inf = 1e17 + 7;
const int MOD = 1e7 + 9;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin>>n;
	if(n==2){
		cout<<1<<endl;
		return 0;
	}
	int cnt = 2;
	for(int i=2;i<=sqrt(n);i++){
		int t = n;
		if(t%i==0){
			while(t%i==0) t/=i;
			if(t%i==1) cnt++;
		}else if(t%i==1){
			if((t/i)==(i)) cnt+=1;
			else cnt+=2;
		}
	}
	cout<<cnt<<endl;
	return 0;
}



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

using namespace std;

void __start__() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef MY
    freopen("/home/ainur/CLionProjects/wow/input.txt", "r", stdin);
    freopen("/home/ainur/CLionProjects/wow/output.txt", "w", stdout);
#else
#define endl '\n'
    //freopen("search.in", "r", stdin);
    //freopen("search.out", "w", stdout);
#endif
}

#define sz(x) (int)x.size()
#define yes cout<<"Yes\n"
#define  no cout << "No\n"
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ft first
#define sd second
#define read(a) for(auto &qwqw:a)cin >> qwqw;
#define print(a) for(auto qwqw:a)cout<<qwqw<<' ';
#define print_plus(a) for(auto qwqw:a)cout<<qwqw+1<<' ';
//#define FOR(i, b, n) for(int i=b;i<n;i++) #define FOR(i, n) FOR(i, 0, n) #define FOR(n) FOR(i, 0, n)
mt19937_64 rnd(time(0));
#define int long long
using ll = long long;
using vi = vector<int>;
using ld = long double;
using vb = vector<bool>;
using pii = pair<int, int>;
using vd = vector<long double>;


int log2(int q) {
    int c = 0;
    while (q) {
        q >>= 1;
        c++;
    }
    return c;
}


void test_case() {
    int n, ans=0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n-1; ++i) {
        if(s.substr(i, 3)=="ABC")
            ans++;
    }
    cout << ans;
}

signed main() {
    __start__();
    int Q = 1;
    //cin >> Q;
    while (Q--) {
        test_case();
    }
}




Measured memory_bytes: 3592
#include <iostream>
#include <set>

int main() {
    long long int n, t, ret = 0;
    std::cin >> n;
    std::set<long long> a;
    for (long long i = 0; i < n; i++) {
        std::cin >> t;
        auto s = a.size();
        a.insert(t);
        if (s == a.size()) ret++;
    }

    std::cout << n - ret - ((ret % 2 == 1) ? 1 : 0) << std::endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  string s,t,u;
  int a,b;
  cin >> s>>t>>a>>b>>u;
  
  if(s==u) a--;
  else b--;
  
  cout << a << " " << b << endl;
  
  
}


Measured memory_bytes: 256
#include <stdio.h>
int gcd(int a, int b);
int main(void)
{
    int n;
    scanf("%d", &n);
    int a[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }

    int b = a[0];
    int i = 1;
    while (i < n)
    {
        b = gcd(b, a[i]);
        i++;
    }

    printf("%d\n",b);
    return 0;
}

int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N, M, X;
vector<int> C;
vector<vector<int>> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M >> X;
  C.resize(N);
  A.resize(N);
  for (int i = 0; i < N; i++) {
    int ci;
    cin >> ci;
    C[i] = ci;
    A[i].resize(M);
    for (int j = 0; j < M; j++) {
      int a;
      cin >> a;
      A[i][j] = a;
    }
  }

  int ans = INF;
  for (int i = 1; i < (1 << N); i++) {
    vector<int> points(M, 0);
    int cost = 0;
    for (int j = 0; j < N; j++) {
      if (i & (1 << j)) {
        for (int k = 0; k < M; k++) {
          points[k] += A[j][k];
        }
        cost += C[j];
      }
    }

    bool ok = true;
    for (int j = 0; j < M; j++) {
      if (points[j] < X) {
        ok = false;
        break;
      }
    }
    if (ok) {
      ans = min(ans, cost);
    }
  }

  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3168
def calc_comb(m)
    return m * (m - 1) / 2
end

n = gets.strip.to_i
a = gets.strip.split(' ')

hash = a.group_by(&:itself).map{|key, value|[key, value.count]}.to_h

comb = Hash.new
sum  = 0
hash.each do |k,v|
  comb_res = calc_comb(v)
  comb[k] = comb_res
  sum = sum + comb_res
end

(1..n).each do |i|
  value = comb[a[i-1]]
  new_value = calc_comb(hash[a[i-1]] - 1)
  puts sum - (value - new_value)
end


Measured memory_bytes: 74244
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll x, y;
	cin >> x >> y;

	ll ans = 0;
	while (x <= y) {
		ans++;
		x *= 2;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    char S;
    bool if3 = true;
    rep(i, N){
        cin >> S;
        if(S == 'Y'){
            if3 = false;
        }
    }

    if(if3){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
// ABC 083 B
#include<bits/stdc++.h>

using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define PB(a) push_back(a)
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int func(int n){
  int a=0;
  while(n){
    a += n%10;
    n /= 10;
  }
  return a;
}
int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int a,b,n;
  cin >> n >> a >> b;
  int ans=0;
  REP(i,n+1){
    int tmp=func(i);
    if(tmp>=a&&tmp<=b)ans+=i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll a, b;
  cin >> a >> b;
  ll foo = min(a, b);
  ll bar = max(a, b);
  rep (i, bar) cout << foo;
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define MOD 1000000007
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define OTP(s) cout<<s<<endl;
#define FOR(i,j,k,l) for(int i=j;i<k;i+=l)
#define REP(i,j) FOR(i,0,j,1)
inline ll add(ll a, ll b){a += b; if(a >= MOD)a -= MOD; return a;}
inline ll sub(ll a, ll b){a -= b; if(a < 0)a += MOD; return a;}
inline ll mul(ll a, ll b){return (ll)((ll) a * b %MOD);}
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

ll min(ll a,ll b)
{
    return a>b?b:a;
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}

vector<pll> pr[4001];

string s,t;
int dp[4001][4001];
char ans[4001];
int ind=0;
int main()
{
    IOS
    cin>>s>>t;
    REP(i,sz(s)+1)
    {
        dp[i][0]=0;
    }
    REP(i,sz(t)+1)
    {
        dp[0][i]=0;
    }
    REP(i,sz(s))
    {
        REP(j,sz(t))
        {
            if(s[i]==t[j])
            {
                dp[i+1][j+1] = dp[i][j]+1;
                pr[dp[i+1][j+1]].pb(mp(i,j));
            }
            else
            {
                dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
            }        
        }
    }
    ll cnt=dp[sz(s)][sz(t)];
    if(cnt==0)  return 0;
    ans[cnt]='\0';
    pll top = pr[cnt][sz(pr[cnt])-1];
    // cout<<top.ff<<" "<<top.ss<<endl;
    ans[cnt-1] = s[top.ff];
    for(int i=cnt-1;i>0;i--)
    {
        REP(j,sz(pr[i]))
        {
            if(pr[i][j].ff<top.ff && pr[i][j].ss<top.ss)
            {
                top = pr[i][j];
                // cout<<top.ff<<" "<<top.ss<<endl;
                ans[i-1] = s[top.ff];
                break;
            }
        }
    }
    // REP(i,sz(s)+1)
    // {
    //     REP(j,sz(t)+1)
    //     {
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    // cout<<"done\n";
    cout<<ans<<endl;
}

Measured memory_bytes: 215168
import java.util.*;

class Main{

	public static void main(String[] args){
	
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		if (N == M)
		System.out.println("Yes");
		else
		System.out.println("No");
	
	
	}


}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int T = scan.nextInt();
        int pushSwitchTime = 0;
        int pushSwitchTimePrevious = 0;
        int totalTime = 0;
        
        for(int i = 0; i < N; i++) {
            if(i != 0) {
                pushSwitchTimePrevious = pushSwitchTime;
                pushSwitchTime = scan.nextInt();
                
                if(pushSwitchTime - pushSwitchTimePrevious < T) {
                    totalTime += pushSwitchTime - pushSwitchTimePrevious;
                } else {
                    totalTime += T;
                }
            } else {
                pushSwitchTime = scan.nextInt();
                totalTime += T;
            }
        }
        
        System.out.println(totalTime);
    }
}


Measured memory_bytes: 62576
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}

int main()
{
    string s, t;
    cin >> s >> t;
    vector<int> S(26,0), T(26,0);
  
  for(int i = 0; i < s.size(); i++){
    S[s[i] - 'a']++;
    T[t[i] - 'a']++;
  }
  
  sort(S.begin(), S.end());
  sort(T.begin(), T.end());
  
  for(int i = 0; i < 26; i++){
    //cout << S[i] << " " << T[i] << endl;
	if(S[i]!=T[i]){
		cout << "No" << endl;
        return 0;
    }
  }
  cout << "Yes" << endl;
}

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

int main(){
   ll n, a, b, c, d;   cin >> n >> a >> b >> c >> d;
   string s;    cin >> s;
   string ans="Yes";
    s = '#' + s + '#';
   if(c<d){
       for(ll i=b+1; i<d; i++){
           if(s.at(i)=='.' || s.at(i+1)=='.') continue;
           ans = "No"; 
       }
       for(ll i=a+1; i<c; i++){
           if(s.at(i)=='.' || s.at(i+1)=='.') continue;
           ans = "No"; 
       }
   }else{
       bool f = false;
       for(ll i=b; i<=d; i++){
           if(s.at(i-1)=='#' || s.at(i)=='#' || s.at(i+1)=='#') continue;
            f = true;
       }
       if(!f) ans = "No";

   }

   cout << ans << endl;
}

Measured memory_bytes: 772
<?php
  
list($a, $b, $k) = explode(' ', trim(fgets(STDIN)));
$ans_a = $a;
$ans_b = $b;

$ans_a = $a - min($a,$k);

if ($ans_a == 0){
  $k = $k - $a;
  $ans_b = $b - min($b,$k);
}
 
echo $ans_a." ".$ans_b; 
  
?>

Measured memory_bytes: 4728
#include <stdio.h>
int main(void){
	int N,num[101]={0},i,j,cnt=0,mini,temp;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&num[i]);
	}
	for(i=0;i<N;i++){
		mini=i;
		for(j=i;j<N;j++){
			if(num[j]<num[mini]){
				mini=j;
			}
		}
		if(num[i]>num[mini]){
			temp=num[i];
			num[i]=num[mini];
			num[mini]=temp;
			cnt++;
		}
	}
	for(i=0;i<N;i++){
		printf("%d",num[i]);
		if(i!=N-1) printf(" ");
	}
	printf("\n%d\n",cnt);
	return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;

  for (int i = 0; i < S.size(); i++) {
    char c = S.back();
    S = c + S;
    S.pop_back();
    if (S == T) {
      cout << "Yes" << "\n";
      return 0;
    }
  }

  cout << "No" << "\n";
}

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] vs = RArInt();
            int r = vs[0];
            int d = vs[1];
            int x = vs[2];

            for (int i = 0; i < 10; i++)
            {
                x = r * x - d;
                Console.WriteLine(x);
            }

        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}


Measured memory_bytes: 11220
n = input()
print(""),

for i in range(1, n+1):
    k = 1
    a = 0
    x = i
    if x%3 == 0:
        print i,
    else:
        while x != 0 and a == 0:
            if x%10 == 3:
                print i,
                a = 1
                k = 2
            else:
                x = x/10
        

Measured memory_bytes: 6424
def main():
    n = int(input())
    A = sorted(list(map(int, input().split())))
    B = [A[0], ]
    s = A[0]
    for a in A[1:]:
        s += a
        B.append(s)
    ans = 1
    for i in range(n - 1, 0, -1):
        if B[i - 1] * 2 >= A[i]:
            ans += 1
        else:
            break
    print(ans)
if __name__ == '__main__':
    main()


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

#define all(x) (x).begin(),(x).end()

#define MOD 1000000007

using namespace std;

int main(){
	long long int x;	cin >> x;
	int i = 0;
	long long int dep = 100;

	while( dep < x ){
		dep *= 1.01;
		i++;
	}

	cout << i << endl;

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 100010;
int n, tot, q, K;
int to[N << 1], head[N], val[N << 1], nex[N << 1];
int fa[N], son[N], top[N], siz[N], dep[N];
LL dis[N];

void SE(int u, int v, int w){
	to[++ tot] = v; nex[tot] = head[u]; head[u] = tot; val[tot] = w;
}

void DFS(int x){
	siz[x] = 1;
	for(int i = head[x]; i; i = nex[i]){
		if(dep[to[i]]) continue;
		dep[to[i]] = dep[x] + 1;
		fa[to[i]] = x;
		dis[to[i]] = dis[x] + val[i];
		DFS(to[i]);
		if(siz[to[i]] > siz[son[x]]) son[x] = to[i];
		siz[x] += siz[to[i]];
	}
	return;
}

void RDFS(int x, int f){
	top[x] = f;
	if(!son[x]) return;
	RDFS(son[x], f);
	for(int i = head[x]; i; i = nex[i])
		if(to[i] != fa[x] && to[i] != son[x])
			RDFS(to[i], to[i]);
	return;
}

int LCA(int x, int y){
	for(int fx = top[x], fy = top[y]; fx != fy; x = fa[fx], fx = top[x])
		if(dep[fx] < dep[fy]) swap(fx, fy), swap(x, y);
	if(dep[x] > dep[y]) return y;
	return x;
}

int main(){
	scanf("%d", &n);
	for(int a, b, c, i = 1; i < n; i ++){
		scanf("%d%d%d", &a, &b, &c);
		SE(a, b, c);
		SE(b, a, c);
	}
	
	scanf("%d%d", &q, &K);
	dep[K] = 1;
	DFS(K);
	//RDFS(K, K);
	int x, y, lca;
	while(q --){
		scanf("%d%d", &x, &y);
		 printf("%lld\n", dis[x] + dis[y]);
	}
	
	return 0;
}

Measured memory_bytes: 9984
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = Integer.parseInt(sc.next());
		long b = Integer.parseInt(sc.next());
		long c = Integer.parseInt(sc.next());
		if (a == b && b == c) {
			if (a % 2 == 0) System.out.println("-1");
			else System.out.println("0");
			return;
		}
		int ans = 0;
		while (true) {
			if ((a + b) % 2 != 0 || (b + c) % 2 != 0 || (c + a) % 2 != 0)
				break;
			long ta = (b + c) / 2;
			long tb = (a + c) / 2;
			long tc = (a + b) / 2;
			a = ta;
			b = tb;
			c = tc;
			ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<stdio.h>
#include<string>
#include<map>
using namespace std;

int main() {
	string ketsueki;
	map<string,int> num;
	int hoge;
	
	num["A"] = 0;
	num["B"] = 0;
	num["O"] = 0;
	num["AB"] = 0;
	
	
	while ( ~scanf("%d,",&hoge)){
		cin >> ketsueki;
		num[ketsueki]++;
	}
	
	cout << num["A"] << endl << num["B"] << endl << num["AB"] << endl << num["O"] << endl;
	
	return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;


int main(){
    int n;
    cin >> n;
    vector<int> x(n),tmp(n);
    rep(i,n){
        cin >> x[i];
        tmp[i] = x[i];
    }
    sort(tmp.begin(),tmp.end(),greater<int>());

    //for (auto e: tmp) cout << e << endl;
    // cout << tmp[n/2-1] << " " << tmp[n/2] << endl;
    // cout << endl;
    rep(i,n){
        if(x[i] <= tmp[n/2]){
            cout << tmp[n/2-1] << endl;
        }else{
            cout << tmp[n/2] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4828
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 107;
const int INF = 1e18 + 7;
const int S = 0, T = N - 1;
int n;
int a[N];
struct Edge {
    int v, c, f;
};  
vector <int> g[N];
vector <Edge> ed;      
void add(int u, int v, int c) {
    #ifdef HOME
    cout << "edge " << u << "->" << v << " : " << c << '\n';
    #endif
    g[u].push_back(ed.size());
    ed.push_back({v, c, 0});
    g[v].push_back(ed.size());
    ed.push_back({u, 0, 0});
}   
bool used[N];
int dfs(int u, int cur) {
    used[u] = 1;
    #ifdef HOME
    cout << "dfs " << u << ' ' << cur << '\n';
    #endif
    if (u == T) return cur;
    for (int i : g[u]) {
        auto &e = ed[i];
        if (!used[e.v] && e.f < e.c) {
            int t = dfs(e.v, min(cur, e.c - e.f));
            if (t) {
                e.f += t;
                ed[i^1].f -= t;
                return t;
            }   
        }   
    }   
    #ifdef HOME
    cout << "out " << u << '\n';
    #endif
    return 0;
}   
int maxflow() {
    int ans = 0;
    while (1) {
        memset(used, 0, sizeof used);
        int t = dfs(S, INF);
        if (t) ans += t;
        else break;
    }   
    return ans;
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) {
        if (a[i] > 0) {
            add(i, T, a[i]);
        }
        else {
            add(S, i, -a[i]);
        }   
    }   
    for (int i = 1; i <= n; ++i) {
        for (int j = i * 2; j <= n; j += i) {
            add(i, j, INF);
        }
    }   
    int best = 0;
    for (int i = 1; i <= n; ++i) best += max(0ll, a[i]);
    cout << best - maxflow() << '\n';
}   

Measured memory_bytes: 256
from heapq import *
Q = int(input())
L, R = [], []
ans = 0
for _ in range(Q):
    a = [int(a) for a in input().split()]
    if a[0] == 1:
        t1 = heappushpop(L, -a[1])
        t2 = heappushpop(R, a[1])
        heappush(L, -t2)
        heappush(R, -t1)
        ans += a[2] + abs(t2+t1)
    else:
        print(-L[0], ans)

Measured memory_bytes: 19024
import copy;

def main():
  H, W, K = list(map(int, input().split()))

  original = [[0 for _ in range(W)] for _ in range(H)]
  ans = 0

  for i in range(H):
    S = [str(s) for s in input()]
    
    for j, v in  enumerate(S):
      if(v == "#"):
        original[i][j] = 1
      else:
        original[i][j] = 0

  for i in range(1 << H):
    for j in range(1 << W):
      m = copy.deepcopy(original);

      count = 0
      for k in range(H):
        if(i >> k & 1):
          m[k] = [0] * W
      
      for k in range(W):
        if(j >> k & 1):
          for l in m:
            l[k] = 0

      for row in m:
        count += row.count(1);

      if(K == count):
        ans += 1

  print(ans)

if __name__ == "__main__":
  main()

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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int N;
    cin >> N;
    vector<pair<int, int>> v(N);
    for (int i = 0; i < N; ++i) {
        cin >> v[i].first >> v[i].second;
    }
    multiset<pair<int, pair<int, int>>> a, b;
    for (int i = 0; i < N; ++i) {
        a.insert({-(v[i].first + v[i].second), {-v[i].first, v[i].second}});
        b.insert({-(v[i].second + v[i].first), {-v[i].second, v[i].first}});
    }
    long long res = 0;
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) {
            const auto &p = *a.begin();
            int v1 = -p.second.first, v2 = p.second.second;
            res += v1;
            a.erase(a.begin());
            b.erase(b.find({- v2 - v1, {-v2, v1}}));
            //cout << v1 << " " << v2 << endl;
        } else {
            const auto &p = *b.begin();
            int v1 = p.second.second, v2 = -p.second.first;
            res -= v2;
            b.erase(b.begin());
            a.erase(a.find({- v1 - v2, {-v1, v2}}));
            //cout << v1 << " " << v2 << endl;
        }
    }
    cout << res << "\n";
    return 0;
}

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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int q;
	cin >> q;
	set<int> rbt;
	while (q--) {
		int com, x;
		cin >> com >> x;
		if (com == 0) {
			rbt.insert(x);
			printf("%d\n", rbt.size());
		}
		else if (com == 1) {
			puts(rbt.count(x) ? "1" : "0");
		}
		else {
			rbt.erase(x);
		}
	}
	return 0;
}



Measured memory_bytes: 12532
import sys
from bisect import bisect_left, bisect_right
s=sys.stdin.readline().strip()
t=sys.stdin.readline().strip()

len_s=len(s)


C={}
for i,a in enumerate(s*2):
		if a not in C:
			C[a]=[i]
		else:
			C[a].append(i)


pointer=-1
mul=0

for x in t:
	try:
		idx=bisect_right(C[x],pointer)
	except:
		print -1
		quit()

	pointer=C[x][idx]

	if len_s<=pointer:
			mul+=1
			pointer-=len_s


print mul*len_s+pointer+1


Measured memory_bytes: 46876
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(elem => int.Parse(elem)).OrderBy(elem => elem).ToArray();
            var check = Enumerable.Repeat(true, A.Last() + 1).ToArray();
            foreach (var i in Enumerable.Range(0, N))
            {
                if (check[A[i]] == false)
                {
                    continue;
                }

                for (var j = 2 * A[i]; j <= A.Last(); j += A[i])
                {
                    check[j] = false;
                }
            }

            var answer = 0;
            foreach (var i in Enumerable.Range(0, N))
            {
                if (i + 1 < N && A[i] == A[i + 1])
                {
                    check[A[i]] = false;
                }
                else
                {
                    if (check[A[i]])
                    {
                        answer++;
                    }
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 47680
while True:
    n = int(input())
    if n == 0:
        break
    d = {}
    for _ in range(n):
        a, b = input().split()
        d[a] = b
    m = int(input())
    ans = ""
    for _ in range(m):
        a = input().strip()
        if a in d:
            ans += d[a]
        else:
            ans += a
    print(ans)

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
           long sum=0;

			for (int i = 1; i <= N; i++) {

				//sum += i * yakusuNum[i];
				var p = N / i;
				sum += i * (1 + p) * p / 2;
			}



			//答えの出力
			var ans = sum;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 28132
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> p(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		if (p[i] == i+1) {
			swap(p[i], p[i+1]);
			ans++;
		}
	}
	if (p[n - 1] == n) {
		swap(p[n-1], p[n-2]);
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int i, n, r[200000], min, max;
	min=0;
	max=-2000000000;
	scanf("%d%d", &n, &r[0]);
	min=r[0];
	for(i=1;i<n;i++){
		scanf("%d", &r[i]);
		if(max<r[i]-min){
			max=r[i]-min;
		}
		if(min>r[i]){
			min=r[i];
		}
	}
	printf("%d\n", max);
	return 0;
}


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

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  D(x)         cout << #x << " - " << x << endl;
  #define  D2(x)        cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
  #define  all(x)       (x).begin(), (x).end()
  #define  D2p(x)       cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;


  void solve(){
	  int n,m;
	  cin >> n >> m;
	  vector<vector<ll>>grid(n,vector<ll>(m));
	  vpi v;
	  vector<vi> ans;
	  for(int i=0;i<n;i++){
	  	  for(int j=0;j<m;j++){
	  	  		cin >> grid[i][j];
	  	  }
	  }
	  	int j = 0;
	  	int inc=1;
		for(int i=0;i<n;i++){
			for(;j<m && j>=0;j+=inc){
				// cout << (i+1)<<(j+1) << ' ';
				if(grid[i][j]%2){
					vi v;
					v.push_back(i);
					v.push_back(j);
					if(j+inc<m && j+inc>=0){
						grid[i][j+inc]+=1;
						v.push_back(i);
						v.push_back(j+inc);	
						ans.push_back(v);
					}
					else if(i+1<n){
						grid[i+1][j]+=1;
						v.push_back(i+1);
						v.push_back(j);
						ans.push_back(v);
					}
				}	
			}
			if(j==m){
				j--;
				inc = -1;
			}
			else{
				j++;
				inc = 1;
			}
			// cout << '\n';
		}
		cout << (int)ans.size() << '\n';
		for(int i=0;i<(int)ans.size();i++){
			for(int j=0;j<4;j++){
				cout << ans[i][j]+1;
				if(j<3)cout << ' ';
			}
			if(i<ans.size()-1)cout << '\n';
		}
	      
  }

  int main(){
    IOS
    solve();
    // cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 12068
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <vector>

using namespace std;
int main(){
  string s;
  cin >> s;
  int stock = 0;
  int score = 0;
  for (int i = 0; i < s.length(); i++){
    if (stock > 0){
      if (s[i] == 'g'){
        stock--;
        score++;
      }else{
        stock--;
      }
    }else{
      stock++;
      if (s[i] == 'p'){
        score--;
      }
    }
  }
  cout << score << endl;
  return 0;
}


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

int main() {
	double a, b, c, d, e, f, xx, yy;
	while (cin >> a >> b >> c >> d >> e >> f) {
	double y = (a * f - c * d) / (a * e - b * d);
	double x = (c - b * y) / a;
	cout << fixed << setprecision(3) << x << " " << y << endl;
	}

	return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
const int INF=1000000000;
int main(){
    int n[3];
    for (int i = 0; i < 3;i++)
        cin >> n[i];
    sort(n, n + 3);
    cout << n[0] << " " << n[1] << " " << n[2]<<endl;
    return 0;
}


Measured memory_bytes: 3140
n = gets.to_i
member = Hash.new
max = 0
n.times do
 x = gets
 y = x.split(" ")
 a = y[0].to_i
 b = y[1].to_i
 
 member[a] = b
 if max < b
  max = b
 end
end

winner = member.select{|k,v| v == max}
winner2 = Hash[winner.sort]
winner2.each do |k,v|
 puts "#{k} #{v}"
 break
end



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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    // vector <int> a(n);
    rep(i,n){
        int a;
        cin >> a;
        while(a % 2 == 0){
            ans++;
            a = a / 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long
#define lli long long int

using namespace std;
using P = pair<int,int>;

int main(){

  ll N;
  ll mod = 1e9+7;
  ll p = 1;
  ll ans = 0;
  cin >> N;

  for (int i = 1; i <= N; i++) {
    p = i*p%mod;
  }

  cout << p << endl;

  return 0;
}

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

const int mod = 1000000007;
struct mint {
ll x; 
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
 }
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
 }
 mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
 mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
 mint inv() const {
return pow(mod-2);
 }
  mint& operator/=(const mint a) {
return (*this) *= a.inv();
 }
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
 }
};
struct combination {
vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
  assert(n < mod);
 fact[0] = 1;
 for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
 ifact[n] = fact[n].inv();
  for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n) return 0;
return fact[n]*ifact[k]*ifact[n-k];
}
  };
int main() {
ios::sync_with_stdio(false);
cin.tie(0);

int n,k;
cin>>n>>k;

combination comb(n);
for(int i=1;i<=k;i++){
 mint ans=comb(n-k+1,i)*comb(k-1,i-1);
 cout<<ans.x<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }

int main(){
    ll D, N;
    cin >> D >> N;
    ll n = N * pow(100, D);
    if (N==100) n += pow(100, D);
    cout << n << "\n";
}


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

class island
{
private:
  int num;
  char data[12][12];
  void calc_r(int x,int y)
  {
    if(data[x][y]=='1'){
      data[x][y]='0';
      if(x!=0)
	calc_r(x-1,y);
      if(y!=0)
	calc_r(x,y-1);
      if(x!=11)
	calc_r(x+1,y);
      if(y!=11)
	calc_r(x,y+1);
    }
  }
public:
  bool input()
  {
    num=0;
    string buf;
    for(int i=0;i<12;i++){
      if(!(cin >> buf))
	return false;
      for(int j=0;j<12;j++){
	data[i][j]=buf[j];
      }
    }
    return true;
    
  }
  int calc()
  {
    num=0;
    for(int i=0;i<12;i++){
      for(int j=0;j<12;j++){
	if(data[i][j]=='1'){
	  num++;
	  calc_r(i,j);
	}
      }
    }
    return num;
  }
};

int main(int argc, char **argv) 
{
  island obj;
  while(true){
    if(!obj.input())
      break;
    cout <<  obj.calc() << endl;
  }
}

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

vector<bool> ans(40,false);
void intto(int n,int keta){
  if(n == 0) return;
  if(n%2 == 1 || n%2 == -1){
    ans[keta] = true;
    --n;
  }
  intto(n/(-2),keta+1);
}

int main(){
  int n;
  cin >> n;
  intto(n,0);
  while(ans.size() > 0 && !ans[ans.size()-1]) ans.pop_back();
  reverse(ans.begin(),ans.end());
  for(int i=0; i<(int)ans.size(); ++i){
    if(ans[i]) cout << 1;
    else cout << 0;
  }
  if(ans.size() == 0) cout << 0;
  cout << endl;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main (void){
	int a,b;
	while(cin>>a>>b){
		int n=a+b;
		if(n%3==0 || a%3==0 || b%3==0 ) cout<<"Possible"<<endl;
		else cout<<"Impossible"<<endl;
	}
	return 0;
}

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

int main(){
	vector<int> r,a;
	int tr,ta,hit=0,blow=0;

	while(true){
		cin>>tr>>ta;
		if(tr==0 && ta==0) break;

		for(int i=1000;i>=1;i/=10){
			r.push_back(tr/i-tr/(i*10)*10);
			a.push_back(ta/i-ta/(i*10)*10);
		}

		for(int i=0;i<r.size();++i){
			if(r[i]==a[i]){
				hit++;
				continue;
			}
			for(int j=0;j<r.size();++j){
				if(i==j) continue;
				if(r[i]==a[j]){
					blow++;
					break;
				}
			}
		}

		cout<<hit<<" "<<blow<<endl;
		r.clear();a.clear();hit=blow=0;
	}

	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

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

  string s;
  cin >> s;
  if(s[0]=='S') cout << "Cloudy" << endl;
  if(s[0]=='C') cout << "Rainy" << endl;
  if(s[0]=='R') cout << "Sunny" << endl;
  
}

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

long long dp[200005],sum[200005],s[200005];

int main()
{
    int n;
    while(cin>>n)
    {
        for(int i=1;i<=n;i++)
            cin>>s[i];
        for(int i=1;i<=n;i++)
        {
            if(i==1)
                sum[i]=s[i];
            else
                sum[i]=sum[i-2]+s[i];
        }
        for(int i=2;i<=n;i++)
        {
            if(i%2==0)
            {
                dp[i]=max(dp[i-2]+s[i],sum[i-1]);
            }
            else
            {
                dp[i]=max(dp[i-2]+s[i],dp[i-1]);
            }
        }
        cout<<dp[n]<<endl;
    }
    return 0;
}

Measured memory_bytes: 8292
#include <iostream>

using namespace std;

int main()
{
  char a;

  cin >> a;
  if( a == 'a' || a == 'i' || a == 'e' || a == 'o' || a == 'u')
    cout << "vowel";
  else
    cout << "consonant";
    return 0;
}


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

using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
using ll=long long;
using p_i_i=pair<int,int>;

int n;
vector<vector<p_i_i>>v;
bool judge(int bit,int n){
  rep(i,n){
    if(!(bit&(1<<i)))continue;
    for(p_i_i xy:v[i]){
      int x=xy.first;//xが
      int y=xy.second;//正直か不親切かy=1正直y=0不親切
      //y=1なのに「不親切」
      if((y==1)&&!(bit&(1<<x)))return false;
      if((y==0)&&(bit&(1<<x)))return false;
    }
  }return true;
}
int main(){
 cin>>n;
 v.resize(n);
 rep(i,n){
   int a;cin>>a;
   v[i].resize(a);
   for(int j=0;j<a;j++){
     cin>>v[i][j].first>>v[i][j].second;
     --v[i][j].first;
   }
 }

 int res=0;
 for(int bit=0;bit<(1<<n);bit++){

   if(judge(bit,n)){

     int count=0;
     for(int i=0;i<n;i++){
       if(bit&(1<<i))count++;
     }
     res=max(res,count);
   }
 }
 cout<<res<<endl;
return 0;
}

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

void L(int i, int64_t &ans1, int64_t &ans2){
    int64_t tmp;
    if(i == 0){
        ans1 = 2;
    }else if(i == 1) {
        ans1 = 1;
        ans2 = 2;
    }else{
        L(i-1,ans1,ans2);
        tmp = ans1;
        ans1 = ans1 + ans2;
        ans2 = tmp;  
    }
}

int main(){
    int N;
    int64_t ans,tmp;
    cin >> N ;
    L(N,ans,tmp);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,K;
P t[100100];
int num[100100];
int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++)cin >> t[i].sec >> t[i].fi;
	sort(t,t+N);
	reverse(t,t+N);
	ll ret = 0ll;
	ll a = 0ll;
	for(int i=0;i<K;i++){
		if(num[t[i].sec]==0)a++;
		num[t[i].sec]++;
		ret += t[i].fi;
	}
	ll ans = ret+a*a;
	vector<P> rem;
	for(int i=K;i<N;i++){
		if(num[t[i].sec]==0){
			rem.pb(t[i]);
			num[t[i].sec]++;
		}
	}
	for(int i=0;i<rem.size();i++)num[rem[i].sec]--;
	int cnt = 0;
	for(int i=0;i<K;i++){
		int idx = K-1-i;
		if(num[t[idx].sec]==1)continue;
		if(cnt>=rem.size())break;
		num[t[idx].sec]--;
		ret -= t[idx].fi;
		num[rem[cnt].sec]++;
		ret += rem[cnt].fi;
		cnt++;
		a++;
		ans = max(ans,ret+a*a);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j,k,x,y,z,m,n,t,a,b,l,r;
    cin>>n;
    bool f=0;
    ll cnt=0;
    for(i=0; i<n; i++)
    {
        cin>>a>>b;
        if(a==b)
        {
            cnt++;
            if(cnt>=3)
                f=1;
        }
        else
            cnt=0;
    }
    if(f)
        cout<<"Yes"<<'\n';
    else
        cout<<"No"<<'\n';
}









Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;
typedef long long ll;

class Mod {

public:
    ll MOD_;

    Mod(ll mod) { MOD_ = mod; }

    ll add(ll a, ll b) { return (a + b) % MOD_; }
    ll sub(ll a, ll b) { return (a - b + MOD_) % MOD_; }
    ll mul(ll a, ll b) { return (a * b) % MOD_; }
    
    ll pow(ll a, ll b) {
        ll res = 1;
        while (b > 0) {
            if (b & 1) res = mul(res, a);
            a = mul(a, a);
            b >>= 1;
        }
        return res;
    }

    ll inv(ll a) {
        ll b = MOD_;
        ll u = 1, v = 0;
        while (b > 0) {
            ll t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD_;
        if (u < 0) u += MOD_;

        return u;
    }


    ll *fac_, *fac_inv_, *inv_;
    int MAX_;

    void bc_init(int max) {
        MAX_ = max;
        fac_ = new ll[MAX_ + 1];
        fac_inv_ = new ll[MAX_ + 1];
        inv_ = new ll[MAX_ + 1];

        fac_[0] = 1;
        fac_[1] = 1;
        fac_inv_[0] = 1;
        fac_inv_[1] = 1;
        inv_[0] = 0;
        inv_[1] = 1;
        for (int i = 2; i <= MAX_; i++) {
            fac_[i] = mul(fac_[i-1], i);
            inv_[i] = MOD_ - (inv_[MOD_ % i] * (MOD_ / i)) % MOD_;
            fac_inv_[i] = fac_inv_[i - 1] * inv_[i] % MOD_;
        }
    }

    ll bc(ll n, ll k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return mul(fac_[n], mul(fac_inv_[k], fac_inv_[n-k]));
    }
};


int main()
{
    ll n, m, k;
    cin >> n >> m >> k;

    Mod mod(1000000007);

    ll a = mod.mul(n, mod.mul(m+1, m-1));
    ll b = mod.mul(m, mod.mul(n+1, n-1));
    ll c = mod.add(a, b);
    ll d = mod.mul(c, mod.mul(n, m));
    ll e = mod.mul(d, mod.inv(6));

    //cout << e << endl;

    mod.bc_init(n*m - 2);

    cout << mod.mul(e, mod.bc(n*m - 2, k - 2)) << endl;

    return 0;
}



Measured memory_bytes: 4992