akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(9), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e5 + 9, M = 5e2 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

vector<int> adj[N];

ll mem[N][2];
ll add(ll a, ll b) {
  a += b;
  if(a >= MOD)
    a -= MOD;
  if(a < 0)
    a += MOD;
  return a;
}

ll mul(ll a, ll b) {
  return (a % MOD) * (b % MOD) % MOD;
}

void dfs(int node, int par) {
  mem[node][0] = 1, mem[node][1] = 1;
  for(int it: adj[node]) {
    if(it == par) continue;
    dfs(it, node);
    ll temp = mem[node][0];
    mem[node][0] = add( mul(temp, mem[it][0]), mul(temp, mem[it][1]));
    mem[node][1] = mul(mem[node][1], mem[it][0]);
  }
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, u, v;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, -1);
  cout << add(mem[1][0], mem[1][1]);
  return 0;
}


Measured memory_bytes: 14208
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val s = sc.next().toCharArray.sorted.mkString
    val ans = if (s == "abc") {
      "Yes"
    } else {
      "No"
    }

    println(ans)
  }

}



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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            
            //入力読取。
            string strBreak = "-";
            List<string> getWordList = new List<string>();
            while(true){
                string strTarget = Console.ReadLine();
                if(strBreak == strTarget){
                    break;
                }
                string strTurn = Console.ReadLine();
                int intTurn = int.Parse(strTurn);
                List<string> timesList = new List<string>();
                for(int turn = 0; turn < intTurn; turn++){
                    timesList.Add(Console.ReadLine());
                }
                
                Shaffule insS = new Shaffule(strTarget, intTurn, timesList);
                string strWord = insS.GetWord();
                getWordList.Add(strWord);
           
            }
           
            //出力
            foreach(string answer in getWordList){
               Console.WriteLine(answer); 
            }
            
        }
        
    }
    
    class Shaffule{
        
        private string strWord;
        private int intTurn;
        private List<string> timesList;
        
        public Shaffule(string strWord, int intTurn, List<string> timesList){
            this.strWord = strWord;
            this.intTurn = intTurn;
            this.timesList = timesList;
            SetWord();
        }
        
        private void SetWord(){
        
            for(int listIndex = 0; listIndex < timesList.Count(); listIndex++){
                int intTimes = int.Parse(timesList[listIndex]);
                char[] wordArray = strWord.ToCharArray();
                
                //シャッフルした文字列の前部分。
                string strTemp = "";
                for(int shaffuleTime = intTimes; shaffuleTime < wordArray.Length; shaffuleTime++){
                    strTemp += wordArray[shaffuleTime].ToString();
                }
                
                //シャッフルした文字列の後ろ部分。
                for(int shaffuleTime = 0; shaffuleTime < intTimes; shaffuleTime++){
                    strTemp += wordArray[shaffuleTime].ToString();
                }
                strWord = strTemp;
            }
            
        }
        
        public string GetWord(){
            
            return strWord;
            
        }
    }

}



Measured memory_bytes: 20276
import sys

