akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n, k, m;
	while (cin >> n >> k >> m,n) {
		vi stone(n);
		REP(i, n)
			stone[i] = i+1;
		int start = m - 1;
		stone.erase(stone.begin() + m - 1);
		while (stone.size()>1) {
			start = (start + k-1)%stone.size();
			stone.erase(stone.begin() + start);
		}
		cout << stone[0] << endl;
	}
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)

ll M = 1e9 + 7;
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}


int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n,k; cin>>n>>k;
	map <int,int> m; int ans = 0;
	for(int i=0;i<k;i++)
	{
	    int d; cin>>d;
	    for(int j=0;j<d;j++)
	    {
	        int p; cin>>p;
	        if(m[p]==0) ans++;
	        m[p]++;
	    }
	}
	cout<<n-ans;
	
	return 0;
}


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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){

  ll A1,A2,A3;
  cin >> A1 >> A2 >> A3;
  if(A1+A2+A3>21){
    cout <<"bust";
  }else{
    cout << "win";
  }
 

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch RedOrNot | diff RedOrNot.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address RedOrNot.cpp && ./a.out

/*
 
 8/18/2019
 
 21:00-
 
 */


int A;
string S;

void solve() {
  cout<<(A>=3200?S:"red")<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>S;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int A = fs.nextInt();
        int B = fs.nextInt();
        int K = fs.nextInt();
        int smaller = Math.min(A, B);

        int cnt = 0;
        for (int i = smaller; i >= 1; --i) {
            if (A % i == 0 && B % i == 0) ++cnt;
            if (cnt == K) {
                System.out.println(i);
                break;
            }
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() { return Double.parseDouble(next());}
}




Measured memory_bytes: 32316
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program
{
    internal static void Main(string[] args)
    {
        var c = new List<List<int>>();
        c.Add(ReadLine().Split(' ').Select(s => int.Parse(s)).ToList());
        c.Add(ReadLine().Split(' ').Select(s => int.Parse(s)).ToList());
        c.Add(ReadLine().Split(' ').Select(s => int.Parse(s)).ToList());

        for (int i = 0; i < 2; i++) {
            if (!(c[0][i] - c[0][i + 1] == c[1][i] - c[1][i + 1] && 
                  c[1][i] - c[1][i + 1] == c[2][i] - c[2][i + 1])) {
                WriteLine("No");
                return;
            }
        }

        for (int i = 0; i < 2; i++)
        {
            if (!(c[i][0] - c[i + 1][0] == c[i][1] - c[i + 1][1] &&
                  c[i][1] - c[i + 1][1] == c[i][2] - c[i + 1][2])) {
                WriteLine("No");
                return;
            }
        }

        WriteLine("Yes");
    }
}


Measured memory_bytes: 13396
n=int(input())
l=list(map(int,input().split()))

s=min(l)
g=max(l)
ans=0
for k in range (n):
  ans+=(l[k]-s)**2

for i in range(s+1,g+1):
  hyp=0
  for j in range (n):
    hyp+=(l[j]-i)**2
  if hyp<ans:
    ans=hyp
    
print (ans)

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

constexpr int inf = 0x3f3f3f3f;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  vector<int> b(n);
  for (auto&& e : b) {
    cin >> e;
  }
  for (int i = 1; i < n; i += 2) {
    swap(a[i], b[i]);
  }
  int res = inf;
  for (int bt = 0; bt < 1 << n; ++bt) {
    if (__builtin_popcount(bt) == n / 2) {
      vector<pair<int, int>> e, o;
      for (int i = 0; i < n; ++i) {
        if (bt >> i & 1) {
          o.emplace_back(b[i], i);
        } else {
          e.emplace_back(a[i], i);
        }
      }
      sort(begin(e), end(e));
      sort(begin(o), end(o));
      vector<int> v(n);
      for (int i = 0; i < n; ++i) {
        if (~i & 1) {
          v[i] = e[i / 2].first;
        } else {
          v[i] = o[i / 2].first;
        }
      }
      if (is_sorted(begin(v), end(v))) {
        int inv = 0;
        vector<pair<int, int>> p(n);
        for (int i = 0; i < n; ++i) {
          if (~i & 1) {
            p[i] = e[i / 2];
          } else {
            p[i] = o[i / 2];
          }
        }
        for (int j = 0; j < n; ++j) {
          for (int i = 0; i < j; ++i) {
            inv += p[i].second > p[j].second;
          }
        }
        res = min(res, inv);
      }
    }
  }
  cout << (res < inf ? res : -1) << '\n';
}


Measured memory_bytes: 256
N,K = map(int,input().split())
R,S,P = map(int,input().split())
t=list(input())
q=['q']*K
t=t+q

s=0
for i in range(K,N+K):
    if t[-i-1] == t[-i-1+K]:
        t[-i-1]='q'
        continue
    elif t[-i-1] =='r':
        s+=P
    elif t[-i-1] =='s':
        s+=R
    elif t[-i-1] =='p':
        s+=S


print(s)

Measured memory_bytes: 52720
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout<<"debug... "<<n1<<"\n"
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n;
    cin>>n;
    ve <ll> arr(n);
    ll sum=0;
    rep (i,0,n)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    ve <ll> ps(n+1,0);
    ps[0]=0;
    rep(i,1,n+1)
    {
        ps[i]=arr[i-1]+ps[i-1];
    }
    ll ans=202020202099;
    for (auto x: ps)
    {
        ans=min(abs(abs(sum-x)-x),ans);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 3328
unittest
{
	assert( [ "5 2", "8 7 6", "rsrpr" ].parse.expand.solve == 27 );
	assert( [ "7 1", "100 10 1", "ssssppr" ].parse.expand.solve == 211 );
	assert( [ "30 5", "325 234 123", "rspsspspsrpspsppprpsprpssprpsr" ].parse.expand.solve == 4996 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	input.popFront;
	auto rsp = input.front.split.to!( long[] );
	input.popFront;
	auto t = input.front.to!( dchar[] );
	return tuple( nk[ 1 ], rsp[ 0 ], rsp[ 1 ], rsp[ 2 ], t );
}

auto solve( long k, long r, long s, long p, dchar[] t )
{
	// dp[ i回目 / k ][ i回目 % k ][ グー/チョキ/パーのどれを出したか ] = i % k 回目ごとの最大スコア
	auto dp = new long[][][]( 1 + ( t.length + k - 1 ) / k, k, 3 );
	auto i = 0L;
	foreach( a; 1L .. dp.length.signed )
	{
		foreach( b; 0L .. dp[ a ].length.signed )
		{
			if( t.length <= i )
			{
				dp[ a ][ b ][] = dp[ a - 1 ][ b ][];
				continue;
			}
			
			final switch( t[ i ] )
			{
				case 'r':
					dp[ a ][ b ][ 0 ] = max( dp[ a - 1 ][ b ][ 1 ], dp[ a - 1 ][ b ][ 2 ] );
					dp[ a ][ b ][ 1 ] = max( dp[ a - 1 ][ b ][ 0 ], dp[ a - 1 ][ b ][ 2 ] );
					dp[ a ][ b ][ 2 ] = max( dp[ a - 1 ][ b ][ 0 ], dp[ a - 1 ][ b ][ 1 ] ) + p;
					break;
				
				case 's':
					dp[ a ][ b ][ 0 ] = max( dp[ a - 1 ][ b ][ 1 ], dp[ a - 1 ][ b ][ 2 ] ) + r;
					dp[ a ][ b ][ 1 ] = max( dp[ a - 1 ][ b ][ 0 ], dp[ a - 1 ][ b ][ 2 ] );
					dp[ a ][ b ][ 2 ] = max( dp[ a - 1 ][ b ][ 0 ], dp[ a - 1 ][ b ][ 1 ] );
					break;
				
				case 'p':
					dp[ a ][ b ][ 0 ] = max( dp[ a - 1 ][ b ][ 1 ], dp[ a - 1 ][ b ][ 2 ] );
					dp[ a ][ b ][ 1 ] = max( dp[ a - 1 ][ b ][ 0 ], dp[ a - 1 ][ b ][ 2 ] ) + s;
					dp[ a ][ b ][ 2 ] = max( dp[ a - 1 ][ b ][ 0 ], dp[ a - 1 ][ b ][ 1 ] );
					break;
			}
			i++;
		}
	}
	
	// k 単位で分割して計算していたスコアを合計
	auto ans = 0L;
	foreach( b; 0L .. dp[ $ - 1 ].length.signed )
	{
		ans += dp[ $ - 1 ][ b ].reduce!max;
	}
	return ans;
}


Measured memory_bytes: 17788
#include<bits/stdc++.h>
using namespace std;
char s[10001];
int l;
int main()
{
    scanf("%s ",s);
    l=strlen(s);
    for( int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    printf("Yes\n");
                    return 0;
                }
            }
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int m = in.nextInt();
		while(m-- > 0) {
			HashSet<String> set = new HashSet<>();
			String s = in.next();
			int n = s.length();
			for (int i=1; i<n; i++) {
				String a = s.substring(0, i);
				String b = s.substring(i, n);
				String ra = new StringBuilder(a).reverse().toString();
				String rb = new StringBuilder(b).reverse().toString();
				set.add(a + b);
				set.add(a + rb);
				set.add(ra + b);
				set.add(ra + rb);
				set.add(b + a);
				set.add(b + ra);
				set.add(rb + a);
				set.add(rb + ra);
			}
			// dump(set);
			out.println(set.size());
		}
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 61196
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long


 
int main(){
    
    ll n,m;
    ll ans=0;
    
    cin>>n>>m;
    if(n<=m/2){
        ans+=n;
        m-=n*2;
        ans+=m/4;
    }
    else{
        ans+=m/2;
    }
    cout<<ans<<endl;
    
    return 0;
    
}

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

#define INF 1<<30

int main()
{
   int n,k;
    cin >> n >> k;
    vector <int> H(n+10, 0);
    for(int i = 0; i < n; i++) 
    {
        cin >> H[i];
    }

    vector<int> ans(n+5, INF);
    
    ans[0] = 0;
    
    for(int i = 0; i < n; i++)
    {
      for(int j = 1; j <= k && (i+j) < n; j++)
      {
        ans[i+j] = min(ans[i+j], ans[i] + abs(H[i+j] - H[i]));
        }
    }
    cout << ans[n-1]<<endl; 
   
   return 0;
}

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

int main()
{
  int r, g;
  cin >> r >> g;
  
  // (r + x) / 2 = g
  // r + x = 2 * g
  // x = 2 * g - r
  cout << 2 * g - r << endl;
  
  return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a == 0){
    if(b == 100){
      cout << 101 << endl;
    }else{
    cout << b << endl;
    }
  }else if(a == 1){
    if(b == 100){
      cout << 100*(b+1) << endl;
    }else{
    cout << 100*b << endl;
    }
  }else if(a == 2){
    if(b == 100){
      cout << 100*100*(b+1) << endl;
    }else{
    cout << 100*100*b << endl;
    }
 }
}

Measured memory_bytes: 256
# aising2019C - Alternating Path
def dfs(sx: int, sy: int) -> None:
    color = [0] * 2
    s_col = S[sx][sy]
    color[s_col] += 1
    S[sx][sy] = 2  # make the grid visited
    stack = [(sx, sy, s_col)]
    while stack:
        x, y, col = stack.pop()
        for dx, dy in dxy:
            nx, ny = x + dx, y + dy
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == col ^ 1:
                stack.append((nx, ny, S[nx][ny]))
                color[S[nx][ny]] += 1
                S[nx][ny] = 2
    return color[0] * color[1]


def main():
    # separate S to connected components
    global H, W, S, dxy, blk, wht
    H, W, *S = open(0).read().split()
    H, W = int(H), int(W)
    S = [[1 if i == "#" else 0 for i in s] for s in S]
    dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    ans = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] != 2:
                ans += dfs(i, j)
    print(ans)


if __name__ == "__main__":
    main()

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

int main() {
    int n;  cin >> n;
    if (n >= 1000)  cout << "ABD" << endl;
    else  cout << "ABC" << endl;
}

Measured memory_bytes: 256
/**
 * @author torith
 * @date 2018-10-15
 */

#include <bits/stdc++.h>

using namespace std;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> X;
    int tmp;
    for (int i = 0; i < N; ++i) {
        cin >> tmp;
        X.push_back(tmp);
    }
    vector<int> Y = X;

    sort(Y.begin(),Y.end());
    int med = Y[Y.size()/2];
    int s_med = Y[Y.size()/2-1];

    for(auto &i : X){
        if (i >= med){
            cout << s_med << "\n";
        }else{
            cout << med << "\n";
        }
    }

    return 0;
}



