akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pll, int> plp;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const bool debug = 0;
//--------------------------------//
 
int N;
int t[101], v[101];
double dp[40001][201];
int ma[40001];
 
int main() {
	cin >> N;
	REP(i, N) scanf("%d", t + i), t[i] *= 2;
	REP(i, N) scanf("%d", v + i), v[i] *= 2;
	
	int now = 0;
	REP(i, N) REP(j, t[i]) ma[now++] = v[i];
	
	fill(dp[0], dp[now + 1], -1.0);
	dp[0][0] = 0.0;
	REP(i, now) REP(j, ma[i] + 1) {
		if (dp[i][j] < 0) continue;
		
		if (j <= ma[i + 1]) chmax(dp[i + 1][j], dp[i][j] + j * 0.25);
		if (j < ma[i] && j + 1 <= ma[i + 1]) chmax(dp[i + 1][j + 1], dp[i][j] + j * 0.25 + 0.25);
		if (j > 0 && j - 1 <= ma[i + 1]) chmax(dp[i + 1][j - 1], dp[i][j] + j * 0.25 - 0.25);
	}
	
	printf("%.15lf\n", dp[now][0]);
	
	return 0;
}

Measured memory_bytes: 63232
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    nl=[]
    l=list(map(int,input().split()))
    ans='APPROVED'
    for i in l:
        if i%2==0 and i%3!=0 and i%5!=0:
            ans='DENIED'
    print(ans)
resolve()


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

bool bad[51];
int main() {
  int n,k;
  cin>>n>>k;
  vector<int> v[k];
  REP(i,k) {
    int m;
    cin >> m;
    REP(j,m) {
      int a;
      cin >> a;
      a--;
      v[i].push_back(a);
    }
  }
  int r;
  cin >> r;
  REP(i,r) {
    int p,q;
    cin >> p >> q;
    p--;q--;
    REP(j,k) {
      bool f1 = 0;
      bool f2 = 0;
      FOR(it, v[j]) {
        if (*it == p) f1 = 1;
        if (*it == q) f2 = 1;
        //cout << p << " " << q << " " << *it << endl;
      }
      if (f1 && f2) bad[p] = bad[q] = 1;
    }
  }
  int ans = 0;
  REP(i,n) ans += bad[i];
  cout << ans << endl;
}

Measured memory_bytes: 0
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: kundaikwangwari
 *
 * Created on August 5, 2019, 1:10 AM
 */


#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct node{

  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};

typedef struct node *Node;
Node root;



Node Find(Node x, int key){

  if(x == NULL||key == x->key)return x;
  if(key < x->key)return Find(x->left,key);
 else return Find(x->right,key);
}

void Preorder(Node u){

  if(u != NULL){
    printf(" %d", u->key);
    Preorder(u->left);
    Preorder(u->right);
  }
}

void Inorder(Node x){

  if(x != NULL){
    Inorder(x->left);
    printf(" %d", x->key);
    Inorder(x->right);
  }
}


Node MinTree(Node node){
while(node->left!=NULL)node=node->left;
  return node;
}

Node FindSuccessor(Node s){

  if(s->right != NULL)return MinTree(s->right);
  Node successor = s->p;
  while(successor != NULL && s == successor->right){

    s=successor;
    successor=successor->p;
  }

  return successor;
}

void treeDelete(Node z){

  Node toDelete, toDelete_Child;

  if(z->left == NULL || z->right == NULL)toDelete = z;
  else toDelete = FindSuccessor(z);

  if(toDelete->left != NULL)toDelete_Child =toDelete->left;
  else toDelete_Child = toDelete->right;

  if(toDelete_Child != NULL)toDelete_Child->p =toDelete->p;
  
  if(toDelete->p == NULL)root =toDelete_Child;
  else if(toDelete == toDelete->p->left)toDelete->p->left =toDelete_Child;
  else toDelete->p->right =toDelete_Child;

  if(toDelete != z)z->key=toDelete->key;
}

void InsertNode(int key){

  Node p = NULL, q = root, newNode;

  newNode = malloc(sizeof(struct node));
  newNode->key = key;
  newNode->left = NULL;
  newNode->right = NULL;

  while(q != NULL){
    p = q;

    if(newNode->key < q->key)q =q->left;
    else q = q->right;
  }

  newNode->p = p;

  if(p == NULL)root =newNode;
  else if(newNode->key < p->key)p->left =newNode;
  else p->right =newNode;
}



