akhauriyash/Code-Regression huggingface dataset:
/*~~~~~~~~~~~~~~~~~ K++ code ~~~~~~~~~~~~~~~~~~~
in(n, m, X, Y)
in(x[n])
in(y[m])
if(Y-X<=1) out("War"); return 0
for(int i in  (X+1~Y)){
    if(max(x) < i <= min(y)) out("No War"); return 0
}
out("War")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

;;;
;
int main(){
  ;;;
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    ;
    int x[n];
    for(int i = 0; i < n; ++i) {cin >> x[i];};
    ;
    int y[m];
    for(int i = 0; i < m; ++i) {cin >> y[i];};
    ;
    if(Y-X<=1) {;;cout << ("War") << endl;; return (0);;};
    if(X+1<Y){;
        for(int i = X+1; i <= Y; ++i){;;;;
    int mx_0_ = x[0];
    for(int i_1_ = 0; i_1_ < sizeof(x)/sizeof(x[0]); ++i_1_){;
        if(mx_0_<x[i_1_]) {; mx_0_ = x[i_1_];};
    };
    int mn_4_ = y[0];
    for(int i_5_ = 0; i_5_ < sizeof(y)/sizeof(y[0]); ++i_5_){;
        if(mn_4_>y[i_5_]) {; mn_4_ = y[i_5_];};
    };
        if((mx_0_<i &&i <= mn_4_)) {;;cout << ("No War") << endl;; return (0);;};
    ;}
    ;}
    else {;
        for(int i = X+1; i >= Y; --i){;;;;
    int mx_2_ = x[0];
    for(int i_3_ = 0; i_3_ < sizeof(x)/sizeof(x[0]); ++i_3_){;
        if(mx_2_<x[i_3_]) {; mx_2_ = x[i_3_];};
    };
    int mn_6_ = y[0];
    for(int i_7_ = 0; i_7_ < sizeof(y)/sizeof(y[0]); ++i_7_){;
        if(mn_6_>y[i_7_]) {; mn_6_ = y[i_7_];};
    };
        if((mx_2_<i &&i <= mn_6_)) {;;cout << ("No War") << endl;; return (0);;};
    ;}
    ;};;;;
    cout << ("War") << endl;;
    ;
}

Measured memory_bytes: 888
/**
 * @brief : c++ code for AtCoder
 * @author: rk222
 * @created: 2019.05.04 20:58:05
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int n, a[200010], b[200010];
vector<int> g[200010];
int maxlen = -1;
int maxs = -1;

void dfs(int s, int len, int from) {
    if (g[s].size() == 1 && len > 0) {
        if (len > maxlen) {
            maxs = s;
            maxlen = len;
        }
        return;
    } else {
        len++;
        rep(i, g[s].size()) {
            int to = g[s][i];
            if (to == from) {
                continue;
            }
            dfs(to, len, s);
        }
    }
    return;
}

int main() {
    scanf("%d", &n);
    rep(i, n - 1) scanf("%d%d", &a[i], &b[i]);
    rep(i, n - 1) {
        g[a[i] - 1].pb(b[i] - 1);
        g[b[i] - 1].pb(a[i] - 1);
    }

    dfs(0, 0, 0);
    dfs(maxs, 0, 0);

    maxlen++;
    if (maxlen % 3 == 2) {
        printf("Second\n");
    } else {
        printf("First\n");
    }

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 25216
n = int(input())
a= list(map(lambda x: int(x),input().split()))
a_di = [i for i in a if i % 2 == 0]
count = 0
for j in range(len(a_di)) :
    if a_di[j] % 3 == 0 or a_di[j] % 5 == 0  :
        count += 1

if count == len(a_di) :
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
	char* c = (char*)malloc(sizeof(char)*6);
	for(int i = 0; i < 6; i++){
		cin >> c[i];
	}
	if(c[2] == c[3] && c[4] == c[5]) cout << "Yes";
	else cout << "No";
	
	cout << endl;
}

Measured memory_bytes: 3620
#define s(a,b) (t=a,a=b,b=t)
f(int*a){*a=(*a&7)<<4|*a>>4;}char p[9];m,a,b,c,t,r;main(n){while(scanf("%d",&n),n){r=1,a=97,b=82,c=67;while(n--){scanf("%s",p);m=*p-76;t=m%6==0?(s(b,c),f(m>0?&c:&b)):1<m&&m<8?(s(a,b),f(m^7?&b:&a)):(s(a,c),f(m>0?&c:&a));r+=a&7;}printf("%d\n",r);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) v.begin(), v.end()
//bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
//bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=200;
ll N,ans=0;
int main() {
  ll N;
  cin >> N;
  vl vec(MAX_N);
  rep(i, N) cin >> vec[i];

  sort(all(vec));
  reverse(all(vec));
  rep(i, N) ans+=vec[2*i];
  rep(i, N) ans-=vec[2*i+1];

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

Measured memory_bytes: 256
hex = {'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15}
num = input().split()
if( hex[num[0]] == hex[num[1]] ):print("=")
elif( hex[num[0]] < hex[num[1]] ):print("<")
else:print(">")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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 (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, d, x;
    cin >> r >> d >> x;
    rep (i, 10) {
        x = r * x - d;
        cout << x << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
# import copy

N = int(input())
X = list(map(int, input().split()))
# S_X = copy.copy(X)
S_X = sorted(X)
miX = S_X[N // 2 - 1]
mi1X = S_X[N // 2]
# print(S_X, X)
# print(miX, mi1X)

# print(miX, mi1X)
# print(X)
for a in X:
    if(a <= miX):
        print(mi1X)
    else:
        print(miX)

Measured memory_bytes: 25620
#!/usr/bin/env python
# coding: utf-8

# In[43]:


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


# In[45]:


# if sum(A) < sum(B):
#     ans = -1
# else:
#     diff_plus = sorted([B[i]-A[i] for i in range(N) if B[i]-A[i]>0])
#     diff_minus = sorted([A[i]-B[i] for i in range(N) if A[i]-B[i]>0],reverse=True)
#     if len(diff_plus) > 0:
#         j = 0
#         cnt = len(diff_plus)
#         for i,x in enumerate(diff_plus):
#             while sum(diff_minus[:j+1]) < x:
#                 j += 1
#             diff_minus[j] = sum(diff_minus[:j+1])-x
#             for k in range(j):
#                 diff_minus[k] = 0
#         ans = j+1+cnt
#     else:
#         ans = 0
# print(ans)


# In[47]:


husoku = [a-b for a, b in zip(A, B) if a-b < 0]
amari = [a-b for a, b in zip(A, B) if a-b > 0]
amari.sort(reverse=True)
 
H = abs(sum(husoku))
if len(husoku) == 0:
    ans = 0
elif H > sum(amari):
    ans = -1
else:
    for i, a in enumerate(amari, start=1):
        H -= a
        if H <= 0:
            ans = len(husoku) + i
            break
print(ans)


# In[ ]:






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

int main(){
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  
  for(int i=0;i<n;i++){
    cout << s.at(i);
    cout << t.at(i);
  }
  cout<<endl;
}

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

int main(){
  ll k,n,s=0;
  cin>>n>>k;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(ll i=k;i<n;i++) s+=a[i];
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m+1,0);
  rep(i,n){
    int k; cin >> k;
    rep(j,k){
      int like; cin>>like;
      a[like]++;
    }
  }
  
  int ans=0;
  rep(i,m+1){if(a[i]==n){ ans++; }}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		final int a = sc.nextInt(); // 500円
		final int b = sc.nextInt(); // 100円
		final int c = sc.nextInt(); // 50円
		final int x = sc.nextInt();

		int count = 0;
		for (int i = 0; i <= a; i++) {
			for (int j = 0; j <= b; j++) {
				for (int k = 0; k <= c; k++) {
					final int sum = 500 * i + 100 * j + 50 * k;
					if (sum == x) {
						count++;
					}

				}
			}
		}

		System.out.print(count);

	}

}


Measured memory_bytes: 23252
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
def gcd(a,b):
    if a>=b:
        if b == 0:
            return a
        else:
            return gcd(b,a%b)
    else:
        if a == 0:
            return b
        else:
            return gcd(a,b%a)
if N == 1:
    print(T[0])
elif N == 2:
    print(int(T[0]//gcd(T[0],T[1])*T[1]))
else:
    T2 = [int(T[0]//gcd(T[0],T[1])*T[1])]
    for i in range(N-2):
        nex = int(T2[i]//gcd(T2[i],T[i+2])*T[i+2])
        T2.append(nex)
    print(T2[-1])

Measured memory_bytes: 3064
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
int W,H,N;
P s,t;
int steps[1003][1003];
int dp[1003][1003];

int cnv(char c) {
    if(c=='R') return 0;
    if(c=='D') return 1;
    if(c=='L') return 2;
    return 3;
}

void normalize(int &a,int s,int t) {
    a=max(s,a);
    a=min(t,a);
}

P walk(P pos,string s) {
    rep(i,s.size()) {
        int k=cnv(s[i]);
        int ny=pos.fr+dy[k];
        int nx=pos.sc+dx[k];
        
        if(!(0<=ny&&ny<H)) continue;
        if(!(0<=nx&&nx<W)) continue;
        //printf("[move] %c %d %d\n",s[i],ny,nx);

        //printf("[++] %c %d %d\n",s[i],pos.fr*2+dy[k]+1,pos.sc*2+dx[k]+1);
        steps[pos.fr*2+dy[k]+1][pos.sc*2+dx[k]+1]++;
        pos=P(ny,nx);
    }
    return pos;
}

int main() {
    cin>>W>>H>>N;
    cin>>s.fr>>s.sc;
    cin>>t.fr>>t.sc;

    swap(t.fr,t.sc);
    swap(s.fr,s.sc);
    rep(i,N) {
        P pos;
        int t;
        string s;
        cin>>pos.fr>>pos.sc;
        swap(pos.fr,pos.sc);
        cin>>t;
        cin>>s;
        rep(j,t) pos=walk(pos,s);

    }
    rep(i,1003) rep(j,1003) dp[i][j]=INF;

    s.fr*=2; s.sc*=2;
    t.fr*=2; t.sc*=2;
    typedef pair<int,P> Pi;
    priority_queue<Pi,vector<Pi>,greater<Pi> > que;
    que.push(Pi(0,s));
    dp[s.fr][s.sc]=0;
    while(que.size()) {
        Pi pi=que.top(); que.pop();
        P p=pi.sc;
        rep(k,4) {
            int ny=p.fr+dy[k];
            int nx=p.sc+dx[k];
            int ny2=ny+dy[k];
            int nx2=nx+dx[k];
            if(!(0<=ny2&&ny2<2*H+1)) continue;
            if(!(0<=nx2&&nx2<2*W+1)) continue;

            if(dp[ny2][nx2]>dp[p.fr][p.sc]+steps[ny][nx]) {
                dp[ny2][nx2]=dp[p.fr][p.sc]+steps[ny][nx];
                que.push(Pi(dp[ny2][nx2],P(ny2,nx2)));
            }
        }
    }

    /*
    rep(y,2*H+1) {
        rep(x,2*W+1) cout<<steps[y][x]<<" ";
        cout<<endl;
    }

    rep(y,2*H+1) {
        rep(x,2*W+1) printf("%10d ",dp[y][x]);
        cout<<endl;
    }
    //*/
    cout<<dp[t.fr][t.sc]<<endl;

    return 0;
}

