akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int N; cin >> N;
  vector<int> a(N); rep(i, N) a.at(i); rep(i, N) cin >> a.at(i);
  bool ok;
  int m = 0;
  int m2 = 0;
  int m4 = 0;
  rep(i, N){
    if(a.at(i) % 4 == 0){
      m4++;
    } else if(a.at(i) % 2 == 0){
      m2++;
    } else {
      m++;
    }
  }
  m += m2 % 2;
  m2 -= m2 % 2;
  if(m4 >= m-1){
    ok = true;
  } else {
    ok = false;
  }
  if(ok){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		bool[] dp = new bool[X + 1];
		int[] a = new int[]{
			100,101,102,103,104,105
		};
		
		dp[0] = true;
		foreach(var v in a){
			for(int i=0;i<X;i++){
				if(!dp[i]) continue;
				if(i + v <= X){
					dp[i + v] = true;
				}
			}
		}
		
		Console.WriteLine(dp[X] ? 1 : 0);
		
	}
	int X;
	public Sol(){
		X = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11156
import kotlin.math.*
import java.util.*
import java.io.*
var ans:Int = 0
var temptemp:Int = 0
var temp:Int = 0
fun main() {
    val S = readLine()!!
    val T = readLine()!!
    val slength:Int = S.length
    val tlength:Int = T.length
    for(i in 0..slength-tlength){
        for(j in 0..tlength-1){
            if(S[i+j] == T[j]){
                temp++
            }
        }
        if(temptemp < temp){
            temptemp = temp
        }
        temp = 0
    }
    ans = tlength-temptemp
    println(ans)
}

Measured memory_bytes: 36060
h,u,d,p;main(n){for(;~scanf("%*d%d"+!!h*3,&n);u=d=p=!printf("%d %d\n",u,d))for(;n--;p=h)scanf("%d",&h),p?u=h-p>u?h-p:u,d=p-h>d?p-h:d:0;}

Measured memory_bytes: 0
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int n;
double a[3100];
double mem[3100][3100];

double dp(int i, int num){
if(i == n){
    if(num <= n/2) return 0;
    else return 1;
}


if(mem[i][num] == mem[i][num]) return mem[i][num];
double ret = 0, ret1 = 0;
ret = 1.0 *a[i]*dp(i+1,num+1);
ret1 = 1.0*(1-a[i]) * dp(i+1,num);
return mem[i][num] = ret+ret1;
}


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

  memset(mem,-1,sizeof(mem));

  cout<<setprecision(10)<<dp(0,0)<<fixed;

}