class UnionFind:
    def __init__(self, size):
        self.parent = [-1 for i in range(size)]#非負なら親ノード，負ならグループの要素数

    def root(self, x): #root(x): xの根ノードを返す．
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x]) #xをxの根に直接つなぐ
            return self.parent[x]

    def merge(self, x, y): #merge(x,y): xのいるグループと$y$のいるグループをまとめる
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.parent[x] > self.parent[y]: #xの要素数がyの要素数より「小さい」とき入れ替える
            x,y=y,x
        self.parent[x] += self.parent[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        return True

    def issame(self, x, y): #same(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)
        
    def size(self,x): #size(x): xのいるグループの要素数を返す
        return -self.parent[self.root(x)]


n, m = map(int, input().split())
bridges = list(sys.stdin)
bridges.reverse()
buf = [n * (n - 1) // 2]
uft = UnionFind(n)
for line in bridges[:-1]:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    if uft.issame(a, b):
        buf.append(buf[-1])
        continue
    ra = uft.size(a)
    rb = uft.size(b)
    buf.append(buf[-1] - ra * rb)
    uft.merge(a, b)
buf.reverse()
print('\n'.join(map(str, buf)))
    
    
    
    
    





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

int main()
{long long n,q,l;
 while(cin>>n)
 {if(n%10==3)
  cout<<"bon"<<endl;
  else if(n%10==0||n%10==1||n%10==6||n%10==8)
  cout<<"pon"<<endl;
  else
  cout<<"hon"<<endl;
  
 }
 return 0;
 } 

Measured memory_bytes: 3620
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

int64 dp[3000][3000][4];

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

  int r, c, k; cin >> r >> c >> k;
  int val[r][c];
  fill(val[0], val[r], 0);
  for (int i = 0; i < k; ++i) {
    int x, y, z; cin >> x >> y >> z;
    --x; --y;
    val[x][y] = z;
  }

  if (val[0][0] != 0) dp[0][0][1] = val[0][0];

  for (int i = 0; i < r; ++i) {
    for (int j = 0; j < c; ++j) {
      if (i == 0 && j == 0) continue;

      if (val[i][j] != 0) {
        if (i > 0) {
          for (int l = 0; l < 4; ++l) dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][l]);
          for (int l = 0; l < 4; ++l) dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][l] + val[i][j]);
        }
        if (j > 0) {
          dp[i][j][0] = max(dp[i][j][0], dp[i][j - 1][0]);
          for (int l = 1; l < 4; ++l) {
            dp[i][j][l] = max({dp[i][j][l], dp[i][j - 1][l], dp[i][j - 1][l - 1] + val[i][j]});
          }
        }
      } else {
        if (i > 0) {
          for (int l = 0; l < 4; ++l) dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][l]);
        }
        if (j > 0) {
          for (int l = 0; l < 4; ++l) dp[i][j][l] = max(dp[i][j][l], dp[i][j - 1][l]);
        }
      }
    }
  }

  int64 ans = 0;
  for (int i = 0; i < 4; ++i) ans = max(ans, dp[r - 1][c - 1][i]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 319984
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<stack>
#include<queue>
#include<string>
#include<deque>
#include<set>
#include<vector>
#include<map>
//#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int num[55];

int main()
{
    IOS
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    	cin>>num[i];
    int ans = -100000000;
    for(int a=0;a<=k;a++)
    {
    	for(int b=0;b<=k;b++)
    	{
    		for(int c=0;c<=k;c++)
    		{
    			if((a + b + c)<=k && (a + b) >= c && (a + b) <= n)
    			{
    				priority_queue<int>q;
    				for(int i=0;i<a;i++) q.push(num[i]);
    				
    				for(int i=0;i<b;i++) q.push(num[n-i-1]);
    				
    				int sum = 0;
    				for(int i=0;i<a+b-c;i++)
    				{
    					sum += q.top();
    					q.pop();
					}
					ans = max(ans,sum);
				}
			}
		}
	}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {

        new Main().solve();
    }

    void solve(){

        long N, A, B;

        Scanner sc = new Scanner(System.in);
        N = sc.nextLong();
        A = sc.nextLong();
        B = sc.nextLong();
        sc.close();

        long numOfblue;

        numOfblue = N / (A + B);
        numOfblue = numOfblue * A;

        if(N % (A + B) >= A){
            numOfblue = numOfblue + A;
        }
        else{
            numOfblue = numOfblue + N % (A + B);
        }

        System.out.println(numOfblue);
    }

       
}

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

#define MAX 100

void intiallize();
int isEmpty();
int isFull();
void push(int x);
int pop();

int top;
int a[MAX];

int main(){
	int x,a,b;
	char s[100];

	intiallize();

	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(s[0]=='-'){
			a=pop();
			b=pop();
			push(b-a);
		}else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			x=atoi(s);
			push(x);
		}
	}

	printf("%d\n",pop());

	return 0;
}

void intiallize(){
	top=0;
}

int isEmpty(){
	if(top==0){
return 1;
}else return 0;
}

int isFull(){
	if(top>MAX-1){
         return 1;
}else return 0;
}

void push(int x){
	if(isFull()){
		exit(1);
	}
	top++;
	a[top]=x;
}

int pop(){
	if(isEmpty()){
		exit(2);
	}
	top--;
	return a[top+1];
}

Measured memory_bytes: 548
#Fukushimaken: 
from heapq import heappop, heappush
OUT, IN = 0, 1
def P(i):
    return 31 if i % 5 == 1 else 3

def M(i):
    return 17 * (i % 2) + 3 * (i % 3) + 19

def check(c, n):
    for i in xrange(16):
        if (c >> i) & n == 0:
            return i
    return None

ans = [-1] * 100 + [0]
eq = map(lambda i: (i * 5, i, IN, None), xrange(100))
c = 1 << 17
while len(eq) != 0:    
    m, n, et, i = heappop(eq)
    if et == IN:        
        p = P(n)
        i = check(c, p)
        if ans[n-1] != -1 and i is not None:
            c = c | (p << i)
            ans[n] = m - n * 5
            heappush(eq, (m + M(n), n, OUT, i))
        else:
            heappush(eq, (m + 1, n, IN, None)) #
    else:        
        p = P(n)
        c = c ^ (p << i)

while True:
    try:
        n = input()
        print ans[n]
    except:
        break

Measured memory_bytes: 4520
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n,m;
int U[2010][2010];
int D[2010][2010];
int L[2010][2010];
int R[2010][2010];
char c[2010][2010];
int t;
int res=0; 
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=0;i<n;i++) scanf("%s",&c[i]);
	for (int i=0;i<n;i++)
	{
		t=0;
		for (int j=0;j<m;j++)
		{
			if (c[i][j]=='.') t++;
			else t=0;
			L[i][j]=t;
		}
		t=0;
		for (int j=m-1;j>=0;j--)
		{
			if (c[i][j]=='.') t++;
			else t=0;
			R[i][j]=t;
		}
	}
	for (int j=0;j<m;j++)
	{
		t=0;
		for (int i=0;i<n;i++)
		{
			if (c[i][j]=='.') t++;
			else t=0;
			U[i][j]=t;
		}
		t=0;
		for (int i=n-1;i>=0;i--)
		{
			if (c[i][j]=='.') t++;
			else t=0;
			D[i][j]=t;
		}
	}
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++)
		{
			if (c[i][j]=='#') continue;
			res=max(res,U[i][j]+D[i][j]+L[i][j]+R[i][j]);
		}
	}
	printf("%d",res-3);
	return 0;
}

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