Measured memory_bytes: 13016
n = int(input())
lis = sorted(list(map(int,input().split())))
now = -1
ans = 0
for x in range(n):
    if lis[x] == now:
        continue
    now = lis[x]
    val = 0
    for y in range(n-x):
        if lis[x]+2 >= lis[x+y]:
            val += 1
            ans = max(ans,val)
        else:
            break

print(ans)


Measured memory_bytes: 13964
import java.util.*;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		char [] alp = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
		int [] num = new int[26];
		while(scan.hasNext()){
			String sent = scan.next();
			String s = sent.toLowerCase();
			for(int i = 0; i < s.length(); i++){
				char c = s.charAt(i);
				for(int j = 0; j < 26; j++){
					if(c == alp[j]){
						num[j]++;
					}
				}
			}
		}

		for(int i = 0; i < 26; i++){
			System.out.printf("%c : %d\n", alp[i], num[i]);
		}
	}
}

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

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

        public void Solve(ConsoleInput cin)
        {
            var S = cin.ReadLine;

            WriteLine(S.Equals("AAA") || S.Equals("BBB") ? "No" : "Yes");
        }

    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

namespace ConsoleApplication36
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (a[0] == 0 && a[1] == 0)
                    break;
                int[] b = new int[a[0] + a[1]];
                for (int c = 0; c < a[0] + a[1]; c++)
                    b[c] = int.Parse(Console.ReadLine());
                int d, e, g;
                d = e = g = 0;
                e++;
                while (true)
                {
                    g++;
                    e += b[a[0] + d];
                    if (e > a[0])
                        break;
                    e += b[e - 1];
                    if (e >= a[0])
                        break;
                    d++;
                }
                Console.WriteLine(g);
            }
        }
    }
}

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