Measured memory_bytes: 75648
#include <stdio.h>
int main()
{
	long long int h,a,t;
	
	scanf("%lld %lld",&h,&a);
	
	t = 0;
	
	while(h > 0)
	{
		h -= a;
		t++;
	}
	
	printf("%lld\n",t);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    double v;
    while(cin>>v) {
        double t = v / 9.8;
        double y = 4.9 * t * t;
        double n = (y+5) / 5;
        printf("%d\n", (int)(n + 1));
    }

    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+9, INF = 0x3f3f3f3f;


int main( void ) {
    ios::sync_with_stdio( false );
    int a, b;
    cin >> a >> b;
    cout << __gcd( a, b ) << '\n';
    return 0;
}



Measured memory_bytes: 3224
def slove():
    import sys
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    s = s[:len(s)-1]
    while True:
        if len(s) % 2 == 0:
            if s[:len(s)//2] == s[len(s)//2:]:
                print(len(s))
                exit()
        s = s[:len(s)-1]


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<vector>

#define int long long

using namespace std;

struct edge{
	int v,w;
	edge():v(0),w(0){}
	edge(int y,int z):v(y),w(z){}
};

class FastFileReader{char buffer[10000001];char *h;int len;inline char gchar(){return *h++;}inline bool validdigit(char c){return c>='0' && c<='9';}public:inline void init(){len=fread(buffer,1,10000000,stdin);h=buffer;}inline int nextint(){register int i=0;register char c;do c=gchar();while(!validdigit(c));do{i=i*10+c-48;c=gchar();}while(validdigit(c));return i;}inline int nextsigned(){register int i=0,f=1;register char c;do{c=gchar();if(c=='-')f=-1;}while(!validdigit(c));do{i=i*10+c-48;c=gchar();}while(validdigit(c));return i*f;}inline long long nextlonglong(){register long long i=0;register char c;do c=gchar();while(!validdigit(c));do{i=i*10+c-48;c=gchar();}while(validdigit(c));return i;}inline long long nextsignedlonglong(){register long long i=0,f=1;register char c;do{c=gchar();if(c=='-')f=-1;}while(!validdigit(c));do{i=i*10+c-48;c=gchar();}while(validdigit(c));return i*f;}inline char nextchar(){register char c;do c=gchar();while(c<=' ');return c;}};

FastFileReader fs;
int N,M,x,y,c[100001],cnt[4],siz,tot,ans;
bool flag,vis[100001];
vector<edge> point[100001];

void dfs(int u){
	++cnt[c[u]],vis[u]=true,++siz;
	for(edge e:point[u])if(e.w==1)++tot;
	for(edge e:point[u]){int v=e.v,w=e.w;if(!vis[v])c[v]=(c[u]+w+2)%3+1,dfs(v);else if(c[v]!=(c[u]+w+2)%3+1)flag=false;}
}

main(){
	fs.init();
	N=fs.nextint(),M=fs.nextint();
	for(int i=1;i<=M;++i)x=fs.nextint(),y=fs.nextint(),point[x].push_back(edge(y,1)),point[y].push_back(edge(x,-1));
	for(int i=1;i<=N;++i)c[i]=1;
	for(int i=1;i<=N;++i)if(!vis[i]){
		flag=true;siz=tot=cnt[1]=cnt[2]=cnt[3]=0;dfs(i);
		if(!flag)ans+=siz*siz;else if(cnt[1]&&cnt[2]&&cnt[3])ans+=cnt[1]*cnt[2]+cnt[1]*cnt[3]+cnt[2]*cnt[3];else ans+=tot;
	}
	printf("%lld",ans);
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int n;
  scanf("%d", &n);
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; ++i) { scanf("%lld", &a[i]); }
  for (int i = 0; i < n; ++i) { scanf("%lld", &b[i]); }

  ll ans = 0;
  for (int bit = 0; bit < 30; ++bit) {
    ll T = (1 << bit);
    vector<ll> bb(n);
    for (int i = 0; i < n; ++i) {
      bb[i] = b[i] % (2 * T);
    }
    sort(bb.begin(), bb.end());
    ll cnt = 0;
    for (int i = 0; i < n; ++i) {
      ll val = a[i] % (2 * T);
      cnt += upper_bound(bb.begin(), bb.end(), 2 * T - val - 1) -
        lower_bound(bb.begin(), bb.end(), T - val);
      cnt += upper_bound(bb.begin(), bb.end(), 4 * T - val - 1) -
        lower_bound(bb.begin(), bb.end(), 3 * T - val);
    }
    if (cnt % 2) { ans |= (1 << bit); }
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 5092
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
    s = input()
    if s.count('A') == 3 or s.count('B') == 3:
        print('No')
    else:
        print('Yes')

main()

Measured memory_bytes: 68588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_que<int> pque;//これは大きい順
//typedef priority_que<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	string a;
	cin >>a;
	int n = a.length();
	int ans = 0;
	rep(i,(n+1)/2){
		if(a[i] == a[n-i-1]) continue;
		ans ++;
	}
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    n,t=map(int,input().split(' '))
    human = list(map(int,input().split(' ')))
    ans = t
    for i in range(n-1):
        if human[i+1]-human[i] >= t:
            ans += t
        else:
            ans += human[i+1] - human[i]
    print(ans)
if __name__ == '__main__':
    main()


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

int main()
{
  ll n, k;
  cin >> n >> k;
  vector<ll> x(n);
  for (auto &e : x)
    cin >> e;
  ll ans = 1e9;
  if (k == 1)
  {
    for (ll i = 0; i < n; ++i)
    {
      ans = min(ans, abs(x[i]));
    }
    cout << ans << endl;
  }
  else
  {
    for (ll i = 0; i < n - k + 1; ++i)
    {
      if (x[i] * x[i + k - 1] < 0)
      {
        if (abs(x[i]) < abs(x[i + k - 1]))
        {
          ans = min(ans, abs(x[i] * 2 - x[i + k - 1]));
        }
        else
        {
          ans = min(ans, abs(x[i] - x[i + k - 1] * 2));
        }
      }
      else
        ans = min(ans, max(abs(x[i]), abs(x[i + k - 1])));
    }
    cout << ans << endl;
  }

  return 0;
}

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

using namespace std;
int n;
bool open[105][15];
long long p[105][15];

long long cal(int x)
{
	long long ret=0;
	for(int i=1;i<=n;i++)
	{
		int sum=0;
		for(int j=0;j<=9;j++)
			if(open[i][j] && (x>>j&1)) sum++;
		ret+=p[i][sum];
	}
	return ret;
}

int main()
{	
	cin >> n;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=9;j++)
			cin >> open[i][j];
	for(int i=1;i<=n;i++)
		for(int j=0;j<=10;j++)
			cin >> p[i][j];
	
	long long res=-(1<<30);
	for(int i=1;i<=1023;i++)
	{
		long long temp=cal(i);
		res=max(res,temp);
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> d(K);
	vector<vector<int>> A(K);
	vector<int> h(N, 0);
	for (int i = 0; i < K; ++i) {
		cin >> d[i];
		A[i].resize(d[i]);
		for (int j = 0; j < d[i]; ++j) {
			cin >> A[i][j];
			--A[i][j];
			++h[A[i][j]];
		}
	}
	int ans = count(h.begin(), h.end(), 0);
	cout << ans << endl;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    ll ans;
    ans=0;
    ll c,d;
    c=max(a,b);
    d=min(a,b);
    int c2;
    c2=c;

    while(ans==0){
        if(c%d==0){
            ans=c;
            break;
        }
        c+=c2;
    }
    cout << c << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int main() {
	string str;
	int n, k;
	cin >> n>>k>>str;
	VI x;
	char ch = str[0];
	int cnt = 0;
	if (str[0] == '0')x.PB(0);
	REP(i, n) {
		if (str[i] == ch)cnt++;
		else {
			x.PB(cnt);
			cnt = 1;
			ch = str[i];
		}
	}
	x.PB(cnt);
	x.PB(0);
	int m = x.size();
	int tmp = 0;
	REP(i, min(m, 2 * k + 1))tmp += x[i];
	int ans = tmp;
	for (int i = 2 * k + 1, j=0; i < m-1; i+=2, j += 2) {
		tmp += x[i] + x[i + 1];
		tmp -= x[j] + x[j+1];
		ans = max(tmp, ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1020
from collections import namedtuple
import heapq

Edge = namedtuple('Edge', ('fr', 'to', 'cost'))
inf = int(1e9)


def bellman_ford(n, start, edges):
    dists = [inf for _ in range(n)]
    dists[start] = 0
    while True:
        updated = False
        for e in edges:
            if dists[e.fr] != inf and dists[e.fr] + e.cost < dists[e.to]:
                updated = True
                dists[e.to] = dists[e.fr] + e.cost

        if not updated:
            break

    return dists


def dijkstra(n, costs):
    dists = [inf for _ in range(n)]
    dists[0] = 0

    queue = []
    for (i, d) in enumerate(dists):
        heapq.heappush(queue, (d, i))

    while len(queue) > 0:
        d, i = heapq.heappop(queue)
        if d > dists[i]:
            continue

        for v in range(n):
            if v == i or costs[i][v] == inf:
                continue

            if dists[i] + costs[i][v] < dists[v]:
                dists[v] = dists[i] + costs[i][v]
                heapq.heappush(queue, (dists[v], v))

    return dists


def warshall_floyd(n, costs):
    dists = [[costs[i][j] for j in range(n)] for i in range(n)]

    for k in range(n):
        for i in range(n):
            for j in range(n):
                dists[i][j] = min(dists[i][j], dists[i][k] + dists[k][j])

    return dists


n = int(input())

m = [[inf if i != j else 0 for i in range(n)] for j in range(n)]
es = []
for i in range(n):
    fs = list(map(int, input().split()))
    ne = fs[1]
    for j in range(ne):
        v = fs[2+2*j]
        c = fs[2+2*j+1]
        m[i][v] = c
        es.append(Edge(i, v, c))


# d = bellman_ford(n, 0, es)
# d = dijkstra(n, m)
d = warshall_floyd(n, m)
for (i, di) in enumerate(d[0]):
    print(i, di)




Measured memory_bytes: 6988
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int H, W, res;
char c[2000][2000];
vector<int>h[2000], w[2000];

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; ++i) {
		h[i].push_back(-1);
	}
	for (int j = 0; j < W; ++j) {
		w[j].push_back(-1);
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> c[i][j];
			if (c[i][j] == '#') {
				h[i].push_back(j);
				w[j].push_back(i);
			}
		}
	}
	for (int i = 0; i < H; ++i) {
		h[i].push_back(W);
	}
	for (int j = 0; j < W; ++j) {
		w[j].push_back(H);
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (c[i][j] == '.') {
				int cnt = 0;
				auto it = lower_bound(h[i].begin(), h[i].end(), j);
				cnt += *it - j;
				--it;
				cnt += j - *it;
				it = lower_bound(w[j].begin(), w[j].end(), i);
				cnt += *it - i;
				--it;
				cnt += i - *it;
				cnt -= 3;
				res = max(res, cnt);
			}
		}
	}
	cout << res << endl;
}

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

int main(void){

	int N;
	char c;
	int i,k;
	int ans=0;
	int ctr=0;

	cin >> c;

	//cout << c+1 << endl;
	printf("%c\n",c+1);

	return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(ll i=0; i<N; i++){
        cin >> A.at(i);
    }
    ll now=A.at(0);
    ll ans=0;
    for(ll i=1; i<N; i++){
        if(A.at(i)>now) now=A.at(i);
        else ans+=now-A.at(i);
    }
    cout << ans;
}

Measured memory_bytes: 4840
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int x[3];
  cin>>x[0]>>x[1]>>x[2];
  sort(x, x + 3);
  int d = x[2] - x[1];
  int ans = 0;
  ans += d;
  x[0] += d;
  int e = x[2] - x[0];
  if(e % 2 == 0) {
    ans += e / 2;
  } else {
    ans += e / 2 + 2;
  }
  cout << ans << endl;

  return 0;
}


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

int find_win(vector<int> &g, vector< vector< pair<int, int > > > &list, int v, int pr, int u1, int u2) {
	int xr = 0;
	for (int i = 0; i < list[v].size(); i++) {
		int nxt = list[v][i].first;
		if ((v == u1 && nxt == u2) || (v == u2 && nxt == u1)) {
			continue;
		}
		if (nxt != pr) {
			xr ^= (find_win(g, list, nxt, v, u1, u2) + 1);
		}
	}
	g[v] = xr;
	return xr;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, r = 1, a, b;
	cin >> n;
	vector< vector< pair<int, int > > > list(n + 1, vector< pair<int, int > >());
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b;
		list[a].push_back({ b, i });
		list[b].push_back({ a, i });
	}
	vector<int> g(n + 1, 0);
	int w = find_win(g, list, r, -1, -1, -1);
	if (w > 0) {
		cout << "Alice" << endl;
	} else {
		cout << "Bob";
	}
	return 0; 
}

Measured memory_bytes: 15488
#include<bits/stdc++.h>
using namespace std;
int n;
int m;
vector<int> v[1000009];
queue<int >q;
int a[1000009];
int vis[1000009];
int s,t;
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>s>>t;
        v[s].push_back(t);
        v[t].push_back(s);
    }
    s=1;
    t=n;
    vis[s]=1;
    a[s]=0;
    q.push(s);
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        for(int i=0;i<v[x].size();i++)
        {
            int k=v[x][i];
            if(vis[k]==0)
            {
                vis[k]=1;
                q.push(k);
                a[k]=a[x]+1;
            }
        }
    }
    if(a[n]==2)
        cout<<"POSSIBLE";
    else
        cout<<"IMPOSSIBLE";
}