struct vec{
    double x,y;
};

const double eps = 0.00001;

int main(void){
    vec p0,p1,p2,v1,v2;
    int q;
    cin >> p0.x >> p0.y >> p1.x >> p1.y;
    v1.x=p1.x-p0.x; v1.y=p1.y-p0.y;
    cin >> q;
    cout.precision(10);
    cout.setf(std::ios::showpoint);
    for(int i=0;i<q;i++){
        cin >> p2.x >> p2.y;
        v2.x=p2.x-p0.x; v2.y=p2.y-p0.y;
        double p=v1.x*v2.y-v1.y*v2.x;
        if(p>eps){
            cout << "COUNTER_CLOCKWISE" << endl;
            continue;
        }
        if(p<-eps){
            cout << "CLOCKWISE" << endl;
            continue;
        }
        if(v1.x!=0){
            p=v2.x/v1.x;
        }else{
            p=v2.y/v1.y;
        }
        if(p<0){
            cout << "ONLINE_BACK" << endl;
        }else if(p<=1){
            cout << "ON_SEGMENT" << endl;
        }else{
            cout << "ONLINE_FRONT" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3152
//### In The Name Of GOD ###

// 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

const int MOD = 1000000007;
const int INF = 100 * 1000 + 20;
const int MAXN = 100 * 1000 + 20;
const int MLOG = 18;
const int NMAX = 60;

//#define int unsigned short
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define ct(x) const_cast<const int&>(x)

int f[MAXN],_sz[MAXN],whr[MAXN];

int fad(int x){
	if(x==f[x])
		return x;
	return fad(f[x]);
}

void mrg(int x, int y){
	if(x == y)
		return ;
	if(_sz[x] >_sz[y]){
		f[y] = x;	
	}else if(_sz[x] == _sz[y]){
		f[x] = y;
		_sz[y]++;
	}else{
		f[x] = y;
	}
}

signed main(){
	IO;
	int n, m;
	cin >> n >> m;
	int p[ct(n)];
	for(int i = 0; i < n; i++){
		cin >> p[i];
		p[i]--;
		whr[p[i]] = i;
	}
	for(int i = 0; i < n; i++){
		f[i] = i;
		_sz[i] = 1;
	}	
	for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		mrg(fad(x), fad(y));
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(fad(i) == fad(whr[i])){
			ans++;
		}
//		cout << fad(i);
	}
	cout << ans;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func main() {

	for {
		var n, x int
		var count int = 0

		fmt.Scanln(&n, &x)

		if (n == 0) && (x == 0) {
		break
		}

		for i := n; i > (x+2)/3; i-- {
			if i <= x-3 {
				for j := x - (i + 1); j > (x - i)/2; j-- { 
					if i > j { 
						count++
					}
				}
			}
		}

	fmt.Println(count)
	}

}


Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool f[100];
int n;
int tr[100];


int trmin(){
  int res=10000,resi;
  for(int i=0;i<n;i++)
    if(f[i]==0 && tr[i]<res) res = tr[i],resi=i;
  return resi;
}


int main (){

  int mp[100][100];

  cin >> n;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      cin >> mp[i][j];

  for(int i=0;i<n;i++) f[i]=0;
  for(int i=0;i<n;i++) tr[i]=10000;
  tr[0] = 0;
  int trsum=0;

  for(int k=0;k<n;k++){
    int r=trmin();
    f[r]=1;
    trsum+=tr[r];

    for(int i=0;i<n;i++) 
      if(mp[r][i]!=-1 && f[i]==0)
	tr[i] = min(tr[i],mp[r][i]);
  }
  cout<<trsum<<endl;

  return 0;
}

Measured memory_bytes: 1196
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("nuroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------


struct mint {
	ll x;
	mint(ll x=0):x(x%mod){}

	bool operator==(const mint a)const{return x==a.x;}
	bool operator!=(const mint a)const{return x!=a.x;}
	bool operator>=(const mint a){return (x >= a.x)? 1: 0;}
	bool operator<(const mint a){return !(*this>=a);}
	bool operator>(const mint a){return (x > a.x)? 1:0;}
	bool operator<=(const mint a){return !(*this>a);}
	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;  //2 square
		if (t&1) a *= *this; 
		return a;
	}
	// for prime mod
	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;
	}
};

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

int n;
map<PLL, int> mp;
int both0 = 0;

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

    cin >> n;
	
    FOR(i,1,n) {
        ll a,b; cin >> a >> b;
		if (!a and !b) {
			both0++; continue;
		}
		if (!a) {
			mp[{0, -1}]++;
			continue;
		}
		if (!b) {
			mp[{1,0}]++;
			continue;
		}

		ll gd = gcd(abs(a),abs(b));
		a /= gd; b /= gd;
		if(a < 0) {
			a = -a;
			b = -b;
		}
		mp[{a,b}]++;
    }


	mint ans = mint(1);
	for(auto [k, v]: mp) {
		// cout << k.first << " " << k.second << " " << v << endl;
		// ll ca = abs(k.second);
		// ll cb = k.first*(k.first*k.second<0?1:-1);
		PLL p;
		if(k.second < 0) p = {-k.second, k.first};
		else p = {k.second, -k.first};
		// cout << ca << " " << cb << " " << v << endl;
		// PII p = {ca, cb};
		// if(k == p) ans *= mint(2).pow(v); 
		if(mp.count(p)) {
			if (k.second < 0) continue;
			ans *= mint(2).pow(v) + mint(2).pow(mp[p]) - 1;
		}
		else ans *= mint(2).pow(v);
		// cout << "ans" << ans.x << endl;
	}

	ans += both0;
	ans -= 1;
	cout << ans.x << endl;
	return 0;
}


Measured memory_bytes: 16100
#include<iostream>
#include<algorithm>
#define MAX 100000
using namespace std;

int n, A[MAX + 1], L[MAX];

int lis() {
    L[0] = A[0];
    int length = 1;
    
    for ( int i = 1; i < n; i++ ) {
        if ( L[length - 1] < A[i] ) {
            L[length++] = A[i];
        } else {
            *lower_bound(L, L + length, A[i]) = A[i];
        }
    }
    
    return length;
}

int main() {
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> A[i];
    }
    
    cout << lis() << endl;
    
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <limits.h>

using namespace std;

void out(const int n, std::string* a)
{
    for(int i=0; i<n; i++){
        cout << a[i];
        if(i != n-1) cout << " ";
    }
    cout << endl;
}

int BubbleSort(const int n, std::string* a)
{
    int cnt = 0;
    for(int i=0; i<n; i++){
        for(int j=n-1; j>i; j--){
            if(a[j-1][1]>a[j][1]){
                std::string tmp = a[j-1];
                a[j-1] = a[j];
                a[j] = tmp;
                cnt++;
            }
        }
    }
    return cnt;
}

int SelectionSort(const int n, std::string* a)
{
    int cnt = 0;
    for(int i=0; i<n; i++){
        int min_index = i;
        for(int j=i+1; j<n; j++){
            if(a[min_index][1] > a[j][1]){
                min_index = j;
            }
        }
        if(min_index != i){
            std::string tmp = a[i];
            a[i] = a[min_index];
            a[min_index] = tmp;
            cnt++;
        }
    }
    return cnt;
}

void chackStable(const int n, std::string* org, std::string* sorted)
{
    std::map<int, std::vector<char>> v1;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(sorted[i][1] == sorted[j][1]){
                int num = sorted[i][1];
                int letter = sorted[i][0];
                v1[num].push_back(letter);
            }
        }
    }
    std::map<int, std::vector<char>> v2;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(org[i][1] == org[j][1]){
                int num = org[i][1];
                int letter = org[i][0];
                v2[num].push_back(letter);
            }
        }
    }
    for(int i=0; i<v1.size(); i++){
        for(int j=0; j<v1[i].size(); j++){
            if(v1[i][j] != v2[i][j]){
                cout << "Not stable" << endl;
                return;
            }
        }
    }
    cout << "Stable" << endl;
}