Measured memory_bytes: 3956
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

a,b,c,x,y = readInts()

ans = 1000000000000000000
for i in range(0,x+1):
	B = max(y-(x-i),0)
	AB = max(2*(x-i),0)
	money = i*a+B*b+AB*c
	ans = min(ans,money)

for i in range(0,y+1):
	A = max(x-(y-i),0)
	AB = max(2*(y-i),0)
	money = A*a+b*i+AB*c
	ans = min(ans,money)

for i in range(0,max(x,y)*2+1,2):
	A = max(x - i//2,0)
	B = max(y - i//2,0)
	money = A*a+B*b+i*c
	ans = min(ans,money)

print(ans)



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


int next_seven(int x,int k){
    return (x * 10 + 7) % k;
}
int main(){
    int k;
    cin >> k;
    vector<int> array(k);
    array.at(0) = 7 % k;
    for(int i=1;i<k;i++){
        array.at(i) = next_seven(array.at(i-1),k);
    }
    int num = -2;
    for(int i=0;i<k;i++){
        if(array.at(i) == 0){
            num = i;
            break;
        }
    }

    cout << num+1 << endl;
}

Measured memory_bytes: 7124
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(vec) (vec).begin(), (vec).end()
#define SUM(...) accumulate(ALL(__VA_ARGS__),0LL)
#define DSUM(...) accumulate(ALL(__VA_ARGS__),0.0)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 便利関数
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;}
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

const int INF = 2002002002;
const string YES = "YES";
const string NO = "NO";

void solve(std::string A, std::string B, std::string C){
    bool ans1 = false;
    bool ans2 = false;
    if (A[A.length() - 1] == B[0]) ans1 = true;
    if (B[B.length() - 1] == C[0]) ans2 = true;
    if (ans1 && ans2) print(YES);
    else print(NO);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string A;
    std::cin >> A;
    std::string B;
    std::cin >> B;
    std::string C;
    std::cin >> C;
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int h,w;
char ara[1001][1001];
long dp[1001][1001];
long func(int x,int y){
    if(dp[x][y]!=-1) return dp[x][y];
    long res;
    
    if(x==h-1 && y==w-1) res=1;
    else if(ara[x][y]!='.') res=0;
    else{
        int t1,t2;
        t1=func(x+1,y)%mod;
        t2=func(x,y+1)%mod;
        res=t1+t2;
    }
    dp[x][y]=res%mod;
    return dp[x][y];
}
int main(){
    memset(dp,-1,sizeof(dp));
    cin >> h >> w;
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> ara[i][j];
        }
    }
    
    cout << func(0,0) << endl;
    
}