Measured memory_bytes: 37744
//Author - Sanket Mundra
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back 
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fin cin
#define PI 3.14159265358979323846
#define M 1000000007;

int main()
{
    
    fastIO;
    ll t,i,j,k,l,r,n,m,ans,sum,mx,mn,cnt; cin>>t;
    string s;
    ll f[t]={0};
    for(i=0;i<t-1;i++)
    {
        cin>>j;
        f[j-1]++;
    }
    for(i=0;i<t;i++) cout<<f[i]<<"\n";
    return 0;
}

Measured memory_bytes: 5180
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<vector>
#define MAXSIZE 1000005
#define LL long long
#define INF 0x3f3f3f3f

using namespace std;

LL pos[MAXSIZE];
LL dist[MAXSIZE];

LL Solve(int n,int k)
{
    LL sum = 0;
    for(int i=1;i<n;i++)
    {
        dist[i] = pos[i+1]-pos[i];
        sum += dist[i];
    }

    sort(dist+1,dist+1+n-1);
    for(int i=n-1;i>=n-k+1 && i>=1;i--)
    {
        sum -= dist[i];
    }
    return sum;
}

int main()
{
    int T,n,k;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d%d",&n,&k);
        for(int i=1;i<=n;i++)
        {
            scanf("%lld",&pos[i]);
        }

        LL ans = Solve(n,k);
        printf("%lld\n",ans);
    }
    return 0;
}