int main()
{
    int n;
    cin >> n;
    std::string aa[n];
    for(int i=0; i<n; i++){
        cin >> aa[i];
    }
    std::string a[n];
    
    std::copy(aa, aa + n, a);
    int cnt1 = BubbleSort(n, a);
    out(n, a);
    chackStable(n, aa, a);
    
    std::copy(aa, aa + n, a);
    int cnt2 = SelectionSort(n, a);
    out(n, a);
    chackStable(n, aa, a);

}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

struct edge{ll to, cost;}; //edgeパラメータ
typedef pair<ll,ll> P;
struct graph{
  ll N; //ノードの個数
  ll M; //辺の個数
  vector<vector<edge> > G; //G[辺の元]((.to辺の先,.costコスト),...)
  vector<ll> d; // dist[n] = ノードnまでのの重み長さ
  ll repeat; // 何回更新したか

  graph(ll n){ //グラフ生成時
    N = n;
    M = 0;
    G.resize(N); //Edge情報
    d.resize(N); //Node情報,ans
    rep(i,N){d[i] = INF;}
  }

  void add_edge(ll s, ll t, ll cost){
    G[s].emplace_back((edge){t, cost});
    ++M;
  }

  bool bellman_ford(ll s, ll g){
    d[s] = 0;
    repeat=0;

    while(true) {
      bool update = false;
      ++repeat;
      rep(v, N) {
        if(d[v] == INF) continue;
        rep(i, G[v].size()){
          edge& E = G[v][i];
          if( d[E.to] > d[v] + E.cost) {
            d[E.to] = max((ll)-INF, d[v] + E.cost);
            if(repeat>M){ //負閉路が回っている箇所からgoalに出るか調べる
              d[E.to]= -INF;
            }
          }
        }
      }
      if(repeat>=2*M){
        if(d[g]> -INF){
          return true;
        }
        else{ //経路に負閉路がある
          return false;
        }
      }
    }
  }
};