Measured memory_bytes: 12488
n,a_start,b_start,a_goal,b_goal = map(int,input().split())
s = input()

no_rock_double = True
for i in range(a_start, max(b_goal,a_goal)):
    if i+1 < n:
        if s[i] == '#' and s[i+1] == '#':
            no_rock_double = False
can_switch = False
if a_goal > b_goal:
    for i in range(b_start-1, b_goal):
        if i + 2 < n:
            if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
                can_switch = True
    if no_rock_double and can_switch:
        print('Yes')
    else:
        print('No')
else:
    if no_rock_double:
        print('Yes')
    else:
        print('No')



Measured memory_bytes: 9332
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    int n;
    cin >> n;
    vector<ll> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    vector<ll> sm(n+1);
    sm[0] = 0;
    rep(i,n){
        sm[i+1] = sm[i] + vec[i];
    }
    ll asum = sm[n];
    ll ans = (1LL << 60);
    rep(i,n-1){
        ll hoge = asum - sm[i+1];
        if(abs(hoge - sm[i+1]) < ans){
            ans = abs(hoge-sm[i+1]);
        }
    }
    cout << ans << endl;
    return 0;
}


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


int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(N, vector<int>(2));
  vector<vector<int>> C(M, vector<int>(2));
  for(auto& s : S){
    cin >> s[0] >> s[1];
  }
  for(auto& c : C){
    cin >> c[0] >> c[1];
  }

  for(auto& s : S){
    vector<int> D(M);
    for(int ii=0; ii<M; ii++){
      D[ii] = abs(s[0] - C[ii][0]) + abs(s[1] - C[ii][1]);
    }
    cout << distance(D.begin(), min_element(D.begin(), D.end())) + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

a,b,c = get_all_int()

if a==b or a==c or b==c:
    if a!=b or a!=c or b!=c:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 38256
#include <stdio.h>

int main() {
 int h, w, a, b, i, j;
 scanf("%d%d%d%d", &h, &w, &a, &b);
 for (i = 0; i < b; i++) {
  for (j = 0; j < a; j++) putchar('0');
  for (     ; j < w; j++) putchar('1');
  putchar('\n');
 }
 for (     ; i < h; i++) {
  for (j = 0; j < a; j++) putchar('1');
  for (     ; j < w; j++) putchar('0');
  putchar('\n');
 }
 return 0;
}

Measured memory_bytes: 1152
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
flag = False
for i in range(n):
    for j in range(n):
        for k in range(m):
            for l in range(m):
                if i + k >= n or j + l >= n:
                    flag = True
                    break
                if a[i + k][j + l] != b[k][l]:
                    flag = True
                    break
            if flag:
                flag = False
                break
            if k == m - 1:
                print('Yes')
                exit()
print('No')

Measured memory_bytes: 3064
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    s, t = args[1].split()
    ret = ''
    for i in range(n):
        ret += s[i]+t[i]
    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 2940
#include <stdio.h>
 
int A[25], n;
 
int main()
{
  int M, q, i;
  
  scanf("%d", &n);  
  for(i=0; i<n; i++){
	scanf("%d", &A[i]);
  }
    scanf("%d", &q);
	
    for(i=0; i<q; i++){
	  scanf("%d", &M);   
	  if(solve(0, M) == 1){
		puts("yes");
	  }
	  else {
		puts("no");
	  }
    }
    return 0;
}


int solve(int p, int t){
  
  if (p == n){
	if (t == 0){
	  return (1);
	}
	else {
	  return (0);
	}
  }
  
  if (solve(p + 1, t - A[p]) == 1){
	return (1);
  }
  if (solve(p + 1, t) == 1){
	return (1);
  }
  return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
#define MAX 1000

void print_array(int *A, int N) {
  int i;
  for(i = 0; i < N - 1; i++) {
    printf("%d ", A[i]);
  }
  printf("%d\n", A[i]);
}

void insertionSort(int *A, int N) {
  int i, j, v;
  print_array(A, N);
  for(i = 1; i < N; i++) {
    v = A[i];
    for(j = i - 1; j >= 0 && A[j] > v; j--) {
      A[j+1] = A[j];
    }
    A[j+1] = v;
    print_array(A, N);
  }
}

int main() { 
  int a[MAX], n, i;
  
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  insertionSort(a, n);
  return 0;
}



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

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

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

    int res = gcd(a[0], a[1]);
    for (int i = 2; i < N; i++)
        res = gcd(res, a[i]);

    cout << res << endl;
    return 0;
}

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


#define ll          long long
#define uint        unsigned int 
#define ld          long double
#define SAM         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define mod         1000000007
#define mxn         200005
#define pb          push_back
#define pii         pair<int,int>
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define all(x)      x.begin(),x.end()

using namespace std;



int main()
{
    SAM;
    int n;
    cin>>n;
    string s1="AC",s2="WA",s3="TLE",s4="RE";
    int count1=0,count2=0,count3=0,count4=0;
    FOR(i,0,n)
    {
        string s;
        cin>>s;
        if(s==s1)
            count1++;
        if(s==s2)
            count2++;
        if(s==s3)
            count3++;
        if(s==s4)
            count4++;
    }
    
    cout<<s1<<" x "<<count1<<"\n";
    cout<<s2<<" x "<<count2<<"\n";
    cout<<s3<<" x "<<count3<<"\n";
    cout<<s4<<" x "<<count4;
    
    
    return 0;
}




Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <cstring>
  
#define INF 2000000010
#define mod7 1000000007
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define INF_LL 9223372036854775
#define EPS 1e-10
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double 
 
using namespace std;

#define MAX_N 2
#define MAX_S 10005

int N;
string S;

void input(){
  cin >> N;
  cin >> S;
}

LL dp[2][MAX_S];

int main(){

  input();

  memset(dp, 0, sizeof(dp));
  dp[0][S.length()] = 1;

  for(int i = 0; i < N; i++){
    for(int j = 0; j < MAX_S; j++){
      dp[(i+1)%2][j] = 0;
    }
    for(int j = 0; j < MAX_S; j++){
      if(dp[i%2][j] == 0)
	continue;
      if(j == 0){
	dp[(i+1)%2][j] += dp[i%2][j];
	dp[(i+1)%2][j] %= mod7;
      }
      else{
	dp[(i+1)%2][j-1] += dp[i%2][j];
	dp[(i+1)%2][j-1] %= mod7;
      }
      dp[(i+1)%2][j+1] += dp[i%2][j]*2;
      dp[(i+1)%2][j+1] %= mod7;
    }
  }

  cout << dp[N%2][0] << endl;

  return 0;

}


Measured memory_bytes: 384
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}
void fprint() { std::cout << '\n'; }
template <class H, class... T> void fprint(H &&head, T &&... args) {
    std::cout << std::fixed << std::setprecision(10) << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    fprint(std::forward<T>(args)...);
}

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

    ld L;
    scan(L);
    ld x   = L / 3.0;
    ld ans = x * x * x;
    fprint(ans);

    return 0;
}

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