int main(){

  int opp, val,flag2;//flag2 control the printing process
    char cmd[8];
    char cmd1[] = "insert";
    char cmd2[] = "print";
    char cmd3[] = "find";
    char cmd4[] = "delete";
    
    scanf("%d",&opp);
    
    for(int a = 0; a < opp; a++){
        scanf("%s",cmd);

    if (strcmp(cmd3,cmd)==0){
      scanf("%d", &val);

      Node Query = Find(root, val);
      if ( Query != NULL )
        printf("yes\n");
      else
        printf("no\n");
    }
    if(strcmp(cmd1,cmd)==0){

      scanf("%d", &val);
      InsertNode(val);
    }
    if(strcmp(cmd2,cmd)==0){

      Inorder(root);
      printf("\n");

      Preorder(root);
      printf("\n");

    } 
    if (strcmp(cmd4,cmd)==0){

      scanf("%d", &val);
      treeDelete(Find(root, val));
    }
  }
  return 0;
}


Measured memory_bytes: 25148
#include <iostream>
#include <queue>

#define lli long long int

using namespace std;

int main(){

	lli x;

	lli ans=0;
	lli now=0;

	cin>>x;

	while(1){
		if(ans<=x && x<= (ans+now)){
			cout<<now<<endl;
			break;
		}		
		ans+=now;
		now+=1;
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
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; }

void _main() {
  int N;
  cin >> N;
  int wild = 0;
  set<int> st;
  rep(i, 0, N) {
    int a;
    cin >> a;
    if      (a <  400) st.insert(0);
    else if (a <  800) st.insert(1);
    else if (a < 1200) st.insert(2);
    else if (a < 1600) st.insert(3);
    else if (a < 2000) st.insert(4);
    else if (a < 2400) st.insert(5);
    else if (a < 2800) st.insert(6);
    else if (a < 3200) st.insert(7);
    else wild++;
  }

  int mi = max(1, (int)st.size());
  int ma = (int)st.size() + wild;

  cout << mi << " " << ma << endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #


n, a, b = Is()
if (a + b) % 2 == 0:
    print((b-a)//2)
else:
    print(min(n-b, a-1)+1+(b-a-1)//2)


Measured memory_bytes: 63852
class atcorder:
    
    N,M=map(int,input().split())
    A=[]
    A=list(map(int,input().split()))
    Sum=sum(A)
    i=0
    for n in range(len(A)):
        if A[n]>=Sum/(4*M):
            i+=1
        else:
            continue
    if i>=M:
        print("Yes")
    else:
        print("No")

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

typedef long long ll;

map <ll, int> M;
int n;
ll res;

int main()
{
	M[0]++;
	ll cur = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int a; scanf("%d", &a);
		cur += a;
		res += M[cur]; M[cur]++;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int n;
    int ans=0;
    
    cin>>n;
    vector<int> a(n,0);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    ll half=sum/2;
    ll sum2=0;
    ll point1,point2;
    bool end=false;
    rep(i,n){
        sum2+=a[i];
        if(end)end=true;
        else if(sum2>=half){
            point1=sum2;
            point2=sum2-a[i];
            end = true;
        }
    }
    ans=min(point1-(sum-point1),sum-point2-point2);
    Out(ans);
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=100005;

int n,cnt,last[N],sg[N];
struct edge{int to,next;}e[N*2];

int read()
{
    int x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

void addedge(int u,int v)
{
    e[++cnt].to=v;e[cnt].next=last[u];last[u]=cnt;
    e[++cnt].to=u;e[cnt].next=last[v];last[v]=cnt;
}

void dfs(int x,int fa)
{
    for (int i=last[x];i;i=e[i].next)
    {
        if (e[i].to==fa) continue;
        dfs(e[i].to,x);
        sg[x]^=sg[e[i].to]+1;
    }
}

int main()
{
    n=read();
    for (int i=1;i<n;i++)
    {
        int x=read(),y=read();
        addedge(x,y);
    }
    dfs(1,0);
    if (sg[1]) puts("Alice");
    else puts("Bob");
    return 0;
}


Measured memory_bytes: 7296
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>

using namespace std;

int main(void) {
	int A, B;

	scanf("%d %d", &A, &B);
	if (A + B == 15) {
		printf("+\n");
	}
	else if (A*B == 15) {
		printf("*\n");
	}
	else {
		printf("x\n");
	}

	return 0;
}









Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
  int pria,prib,pric,neda,nedb,i,j;
  scanf("%d%d%d%d%d",&pria,&prib,&pric,&neda,&nedb);
  int count=0;
  if(pria+prib<=pric*2) count=pria*neda+prib*nedb;
  else
  {
    if(neda>=nedb)
    {
      count=pric*2*nedb;
      neda=neda-nedb;
      if(neda>0)
      {
        if(pria<pric*2) count=count+pria*neda;
        
        else count=count+pric*2*neda;

      }
    }
    else
    {
      count=pric*2*neda;
      nedb=nedb-neda;
      if(nedb>0)
      {
        if(prib<pric*2) count=count+prib*nedb;
        else count=count+pric*2*nedb;
      }
    }
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define LL long long int
#define REP(i,n) for (int i = 1; i <= (n); i++)
#define Redge(u) for (int k = h[u],to; k; k = ed[k].nxt)
#define cls(s,v) memset(s,v,sizeof(s))
#define mp(a,b) make_pair<int,int>(a,b)
#define cp pair<int,int>
using namespace std;
const int maxn = 100005,maxm = 100005,INF = 0x3f3f3f3f;
inline int read(){
	int out = 0,flag = 1; char c = getchar();
	while (c < 48 || c > 57){if (c == '-') flag = 0; c = getchar();}
	while (c >= 48 && c <= 57){out = (out << 1) + (out << 3) + c - 48; c = getchar();}
	return flag ? out : -out;
}
int main(){
	int x = read();
	if (x >= 30) puts("Yes");
	else puts("No");
	return 0;
}

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

struct SuffixArray {
    string a;
    int N, m;
    vector<int> SA, LCP, x, y, w, c;

    SuffixArray(string _a, int m) : a(" " + _a), N(a.length()), m(m),
            SA(N), LCP(N), x(N), y(N), w(max(m, N)), c(N) {
        a[0] = 0;
        DA();
        kasaiLCP();
        #define REF(X) { rotate(X.begin(), X.begin()+1, X.end()); X.pop_back(); }
        REF(SA); REF(LCP);
        a = a.substr(1, a.size());
        for(int i = 0; i < (int) SA.size(); ++i) --SA[i];
        #undef REF
    }

    inline bool cmp (const int a, const int b, const int l) { return (y[a] == y[b] && y[a + l] == y[b + l]); }

    void Sort() {
        for(int i = 0; i < m; ++i) w[i] = 0;
        for(int i = 0; i < N; ++i) ++w[x[y[i]]];
        for(int i = 0; i < m - 1; ++i) w[i + 1] += w[i];
        for(int i = N - 1; i >= 0; --i) SA[--w[x[y[i]]]] = y[i];
    }

    void DA() {
        for(int i = 0; i < N; ++i) x[i] = a[i], y[i] = i;
        Sort();
        for(int i, j = 1, p = 1; p < N; j <<= 1, m = p) {
            for(p = 0, i = N - j; i < N; i++) y[p++] = i;
            for (int k = 0; k < N; ++k) if (SA[k] >= j) y[p++] = SA[k] - j;
            Sort();
            for(swap(x, y), p = 1, x[SA[0]] = 0, i = 1; i < N; ++i)
                x[SA[i]] = cmp(SA[i - 1], SA[i], j) ? p - 1 : p++;
        }
    }

    void kasaiLCP() {
        for (int i = 0; i < N; i++) c[SA[i]] = i;
        for (int i = 0, j, k = 0; i < N; LCP[c[i++]] = k)
            if (c[i] > 0) for (k ? k-- : 0, j = SA[c[i] - 1]; a[i + k] == a[j + k]; k++);
            else k = 0;
    }
};

int main() {
    ios::sync_with_stdio(false);
    string s; cin >> s; int n = s.size();
    SuffixArray sa (s, 256);
    //for (auto x : sa.SA) cout << x << ' '; cout << endl;
    //for (auto x : sa.LCP) cout << x << ' '; cout << endl;
    vector<int> f (n + 2); f[0] = n; f.back() -= n;
    for (int i = 0; i < s.size(); ++i) {
        // [0 .. sa.LCP[i]]
        // [n - sa.SA[i] + 1, n]
        --f[0];
        ++f[sa.LCP[i] + 1];
        --f[n - sa.SA[i] + 1];
        ++f[n + 1];
    }
    for (int i = 1; i < (int) f.size(); ++i) f[i] += f[i - 1];
    //for (auto x : f) cout << x << ' '; cout << endl;
    cout << *max_element(f.begin(), f.end()) << endl;
    return 0;
}


Measured memory_bytes: 3280
card=[list(map(int,input().split())) for i in range(3)]
N=int(input())
b=[int(input()) for i in range(N)]
for i in range(N):
    for j in range(3):
        for k in range(3):
            if card[j][k]==b[i]:
                card[j][k]=0
if (card[0][0]==card[0][1]==card[0][2]==0) or (card[1][0]==card[1][1]==card[1][2]==0) or (card[2][0]==card[2][1]==card[2][2]==0) or (card[0][0]==card[1][0]==card[2][0]==0) or (card[0][1]==card[1][1]==card[2][1]==0)  or (card[0][2]==card[1][2]==card[2][2]==0) or (card[0][0] == card[1][1] == card[2][2] == 0) or (card[2][0]==card[1][1]==card[0][2]==0):
    print('Yes')
else:
    print('No')

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

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    cout<<setprecision(10)<<fixed;

    ll n,k,x,m=0;
    scanf("%lld%lld",&n,&k);
    ll s[n+1];
    s[0] = 0;

    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&x);
        s[i]=(x+1+s[i-1]);
    }

    for(int i=k;i<=n;i++)
        m = (s[i]-s[i-k] > m) ? s[i]-s[i-k] : m;

    printf("%0.12lf\n",(m/2.0));

    return 0;
}


Measured memory_bytes: 1792
import math

N = int(input())
X = list(map(int, input().split()))

center = sum(X) / len(X)
if center - int(center) >= 0.5:
    center = math.ceil(center)
else:
    center = math.floor(center)
ans = 0
for x in X:
    ans += (center - x) ** 2
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n;
    cin >> n;
    int ans = 1;
    while(ans * 2 <= n){
        ans *= 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;

const LL INF=1<<30;
const LL MOD=1000000007;





int main(){
    LL n;
    cin>>n;
    LL s[100100]={0};
    LL amax=0;
    for(LL i=0;i<n;++i){
        LL a;
        cin>>a;
        s[a]++;
        if(a>amax)amax=a;
    }
    LL ans=0;
    for(LL i=1;i<=100000-1;++i){
        ans=max(ans,s[i-1]+s[i]+s[i+1]);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ll Pow(ll a , ll b){
	if(b == 0) return 1 ;
	ll c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c)% mod )) % mod ;
	return (c * c) % mod ;
}

//check modulo
int main(){
	IOS;
	cout.precision(50) ;
	ll a , b ;cin >> a >> b ; ll ans = 0 ;
	ll  i ;
	for(i = a ; i % 4 != 2 && i <= b ;i++) ans ^= i ;
	for(ll j = b ; j % 4 != 1 && j >= i ; j--) {ans ^= j ;}
	cout << ans << endl; 
	
	return 0;
}


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

int main()
{
  uint64_t n, a, b;
  cin >> n >> a >> b;
  cout << ((b - a) % 2 == 0 ? (b - a) / 2 : (b - a + 1) / 2 + min(a - 1, n - b)) << endl;
}


Measured memory_bytes: 256
int main()
{
  int N, n = 0;
  double x, X = 0;
  char u[4];

  scanf("%d", &N);
  do {
    scanf("%lf %s", &x, u);
    if(strcmp(u, "JPY"))
    {
      x *= 380000.0;
    }
    X += x;
    n++;
  } while(n < N);
  printf("%f", X);
}


Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  ll x;
  cin >> x;
  for (ll a = -200; a <= 200; a++) {
    for (ll b = -200; b <= 200; b++) {
      if (pow(a, 5) - pow(b, 5) == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3616
#include <stdio.h>
int main(void){
    // Your code here!
    int a, b, c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b&&b<c){
        printf("Yes\n");
        }
        else {
            printf("No\n");
            } 
            return 0;
            }



Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  string s;
  cin>>s;
  int n;
  n = s.size();
  
  long long dp[n+1][4]={};
  dp[0][0]=1;
  REPP(i,n){
    //i文字目をABCの中に含まない場合の数え上げ
    REP(j,4){
      if(s[i-1]!='?'){
        dp[i][j] = mod(dp[i][j]+dp[i-1][j]);
      }else{
        //'?'をAかBかCに置き換えてi文字目までを文字列として決定する。
        dp[i][j] = mod(dp[i][j]+mod(dp[i-1][j]*3));
      }
    }
    //i文字目をABCの中に含む場合の数え上げ
    if(s[i-1]=='A'){
      dp[i][1] = mod(dp[i][1]+dp[i-1][0]);
    }else if(s[i-1]=='B'){
      dp[i][2] = mod(dp[i][2]+dp[i-1][1]);
    }else if(s[i-1]=='C'){
      dp[i][3] = mod(dp[i][3]+dp[i-1][2]);
    }else{
      REP(j,3){
        dp[i][j+1] = mod(dp[i][j+1]+dp[i-1][j]);
      }
    }
  }
  
  long long ans;
  ans = dp[n][3];
  cout<<ans<<endl;
    
  return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main{
	
	public static void part(int [] arr, int p, int r) {
		int x = arr[r];
		int i = p - 1;
		
		for(int j = p; j < r; j++) {
			if(arr[j] <= x) {
				i++;
				int temp = arr[i];
				arr[i] = arr[j];
				arr[j] = temp;
				
			}
			
			
		
		}
		int temp = arr[i + 1];
		arr[i + 1] = arr[r];
		arr[r] = temp;
		
	
		
		for(int k = 0; k < arr.length; k++) {
			if(arr[k] == x && k == arr.length - 1) {
				System.out.print("[" + x + "]\n");
			}
			
			else if(k == i + 1) {
				System.out.print("[" + x + "] ");
			}
			
			else if(k == arr.length - 1) {
				System.out.print(arr[k] + "\n");
			}
			
			else {
				System.out.print(arr[k] + " ");
			}
		}
	}
	
	public static void main(String [] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int [] arr = new int [n];
		
		for(int i = 0; i < n; i++) {
			arr[i] = in.nextInt();
		}
		
		part(arr, 0, arr.length - 1);
	}

}



Measured memory_bytes: 70708
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

const int limit = 50;

int n, m;
int a[limit], b[limit];
bool graph[limit][limit];
bool visited[limit];

class unionfind {
private:
	vector<int> par, r;

public:
	unionfind() {};
	unionfind(int n) {
		par.resize(n);
		r.resize(n);
		init(n);
	};

	int get_par(int i) {
		return par[i];
	}
	
	void init(int n) {
		rep(i, n) par[i] = i;
		rep(i, n) r[i] = 0;
	}

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

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (r[x] < r[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (r[x] == r[y]) r[x]++;
		}
	}

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

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

	vector<pair<int, int>> e(m);
	rep(i, m) {
		cin >> e[i].first >> e[i].second;
		e[i].first--;
		e[i].second--;
	}
	int ans = 0;
	rep(i, m) {
		unionfind uf(n);
		rep(j, m) {
			if (i != j && !uf.same(e[j].first, e[j].second)) {
				uf.unite(e[j].first, e[j].second);
			}
		}
		set<int> s;
		rep(j, n) {
			if (uf.get_par(j) == j) {
				s.insert(uf.get_par(j));
			}
		}
		if (s.size() > 1) ans++; //根が二つ以上あるなら
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

const int M = 256;
int n;
int orig[300], r[300], conv[300];
signed main() {
    while(cin >> n , n) {
        rep(i,0,n) cin >> orig[i];
        double ent = DBL_MAX;
        int as, aa, ac;
        repq(S,0,15) repq(A,0,15) repq(C,0,15) {
            int cnt[300] = {};
            r[0] = S;
            repq(i,1,n) {
                r[i] = (A * r[i-1] + C) % M;
                conv[i] = (orig[i-1] + r[i]) % M;
                cnt[ conv[i] ]++;
            }
            double temp = 0.0;
            rep(i,0,300) {
                if(cnt[i] == 0) continue;
                double d = cnt[i] / (double) n;
                temp -= d * log(d);
            }
            // printf("S = %lld, A = %lld, C = %lld, temp = %lf\n", S, A, C, temp);
            if(ent > temp + EPS) {
                ent = temp;
                as = S, aa = A, ac = C;
            }
        }
        printf("%lld %lld %lld\n", as, aa, ac);
    }
    return 0;
}

Measured memory_bytes: 3380
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < 4; i++)
    cout << s[i];
  cout << " ";
  for(int i = 4; i < 12; i++)
    cout << s[i];
  cout << endl;
}


Measured memory_bytes: 256
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,K = inputlist()
S = list(input())
li = []
s = S[0]
for i in range(1,N):
    if S[i] == S[i-1]:
        s += S[i]
    else:
        li.append(s)
        s = S[i]
li.append(s)
n = len(li)
dic = {}
indexa = 0
ans = 0
ksum = [0]*n
ksum[0] = len(li[0])
for i in range(1,n):
    ksum[i] = ksum[i-1]+len(li[i])
for i in range(n):
    if li[i][0] == '0':
        indexa +=1
        dic[indexa] = i
if indexa <= K:
    print(N)
    exit()
if K == 1:
    for i in range(1,indexa+1):
        j = dic[i]
        if i == 1:
            m = ksum[j+1]
            ans = max(ans,m)
            continue
        if j == n-1:
            m = ksum[j]-ksum[j-2]
            ans = max(ans,m)
            continue
        else:
            m = ksum[j+1]-ksum[j]+1
            m += ksum[j-1]-ksum[j-2]
            ans = max(m,ans)
else:
    for i in range(K,indexa+1):
        j = dic[i]
        l = dic[i-K+1]
        sup = 0
        inf = 0
        if j == n-1:
            sup = ksum[j]
        if j != n-1:
            sup = ksum[j+1]
        if l != 0:
            inf = ksum[l-2]
        m = sup-inf
        ans = max(ans,m)
print(ans)

Measured memory_bytes: 16040
from heapq import *
INF = 1e10

def floyd(n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

N,M,L = map(int,input().split())

d = [[INF]*N for i in range(N)]

for x in range(M):
    a,b,w = map(int,input().split())
    d[a-1][b-1] = w
    d[b-1][a-1] = w

floyd(N)

grafo2 = [[INF] * N for i in range(N)]

for x in range(N):
    for y in range(N) :
        if d[x][y] <= L:
            grafo2[x][y] = 1

for k in range(N):
    for i in range(N):
        for j in range(N):
            if grafo2[i][j] > grafo2[i][k] + grafo2[k][j]:
                grafo2[i][j] = grafo2[i][k] + grafo2[k][j]

query = int(input())

for x in range(query):
    s,t = map(int,input().split())
    if grafo2[s-1][t-1] == INF:
        print(-1)
    else:
        print(grafo2[s-1][t-1] - 1)


Measured memory_bytes: 70108
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,k,a[120000],b[120000];
signed main() {
	cin>>n>>k;
	int ans=0x3f3f3f3f;
	for(int i=1;i<=n;i++) {
		cin>>a[i]>>b[i];
		if(b[i]<=k && a[i]<ans) ans=a[i];
	}
	if(ans==0x3f3f3f3f) puts("TLE");
	else cout<<ans;




}

Measured memory_bytes: 256
#include <climits>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;
constexpr int kMax = 401;

int main() {
  LL dp[kMax][kMax];
  int N; std::cin >> N;
  std::vector<LL> a(N), ac(N+1);
  for (int i = 0; i < N; ++i) std::cin >> a[i];

  ac[0] = 0;
  for (int i = 0; i < N; ++i) ac[i+1] = ac[i] + a[i];

  for (int i = 0; i < N; ++i) dp[i][i+1] = 0;

  for (int j = 2; j <= N; ++j) {
    for (int i = 0; i <= N - j; ++i) {
      dp[i][i+j] = dp[i+1][i+j];
      for (int k = i + 2; k < i + j; ++k) {
        dp[i][i+j] = std::min(dp[i][i+j], dp[i][k]+dp[k][i+j]);
      }
      dp[i][i+j] += ac[i+j] - ac[i];
    }
  }

  std::cout << dp[0][N] << std::endl;
}


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

int main() {
  int n,m,q;
  cin>>n>>m>>q;
  vector<vector<int>>x(q,vector<int>(4));
  for(int i=0;i<q;i++){
    for(int j=0;j<4;j++) cin>>x[i][j];
  }
  int ans=0;
  vector<int>a(10);
  a[0]=1;
  for(int i=1;i<=m;i++){
    a[1]=i;
    for(int j=a[1];j<=m;j++){
      a[2]=j;
      for(int k=a[2];k<=m;k++){
         a[3]=k;
        for(int l=a[3];l<=m;l++){
          a[4]=l;
          for(int o=a[4];o<=m;o++){
            a[5]=o;
            for(int p=a[5];p<=m;p++){
              a[6]=p;
              for(int r=a[6];r<=m;r++){
                a[7]=r;
                for(int s=a[7];s<=m;s++){
                  a[8]=s;
                  for(int t=a[8];t<=m;t++){
                    a[9]=t;
                    int answer=0;
                    for(int u=0;u<q;u++){
                      if(a[x[u][1]-1]-a[x[u][0]-1]==x[u][2]) answer+=x[u][3];
                    }
                    ans=max(ans,answer);
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <stack>
#include <queue>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;
int main(){
  ll i,j,k,n,m;
  cin >> n >> m;
  ll s[n+1];
  ll t[m+1];
  for(i=1;i<=n;i++)cin >> s[i];
  for(i=1;i<=m;i++)cin >> t[i];
  s[0]=-1;
  t[0]=-5;
  ll dp2[n+1][m+1];
  for(i=0;i<=m;i++)dp2[0][i]=0;
  for(i=0;i<=n;i++)dp2[i][0]=0;
  for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
      dp2[i][j]=max(dp2[i-1][j],dp2[i][j-1]);
      if(s[i]==t[j])dp2[i][j]=dp2[i-1][j-1]+1;
      //dp[i][j]%=MOD;
    }
  }
  ll dp[n+1][m+1];
  for(i=0;i<=m;i++)dp[0][i]=0;
  for(i=0;i<=n;i++)dp[i][0]=0;
  for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
      if(s[i]!=t[j])dp[i][j]=(dp[i-1][j]+dp[i][j-1]+MOD-dp[i-1][j-1])%MOD;
      if(s[i]==t[j])dp[i][j]=dp[i][j-1]+dp[i-1][j]+1;
      dp[i][j]%=MOD;
    }
  }
  cout << (dp[n][m]+1)%MOD << endl;
  return 0;
}


Measured memory_bytes: 62848
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10




int main() {
	int N;
	int A, B;
	cin >> N >> A >> B;
	int res = min(A*N, B);
	print(res);



	return 0;
}


Measured memory_bytes: 764
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]

num = 0
num_max = 0
for i in 1..N do
  if lines[i][0] == lines[i][1] then
    num += 1
  else
    num = 0
  end
  if num > num_max then
    num_max = num
  end
end
    
if num_max >= 3 then
  puts "Yes"
else
  puts "No"
end

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

int N,S;
void solve(){
	int a[N];
	for(int i=0; i<N; ++i)	cin>>a[i];
	bool dp[N][S+1];
	for(int i=0; i<N; ++i)	dp[i][1]=true;
	for(int j=2; j<=S; ++j){
		for(int i=0; i<N; ++i){
			bool b=false;
			int idx=(i+1)%N;
			for(int k=1; k<=a[i]; ++k){
				if(j-k < 1)	break;
				b |= dp[idx][j-k];
			}
			dp[i][j]=!b;
		}
	}
	cout << !dp[0][S] << endl;
}

int main(){
	while(cin>>N, N){
		cin>>S;
		N*=2;
		solve();
	}
}

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

inline void ioThings() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif
}

#define debug(x)    cerr << #x << ": <" << (x) << ">\n"
#define dotc()      int tcs; if (cin >> tcs) for (int tc = 0; tc < tcs; tc++)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second
#define mod         1000000007

using ll = long long;
using vi = vector<int>;

int main() {
  ioThings();

  int n, k; cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];
  sort(all(h));
  cout << (n > k ? accumulate(h.begin(), h.end() - k, 0ll) : 0);

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>

using namespace std;
typedef long long int lint;

void answer()
{
	int a, b, c, ans;
	ans = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		if (c % i == 0) ans++;
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>

constexpr int MAX_N=20001,MAX_M=1001;
constexpr long long int INF=(long long int)1e18;

int n,m,k;
long long int dp[MAX_N];
long long int a[MAX_N];

int main(){
	std::cin>>n>>m>>k;
	for(int i=1;i<=n;++i)
		std::cin>>a[i];
	std::fill(dp+1,dp+n+1,INF);
	long long int max,min;
	for(int i=1;i<=n;++i){
		max=0;
		min=INF;
		for(int j=1;j<=m&&j<=i;++j){
			max=std::max(max,a[i-j+1]);
			min=std::min(min,a[i-j+1]);
			dp[i]=std::min(dp[i],dp[i-j]+(max-min)*j+k);
		}
	}
	std::cout<<dp[n]<<std::endl;
	return 0;
}

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
    stack<int> S;
    S.push(r);
    color[r] = c;
    while(!S.empty()) {
        int u=S.top(); S.pop();
        for (int i=0; i<G[u].size(); i++) {
            int v = G[u][i]; 
            if(color[v] == NIL) {
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor() {
    int id = 1;
    for (int i=0; i<n; i++) color[i] = NIL;
    for (int u=0; u<n; u++) {
        if(color[u] == NIL) dfs(u, id++);
    }
}

int main() {
    int s, t, m, q;
    
    cin >> n >> m;
    
    for (int i=0; i<m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    
    assignColor();
    
    cin >> q;
    
    for (int i=0; i<q; i++) {
        cin >> s >> t;
        if(color[s] == color[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 8956
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
       int flag=1;
       for(int i=1;i<=n;i++)
       {
           char b;
           cin>>b;
           if(b=='Y')
            flag=0;
       }
       if(flag)
        cout<<"Three\n";
       else
        cout<<"Four\n";
    }
    return 0;
}


Measured memory_bytes: 256
c = [list(map(int,input().split())) for i in range(3)]
a = [0]*3
b = [0]*3
b[0] = c[0][0]
b[1] = c[0][1]
b[2] = c[0][2]
a[1] = c[1][1]-b[1]
a[2] = c[2][2]-b[2]

for i in range(3):
    for j in range(3):
        if c[i][j] != a[i]+b[j]:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n;
cin>>n;
string s[n];
for(long long i=0;i<n;i++){
    cin>>s[i];
}
sort(s,s+n);
vector<string>a;
string temp;
long long count=0;
long long tcount=0;
for(long long i=0;i<n;i++){
    if(i==0){
        temp=s[i];
        tcount++;
    }
    else if(s[i]==temp){
        tcount++;

    }
    else if(s[i]!=temp){

        if(tcount>count){
            count=tcount;
            a.clear();
            a.push_back(temp);
            tcount=1;
            temp=s[i];
        }
        else if(tcount==count){
            a.push_back(temp);
            tcount=1;
            temp=s[i];
        }
        else{
            count=max(tcount,count);
            tcount=1;
            temp=s[i];
        }
    }
    if(i==n-1){
        if(tcount>count){
            a.clear();
            a.push_back(temp);
        }
        else if(tcount==count){
            a.push_back(temp);
        }
    }
}
for(long long i=0;i<a.size();i++){
    cout<<a[i]<<endl;
}

    return 0;

}


Measured memory_bytes: 15988
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    s = input()
    if len(set(s))==1:
        print('No')
    else:
        print('Yes')



if __name__ == '__main__':
    main()

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


int main()
    {
        int n;
        cin >> n;
        int arr[n][3] , dp[n][3];
       for(int i=0;i<n;i++){
       	cin>>arr[i][0]>>arr[i][1]>>arr[i][2];

       }
       		dp[0][0] = arr[0][0];
       		dp[0][1] = arr[0][1];
       		dp[0][2] = arr[0][2];
   			for(int i=1;i<n;i++){


   					dp[i][0] = max(dp[i-1][1] , dp[i-1][2]) + arr[i][0];
   					dp[i][1] = max(dp[i-1][2] , dp[i-1][0]) + arr[i][1];
   					dp[i][2] = max(dp[i-1][0] , dp[i-1][1]) + arr[i][2];
   			
   		}
        int ans = -1;
        ans = max(dp[n-1][0] , dp[n-1][1]);
        ans = max( ans , dp[n-1][2]);
        cout<<ans;
    
	return 0;
}


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

int main(){
  int D;
  cin >>D;
  
  string ans;
  string s1 = "Christmas";
  string s2 = " Eve";
  if(D==25) ans = s1;
  if(D==24) ans = s1+s2;
  if(D==23) ans = s1+s2+s2;
  if(D==22) ans = s1+s2+s2+s2;
  
  cout <<ans<< endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int O, c, a, n, i, num;
	
	scanf("%d", &O);
	
	for (i = 0; i < O; i++){
		num = 0;
		scanf("%d %d %d", &c, &a, &n);
		
		while (1){
			if (c >= 1 && a >= 1 && n >=1){
				c--;
				a--;
				n--;
				num++;
			}
			else if (c >= 2 && a >= 1){
				c -= 2;
				a--;
				num++;
			}
			else if (c >= 3){
				c -= 3;
				num++;
			}
			else {
				break;
			}
		}
		
		printf("%d\n", num);
	}
	
	return (0);
}

Measured memory_bytes: 600
# 169A
# A × B を整数として出力せよ

# 1. 入力をプログラミングで扱えるように受け取ること
a, b = map(int, input().split())
# print(a, b)

# 2. 受け取った入力値を使って、適切に処理（計算）すること
answer = a * b

# 3.計算した結果を出力すること
print(answer)

Measured memory_bytes: 9088
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    int k, a, b;
    cin >> k >> a >> b;

    rep (i, a, b) {
    	if (i % k == 0) {
    		cout << "OK";
    		return;
    	}
    }
    cout << "NG";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3636
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

ll N, A[202020];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 0; i < N; ++i) { cin >> A[i]; }
    ll tot = 0;
    for (int i = 0; i < N; ++i) tot += A[i];
    ll d = tot, acc = 0;
    for (int i = 0; i < N; ++i) {
        acc += A[i];
        d = min(d, abs(acc - (tot - acc)));
    }
    cout << d << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  ll n, a, ans = 1;
  cin >> n;
  vector<ll> cnt(100003, 0);
  rep(i, n) {
    cin >> a;
    if (a == 0)
      (ans *= (3 - cnt[a])) %= mod, cnt[a]++;
    else
      (ans *= (cnt[a - 1] - cnt[a])) %= mod, cnt[a]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define in(e,l) (std::find(l.begin(), l.end(), e) != l.end())
#define asort(l) (std::sort(l.begin(), l.end()))
#define dsort(l) (std::sort(l.rbegin(), l.rend()))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;

int main() {
  ll N;
  cin >> N;
  priority_queue<double, vector<double>, greater<double> > q;
  rep(i, N){
    ll val;
    cin >> val;
    q.push(val);
  }
  while(q.size() > 1){
    double a = q.top();
    q.pop();
    double b = q.top();
    q.pop();
    double tmp = (a + b) / 2;
    q.push(tmp);
  }
  cout << q.top() << endl;
  return 0;
}



Measured memory_bytes: 256