int main()
{
    int h, w;
    while (cin >> h >> w, h || w)
    {
        for (int i = 0; i < h; ++i)
        {
            for (int j = 0; j < w; ++j)
            {
                if ((i + j) % 2 == 0)
                    cout << '#';
                else
                    cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
}



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

string remover(string s){
	string ret;
	int i;
	for(i=0;i<s.size() && s[i] == '0';i++);
	for(;i<s.size();i++){
		ret += s[i];
	}
	return ret;
}

bool comp(string s1, string s2){
	if(s1.size() > s2.size()) return true;
	if(s1.size() < s2.size()) return false;
	for(int i=0;i<s1.size();i++){
		if(int(s1[i] - '0') > int(s2[i] - '0')) return true;
		if(int(s1[i] - '0') < int(s2[i] - '0')) return false;
	}
	return false;
}

int main(){
	int w,h;
	while(cin >> w >> h,w > 0 && h > 0){
		vector<string> c(h);
		for(int i=0;i<h;i++){
			cin >> c[i];
		}
		string ans = "";
		string num[70][70];
		for(int i=h-1;i>=0;i--){
			for(int j=w-1;j>=0;j--){
				if(c[i][j] < '0' || c[i][j] > '9') continue;
				if(j!=w-1 && i!=h-1){
					if(comp(num[i][j+1],num[i+1][j])){
						num[i][j] = c[i][j] + num[i][j+1];
					} else {
						num[i][j] = c[i][j] + num[i+1][j];
					}
				} else if(j!=w-1){
					num[i][j] = c[i][j] + num[i][j+1];
				} else if(i!=h-1){
					num[i][j] = c[i][j] + num[i+1][j];
				} else {
					num[i][j] = c[i][j];
				}
				if(comp(remover(num[i][j]),ans)){
					ans = remover(num[i][j]);
				}
			}
		}
		cout << remover(ans) << endl;
	}
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  int j = 0;
  int k = 0;
  for(int i = 0;i < n;i++){
    cin>>a.at(i);
  }
  for(int i = 0;i < 1000;i++){
    for(int i = 0;i < n;i++){
      if(a.at(i) % 2 == 0){
        j++;
      }
    }
    for (int i = 0; i < n; i++){
      a.at(i) /= 2;
    }
    if(j == n){
      k++;
    }else{
      break;
    }
    j = 0;
  }
  cout<<k<<endl;
}

Measured memory_bytes: 3136
N=int(input())
XY=[list(map(int,input().split())) for i in range(N-1)]
c=[[] for i in range(N)]
for x,y in XY:
    c[x-1].append(y-1)
    c[y-1].append(x-1)
from collections import deque
v=[0]*N
v[0]=1
m=10**9+7
import sys
sys.setrecursionlimit(10**9)
def f(p):
    rw,rb=1,1
    for n in c[p]:
        if not v[n]:
            v[n]=1
            w,b=f(n)
            rw=rw*(w+b)%m
            rb=rb*w%m
    return rw,rb
print(sum(f(0))%m)

Measured memory_bytes: 120592
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    string s;
    cin >> s;
    cout << min(count(ALL(s),'0'),count(ALL(s),'1'))*2 << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        int c = b - a;
        int cnt = 0;
        for (int i = 1; i < c; i++) {
            cnt += i;
        }
        
        System.out.println(cnt - a);
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll fr(ll a){
ll c=0;
while(a>0){
    c++;
    a/=10;
}
return c;
}
int main()
{
    //cout << "Hello world!" << endl;
    ll i,j,k,m,n,t;
  cin>>n>>m;vector<pair<pair<ll,ll>,ll > > v,vv;
  vector<ll>u[n+1];
  for(i=0;i<m;i++){
    cin>>j>>k;
    v.push_back(make_pair(make_pair(j,k),i));
    u[j].push_back(k);
  }
for(i=1;i<=n;i++){
    sort(u[i].begin(),u[i].end());
}
vector<pair<ll,ll> >ans;

  for(i=0;i<m;i++){
    j=v[i].first.first;
    k=v[i].first.second;
    ll in=lower_bound(u[j].begin(),u[j].end(),k)-u[j].begin();
    ans.push_back(make_pair(j,in+1));
  }
  for(i=0;i<m;i++){
   // cout<<ans[i].first<<" "<<ans[i].second<<"\n";
    j=fr(ans[i].first);
    ll jj=6-j;
    k=fr(ans[i].second);
    ll kk=6-k;
    for(ll q=0;q<jj;q++){
        cout<<0;
    }
    cout<<ans[i].first;
    for(ll q=0;q<kk;q++){
        cout<<0;
    }
    cout<<ans[i].second<<"\n";
  }
    return 0;
}


Measured memory_bytes: 13104
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  int A, B, max = -1000000;
  unused = scanf("%d %d", &A, &B);

  if(A+B > max) max = A+B;
  if(A-B > max) max = A-B;
  if(A*B > max) max = A*B;
  printf("%d", max);
  return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define LL long long
#define pii pair<int,int>
#define SZ(x)  (int)x.size()
#define all(x) x.begin(),x.end()

using namespace std;

LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
LL lcm(LL a, LL b) {return a / gcd(a, b) * b;}
LL powmod(LL a, LL b, LL MOD) {LL ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
const int N = 2e5 + 11;
int n;
struct uzi
{
	int a, b;
	bool operator <(const uzi & t)const {
		return 	atan2(a, b) < atan2(t.a, t.b);
	}
} p[N];
double get(LL l, LL r) {
	return sqrt(l * l + r * r);
}
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> p[i].a >> p[i].b;
	sort(p + 1, p + 1 + n);
	double ans = 0;
	for (int i = 1; i <= n; i++) {
		LL x = 0, y = 0;
		for (int j = 0; j < n; j++) {
			x += p[((i + j) % n) == 0 ? n : ((i + j) % n)].a;
			y += p[((i + j) % n) == 0 ? n : ((i + j) % n)].b;
			ans = max(ans, get(x, y));
		}
	}
	cout << fixed << setprecision(20) << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T &a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T &a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T &a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}
}

int main() {

	string s, t;
	cin >> s >> t;

	int ans = 0;
	rep(i, 3) if (s[i] == t[i]) ans++;

	cout << ans << endl;

	return 0;
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int m,n;
    cin >> m >> n;
    vector<int> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    if (m == 2) {
        int cnt = 0;
        for (int i = 0;i < n;++i) if ((a[i] == 1) == (i&1)) cnt++;
        cout << min(cnt,n-cnt) << endl;
        return 0;
    }
    int cnt = 1,ans = 0;
    for (int i = 1;i < n;++i) {
        if (a[i-1] == a[i]) cnt++;
        else {
            ans += cnt/2;
            cnt = 1;
        }
    }
    cout << ans+cnt/2 << endl;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,s,m,h;
  cin >> x;
  s = x % 60;
  h = x / (60*60);
  m = x / 60;
  m = m % 60;
  cout << h << ":" << m << ":" << s << endl;

  return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    vector<int> c(m);
    for(int i=0;i<m;i++)cin>>c[i];
    sort(All(c));
    int dp[n+10];
    //dp[i]:i円払うのに必要な最小の枚数
    for(int i=0;i<=n+5;i++)dp[i]=i;
    for(int i=0;i<m;i++){
        for(int j=0;j<=n;j++){
            if(j-c[i]<0)continue;
            dp[j]=min(dp[j-c[i]]+1,dp[j]);
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 3524
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#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++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int t[] = {0,1,2,3,5,7,8,9};

void f(int n)
{
	if(8 <= n) f(n / 8);
	cout << t[n%8];
}

int main()
{
	int n;
	while(cin >> n && n)
	{
		f(n);
		cout << endl;
	}
}

Measured memory_bytes: 864
(require 'sb-queue)

(defconstant +inf+ #xffffffff)

(defun get-shortest (h w map start-x start-y)
  (let ((q (sb-queue:make-queue))
        (looked (make-array (list h w) :element-type 'unsigned-int
                            :initial-element +inf+)))
    (declare (optimize (speed 3) (safety 0) (debug 0))
             ((simple-array bit (* *)) map))
    (labels ((visit (y x score)
               (when (and (<= 0 x (1- w))
                          (<= 0 y (1- h))
                          (= +inf+ (aref looked y x))
                          (zerop (aref map y x)))
                 (setf (aref looked y x) score)
                 (sb-queue:enqueue (cons x y) q))))
      (visit start-y start-x 0)
      (loop until (sb-queue:queue-empty-p q)
            for (x . y) = (sb-queue:dequeue q)
            for score = (aref looked y x)
            do (progn
                 ;; left
                 (visit y (1- x) (1+ score))
                 ;; up
                 (visit (1- y) x (1+ score))
                 ;; right
                 (visit y (1+ x) (1+ score))
                 ;; down
                 (visit (1+ y) x (1+ score)))))
    (loop for score across (array-storage-vector looked)
          when (< score +inf+)
          maximize score)))

(defun solve (h w map)
  (loop for y from 0 below h
        maximize (loop for x from 0 below w
                       if (= 0 (aref map y x))
                       maximize (get-shortest h w map x y))))

#-swank
(let* ((h (read))
       (w (read))
       (map (make-array (list h w) :element-type 'bit)))
  (loop for y from 0 below h
        do (loop for x from 0 below w
                 for byte = (read-byte *standard-input*)
                 do (setf (aref map y x)
                          (if (= byte #.(char-code #\.))
                              0
                              1)))
        do (read-byte *standard-input*))
  (format t "~A~%" (solve h w map)))


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

signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(i%2==1 && a[i-1]%2==1)ans++;
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
vector<long long> A(100100, 0);

int main() {
    cin >> n;
    long long sum = 0;
    long long subsum = 0;
    for(int i = 0; i < n; ++i) {
        cin >> A.at(i); sum += A.at(i);
        if(i % 2 == 0 && i != n-1) subsum += A.at(i);
    }

    vector<long long> ans(n, 0);
    ans.at(n-1) = 2*(sum/2-subsum);
    long long nrain = sum/2 - subsum;
    for(int i = n-2; i >= 0; --i) {
        long long prain = A.at(i) - nrain;
        ans.at(i) = prain*2;
        nrain = prain;
    }

    for(int i = 0; i < n; ++i) {
        if(i == n-1) cout << ans.at(i) << endl;
        else cout << ans.at(i) << " ";
    }
}

Measured memory_bytes: 2944
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define bug2(v1,v2)               cerr<<#v1<<" = "<<(v1)<< ' ' << #v2<<" = "<<(v2)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
//const ll mod = 998244353;
const ll mod = 1000000007;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

//////////////////// start /////////////////////////////////
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];


int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

cin >> n;
cin >> k;
fr(i,1,n)
{
	cin >> m;
	l += max(0LL,k-m);
	k = max(k,m);
}
cout << l;
  
 eNd();
  return 0;
 
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;

int main()
{
    int n, m;
    cin >> n;
    set<string> str;
    string s;
    map<string, int> mapping;
    for (int i=0; i<n; ++i){
        cin >> s;
        str.insert(s);
        if(mapping.find(s) == mapping.end()){
            mapping.insert(make_pair(s, 1));
        }
        else {
            int yen = mapping.at(s);
            mapping.erase(s);
            mapping.insert(make_pair(s, yen+1));
        }
    }
    cin >> m;
    for (int i=0; i<m; ++i){
        cin >> s;
        str.insert(s);
        if(mapping.find(s) != mapping.end()){
            int yen = mapping.at(s);
            mapping.erase(s);
            if(yen - 1 > 0){
                mapping.insert(make_pair(s, yen-1));
            }
        }
    }
    int ans = 0;
    for (auto itr = str.begin(); itr != str.end(); ++itr){
        if(mapping.find(*itr) != mapping.end()){
            ans = max(ans, mapping.at(*itr));
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


const ll MRINF = 5000000000000000;
int main() {

    int X, Y;
    cin >> X >> Y;

    int ansy = Y-2*X;
    int ansx = 4*X-Y;
    if(ansy >= 0 && ansy % 2 == 0){
        if(ansx >= 0 && ansx % 2 == 0){
            cout << "Yes" << endl;
            return 0;
        }        
    }
    cout << "No" << endl;
    return 0;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    string S;
    cin >> S;
    if((S[6]=='1' || S[6]=='2' || S[6]=='3' || S[6]=='4') && S[5]=='0')cout << "Heisei";
    else cout << "TBD";
    


}

/*



 */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n;
	string s;
	cin >> s;
	n = s.size();
	int res = 0;
	REP(i, n / 2) {
		if (s[i] != s[n - 1 - i]) {
			res++;
		}
	}
	put(res);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m,a,b,c;
	string str;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>str;
	
	if(str[0]==str[1]||str[1]==str[2]||str[2]==str[3]){
		cout<<"Bad";
	}else{cout<<"Good";}

	cout<<endl;
} 


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int time = a + b;

		if (time >= 24) {
			time -= 24;
		}
		System.out.println(time);
	}

}


Measured memory_bytes: 35700
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

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;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}

int main(void){
    int A,B,C; cin >> A >> B >> C;
    vector<int> veq = {A, B, C};
    sort(veq.begin(), veq.end());
    int num_max = veq[2];
    int num_median = veq[1];
    int num_min = veq[0];
    int dis_max_med = veq[2] - veq[1];
    
    int ans = dis_max_med + (num_max - (dis_max_med + num_min))/2;
    if(!((num_max - (dis_max_med + num_min)) % 2 == 0)) ans += 2;
    
    cout << ans << endl;
}

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

int main(){
  char tmp[32];
  int i,len;
  while(fgets(tmp, 32, stdin)!=NULL){
	len = strlen(tmp);
	for(i=len-2;i>=0;i--){
	  printf("%c", tmp[i]);
	}
	printf("\n");
  }
  return 0;
}

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

#define ll long long

ll knapsack(ll n, ll W, vector<ll> &w, vector<ll> &v){

    ll dp[n+1][W+1];

    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=W;j++){
            if(i==0 || j==0)
                dp[i][j] = 0;
        }
    }

    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=W;j++){
            if(w[i]<=j){
                dp[i][j] = max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
            }
            else
                dp[i][j] = dp[i-1][j];
        }
    }

    return dp[n][W];

}

int main() {
    
    ll n,W;
    cin>>n>>W;

    vector<ll> w(n+1);
    vector<ll> v(n+1);

    for(ll i=1;i<=n;i++){
        cin>>w[i]>>v[i];
    }

    cout<<knapsack(n,W,w,v);

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K;
    vector<ll> A;
    cin >> N >> K;
    A.resize(N);
    rep(i, N) cin >> A[i];
    if(N == 1) {
        if(A[0] == K) cout << "POSSIBLE" << endl;
        else cout << "IMPOSSIBLE" << endl;
    } else {
        ll mini;
        ll prev;
        sort(A.begin(), A.end());
        mini = A[1] - A.front();
        prev = A.front();
        while(mini != prev) {
            ll temp;
            temp = mini;
            mini = abs(prev - mini);
            prev = temp;
            if(mini == 0) {
                mini = prev;
                break;
            }
        }
        iter(a, A) {
            if(a >= K && (a - K) % mini == 0) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int A,B;
		Scanner sc = new Scanner(System.in);
		A = sc.nextInt();
		B = sc.nextInt();
		System.out.println(Math.abs(A + B) % 24);
		sc.close();
	}
}


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

using namespace std;

int main(void) {
  int n;
  cin >> n;
  vector <int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector <int> color(9);
  for(int i = 0; i < 9; i++) {
    color[i] = 0;
  }
  for(int i = 0; i < n; i++) {
    if(a[i] < 3200) {
      color[(int)(a[i] / 400)]++;
    }
    else {
      color[8]++;
    }
  }

  int base = 0;
  for(int i = 0; i < 8; i++) {
    if(color[i] > 0) {
      base++;
    }
  }

  int mn, mx;
  if(base == 0) {
    mn = 1;
  }
  else {
    mn = base;
  }

  mx = base + color[8];

  cout << mn << " " << mx << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define lli long long int
int main() {
	string s;
	cin>>s;
	int x=0,mx=0;
	for(int i=0;i<3;i++)
	{
		if(s[i]=='R')
		x++;
		else{
			mx = max(mx,x);
			x=0;
		}
	}
	cout<<max(mx,x)<<endl;
	return 0;
}

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

using namespace std;

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

    int n, m;
    cin >> n >> m;

    vector<pair<int, int> > v;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(max(a,b), min(a,b)));
    }

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

    int last = -2;
    int ans = 0;

    for (int i = 0; i < v.size(); i++) {
        int b = v[i].first;
        int a = v[i].second;
        if (a >= last) {
            last = b;
            ans++;
        }
    }

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


Measured memory_bytes: 1400
//Volume5 -> 0501

#include <iostream>
#include <vector>
//#include <math.h>
//#include <string>
#include <cmath>
#include <iomanip>

int main();

int main(){
	std::vector<int> totalAPoint;		//Aの得点
	std::vector<int> totalBPoint;		//Bの得点
	int dataSetCount = 0;				//ゲーム数

	while (1){
		int n = 0;		//1ゲームの入力数

		std::cin >> n;
		//n=0で終了
		if (n == 0){
			break;
		}

		dataSetCount++;

		int aPoint = 0;		//1ゲームにおけるAの得点
		int bPoint = 0;		//1ゲームにおけるBの得点

		for (int i = 0; i < n; i++){
			int tempA;
			int tempB;

			std::cin >> tempA >> tempB;
			if (tempA > tempB){
				aPoint += (tempA + tempB);
			}
			else if (tempA < tempB){
				bPoint += (tempA + tempB);
			}
			//引き分け
			else{
				aPoint += tempA;
				bPoint += tempB;
			}
		}

		totalAPoint.push_back(aPoint);
		totalBPoint.push_back(bPoint);
	}

	//結果出力
	for (int i = 0; i < dataSetCount; i++){
		std::cout << totalAPoint[i] << " " << totalBPoint[i] << std::endl;
	}

	//while (1);
	return 0;
}


Measured memory_bytes: 3128
#include <vector>
#include <utility>
#include <cstdio>
#include <cstdlib>

int dist(std::pair<int, int>& a, std::pair<int, int>& b) {
    return std::abs(a.first - b.first) + std::abs(a.second - b.second);
}

int main() {
    int h,w,d,q,tmp;
    scanf("%d%d%d", &h, &w, &d);
    std::vector<std::pair< int,  int>> v(h*w+1);
    std::vector<int> table(h*w+1);
    for ( int i = 0; i < h; i++) {
        for ( int j = 0; j < w; j++) {
            scanf("%d", &tmp);
            v[tmp] = std::make_pair(i,j);
        }
    }

    for (int i = d + 1; i < h*w + 1; i++) {
        table[i] = table[i - d] + dist(v[i], v[i-d]);
    }

    scanf("%d", &q);
    int l, r, ret = 0;
    for ( int i = 0; i < q; i++) {
        scanf("%d%d", &l, &r);
        auto c = l % d;

        printf("%d\n", table[r] - table[l]);
    }

    return 0;
}

Measured memory_bytes: 2176