Measured memory_bytes: 4664
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str;
        int i,j,k,a,b,c;
        long x[][];
        long y[][];
        long z[][];
        str = scan.nextLine();
        String[] num = str.split(" ", 0);
        a = Integer.valueOf(num[0]);
        b = Integer.valueOf(num[1]);
        c = Integer.valueOf(num[2]);
        x = new long[a][b];
        y = new long[b][c];
        z = new long[a][c];
       for(i=0;i<a;i++){
           str = scan.nextLine();
           num = str.split(" ", 0);
           for(j=0;j<b;j++){
               x[i][j] = Integer.valueOf(num[j]);
           }
       }
        for(i=0;i<b;i++){
            str = scan.nextLine();
            num = str.split(" ", 0);
            for(j=0;j<c;j++){
                y[i][j] = Integer.valueOf(num[j]);
            }
        }
        for(i=0;i<a;i++){
            for(j=0;j<c;j++){
                for(k =0;k<b;k++){
                    z[i][j] += x[i][k] * y[k][j];   
                }
            }
        }
        for(i=0;i<a;i++){
            for(j=0;j<c-1;j++){
                System.out.print(z[i][j]+" ");
            }
            System.out.println(z[i][j]);
        }


        scan.close();
    }

}




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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int N;
vector<vector<int>> s;

