akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main() {
    string o, e;
    cin >> o >> e;

    for (int i = 0; i < static_cast<int>(o.size()); i++) {
        cout << o[i];
        if (i < static_cast<int>(e.size())) {
            cout << e[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  int m, d;
  cin >> m >> d;
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= d; j++) {
      int a = j % 10;
      int b = j / 10;
      if (a * b == i && a >= 2 && b >= 2) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

using VI = vector <int> ;
using VVI = vector <VI> ;
using VVVI = vector <VVI> ;

class FenwickTree {
    VI sum;
public:
    FenwickTree (int treeSize) {
        sum = move(VI(treeSize+1));
    }

    void addVal(int idx, int val) {
        while (idx < sum.size()) {
            sum[idx] += val;
            idx += (idx & (-idx));
        }
    }

    int getVal(int idx) {
        if (idx <= 0) {
            return 0;
        }

        int ret = 0;

        while (idx) {
            ret += sum[idx];
            idx -= (idx & (-idx));
        }

        return ret;
    }

    int queryRange(int a, int b) {
        return getVal(b) - getVal(a-1);
    }
};

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

    VI c(N);
    VI idx(N);
    VVI colorVec(N);
    FenwickTree ft(N+1);

    for (int i = 0; i < N; ++i) {
        cin >> c[i];
        colorVec[--c[i]].push_back(i);
    }

    // sort all colors
    for (int i = 0; i < N; ++i) {
        sort(colorVec[i].begin(), colorVec[i].end());

        if (colorVec[i].size()) {
            ft.addVal(colorVec[i][0]+1, 1);
            ++idx[i];
        }
    }

    VVVI query(N);
    VI ans(Q);

    for (int q = 0; q < Q; ++q) {
        int l;
        int r;
        cin >> l >> r;
        query[l-1].push_back({r, q});
    }

    // enumerate coordinate
    for (int i = 0; i < N; ++i) {

        if (i) { // remove previous cell
            int color = c[i-1];
            ft.addVal(i, -1);

            if (idx[color] < colorVec[color].size()) {
                ft.addVal(colorVec[color][idx[color]]+1, 1);
                ++idx[color];
            }
        }

        for (int q = 0; q < query[i].size(); ++q) {
            ans[query[i][q][1]] = ft.queryRange(i+1, query[i][q][0]);
        }
    }

    for (int i = 0; i < Q; ++i) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 82564
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		if(N==2)
			System.out.println("Borys");
		else
			if((A-B-1)%2==0)
				System.out.println("Borys");
			else
				System.out.println("Alice");
	}

}

Measured memory_bytes: 21844
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int w=sc.nextInt();
		int num[]=new int[w+1];
		for(int i=1;i<=w;i++){
			num[i]=i;
		}

		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			String[] str=sc.next().split(",");
			int a=Integer.parseInt(str[0]);
			int b=Integer.parseInt(str[1]);
			int c=num[a];
			num[a]=num[b];
			num[b]=c;
		}

		for(int i=1;i<=w;i++){
			System.out.println(num[i]);
		}
		sc.close();
	}

}

Measured memory_bytes: 26184
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;