class UnionFind
{
protected:
    vector<int> par;
    vector<int> rank;
    vector<int> sz;
    int _count;

public:
    UnionFind(int n) : par(n), rank(n, 0), sz(n, 1), _count(n) {
        iota(par.begin(), par.end(), 0);
    }

    virtual int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return;

        _count--;
        if (rank[x] < rank[y]) {
            swap(x, y);
        }
        if (rank[x] == rank[y]) rank[x]++;

        par[y] = x; sz[x] += sz[y];
    }

    bool same(int x, int y) { return find(x) == find(y); }

    int size(int x) { return sz[find(x)]; }

    int count() { return _count; }
};

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

    int n, m, k; cin >> n >> m >> k;
    vector<int> a(m), b(m), c(k), d(k);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }
    for (int i = 0; i < k; i++) {
        cin >> c[i] >> d[i];
        c[i]--, d[i]--;
    }

    UnionFind uf(n);
    for (int i = 0; i < m; i++) uf.unite(a[i], b[i]);

    vector<int> fr(n, 0), bl(n, 0);
    for (int i = 0; i < m; i++) {
        if (uf.same(a[i], b[i])) fr[a[i]]++, fr[b[i]]++;
    }
    for (int i = 0; i < k; i++) {
        if (uf.same(c[i], d[i])) bl[c[i]]++, bl[d[i]]++;
    }
    
    for (int i = 0; i < n; i++) {
        int ans = max(0, uf.size(i) - 1 - fr[i] - bl[i]);
        cout << ans << " \n"[i == n - 1];
    }
    return 0;
}