signed main()
{
    cin >> N;
    s.resize(N);
    char temp;

    rep(i, N)
    {

        s[i].resize(10);
        rep(j, 10)
        {
            cin >> temp;
            s[i][j] = temp - '0';
        }
    }

    map<vector<int>, int> index;

    rep(i, N)
    {
        sort(all(s[i]));
        index[s[i]]++;
    }

    int ans = 0;

    for (auto x : index)
    {
        if (x.second > 1)
        {
            ans += x.second * (x.second - 1) / 2;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
	cin.sync_with_stdio(false);
	int n, d, x;
	cin >> n >> d >> x;
	vector<vector<ll>> p(d, vector<ll>(n));
	for (int i = 0; i < d; i++) {
		for (int j = 0; j < n; j++) {
			cin >> p[i][j];
		}
	}
	for (int i = 1; i < d; i++) {
		vector<ll> dp(100001, -1);
		dp[x] = x;
		for (int j = 0; j < n; j++) {
			for (int k = 0; k <= 100000 - p[i][j]; k++) {
				if (dp[k] >= p[i - 1][j]) {
					dp[k + p[i][j] - p[i - 1][j]] = max(dp[k + p[i][j] - p[i - 1][j]], dp[k] - p[i - 1][j]);
				}
			}
		}
		int ma = 0;
		for (int k = 0; k <= 100000; k++) {
			if (dp[k] >= 0) {
				ma = k;
			}
		}
		x = ma;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 3940
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>

using namespace std;

void name(long long n){
    char last = --n % 26 + 'a';
    n /= 26;
    if(n)
        name(n);
    printf("%c", last);
}

int main()
{
    long long N;

    scanf("%lld", &N);
    name(N);

    return 0;
}


Measured memory_bytes: 1660
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			System.gc();
			
			final int N = sc.nextInt();
			final int M = sc.nextInt();
			
			if(N == 0 && M == 0){
				break;
			}
			
			int[] h_array = new int[N];
			int[] w_array = new int[M];
			
			for(int i = 0; i < N; i++){
				h_array[i] = sc.nextInt();
			}
			
			for(int i = 0; i < M; i++){
				w_array[i] = sc.nextInt();
			}
			
			 int[] h_map = new int[1500001];
			 int[] w_map = new int[1500001];
			
			for(int len = 1; len <= h_array.length; len++){
				int sum = 0;
				for(int t = 0; t < len; t++){
					sum += h_array[t];
				}
				
				h_map[sum]++;
				
				for(int in = len; in < h_array.length; in++){
					sum += h_array[in];
					sum -= h_array[in - len];
					
					h_map[sum]++;
				}
			}
			
			for(int len = 1; len <= w_array.length; len++){
				int sum = 0;
				for(int t = 0; t < len; t++){
					sum += w_array[t];
				}
				
				w_map[sum]++;
				
				for(int in = len; in < w_array.length; in++){
					sum += w_array[in];
					sum -= w_array[in - len];
					
					w_map[sum]++;
				}
			}
			
			
			int count = 0;
			for(int h = 0; h < h_map.length; h++){
				if(h_map[h] == 0){
					continue;
				}else if(w_map[h] == 0){
					continue;
				}else{
					count += h_map[h] * w_map[h];
				}
			}
			
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 50636
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int N; cin >> N;
	for (int i = 0; 4 * i <= N; i++) {
		if ((N - 4 * i) % 7 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
}

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

long int gcd(long int a, long int b);
long int lcm(long int a, long int b);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    long int A, B;
    cin >> A >> B; 

    if (A < B){
        swap(A, B);
    }

    cout << lcm(A, B) << "\n"; 

    return 0;
}

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

long int lcm(long int a, long int b){
    return ((a * b) / gcd(a, b));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int x,t;
	int ans=0;
	cin >>x>>t;
	cout<<max(0,x-t)<<endl;
}

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

using namespace std;

int main(void)  { 
    int n, x;
    cin >> n >> x;

    vector<int> l(n);
    for(int i = 0; i < n; i++)  l[i] = 0;
    for(int i = 0; i < n; i++) cin >> l[i];

    int d = 0;
    int count = 0;
    for(int i = 1; i < n+1; i++) {
        d = d + l[i-1];
        if(d > x) { 
            break;
        }
        count++;
    }

    cout << count + 1<< endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define  rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i>=0; i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int A, B; std::cin >> A >> B;
  if ( A % 3 == 0 || B % 3 == 0 || (A+B)%3 == 0 ) std::cout << "Possible" << std::endl;
  else std::cout << "Impossible" << std::endl;
  return 0;
}


Measured memory_bytes: 256
void main() {
	auto a = ri;
	writeln(a + a*a + a*a*a);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2720
import bisect
import sys
input = sys.stdin.readline

INF = 10**12
n, q = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

# Calc cumrative sum
sum_even = [0] * (n + 1)
sum_odd = [0] * (n + 1)
sum_all = [0] * (n + 1)
for i, item in enumerate(a):
    if i % 2 == 0:
        sum_odd[i+1] = sum_odd[i] + a[i]
        sum_even[i+1] = sum_even[i]
    else:
        sum_even[i+1] = sum_even[i] + a[i]
        sum_odd[i+1] = sum_odd[i]
    sum_all[i+1] = sum_all[i] + a[i]

# Iterate in query
a.append(INF)
ans = []
for i in range(q):
    x = int(input())
    # Get div of aoki - takahashi
    # l: aoki takes, r: takahashi takes
    l = 0; r = n - 1
    while r - l > 1:
        m = (r + l) // 2
        rng = abs(x - a[m])
        t_num = n - m
        a_num = n - t_num - (bisect.bisect_left(a, x - rng))
        if t_num <= a_num + 1:
            r = m
        else:
            l = m
    rng = abs(x - a[r])
    t_num = n - r
    rest = n - 2 * t_num
    t_sum = sum_all[n] - sum_all[n - t_num]
    a_sum = sum_all[r] - sum_all[r - t_num]

    # Add stripe area
    if n - t_num * 2 > 0:
        if rest % 2 == 0:
            t_sum += sum_even[rest]
            a_sum += sum_odd[rest]
        else:
            t_sum += sum_odd[rest]
            a_sum += sum_even[rest]
    ans.append(t_sum)

print("\n".join([str(item) for item in ans]))

Measured memory_bytes: 96108
import sys
import numpy as np
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    if a[i]%2 == 1:
        continue
    else:
        if a[i]%3 != 0 and a[i]%5 != 0:
            print("DENIED")
            sys.exit()
print("APPROVED")


Measured memory_bytes: 12676
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   string S;
   cin >> S;
   for(int i = 0 ; i < 3; i++){
      if(S[i]==S[i+1]){
         cout <<"Bad"<< endl;
         return 0;
      }

   }
   cout <<"Good"<< endl;
   return 0;
}


Measured memory_bytes: 764
N, T = gets.split.map(&:to_i)
route_map = []
min_route = {c: 2000, t: 0}

N.times do
  c, t = gets.split.map(&:to_i)
  route_map << {c: c, t: t}
end

route_map.each do |item|
  if (min_route[:c] > item[:c]) && (item[:t] <= T)
    min_route = item
  end
end

if min_route == {c: 2000, t: 0}
  puts "TLE"
else
  puts min_route[:c]
end


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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend())
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 1000000007
#define F(i, a, n) for (i = a; i < n; i++)
#define B(i, a, n) for (i = n - 1; i >= 0; i--)
#define SI(x) cin >> x
#define DI(x, y) cin >> x >> y
#define TI(x, y, z) cin >> x >> y >> z
#define FI(w, x, y, z) cin >> w >> x >> y >> z
#define SO(x) cout << x << endl
#define DO(x, y) cout << x << " " << y << endl
#define TO(x, y, z) cout << x << " " << y << " " << z << endl
#define FO(w, x, y, z) cout << w << " " << x << " " << y << " " << z << endl

bool compare(pair<int, pair<string, int>> a, pair<int, pair<string, int>> b)
{
    if(a.second.first < b.second.first)
        return true;
    if(a.second.first > b.second.first)
        return false;
    if(a.second.first == b.second.first)
    {
        if(a.second.second > b.second.second)
            return true;
        else
            return false;
    }
    return true;
}

int main(void) 
{
    int i, j;
    int n;
    SI(n);
    vector <pair<int, pair<string, int>>> dp;
    string s;
    int p;
    F(i, 0, n)
    {
        DI(s, p);
        dp.pb(mp(i + 1, mp(s, p)));
    }
    sort(dp.begin(), dp.end(), compare);
    F(i, 0, n)
        SO(dp[i].first);
    return 0;

}


Measured memory_bytes: 256
a,b,c,d = map(int, input().split())
def gcd(a,b):
  while b > 0:
    a,b = b,a%b
  return a
def lcm(a,b):
  return a*b//gcd(a,b)
def f(x):
  return x//c + x//d - x//lcm(c,d)
def g(x):
  return x-f(x)
print(g(b)-g(a-1))

Measured memory_bytes: 3060
n = int(input())
ret = {}
for i in range(n):
    s = input()
    ret[s] = ret.get(s, 0) + 1
m = int(input())
for i in range(m):
    s = input()
    ret[s] = ret.get(s, 0) - 1

print(max(list(ret.values()) + [0]))


Measured memory_bytes: 2940
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;

namespace Header_Template {
  typedef long long li;
  template<class T>inline void read(T &x) {
    x = 0;
    T tmp = 1;
    char c = getchar();
    while ((c < '0' || c > '9') && c != '-') c = getchar();
    if (c == '-') tmp = -1, c = getchar();
    while (c >= '0' && c <= '9')
      x = (x << 1) + (x << 3) + c - '0', c = getchar();
    x *= tmp;
  }
  template<class T>inline void Max(T &x, T y) {
    if (y > x) x = y;
  }
  template<class T>inline void Min(T &x, T y) {
    if (y < x) x = y;
  }
}
using namespace Header_Template;

const int N = 1e5 + 10;
int n, a[N], v[N];
int b[N], s[N];

namespace BIT {
  li c[N << 1];
  void Init(void) { memset(c, 0, sizeof c); }
  inline int lowbit(int x) { return x & -x; }
  void Add(int x, int val) {
    x += n;
    for (; x <= n + n; x += lowbit(x))
      c[x] += val;
  }
  li Query(int x) {
    x += n;
    li res = 0;
    for (; x; x -= lowbit(x))
      res += c[x];
    return res;
  }
}

li Check(int x) {
  for (int i = 1; i <= n; ++i)
    b[i] = (a[i] >= x) ? 1 : -1;
  // for (int i = 1; i <= n; ++i)
  //   printf("%d ", b[i]);
  // putchar('\n');
  BIT::Init();
  s[0] = 0;
  for (int i = 1; i <= n; ++i)
    s[i] = s[i - 1] + b[i];
  li ans = 0;
  BIT::Add(0, 1);
  for (int i = 1; i <= n; ++i) {
    ans += BIT::Query(s[i]);
    BIT::Add(s[i], 1);
  }
  return ans;
}

int main(void) {
  read(n);
  li m = 1LL * n * (n + 1) / 2;
  m = (m + 1) / 2;
  //printf("m = %lld\n", m);
  for (int i = 1; i <= n; ++i)
    read(a[i]), v[i] = a[i];
  sort(v + 1, v + 1 + n);
  int n0 = unique(v + 1, v + 1 + n) - v - 1;
  for (int i = 1; i <= n; ++i)
    a[i] = lower_bound(v + 1, v + 1 + n0, a[i]) - v;
  
  int l = 1, r = n0, ans = 1;
  while (l <= r) {
    int mid = l + r >> 1;
    li cur = Check(mid);
    //printf("%d %d %d %lld\n", l, mid, r, cur);
    if (cur >= m) ans = mid, l = mid + 1;
    else r = mid - 1;
  }
  printf("%d\n", v[ans]);

  return 0;
}


Measured memory_bytes: 3328
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef long long LL;
const int MAX=10002;
int V,E;
int indeg[MAX]={0},inq[MAX]={0};
vector<int> out,G[MAX];
void bfs(int s){
	queue<int> Q;
	Q.push(s);
	inq[s]=1;
	while (!Q.empty()){
		int u=Q.front();
		out.push_back(u);
		Q.pop();
		for(int i=0;i<G[u].size();i++){
			int v=G[u][i];
			indeg[v]--;
			if(!indeg[v] && !inq[v]){
				Q.push(v);
				inq[v]=1;
			}
		}
	}
}
void topologicalSort(){
	for(int i=0;i<V;i++){
		if(!indeg[i]&&!inq[i])
			bfs(i);
	}
}
int main(){
	cin>>V>>E;
	int s,t;
	for(int i=0;i<E;i++){
		cin>>s>>t;
		G[s].push_back(t);
		indeg[t]++;
	}
	topologicalSort();
	for(int i=0;i<V;i++){
		cout<<out[i]<<endl;
	}
	return 0;
} 


Measured memory_bytes: 3492
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if(s == "abc") cout << "Yes\n";
  else cout << "No\n";
}

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

int main(){
  int A;
  int B;
  int j;
  cin >> A >>B;
  int N =100;
  for (int i= 0; i<N; ++i){
    if (A*i-i+1 >= B){
      j = i;
    break;  
    }
  }
  cout << j <<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug != false) {
            return;
        }
        System.out.println(str);
    }

    public static void main(String[] args) {

        long A;
        long B;

        try (Scanner sc = new Scanner(System.in)) {
            A = sc.nextLong();
            B = sc.nextLong();
        }
        long K = 0;
        if(Math.abs(A - B ) %2 ==1 ){
            System.out.println("IMPOSSIBLE");
            return;
        }
        if(A > B){
            K = A - ((A - B) / 2);
        }else{
            K = B - ((B - A) /2);
        }
        System.out.println(K);
        return;
    }
}