int main(){
	int N,D,X;
	int A[100];
	scanf("%d", &N);
	scanf("%d %d", &D, &X);
	for(int i=0;i<N;i++){
		scanf("%d", &A[i]);
	}

	int ans = X;
	for(int i=0;i<N;i++){
		ans += D/A[i] + 1;
		if(D%A[i]==0) ans--;
	}

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

	return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
	int w;
	while (1) {
		cin >> w;
		if (w == -1)break;
		int ans = 0;
		
		ans += 1150;
		w -= 10;
		if (w > 0) { ans += 125 * min(w, 10); w -= 10; }
		if (w > 0) { ans += 140 * min(w, 10); w -= 10; }
		if (w > 0) ans += 160 * w;
		
		cout << 4280 - ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2984
#include <iostream>
using namespace std;
    
int main ()
{
    int a;
    cin >> a;
    if (a<1200)
    {
        cout << "ABC" << endl;
    }  
    if (a>=1200&&a<2800)
    {
        cout << "ARC" << endl;
    }
    if (a>=2800)
    {
        cout << "AGC" << endl;
    }
return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<cstring>
#define MAX 50 
#include<algorithm>
using namespace std; 
  

 
int main() {
    long long a[100010];
    memset(a,0,sizeof(a));
    long long s=0;
    int n;
    int t;
    cin>>n;
    for(int i=0;i<n;i++){
    	cin>>t;
    	a[t]++;
    	s+=t;
	}
	
	int q;
	cin>>q;
	int d;
	while(q--){
		cin>>t>>d;
		s+=(d-t)*a[t];
		a[d]+=a[t];
		a[t]=0;
		cout<<s<<endl;
	}
	
}

Measured memory_bytes: 4400
#include <cstdio>
#include <deque>
#include <numeric>
#include <functional>
#include <array>
#include <unordered_map>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H &&h, T... t){out(h);out(t...);}
template <typename... T> _OUTL(T... t){out(t...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int main() {
	array<unordered_map<int, int>, 1 << 10> m;
	array<array<int, 10001>, 11> r {};
	m[0][0] = 1;
	for (int i: range(1, 1 << 10)) {
		int c {__builtin_popcount(i)};
		for (int j: range(10))
			if (i >> j & 1) {
				for (auto k: m[i & ~(1 << j)]) {
					int x = k.first + c * j;
					m[i][x] += k.second;
					r[c][x] += k.second;
				}
			}
	}
	for (int n, s; scan(n, s);)
		outl(r[n][s]);
}


Measured memory_bytes: 4644
#include <stdio.h>

int main(){
  int i,j,count=0,n,q,s[10000],t[500];

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&t[i]);

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(t[i]==s[j]){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2100
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
 
class Main {
    
    public static void main(String[] args) throws IOException {
    	int n = in.nextInt() + 1;
    	int m = in.nextInt() + 1;
    	int[] x = new int[n];
    	x[0] = in.nextInt();
    	int[] y = new int[m];
    	y[0] = in.nextInt();
    	for(int i = 1; i < n; i ++)
    		x[i] = in.nextInt();
    	for(int i = 1; i < m; i ++)
    		y[i] = in.nextInt();
    	Arrays.sort(x);
    	Arrays.sort(y);
    	if(y[0] > x[n - 1])
    		sop("No War");
    	else
    		sop("War");
    }
    
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        char nextChar() {
            return in.next().charAt(0);
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    
    static FastReader in = new FastReader();
    static OutputStream out = new BufferedOutputStream(System.out);
    
    public static byte[] toByte(Object o) {
        return String.valueOf(o).getBytes();
    }
    
    public static void sop(Object o) {
        System.out.print(o);
    }
} 

Measured memory_bytes: 24660
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
#define ll long long
int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d;
    cin >> n;
    ll ans = (n/2)*min(8*q, min(4*h, min(2*s, d))) + (n%2)*min(4*q, min(2*h, s));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x);
#define CMIN(m, x)  m = min(m,x);
#define itn int
typedef long long lint;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    int n;
    cin >> n;
    int sum = 0;
    FOR(i,1,n + 1){
        FOR(j, 1, n + 1){
            FOR(k, 1, n + 1){
                int g = std::gcd<int,int>(i, j);
                sum += std::gcd<int,int>(g,k);
            }
        }
    }
  cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
import bisect

A, B, Q = map(int,input().split())
INF = 10**18
s = [-INF] +  [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
x_list = [int(input()) for i in range(Q)]

for x in x_list:
    
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    a = b - 1
    c = d - 1 
    ans = min(abs(s[a]-x) + min(abs(t[c]-s[a]), abs(t[d]-s[a])),
              abs(s[b]-x) + min(abs(t[c]-s[b]), abs(t[d]-s[b])),
              abs(t[c]-x) + min(abs(s[a]-t[c]), abs(s[b]-t[c])),
              abs(t[d]-x) + min(abs(s[a]-t[d]), abs(s[b]-t[d])))

    # for s in [s_list[a], s_list[b]]:
    #     for t in [t_list[c], t_list[d]]:
    #         dist1 = abs(s-x) + abs(t-s)
    #         dist2 = abs(t-x) + abs(t-s)
    #         ans = min(ans, dist1,dist2)
    print(ans)


Measured memory_bytes: 16144
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

struct st{
	int a,b,c;
};
st p[2000];
ll dp[1001][20001];

int main(){
	int n;scanf("%d",&n);
	rep(i,n){
		scanf("%d%d%d",&p[i].a,&p[i].b,&p[i].c);
	}
	sort(p,p+n,[](st a,st b){return a.a+a.b<b.a+b.b;});
	dp[0][0]=0;
	rep(i,n){
		for(int j=0;j<=20000;j++){
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
			if(j<=p[i].b&&j+p[i].a<=20000){
				dp[i+1][j+p[i].a]=max(dp[i+1][j+p[i].a],dp[i][j]+p[i].c);
			}
		}
	}
	cout<<*max_element(dp[n],dp[n]+20001)<<endl;
}

Measured memory_bytes: 156544
n = int(input())
l = [list(map(int,input().split())) for i in range(n)]

m = [0]*2
for i,j in l:
    m[(i+j)%2] += 1
if m[0]*m[1]>0:
    print(-1)
    exit()

if m[1]>0:
    arm = [2**i for i in range(32)]
else:
    arm = [1]+[2**i for i in range(32)]

print(len(arm))
print(*arm)
for x,y in l:
    ans = []
    nx = x
    ny = y
    for i in arm[::-1]:
        if abs(nx) >= abs(ny):
            if nx >= 0:
                ans.append("R")
                nx -= i
            else:
                ans.append("L")
                nx += i
        else:
            if ny >= 0:
                ans.append("U")
                ny -= i
            else:
                ans.append("D")
                ny += i
    
    print(*ans[::-1],sep="")

Measured memory_bytes: 4696
def solve():
    N = int(input())
    edges = []
    for _ in range(N-1):
        u,v = map(int, input().split())
        edges += [(min(u,v), max(u,v))]
    V = 0
    for i in range(N):
        V += (N-i) * (i+1)
    E = 0
    for (u, v) in edges:
        E += (u-1+1) * (N-v+1)
    print(V-E)

solve()

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

// #define int long long

/* short */
#define pb push_back
#define print(Target) cout << Target << '\n'

/* REPmacro */
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

/* const */
const int INF = INT_MAX;

signed main()
{
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vi m(n); REP(i, n) cin >> m[i];

  REPS(i, 1, *max_element(m.begin(), m.end()) + 1){
    bool flg = true;
    REP(j, m.size()){
      if (m[j] % i != 0){
        flg = false;
        break;
      }
    }
    if (flg) print(i);
  }
  
  return (0);
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define ll long long
#define c continue
using namespace std; 
int main(){ll mod=1e9+7,x,y,z=1,w=0,o,p,q,v[93],t[91][91][2],a,b;v[0]=1,v[1]=1;for(ll i=2;i<93;i++)v[i]=v[i-1]+v[i-2];for(ll i=2;i<91;i++){for(ll j=1;j<i;j++){a=v[i],b=v[i+1];if(j==1){t[i][j-1][0]=a,t[i][j-1][1]=b,t[i][j][0]=b,t[i][j][1]=2*b-a;c;}t[i][j][0]=t[i-1][j-1][1],t[i][j][1]=t[i-1][j-1][1]+t[i-1][j-1][0];}}cin>>q;while(q--){cin>>x>>y;if(x>y)swap(x,y);if(y==1){cout<<"1 1\n";c;}for(ll i=0;i<93;i++){if(v[i]>x||v[i+1]>y){z=i-1;break;}}cout<<z<<" ";if(z==1){cout<<x*y%mod<<endl;c;}w=0;for(ll j=0;j<z;j++){o=t[z][j][0],p=t[z][j][1];if(o>x||p>y)c;w+=(y-p)/o+1;w%=mod;if(x>=p)w+=(x-p)/o+1;w%=mod;}cout<<w<<"\n";}}

Measured memory_bytes: 4096
#include<stdio.h>
#include<math.h>

int main(void)
{
   double a, b, c;
   
   scanf("%lf", &a);
	
   b = M_PI*a*a;
   c = M_PI*2*a;
   
   printf("%f %f\n", b, c);
   
   return 0;
}


Measured memory_bytes: 2092
n=int(input())
ans=0
dp=[1,1]+[0 for _ in range(int(n**0.5)-1)]

if n == 1:
  print("0")
  exit()
for i in range(2,int(n**0.5)+1):
  if dp[i] == 1:
    continue
  A,j=0,1
  while n % i == 0:
    n //= i
    A += 1    
  while j*(j+1)//2 <= A:
    ans += 1
    j += 1
  for k in range(i,int(n**0.5)+1,i):
    dp[k] = 1

if n != 1:
  ans += 1
print(ans)

Measured memory_bytes: 24900
#include<stdio.h>
int main(){
    char weather[3];
    int seaquence = 0;
    int i,s=0;
    scanf("%s",weather);
    for(i=0; i<3; i++){
        if(weather[i] == 'R'){
            s++;
        }else{
            s=0;
        }
        if(seaquence <= s){
            seaquence = s;
        }
    }
    printf("%d\n",seaquence);
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e7;  
using  p = pair<int,int>;
using  v = vector<int>;

int main(){
   string s;
   cin >>s;
   int c =0;

   int n = s.size();
   bool f = true;
   s.pop_back();
   while(1){
      c=0;
      f=true;
      for (int i = 0; i < s.size()/2; i++)
      {
         if(s[i]!=s[s.size()/2+i]){
            f = false;
            break;
         } 
         c++;
      }
      if(f&&c!=0)break;
      s.pop_back();
   }
   cout << c*2;
}
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    //ifstream cin("input.in");
   // ofstream cout("output2.out");
    ios::sync_with_stdio(0);cin.tie(0);
    long N,X,A[100009];
    cin>>N>>X;
    for(long i=0;i<N;i++)
        cin>>A[i];
    long C=0;
    if(A[0]>X)
    {
        C+=(A[0]-X);
        A[0]-=(A[0]-X);
    }
    //for(long i=0;i<N;i++)
    //    cout<<A[i]<<" ";
    //cout<<"\n";
    for(long i=1;i<N;i++){
        if(A[i]+A[i-1]>X)
        {
            long H=A[i-1]+A[i]-X;
            //cout<<i<<" "<<H<<"\n";
            if(A[i]>H)
            {
                C+=H;
                A[i]-=H;
            }
            else
            {
                C+=H;
                A[i-1]-=(H-A[i]);
                A[i]=0;
            }
        }
        //for(long i=0;i<N;i++)
        //cout<<A[i]<<" ";
    //cout<<"\n";
    }
    //for(long i=0;i<N;i++)
    //    cout<<A[i]<<" ";
    //cout<<"\n";
    cout<<C;
}

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

using static Input;
using static Util;
class Program
{
    static int N;
    static int[] H;
    static void INPUT()
    {
        N = NextInt();
        H = LineInt();
    }

    static void OUT()
    {
        var dp = new int[N];
        for (int i = 1; i < N; i++)
        {
            dp[i] = INF;
        }
        for (int i = 0; i < N - 1; i++)
        {
            dp[i + 1] = Math.Min(dp[i + 1], dp[i] + Math.Abs(H[i] - H[i + 1]));
            if(i < N - 2)
            dp[i + 2] = Math.Min(dp[i + 2], dp[i] + Math.Abs(H[i] - H[i + 2]));
        }
        Console.WriteLine(dp[N - 1]);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 18144
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int NR= 2e5 + 5 ;
ifstream in("viitor.in");
ofstream out("viitor.out");

long long n , m ;
int main()  {
    cin >> n >> m ;
    if ( n ==1 || m == 1 )  {
        return cout << 1 , 0 ;
    }
    cout << max ( ((n+1)/2) * ((m+1)/2) + (n/2) * (m/2), ((n)/2) * ((m+1)/2) + ((n+1)/2) * (m/2) ) ;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int N;
    cin >> N;
    int macnt = 0, ans = 0;
    for (int i = 1; i <= N; i++) {
        int cnt = 0;
        int s = i;
        while (s % 2 == 0) {
            cnt++;
            s /= 2;
        }

        if (cnt >= macnt)
            macnt = cnt, ans = i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3660
package main

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

	func main() {
		r := bufio.NewReader(os.Stdin)
		var a, b int
		fmt.Fscan(r, &a)
		fmt.Fscan(r, &b)

		if a <= 8 && b <= 8 {
			fmt.Println("Yay!")
		} else {
			fmt.Println(":(")
		}
	}

	// Union-Find
	type unionFind struct {
		d []int
	}

	func newUnionFind(n int) *unionFind {
		uf := new(unionFind)
		uf.d = make([]int, n)
		for i := 0; i < n; i++ {
			uf.d[i] = -1
		}
		return uf
	}

	func (uf *unionFind) find(x int) int {
		if uf.d[x] < 0 {
			return x
		}
		uf.d[x] = uf.find(uf.d[x])
		return uf.d[x]
	}

	func (uf *unionFind) unite(x, y int) bool {
		rootX := uf.find(x)
		rootY := uf.find(y)
		if rootX == rootY {
			return false
		}

		if uf.d[rootX] < uf.d[rootY] {
			uf.d[rootX] += uf.d[rootY]
			uf.d[rootY] = rootX
		} else {
			uf.d[rootY] += uf.d[rootX]
			uf.d[rootX] = rootY
		}

		return true
	}

	func (uf *unionFind) same(x, y int) bool {
		return uf.find(x) == uf.find(y)
	}

	func (uf *unionFind) size(x int) int {
		return -uf.d[uf.find(x)]
	}

	// mod combination
	func modpow(a, n, mod int) int {
		res := 1
		for n > 0 {
			if n%2 != 0 {
				res = res * a % mod
			}
			a = a * a % mod
			n = n / 2
		}
		return res
	}

	func modcomb(n, a, mod int) int {
		x := 1
		y := 1
		for i := 0; i < a; i++ {
			x = x * (n - i)
			x %= mod
			y = y * (i + 1)
			y %= mod
		}
		return x * modpow(y, mod-2, mod) % mod
	}

	func modfactorial(n, mod int) int {
		result := 1
		for i := 1; i <= n; i++ {
			result = (result * i) % mod
		}
		return result
	}

	// Utility

	func min(x, y int) int {
		if x < y {
			return x
		}
		return y
	}

	func max(x, y int) int {
		if x > y {
			return x
		}
		return y
	}

	func abs(x int) int {
		if x < 0 {
			return -x
		}
		return x
	}

	func primeFactor(x int) map[int]int {
		res := make(map[int]int)
		for i := 2; i*i <= x; i++ {
			for x%i == 0 {
				res[i]++
				x = x / i
			}
		}
		if x != 1 {
			res[x] = 1
		}
		return res
	}

	func divisor(x int) []int {
		res := make([]int, 0)
		for i := 1; i*i <= x; i++ {
			if x%i == 0 {
				res = append(res, i)
				if i != x/i {
					res = append(res, x/i)
				}
			}
		}
		return res
	}

	func gcd(x, y int) int {
		if y == 0 {
			return x
		}
		return gcd(y, x%y)
	}

	func lcm(x, y int) int {
		return x / gcd(x, y) * y
	}

	func reverseString(s string) string {
		r := []rune(s)
		for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
			r[i], r[j] = r[j], r[i]
		}
		return string(r)
	}

	// Queue ...
	type Queue []int

	// pop ...
	func (q *Queue) empty() bool {
		return len(*q) == 0
	}

	// push ...
	func (q *Queue) push(i int) {
		*q = append(*q, i)
	}

	// pop ...
	func (q *Queue) pop() (int, bool) {
		if q.empty() {
			return 0, false
		} else {
			res := (*q)[0]
			*q = (*q)[1:]
			return res, true
		}
	}

	// Stack ...
	type Stack []int

	// pop ...
	func (s *Stack) empty() bool {
		return len(*s) == 0
	}

	// push ...
	func (s *Stack) push(i int) {
		*s = append(*s, i)
	}

	// pop ...
	func (s *Stack) pop() (int, bool) {
		if s.empty() {
			return 0, false
		} else {
			index := len(*s) - 1
			res := (*s)[index]
			*s = (*s)[:index]
			return res, true
		}
	}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> d(k);
  vector<int> x(n);
  for(int i=0;i<n;i++){
    x[i]=1;
  }
  for(int i=0;i<k;i++){
    cin>>d[i];
    vector<int> a(d[i]);
    for(int j=0;j<d[i];j++){
      cin>>a[j];
    }
    for(int j=0;j<d[i];j++){
      x[a[j]-1]=0;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=x[i];
  }
  cout<<ans<<endl;
  
}

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

int main(){
  while(1){
    int r,c;
    cin>>r>>c;
    if(r==0 && c==0) break;
    if(r%2==1 && c%2==1) cout<<"no"<<endl;
    else cout<<"yes"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

const int B = 1024;
const int N = 205000 / B * B;

int a[N], b[N];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", a+i);
    for (int i = 0; i < n; i++) scanf("%d", b+i);
    int ans = 0;
    if (n % 2) {
        for (int i = 0; i < n; i++) ans ^= a[i] ^ b[i];
    }
    for (int sa = 0; sa < N; sa += B) {
        for (int sb = 0; sb < N; sb += B) {
            for (int i = sa; i < sa+B; i++) {
                for (int j = sb; j < sb+B; j++) {
                    ans ^= (a[i] + b[j]);
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

int main(){
  int N;cin>>N;
  string S;cin>>S;
  if(N%2!=0){
    cout<<"No"<<endl;
  }else{
    int t=1;
    for(int i=0;i<N/2&&t==1;i++){
      if(S[i]!=S[i+N/2]){
        t=0;
      }
    
  }
  if(t==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,k;
double ans;

void rec(int x,int sum){
  if(x==n){
    if(sum>k)ans+=(sum-k);
    else ans+=1.0;
  }else{
    for(int i=1;i<=m;i++){
      rec(x+1,sum+i);
    }
  }
}

int main(){
  while(1){
    cin>>n>>m>>k;
    if(n==0&&m==0&&k==0)break;
    if(n==1){
      double M=m,K=k;
      double a=(1.0+M-K)*0.5*(M-K);
      printf("%.8f\n",(a+K)/M);
    }else{
      ans=0;
      rec(0,0);
      double p=1.0;
      for(int i=0;i<n;i++)p*=m;
      printf("%.8f\n",ans/p);
    }
  }
  return 0;
}

Measured memory_bytes: 1192
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int N = Integer.parseInt(s);

            System.out.println(getLucas(N));
        }
    }

    static long getLucas(int N) {
        long[] L = new long[N + 1];

        L[0] = 2;
        L[1] = 1;

        if (N == 0) return L[0];
        if (N == 1) return L[1];

        for (int i = 2; i < N + 1; i++)
        {
            L[i] = L[i - 2] + L[i - 1];
        }
        return L[N];
    }
}


Measured memory_bytes: 21972
#include <cstdio>
char str[1001];
int main (int argc, char const* argv[])
{
	scanf("%s",str);
	for(int i=0;str[i];i++) {
		if(str[i]>='D')putchar(str[i]-3);
		else putchar('Z'-('C'-str[i]));
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 932
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;


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

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

    //int size =  S.size();
    int ans = 10000;


    for(int i = 0; i<=(S.size()-T.size()); ++i){
        int tmp = 0;
        for(int j=0; j < T.size(); ++j){
            
            if(S[i+j] != T[j]){
                ++tmp;
            }
        }
        /*
        if(tmp == 0){
            cout << 0 << endl;
            return 0;
        }
        */
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3168
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

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

const int N = 2000 + 10;
const ll MOD = 924844033;
const ll INF = 1000000010;
const ll LOG = 25;

int n, K, a[N], DP[N][N][4], dp[N][N], fac[N];
vi M[N];

int add(int a, int b){
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

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

int minu(int a, int b){
	a -= b;
	if (a < 0) a += MOD;
	return a;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> K;
	for (int i = 0; i < N; i++) fac[i] = (i == 0?1:mul(fac[i - 1], i));
//	cout << fac[n] << '\n';
	for (int i = 1; i <= n; i++){
		M[i % K].pb(i);
	}
	DP[0][0][0] = 1;
	for (int i = 0; i < N - 1; i++)for (int j = 0; j <= i; j++) for( int l = 0; l < 4; l++){
		if (i != 0){
			if ((l & (1 << 1)) == 0){
				DP[i + 1][j + 1][(l & 1) << 1] = add(DP[i + 1][j + 1][(l & 1) << 1], DP[i][j][l]);
			} 
		}
		DP[i + 1][j + 1][((l & 1) << 1) | 1] = add(DP[i + 1][j + 1][((l & 1) << 1) | 1], DP[i][j][l]);
		DP[i + 1][j][(l & 1) << 1] = add(DP[i + 1][j][(l & 1) << 1], DP[i][j][l]);
//		cout << i << ' ' << j << ' ' << l << ' ' << DP[i][j][l] << '\n'; 
	}
	int sz = 0;
	dp[0][0] = 1;
	for (int i = 1; i <= K; i++){
		for (int j = 0; j <= sz; j++)for (int k = 0; k <= M[i - 1].size(); k++){
			dp[i][j + k] = add(dp[i][j + k], mul(dp[i - 1][j], add(DP[M[i - 1].size()][k][0], DP[M[i - 1].size()][k][2])));
		}
		sz += M[i - 1].size();
//		cout << sz << '\n';
	} 
	int ans = 0;
	for (int i = 0; i <= n; i++){
		if (i % 2 == 0){
			ans = add(ans, mul(fac[n - i], dp[K][i]));
		}else ans = minu(ans, mul(fac[n - i], dp[K][i]));
	}	
	cout << ans;









	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  int m = -100;
  for (int i = 0; i < n; i++) {
    m = max(m, p[i]);
  }
  int s = accumulate(p.begin(), p.end(), 0);
  cout << s - m / 2 << endl;
}


Measured memory_bytes: 256
N,L=map(int, raw_input().split())

AJI=[ L+i-1 for i in range(1,N+1) ]
total=sum(AJI)

sa_min=float("inf")
for x in AJI:
	sa_min=min(sa_min, abs(x))

if sa_min in AJI:
	print total-sa_min
else:
	print total-(-1*sa_min)


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

int main(){
	int five=0,seven=0;

	int x;
	for(int i=0;i<3;i++){
		cin>>x;
		if(x==5)five++;
		else if(x==7)seven++;
	}

	if(five==2 && seven==1)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int  nax = 100005;
vector<ll> edges[nax];
bool vis[nax] = {false};
ll dist[nax] = {0};
ll indegree[nax] = {0};

void dfs(int a)
{
	if (!vis[a])
		vis[a] = true;

	for (ll b : edges[a])
	{
		dist[b] = max(dist[b], dist[a] + 1);
		--indegree[b];
		if (indegree[b] == 0)
		{
			dfs(b);
		}
	}
}

int main()
{


	ll n, m;
	cin >> n >> m;

	while (m--)
	{
		ll a, b;
		cin >> a >> b;
		edges[a].pb(b);
		++indegree[b];
	}

	for (ll i = 1; i <= n; i++)
	{
		if (!vis[i] && indegree[i] == 0)
		{
			dfs(i);
		}
	}

	ll ans = 0;
	for (ll i = 1; i <= n; i++)
	{
		ans = max(ans, dist[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 10496
#include <cstdio>
template<typename Elem>
Elem gcd(Elem a,Elem b){
	if(b==0){
		return a;
	}
	return gcd(b,a%b);
}
template<typename Elem>
Elem lcm(Elem a,Elem b){
	if(a==0||b==0){
		return a+b;
	}
	return a/gcd(a,b)*b;
}
typedef long long ll;
const int Maxn=500;
const int Maxv=10000;
const int d[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
int n;
ll a[Maxn+5][Maxn+5];
bool np[Maxv+5];
int p[Maxv+5],p_len;
void init(){
	np[0]=np[1]=1;
	for(int i=2;i<=Maxv;i++){
		if(!np[i]){
			p[++p_len]=i;
			for(int j=i*i;j<=Maxv;j+=i){
				np[j]=1;
			}
		}
	}
}
int val_1[Maxn<<1|5],val_2[Maxn<<1|5];
int main(){
	init();
	scanf("%d",&n);
	if(n==2){
		puts("4 7");
		puts("23 10");
		return 0;
	}
	int id_tot=0;
	for(int i=2;i<=(n<<1);i+=2){
		val_1[i]=p[++id_tot];
	}
	int m;
	if(n&1){
		m=n+1;
		for(int i=(n<<1);i>0;i-=2){
			val_2[i]=p[++id_tot];
		}
	}
	else{
		m=n;
		for(int i=(n<<1)-2;i>0;i-=2){
			val_2[i]=p[++id_tot];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if((i+j)&1){
				continue;
			}
			a[i][j]=1ll*val_1[i+j]*val_2[j-i+m];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(!((i+j)&1)){
				continue;
			}
			for(int k=0;k<4;k++){
				int nx=i+d[k][0],ny=j+d[k][1];
				if(nx<1||ny<1||nx>n||ny>n){
					continue;
				}
				a[i][j]=lcm(a[i][j],a[nx][ny]);
			}
			a[i][j]++;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			printf("%lld ",a[i][j]);
		}
		puts("");
	}
	return 0;
}


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

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

  long long max = floor(sqrt(N*1.0));
  long long count = 0;

  for(int i=1;i<max+1;++i){
    long long a = N/i -1;
    if(a && N%i == 0 && N%a==N/a) count += a;
  }

  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define pb push_back
#define mp make_pair
#define fi(i,start,end) for(int i=start; i < end ; ++i)
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
//#define mod 100000000

using namespace std;



int main()
{
    int n,k;
    cin>>n>>k;
    int temp;
    vector<int> v;
    fi(i,0,n)
    {
        cin>>temp;
        v.pb(temp);
    }
    sort(v.begin(),v.end());
    int ans=0;
    fi(i,0,k)
    {
        ans+=v[i];
    }
    cout<<ans;

}









Measured memory_bytes: 3616
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  getc solve >>= mapM_ print

solve :: [String] -> [Int]
solve [] = []
solve (x:y:ys) = (last $ foldl rsf [0..n-1] cs) : solve ys
  where
    [n,r] = map toInt $ words x
    cs = map toInt $ words y
    m = n `div` 2
    rsf :: [Int] -> Int -> [Int]
    rsf xs c = f (drop m xs) (take m xs) []
      where
        f :: [Int] -> [Int] -> [Int] -> [Int]
        f as bs cs
          | null as && null bs = cs
          | otherwise = f (drop c as) (drop c bs) (cs ++ (take c as) ++ (take c bs))
        
toInt :: String -> Int
toInt = read

getc :: ([String] -> a) -> IO a
getc f = f . lines <$> getContents

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

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

int main(){
  ll x,y;
  cin>>x>>y;
  cout<<gcd(x,y)<<endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
const int INF = 1e8;



int main(){
  int n,m;cin >> n>> m;
  vector<pair<int,int>> Req(m);
  rep(i,m) cin >> Req[i].first >> Req[i].second;
  sort(all(Req),[](auto x,auto y){return x.second < y.second;});
  int res = 0;
  int end = 0;
  for(int i=0;i<m;i++){
    if(Req[i].first >= end){
      end = Req[i].second;
      ++res;
    }
  }
  cout << res << endl;
  
} 

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var k = int.Parse(Console.ReadLine());

        if (k % 2 == 0 || k % 5 == 0)
        {
            Console.WriteLine("-1");
            return;
        }

        var table = new int[10];
        for (int t = 9; t > 0; --t)
        {
            table[t * (k % 10) % table.Length] = t;
        }

        var length = 0;
        var upper = 0;
        while (upper > 0 || length == 0)
        {
            var r = upper % 10;
            var coefficientMsd = table[(7 - upper % 10 + table.Length) % table.Length];
            upper = (upper + coefficientMsd * k) / 10;
            ++length;
        }

        Console.WriteLine(length);
    }
}


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

int main() {
  int64_t n; cin>>n;
  vector<int64_t> vec(n);
  int64_t sum=0;
  for (int i = 0; i < n; i++) {
    cin>>vec.at(i);
    sum+=vec.at(i);
  }

  sort(vec.begin(), vec.end());
  cout<<vec.at(0)<<" "<<vec.at(n-1)<<" "<<sum<<endl;
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
lli dp[100001][2];
lli n,k;
lli arr[100];
lli solve(lli x,lli mov){
	if(x<0)
	return mov;
	if(x==0)
	return 1-mov;
	if(dp[x][mov]!=-1)
	return dp[x][mov];
	for(lli i=0;i<n;i++){
		lli new_mov=solve(x-arr[i],1-mov);
		if(new_mov==mov){
			dp[x][mov]=mov;
		}
	}
	if(dp[x][mov]==mov)
	return dp[x][mov];
	else
	dp[x][mov]=1-mov;
	return dp[x][mov];
}
int main(){
	cin>>n>>k;
	for(lli i=0;i<n;i++)
	cin>>arr[i];
	for(lli i=0;i<=k;i++){
	dp[i][0]=-1;
	dp[i][1]=-1;
	}
	lli ans=solve(k,0);
	//for(lli i=1;i<=k;i++)
	//cout<<dp[i]<<" ";
	//cout<<"\n";
	if(ans==0)
	cout<<"First";
	else
	cout<<"Second";
	return 0;
}


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

int main(){

        int a,b;

        cin >> a;
        cin >> b;

        if(a < b){
                cout << "a < b" << endl;
        }

        else if(a > b){
                cout << "a > b" << endl;
        }

        else{
                cout << "a == b" << endl;
        }

        return 0;

}



Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n=sc.nextInt();
            if(n==0)break;
            int A=0,B=0;
            for(int i=0;i<n;i++){
                int a=sc.nextInt(),b=sc.nextInt();
                if(a<b){
                    B+=a+b;
                }else if(a>b){
                    A+=a+b;
                }else{
                    A+=a;
                    B+=a;
                }
            }
            System.out.println(A+" "+B);
        }
    }
}

Measured memory_bytes: 51548
using System;
using System.Linq;

namespace agc030_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var text = Console.ReadLine();

            var a = int.Parse(text.Substring(0, 2));
            var b = int.Parse(text.Substring(2, 2));

            var isAmonth = (a >= 1) && (a <= 12);
            var isBmonth = (b >= 1) && (b <= 12);

            if (isAmonth && isBmonth)
            {
                Console.WriteLine("AMBIGUOUS");
            }
            else if (isAmonth){
                Console.WriteLine("MMYY");
            }
            else if (isBmonth){
                Console.WriteLine("YYMM");
            }
            else{
                Console.WriteLine("NA");
            }


            
        }
    }
}


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

int main(void) {
    int64_t N,A;
    string output = "APPROVED\n";
    cin >> N;
    for(int i=0;i<N;i++) {
        cin >> A;
        if((A%2) == 0) {
            if((A%3) && (A%5))output = "DENIED\n";
        }
    }

    cout  << output;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n, k, ans = 0;
	cin >> n >> k;
	rep(i, 0, n) {
		int h;
		cin >> h;
		if (h >= k)ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    char s[16];
    int i=0, cntm=0, k=0;
    scanf("%s", s);
    while(s[i]!='\0'){
        if(s[i]=='o') cntm++;
        k++;
        i++;
    }
    if(cntm+15-k>=8) printf("YES\n");
    else printf("NO\n");
    
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 200002;
ll n;
vector<ll> v,y;
double ans=0;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	set<ll> s;
	FOR(i,0,3){
		ll k;
		cin>>k;
		s.insert(k);
	}
	cout<<s.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

void bfs(const vvi &adlist, vi &arrive, int s){
    queue<int> que;
    que.push(s);
    arrive[s]=1;
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(int next : adlist[v]){
            if(arrive[next]!=0) continue;
            arrive[next]=v;
            que.push(next);
        }
    }
    return;
}

int main(){
    int N,M;
    cin >> N >> M;
    vvi adlist(N+1,vi());
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >>b;
        adlist[a].push_back(b);
        adlist[b].push_back(a);
    }
    vi arrive(N+1,0);
    bfs(adlist,arrive,1);
    bool flag=false;
    for(int i=2;i<=N;i++){
        if(arrive[i]==0) flag=true;
    }
    if(flag) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
    }
    for(int i=2;i<=N;i++){
        cout << arrive[i] << endl;
    }
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

const ll INF = (1ll << 60);

void dfs(ll now, ll pre, vector<ll>& dp, vector<ll>& ans, vector<vector<ll>>& graph, vector<ll>& a)
{
    ll num = a.at(now);
    ll ind = lower_bound(all(dp), num) - dp.begin();
    ll mae = dp.at(ind);
    dp.at(ind) = num;
    ll tmp = lower_bound(all(dp), INF) - dp.begin();
    ans.at(now) = tmp;
    ll i;
    for(i = 0;i < graph.at(now).size();++i){
        ll next = graph.at(now).at(i);
        if(next != pre){
            dfs(next, now, dp, ans, graph, a);
        }
    }
    dp.at(ind) = mae;
    return;
}

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    vector<vector<ll>> graph(n);
    rep(i,n-1){
        ll u,v;
        cin >> u >> v;
        --u,    --v;
        graph.at(u).push_back(v);
        graph.at(v).push_back(u);
    }
    
    vector<ll> dp(n, INF);
    vector<ll> ans(n);
    dfs(0, -1, dp, ans, graph, a);
    rep(i,n) cout << ans.at(i) << endl;

    return 0;
}

Measured memory_bytes: 38820
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  bool F=true;
  cin>>N;
  vector<int>T(N+1);
  vector<int>X(N+1);
  vector<int>Y(N+1);
  for(int D=0;D<N;D++){
    cin>>T[D+1]>>X[D+1]>>Y[D+1];
    if((T[D+1]-T[D])%2==(abs(X[D]-X[D+1])+abs(Y[D]-Y[D+1]))%2&&(abs(X[D]-X[D+1])+abs(Y[D]-Y[D+1]))<=(T[D+1]-T[D])){
    }
    else{
      F=false;
      break;
    }
  }
  if(F==true){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 4272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!
// わけわからん

const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    P red[n], blue[n];
    for (int i = 0, a, b; i < n; i++) {
        cin >> a >> b;
        red[i] = { a, b };
    }
    for (int i = 0, c, d; i < n; i++) {
        cin >> c >> d;
        blue[i] = { c, d };
    }
    sort(blue, blue + n);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        P t = { -1, -1 };
        int idx = -1;
        for (int j = 0; j < n; j++) {
            if (red[j].first >= blue[i].first || red[j].second >= blue[i].second) continue;
            if (t.second < red[j].second) {
                t = red[j];
                idx = j;
            }
        }
        if (idx == -1) continue;
        red[idx] = { INF, INF };
        ans++;
    }
    cout << ans << endl;
}

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


using namespace std;


class Dice{
	private:
		int dice[6];

	public:
		// コンストラクタ
		Dice();
		// サイコロころころシュミレート
		int corocoro();
};


// コンストラクタ
Dice::Dice()
{
	for(int i = 0; i < 6; i++)
		cin >> dice[i];
}
// サイコロころころシュミレート
int Dice::corocoro()
{
	string test;
	int tmp;

	cin >> test;
	for(int i = 0; i < test.length(); i++){
		switch(test[i]){
			case 'N':
				tmp = dice[5];
				dice[5] = dice[4];
				dice[4] = dice[0];
				dice[0] = dice[1];
				dice[1] = tmp;
				break;
			case 'S':
				tmp = dice[5];
				dice[5] = dice[1];
				dice[1] = dice[0];
				dice[0] = dice[4];
				dice[4] = tmp;
				break;
			case 'W':
				tmp = dice[5];
				dice[5] = dice[3];
				dice[3] = dice[0];
				dice[0] = dice[2];
				dice[2] = tmp;
				break;
			case 'E':
				tmp = dice[5];
				dice[5] = dice[2];
				dice[2] = dice[0];
				dice[0] = dice[3];
				dice[3] = tmp;
				break;
		}
	}

	return dice[0];
}


int main()
{
	Dice *x = new Dice();

	cout << x->corocoro() << endl;

	return 0;
}


Measured memory_bytes: 3200
_ = input()
even = [int(i) for i in input().split() if int(i) % 2 == 0]
i = 0
while len(even) != 0:
    i = i + len(even)
    even = [i // 2 for i in even if (i // 2) % 2 == 0]
print(i)

Measured memory_bytes: 4140