Measured memory_bytes: 4352
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scanner.nextInt();
		}
		long g=gcd(a[0],a[1]);
		for(int i=2;i<n;i++) {
			g=gcd(g,a[i]);
		}
		System.out.println(g);
	}
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22100
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, X = map(int, input().split())

    a, p = [1], [1]
    for i in range(N):
        a.append(a[i] * 2 + 3)
        p.append(p[i] * 2 + 1)

    def f(N, X):
        if N == 0:
            return 0 if X <= 0 else 1
        elif X <= 1 + a[N - 1]:
            return f(N - 1, X - 1)
        else:
            return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1])

    print(f(N, X))


if __name__ == '__main__':
    main()


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



int main(void)
{
	//入力変数
	int n = 0;
	//入力配列
	int h_input[101] = {0};
	//一時入力変数
	int h_hozon[101] = {0};
	
	while (true)
	{
		cin >> n;

		if (n == 0)	{	return 0;	}

		//入力する
		for (int i = 0; i <= n; i++)
		{
			cin >> h_input[i];
		}
		
		for (int i = 0; i <= n; i++)
		{
			int count = 0;
			for (int j = 0; j <= n; j++)
			{
				if (i != j)
				{
					h_hozon[count++] = h_input[j];
				}
			}

			//forを回して調べる
			int sa = h_hozon[1] - h_hozon[0];

			int k = 0;
			for (k = 0; k < n - 1; k++)
			{
				if (h_hozon[k] + sa != h_hozon[k + 1])
				{
					break;
				}
			}
			if (k == n - 1)
			{
				cout << h_input[i] << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1160
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<climits>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

int main(){
    int A,B;
    cin>>A>>B;
    int wa=A+B;
    if(wa%2==1) cout<<"IMPOSSIBLE"<<endl;
    else cout<<wa/2<<endl;
}


Measured memory_bytes: 3160
#include <iostream>

using namespace std;

int main()
{
    int w,h,x,y,r;

    cin >>w >>h >>x >>y >>r;

    if ((x+r)>w){
        cout<<"No" <<endl;
    }
    else if((x-r)<0){
        cout<<"No" <<endl;
    }
    else if((y+r)>h){
        cout<<"No" <<endl;
    }
    else if((y-r)<0){
        cout<<"No" <<endl;
    }
    else{
        cout<<"Yes" <<endl;
    }


    return 0;
}



Measured memory_bytes: 3116
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define M (244140624 / 13)
#define L 13

bool isExist[M][L] = {{false}};

void insert(char *in_str);
bool find(char *target_str);

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

    char op[6];
    char word_str[13];

    while (num_op--) {
        scanf("%s %s", op, word_str);
        if (strcmp(op, "insert") == 0) {
            insert(word_str);
        } else if (strcmp(op, "find") == 0) {
            if (find(word_str)) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        } else {
            printf("ERROR! Wrong operation.\n");
        }
    }

    return 0;
}

int char2int(char in);
long str2long(char *in_str);

long hashFunc1(long in);
int hashFunc2(long in);

void insert(char *in_str)
{
    if (find(in_str) == false) {
        long in_long = str2long(in_str);
        long hash1 = hashFunc1(in_long);
        int hash2 = hashFunc2(in_long);
        isExist[hash1][hash2] = true;
    }
}

int char2int(char in)
{
    if (in == 'A') {
        return 1;
    } else if (in == 'C') {
        return 2;
    } else if (in == 'G') {
        return 3;
    } else if (in == 'T') {
        return 4;
    } else {
        printf("ERROR! Wrong character.\n");
        return -1;
    }
}

long str2long(char *in_str)
{
    int i;

    int p = 1;
    int in_long = 0;
    for (i = 0; i < (int)(strlen(in_str)); i++) {
        in_long += p * char2int(in_str[i]);
        p *= 5;
    }

    return in_long;
}

long hashFunc1(long in)
{
    return (in % M);
}

int hashFunc2(long in)
{
    return (in % L);
}

bool find(char *target_str)
{
    long target_long = str2long(target_str);
    long hash1 = hashFunc1(target_long);
    int hash2 = hashFunc2(target_long);
    return isExist[hash1][hash2];
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) { // n: 要素数 SUM_UNITY: 基本的に 0 を入れます
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) { // x と y が同じグループにいるかどうかを判定する
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) { // weight(y) = weight(x) + w となるように x と y をマージする
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) { // x と y とが同じグループにいるとき、weight(y) - weight(x) をリターンする
        return weight(y) - weight(x);
    }
};

int main(){
    int n, m;
    cin>>n>>m;
    vector<int> l(m), r(m), d(m);
    rep(i,m) cin>>l[i]>>r[i]>>d[i];
    UnionFind<int> uf(n+1);
    int i=0;
    for(i=0;i<m;i++){
        if(uf.issame(l[i], r[i])){
            if(uf.diff(l[i], r[i])!=d[i]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        uf.merge(l[i], r[i], d[i]);
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

int main(){
    int n; cin >> n;
    bool flag=false;
    for(int i=0;i<n;i++){
        char c; cin >> c;
        if(c=='Y') flag=true;
    }
    if(flag) cout << "Four" << endl;
    else cout << "Three" << endl;
    return 0;
}

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

int main() {
  vector<int> num(3);
  for(int i= 0; i < 3; i++){
    cin >> num.at(i);
  }

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

  if(num.at(0) == 5 && num.at(1) == 5 && num.at(2) == 7){
    cout << "YES" << endl;
  }else{
     cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
using System;

class Program
{
    const int MAX = 1000000;

    static void Main(string[] args)
    {
        int[] p = new int[MAX];
        p[2] = 1;
        for (int i = 3; i < MAX; i++)
        {
            if (i % 2 == 0)
            {
                p[i] = p[i - 1];
            }
            else if (IsPrime(i))
            {
                p[i] = p[i - 1] + 1;
            }
            else
            {
                p[i] = p[i - 1];
            }
        }

        string s;
        while ((s = Console.ReadLine()) != null)
        {
            int n = int.Parse(s);
            Console.WriteLine(p[n]);
        }
    }

    static bool IsPrime(int n)
    {
        bool res = true;
        for (int i = 3; i <= Math.Sqrt(n); i = i + 2)
        {
            if (n % i == 0)
            {
                res = false;
            }
        }

        return res;
    }
}

Measured memory_bytes: 9524