Measured memory_bytes: 23124
#include <iostream>

int main(int argc, char const* argv[])
{
    uint_fast32_t a[200];
    int i;
    std::cin >> i;
    i = 0;
    while (std::cin >> a[i]) {
        if (a[i]&0x1) {
            std::cout << 0 << std::endl;
            return 0;
        }
        a[i] >>= 1;
        i++;
    }

    int result = 1;
    while (1) {
        for (int j=0; j<i; j++) {
            if (a[j] & 0x1) {
                std::cout << result << std::endl;
                return 0;
            }
            a[j] >>= 1;
        }
        result++;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, k; cin>>n>>k;
	int cnt[101]={};
	for(int i=0; i<k; i++){
		int d; cin>>d;
		for(int j=0; j<d; j++){
			int a; cin>>a; a--;
			cnt[a]++;
		}
	}
	int ans=0;
	for(int i=0; i<n; i++){
		if(cnt[i]==0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3596
n = int(input())
A = [int(x) for x in input().split()]
sumA = 0
for a in A:
    sumA += a
q = int(input())
M = [int(x) for x in input().split()]

def solve(i, m):
    if m == 0:
        return True
    elif i >= n or m < 0 or m > sumA: #A[i] < 0 があり得るならm < 0はダメ
        return False
    return solve(i + 1, m) or solve(i + 1, m - A[i])

for i in range(q):
    if solve(0, M[i]) == True:
        print("yes")
    else:
        print("no")



Measured memory_bytes: 5624
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
ll dx[] = {1,0,-1,0};
ll dy[] = {0,1,0,-1};
ll n,m;
bool isafe(ll x,ll y)
{
	if(x>=1 and x<=n and y>=1 and y<=m) return true;
	return false;
}
signed main()
{
    fast;
  
    ll k,i,j;
    cin>>n>>m>>k;
    char mat[n+2][m+2];
    ll x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    for(i=1;i<=n;i++)
    {
    	for(j=1;j<=m;j++) cin>>mat[i][j];
    }
    vector<vector<ll>> dj(n+2,vector<ll>(m+2,inf));
    queue<pii> q;
    q.push({x1,y1});
    dj[x1][y1] = 0;
    while(!q.empty())
    {
    	pii st = q.front();
    	q.pop();
    	for(i=0;i<4;i++)
    	{
    		for(j=1;j<=k;j++)
    		{
    			ll nx = dx[i]*j + st.fi;
    			ll ny = dy[i]*j + st.se;
    			if(isafe(nx,ny))
    			{
    				if(mat[nx][ny]=='@') break;
    				if(dj[nx][ny] <= dj[st.fi][st.se] and dj[nx][ny]!=inf) break;
    				if(dj[nx][ny]==inf)
    				{
    					dj[nx][ny] = dj[st.fi][st.se] + 1;
    					q.push({nx,ny});
    				}
    			}
    		}
    	}
    }
    //cout<<dj[x2][y2];
    cout<<((dj[x2][y2] == inf) ? -1 :  dj[x2][y2]);
}

Measured memory_bytes: 35380
#include<iostream>
using namespace std;
int main(){
	int h1, h2, s1, s2;
	cin >> h1 >> s1 >> h2 >> s2;
	while(h1>0&&h2>0){
		h1-=s2;
		h2-=s1;
	}
	if(h2<=0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3556
N = int(input())
ac=0
wa=0
tle=0
re=0


for i in range(1,N+1):
  S = input()
  
  if S == "AC":
    ac+=1
  elif S == "WA":
    wa+=1
  elif S=="TLE":
    tle+=1
  elif S=="RE":
    re+=1

print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 9232
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
       

template <typename T>
class Grid {
  struct Pos {
    int i, j;
    Pos(int i, int j) : i(i), j(j) {}
  };

  int H, W;
  vector<vector<T>> G;

  vector<int> di8 = {1, 1, 0, -1, -1, -1, 0, 1},
              dj8 = {0, 1, 1, 1, 0, -1, -1, -1};
  vector<int> di4 = {1, 0, -1, 0}, dj4 = {0, 1, 0, -1};

  vector<Pos> neighbor(int i, int j, const vector<int>& dis,
                       const vector<int>& djs) const {
    vector<Pos> res;
    for (int k = 0; k < dis.size(); ++k) {
      if (in(i + dis[k], j + djs[k])) res.emplace_back(i + dis[k], j + djs[k]);
    }
    return res;
  }

 public:
  static bool in(int H, int W, int i, int j) {
    return 0 <= i && i < H && 0 <= j && j < W;
  }

  Grid(int H, int W) : H(H), W(W) { G.resize(H, vector<T>(W)); }

  vector<T>& operator[](int i) { return G[i]; }

  bool in(int i, int j) const { return (0 <= i && i < H && 0 <= j && j < W); }

  vector<Pos> neighbor8(int i, int j) const { return neighbor(i, j, di8, dj8); }

  vector<Pos> neighbor4(int i, int j) const { return neighbor(i, j, di4, dj4); }

  void scanFrom(istream& strm) { for (int i = 0; i < (int)H; ++i) for (int j = 0; j < (int)W; ++j) strm >> G[i][j]; }

  void outputTo(ostream& strm) {
    for (int i = 0; i < (int)H; ++i) {
      for (int j = 0; j < (int)W; ++j) cout << G[i][j];
      strm << endl;
    }
  }
};

template <typename T>
inline istream& operator>>(istream& strm, Grid<T>& g) {
  g.scanFrom(strm);
  return strm;
}

template <typename T>
inline ostream& operator<<(ostream& strm, Grid<T>& g) {
  g.outputTo(strm);
  return strm;
}

int main() {
  int H, W, N;
  cin >> H >> W >> N;

  using P = pair<int, int>;
  map<P, int> C;
  for (int i = 0; i < (int)N; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    for (int i = 0; i < (int)3; ++i) for (int j = 0; j < (int)3; ++j) {
      if (Grid<int>::in(H, W, a - i, b - j) &&
          Grid<int>::in(H, W, a - i + 2, b - j + 2)) {
        C[make_pair(a - i, b - j)] += 1;
      }
    }
  }

  vector<ll> ans(10, 0);

  for (auto &p : C) ans[p.second] += 1;

  ans[0] = (H - 2LL) * (W - 2LL) - accumulate(ans.begin() + 1, ans.end(), 0LL);
  for (int i = 0; i < (int)10; ++i) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 56448
import sys
import math


def int1(x): return int(x) - 1
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def mi1(): return map(int1, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def lli(rows_number): return [li() for _ in range(rows_number)]


if __name__ == "__main__":
    a, b, h, m = mi()
    hsita = 360*(h+m/60)/12
    msita = 360*m/60
    if abs(hsita-msita) >= 180:
        sita = math.radians(360-abs(hsita-msita))
    else:
        sita = math.radians(abs(hsita-msita))
    ans = math.sqrt(a**2 + b**2 - 2*a*b*(math.cos(sita)))
    print(ans)


Measured memory_bytes: 9536