void Main(){

  ll n,M;

  cin>>n>>M;

  graph g(n);

  rep(i,M){
    ll a,b,c;
    cin>>a>>b>>c;
    g.add_edge(a-1,b-1,-c);
  }

  if(g.bellman_ford(0, n-1)){
    cout<< -g.d[n-1]<<"\n";
  }
  else{
    cout<< "inf"<<"\n";
  }



}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 384
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a,b;
    cin>>a;
    cin>>b;
    cout<<6-(a+b)<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    static int N, W;

    static int get(int[][] dp, int n, int w, int a){
        if(n<0 || n>=N || w<0 || w>W)
            return 0;
        else
            return dp[n][w] + a;
    }

    static int max(int a, int b, int c){
        if(a>b && a>c)
            return a;
        else if(b>c)
            return b;
        else 
            return c;
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        W = sc.nextInt();
        int[][] dp = new int[N][W+1];

        int tv = sc.nextInt();
        int tw = sc.nextInt();
        for(int w=0; w<=W; w++){
            if(w<tw)
                dp[0][w] = 0;
            else
                dp[0][w] = tv;
        }

        for(int n=1; n<N; n++){
            tv = sc.nextInt();
            tw = sc.nextInt();
            for(int w=0; w<=W; w++){
                dp[n][w] = max(get(dp,n-1,w-tw,tv), get(dp,n-1,w,0), get(dp,n,w-1,0));
            }
        }
        System.out.println(dp[N-1][W]);

        // for(int[] arr: dp) {
        //     for(int i: arr){
        //         System.out.print(i + " ");
        //     }
        //     System.out.println();
        // }
    }
}


Measured memory_bytes: 31348
C=[]
for _ in range(3):
    C.append(list(map(int,input().split())))

from itertools import combinations,product

flag=True
for (i,j),(k,l) in product(combinations(range(3),2),repeat=2):
    flag = flag and (C[k][i]-C[k][j] == C[l][i]-C[l][j])
    flag = flag and (C[i][k]-C[j][k] == C[i][l]-C[j][l])
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38520
a = [list(input()) for _ in range(3)]
t = 0
for i in range(10 ** 9):
    if a[t] != []:
        tmp = a[t].pop(0)
        if tmp == "a":
            t = 0
        elif tmp == "b":
            t = 1
        else:
            t = 2
    else:
        print("A" if t == 0 else "B" if t == 1 else "C")
        exit()

Measured memory_bytes: 3064
N, M = map(int, input().split())
student = []
for i in range(N):
    x_y = list(map(int, input().split()))
    student.append(x_y)
    
check = []
for i in range(M):
    x_y = list(map(int, input().split()))
    check.append(x_y)
    
for i in student:
    cnt = []
    for j in check:
        dis = abs(i[0] - j[0]) + abs(i[1] - j[1])
        cnt.append(dis)
    print(cnt.index(min(cnt)) + 1)

Measured memory_bytes: 3064
r, c = map(int, input().split())
matrix = []
for i in range(r):
    l = list(map(int, input().split()))
    l.append(sum(l))
    matrix.append(l)
matrix.append([sum(i) for i in zip(*matrix)])
for l in matrix:
    print(" ".join(str(n) for n in l))

Measured memory_bytes: 6732
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli mod = 1e9 + 7;

int main(){
	vector<bool> prime(1000000, true);
	prime[0] = prime[1] = false;
	for(int i=2; i*i<1000000; i++){
		if(!prime[i]) continue;
		for(int j=i*2; j<1000000; j+=i){
			prime[j] = false;
		}
	}
	vector<int> isa(100001, 0);
	for(int i=3; i<=100000; i+=2){
		if(prime[i] and prime[(i+1)/2]) isa[i]++;
	}
	for(int i=0; i<100000; i++){
		isa[i+1] += isa[i];
	}

	int q;
	cin >> q;
	for(int i=0; i<q; i++){
		int l,r;
		cin >> l >> r;
		cout << isa[r] -isa[l-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int i,j,k,n,m,x,y,z,flag;
struct yea{
	int x,y;
	char num[20];
} a[10000];
char ch;
bool cmp(struct yea a,struct yea b)
{
	if (a.x<b.x) return true;
 	return false;
}


int main()
{
	
	while(1)
	{
		scanf("%d%d",&n,&m);
		if ((n==0)&&(m==0)) break;
		scanf("%c",&ch);
		for(i=0;i<n;i++)
		{
			scanf("%s%d%d",&a[i].num,&x,&y);
			a[i].x=y-x+1;
			a[i].y=y;
		}
		sort(a,a+n,cmp);
		for(i=0;i<m;i++)
		{
			scanf("%d",&x);
			flag=-1;
			for(j=0;j<n;j++)
			{
				if (a[j].x<=x && x<= a[j].y)
				{
					flag=j;
					break;
				}
				if (a[j].x>x) break;
			}
			if (flag==-1) printf("Unknown\n");
			else {
				printf("%s %d\n",a[flag].num,x-a[flag].x+1);
			}
		}
	}
	return 0;
	
}

Measured memory_bytes: 1256
even = [0, 0]
odd = [0, 0]
gets.chomp.chars.map(&:to_i).each_with_index{|c, i|
    if i % 2 == 0
        even
    else
        odd
    end[c] += 1
}
puts [even, odd.reverse].transpose.map{|it| it.inject(:+)}.min


Measured memory_bytes: 7676
#include <cstdio> 
using namespace std;
#define abs(_x) (_x > 0 ? _x : -(_x)) 
int main(){
	register int n, i, a, maxabs, reala, pos;
	scanf("%d", &n);
	maxabs = pos = 0;
	for (i = 1; i <= n; ++i) {
		scanf("%d", &a);
		if (maxabs < abs(a)) maxabs = abs(a), reala = a, pos = i;
	}
	if (pos == 0) {
		puts("0");
	}
	else {
		printf("%d\n", (n - 1) << 1);
		for (i = 1; i <= n; ++i) if (i != pos) printf("%d %d\n", pos, i);
		if (reala > 0) {
			for (i = 1; i < n; ++i) printf("%d %d\n", i, i + 1);
		}
		else {
			for (i = n; i > 1; --i) printf("%d %d\n", i, i - 1);
		}
	}
	return 0;
}

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

using namespace std;

const int INF = (int)1e9;

int main()
{
    int n; scanf("%d", &n);

    vector<int> dp(n + 1, INF);

    dp[1] = 1;
    for (int i = 6; i <= n; i *= 6) dp[i] = 1;
    for (int i = 9; i <= n; i *= 9) dp[i] = 1;

    for (int i = 1; i <= n; i++){
        if (i < n) dp[i + 1] = min(dp[i + 1], dp[i] + 1);
        int a = 6;
        int b = 9;
        while(i + min(a, b) <= n){
            if (a <= b){
                dp[i + a] = min(dp[i + a], dp[i] + 1);
                a *= 6;
            }
            else{
                dp[i + b] = min(dp[i + b], dp[i] + 1);
                b *= 9;
            }
        }
    }

    printf("%d\n", dp[n]);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int N, L;
	cin >> N >> L;
	vector<string> S(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> S[i];
	}

	sort(S.begin(), S.end());

	for (auto i = 0; i < N; ++i)
	{
		cout << S[i];
	}
	cout << endl;

	return 0;
}

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

int a,b,c,n,d,x[100][100],ans;

int  main(){
    cin>>n>>d;
    for(int i=0;i<n;i++){
        for(int u=0;u<d;u++){
            cin>>x[i][u];
        }
    }
    for(int i=0;i<n;i++){
        for(int u=i+1;u<n;u++){
            double gg=0;
            for(int q=0;q<d;q++){
                gg+=(x[i][q]-x[u][q])*(x[i][q]-x[u][q]);
            }
            gg=sqrt(gg);
            if(ceil(gg)==floor(gg))ans++;
        }
    }
    cout<<ans<<endl;



}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 

#include <bits/stdc++.h>
using namespace std;

int main(void)
{
    int n,j=0;
    std::cin >> n;
    int a[n];
    rep(i,n)std::cin >>a[i] ;
    for(int i=1;i<n-1;i++){
        if((a[i-1]<a[i]&&a[i]<a[i+1])||(a[i-1]>a[i]&&a[i]>a[i+1]))j++;
    }std::cout << j << std::endl;
}


Measured memory_bytes: 256
#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(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main(){
  int n; cin >> n;
  int h[n+1]; FOR(i, 1, n+1) cin >> h[i];
  int cost[n+1]{};

  FOR(i, 1, n+1){
    if(i == 1) {
      continue;
    } else if(i == 2) {
      cost[i] = cost[i-1] + abs(h[i] - h[i-1]);
    } else {
      cost[i] = min(cost[i-1] + abs(h[i] - h[i-1]), cost[i-2] + abs(h[i] - h[i-2]));
    }
  }

  cout << cost[n] << endl;

  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import itertools
import math
import sys

INF = float('inf')
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]"):
    t = sum(A)/4/M
    return [YES, NO][len([a for a in A if a >= t]) < M]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(f'{solve(N, M, A)}')


if __name__ == '__main__':
    main()


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


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18



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

	for (int i = 0; i < n; i++) {
		vector<int>e(3);
		
		cin >> e[0] >> e[1] >> e[2];

		sort(e.begin(), e.end());

		if (e[0] * e[0] + e[1] * e[1] == e[2] * e[2]) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
		
	}
	return 0;
}




Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int comp(pair<int,int>&a,pair<int,int>&b)
{
  return a.first<b.first;
}
  
int main()
{
  int n;
  ll k;
  cin>>n>>k;
  vector<pair<int,int> >a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i].first>>a[i].second;
  }
  sort(a.begin(),a.end(),comp);
  //cout<<a[0].first<<endl;
  ll sum=0;
  for(int i=0;i<n;i++)
  {
    sum+=a[i].second;
    if(sum>=k)
    {
      cout<<a[i].first<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn readu() -> usize {
    read::<usize>()
}

#[allow(dead_code)]
fn readi() -> i32 {
    read::<i32>()
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut ac = a.clone();
    ac.sort();
    let m = ac[n - 1];
    let mn = ac[n - 2];

    for &ai in &a {
        if ai == m {
            println!("{}", mn);
        } else {
            println!("{}", m);
        }
    }
}


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

int func(int x)
{
    if(x%2==0)
    {
        return x/2;
    }
    else
    {
        return 3*x+1;
    }
}
int main()
{
    int s;
    cin>>s;
    if(s==1||s==2||s==4)
    {
        cout<<4<<endl;
        return 0;
    }
    
    int a[100001];
    for(int i=0;i<100001;i++)
    {
        if(i==0)
        {
            a[i]=s;
        }
        else
        {
            a[i]=func(a[i-1]);
        }
    }
    int count=0;
    
    for(int i=0;i<100001;i++)
    {
        if(a[i]==4)
        {
            count++;
        }
        if(count==2)
        {
            cout<<i+1<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
int main()
{
	ll n,k; cin>>n>>k;
	
	pair<ll,ll>p1[n+1],p2[n+1],p3[n+1];
	
	for(ll i=1;i<=n;i++)
	{
		ll x;
		cin>>x;
		p1[i].f=x;
		p1[i].s=i;
		
		p2[i].f=0;
		p2[i].s=i;
		
		p3[i].f=k;
		p3[i].s=i;
	}
	
	ll ans=0;
	
	for(ll i=1;i<=n;i++)
	{
		ll x=abs(p1[i].f-p2[i].f);
		
		ll y=abs(p1[i].f-p3[i].f);
		
		ans=ans+2*min(x,y);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        //A <= 0.08x < A + 1
        //B <= 0.10x < B + 1
        
        int axmin = (int)(A / 0.08);
        int axmax = (int)((A+1) / 0.08);
        int bxmin = B * 10;
        int bxmax = (B+1) * 10;
        
        int ans = -1;
        for(int i = 1; i <= 1009; i++) {
            if((int)(0.08 * i) == A && (int)(0.1 * i) / 1 == B) {
                ans = i;
                break;
            }
        }
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{

    int A,B,C;
    cin>>A>>B>>C;

    int MAX = max(A,max(B,C));
    
    cout << MAX*10 + A+B+C - MAX <<endl;

    return 0;
}


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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    int N;
    cin >> N;
    int cnt[4];
    mem0(cnt);
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        if(s == "AC"){
            cnt[0]++;
        } else if(s == "WA"){
            cnt[1]++;
        } else if(s == "TLE"){
            cnt[2]++;
        } else {
            cnt[3]++;
        }
    }
    cout << "AC x " << cnt[0] << endl;
    cout << "WA x " << cnt[1] << endl;
    cout << "TLE x " << cnt[2] << endl;
    cout << "RE x " << cnt[3] << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<tuple>
#include<set>

using ull = unsigned long long;
template<class C,class T>
auto bs(const C& c, const T&key) {
	using ix_t = decltype(c.size());
	auto size = c.size();
	ix_t imin = 0;
	auto imax = size - 1;
	auto ip = (imax + imin) / 2;
	while (imin <= imax) {
		if (c[ip] == key) {
			return std::make_tuple(true, ix_t{ ip },c[ip]);
		}
		else if (c[ip] < key) {
			imin = ip + 1;
			ip = (imax + imin) / 2;
		}
		else if (key < c[ip]) {
			imax = ip - 1;
			ip = ( imax + imin ) / 2;
		}
	}
	return std::make_tuple(false, ix_t{ 0 },c[0]);
}

int main() {
	ull n{}, q{};
	std::vector<ull> s;//s is sorted
	ull qlog[50000]{};

	std::cin >> n;
	for (ull i{}; i < n; i++) {
		ull tmp; std::cin >> tmp;
		s.emplace_back(tmp);
	}
	
	//std::vector<ull> t;//
	std::set<ull> st;
	std::cin >> q;
	for (ull i{}; i < q; i++) {
		ull tmp; std::cin >> tmp;
		auto tpl = bs(s, tmp);
		if (std::get<0>(tpl)) {
			st.emplace( std::get<1>(tpl) );
		}
	}
	
	std::cout << st.size() << "\n";
/*	ull sum{};
	for (ull i{}; i < q : t) {
		auto t = bs(s, e);
//		if (std::get<0>(t))
	}

	ull sum{};
	/*
	for (const auto&e : qlog)
		if (e > 0)++sum;
	
	std::cout << sum << "\n";
*/
}


Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    ll n;
    cin>>n;
    ll f[n]={};
    for(ll x=1;x*x<=n;x++){
        for(ll y=1;y*y<=n;y++){
            for(ll z=1;z*z<=n;z++){
                ll t=x*x+y*y+z*z+x*y+y*z+z*x;
                if(t>n)break;
                f[t-1]++;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<f[i]<<endl;
    }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;


int main(){
	ll n;
	cin>>n;
    ll a[n];
    rep(i,0,n)cin>>a[i];

    ll st[110000]={0};

    rep(i,0,n){
        while(a[i]%2==0) {
            a[i]/=2;
            st[i]++;
            if(st[i]==2)break;
        }
    }
    ll x0=0,x2=0,x4=0;
    rep(i,0,n){
        if(st[i]==0) x0++;
        if(st[i]==1) x2++;
        if(st[i]==2) x4++;
    }
    ll p=x0+(x2%2)-1;
    if(x4>=p)cout<<"Yes";
    else cout<<"No";
  // cout<<x0<<" "<<x2%2<<" "<<x4<<" "<<p;
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;

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

    int x, y;
    cin >> x >> y;

    int ans = x + y/2;
    

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


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

using namespace std;

int main(){
    long long int x;
    cin >> x;
    long long int happy=0;
    while(x >= 500 || x >= 5){
        if(x >= 500){
            x -= 500;
            happy += 1000;
        }else{
            x -= 5;
            happy += 5;
        }
    }
    cout << happy << "\n";
    return 0;
}

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

using namespace std;

int main()
{
	int n,ca,cb,A,B;

	cin>>n;
	while(n>0){
		ca=cb=A=B=0;
		for(int i=0;i<n;i++){
			cin>>ca>>cb;
			if(ca>cb) A+=ca+cb;
			else if(cb>ca) B+=ca+cb;
			else{A+=ca;B+=cb;}
		}
		cout<<A<<" "<<B<<endl;
		cin>>n;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int solve(int a, int b, int c)
{
    vector<int> ans(3);
    ans[0] = a;
    ans[1] = b;
    ans[2] = c;
    sort(ans.begin(), ans.end());
    return ans[1];
}

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


Measured memory_bytes: 256
using System;

namespace AtCoderBeginnerContest096
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            var m = int.Parse(input[0]);
            var d = int.Parse(input[1]);

            Console.WriteLine( m > d ? m - 1 : m );
        }
    }
}


Measured memory_bytes: 11092
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <iostream>
#include <limits>
#include <algorithm>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <cmath>


using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
typedef stringstream ss;
const int mii = numeric_limits<int>::min();
const int mai = numeric_limits<int>::max();
const ll mil = numeric_limits<long long>::min();
const ll mal = numeric_limits<long long>::max();

#define REP(i, a, b) for(long long i=a; i<=b; ++i)
#define RREP(i, a, b) for(long long i=a; i>=b; --i)
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

int main(int argc, char **argv) {

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

    int n1l = a/0.08;
    int n1h = ((a+1)/0.08) - 1;
    int n2l = b/0.1;
    int n2h = ((b+1)/0.1) - 1;

    set<int> s1;
    set<int> s2;
    vi res;

    REP(i, n1l, n1h)
        if(i * 0.08 >= a && i > 0)
            s1.insert(i);
    REP(i, n2l, n2h)
        if(i * 0.1 >= b && i > 0)
            s2.insert(i);

    set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(), back_inserter(res));
    sort(res.begin(), res.end());

    /*int res = -1;

    REP(i, 1, 1008) {
        if(floor(i*0.08) == a && floor(i*0.1) == b) {
            res = i;
            break;
        }

    }*/

    if(res.empty())
        cout << "-1" << endl;
    else
        cout << *res.begin() << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[100010],ans=1,pre,INF=1000000000000000000;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	if(a[1]==0) {
		printf("0\n");
		return 0;
	}
	for(int i=1;i<=n;++i) {
		pre=ans;
		ans*=a[i];
		if(ans>INF||ans<pre) {
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4508
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n ;
	int odd=0;
	int even=0;
	int now;
	for(int i=1;i<=n;i++)
	{
		cin >> now;
		if(now%2)
			odd++;
		else
			even++;
	}
	if(odd%2)
		cout<<"NO"<<endl;
	else
		cout<<"YES"<<endl;
}

Measured memory_bytes: 256
s = gets.chomp!
if s[0] == s[1]
  puts "1 2"
  exit
end
(0..(s.length - 3)).each do |num|
  if s[num] == s[num + 1] || s[num + 1] == s[num + 2] || s[num] == s[num + 2]
    puts (num + 1).to_s + " " + (num + 3).to_s
    exit
  end
end
puts "-1 -1"


Measured memory_bytes: 1916