akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+100000000
#define small -big
#define pb push_back



template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}



void solve() {
        
      ll n;
      cin >> n;
      
      ll type1ma = small;
      ll type1mi = big;
      ll type2ma = small;
      ll type2mi = big;
      
      for(ll i = 1; i <= n; i++) {
            ll a, b;
            cin >> a >> b;
            type1ma = max(type1ma, (a + b));
            type1mi = min(type1mi, (a + b));
            type2ma = max(type2ma, (a - b));
            type2mi = min(type2mi, (a - b));
      }
      
      cout << max(abs(type1ma - type1mi), abs(type2ma - type2mi)) << endl;
}


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

    int t=1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 3628
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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

	int N;
	cin >> N;

	pair<ll, ll> XY[200001];

	rep(i, N) {
		ll x, y;
		cin >> x >> y;
		XY[i] = mp(x, y);
	}

	sort(XY, XY + N);

	ll ue = XY[0].first + XY[0].second, sita = XY[0].second - XY[0].first;

	ll kotae = 0;
	rep1(i, N - 1) {
		ll x = XY[i].first;
		ll y = XY[i].second;
		chmax(kotae, max(y - ue + x, sita - y + x));

		chmin(ue, x + y);
		chmax(sita, y - x);
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 6800
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components
import sys
input=sys.stdin.readline

n,m=map(int,input().split())
l=[]
for i in range(n):
    for j in input().split()[1:]:
        l.append((i,int(j)+n-1,1))
edge=np.array(l,dtype=np.int64).T
graph=csr_matrix(((edge[2],edge[:2])),(n+m,n+m))

_,ll=connected_components(graph)

if 1 in ll[:n]:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 35748
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int H,W; cin >> H >> W;
    vector<string> S(H);
    REP(i,H) cin >> S[i];
    vecveci cnt_W(H,veci(W)),cnt_H(H,veci(W));
    REP(i,H) {
        int cnt = 1;
        REP(j,W) {
            if(S[i][j] == '#') cnt = 1;
            else {
                cnt_W[i][j] = cnt;
                cnt++;
            }
        }
        for(int j = W-2; j >= 0; --j) {
            if(S[i][j] == '.' && S[i][j+1] == '.') cnt_W[i][j] = cnt_W[i][j+1];
        }
    }
    REP(j,W) {
        int cnt = 1;
        REP(i,H) {
            if(S[i][j] == '#') cnt = 1;
            else {
                cnt_H[i][j] = cnt;
                cnt++;
            }
        }
        for(int i = H-2; i >= 0; --i) {
            if(S[i][j] == '.' && S[i+1][j] == '.') cnt_H[i][j] = cnt_H[i+1][j];
        }
    }

    int ans = 0;

    REP(i,H) REP(j,W) {
        if(S[i][j] == '#') continue;
        else {
            chmax(ans,cnt_H[i][j]+cnt_W[i][j]-1);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 35712
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);

		int ans = Integer.MAX_VALUE;
		for (int i = a[0]; i <= a[a.length - 1]; i++) {
			int sum = 0;
			for (int j = 0; j < a.length; j++) {
				sum += Math.pow((a[j] - i), 2);
			}
			ans = Math.min(ans, sum);
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<cstdio>
int main(){
    int n,k=3;
    scanf("%d",&n);
    if(n==1){
        printf("Yes\n2\n1 1\n1 1");
        return 0;
    }
    while(k*(k-1)/2<n)k++;
    if(k*(k-1)/2!=n){
        printf("No");
        return 0;
    }
    printf("Yes\n%d\n",k);
    printf("%d ",k-1);
    for(int i=1;i<k;i++)printf("%d ",i*(i+1)/2);
    printf("\n");
    for(int i=1;i<k;i++){
        printf("%d ",k-1);
        for(int j=i*(i-1)/2+1;j<=i*(i+1)/2;j++)printf("%d ",j);
        for(int j=i;j*(j+1)/2+i<=n;j++)printf("%d ",j*(j+1)/2+i);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1280
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
xyc=[list(map(int,input().split()))for i in range(M)]
ans=min(a)+min(b)
for i in range(M):
    tmp = a[xyc[i][0]-1]+b[xyc[i][1]-1]-xyc[i][2]
    if ans > tmp:
        ans=tmp
print(ans)

Measured memory_bytes: 38560
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vl A(5);
  ll k;
  REP(i, 5) cin >> A[i];
  cin >> k;
  bool ok = true;
  REP(i, 4) {
    FOR(j, i + 1, 5)
    if (A[j] - A[i] > k)
      ok = false;
  }
  if (ok)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}
bool cmp(ll a,ll b) {

	return abs(a) > abs(b);
}

int main() {

	ll n,k;
	cin >> n >> k;
	vector<ll>a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(all(a),cmp);
 
	
	ll neg = 0, last_pos = -1, last_neg = -1;
	for(ll i = 0; i < k; i++){
		if(a[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
		if(a[i] > 0) {
			last_pos = i;
		}
		else
			if(a[i] < 0 ) {
				last_neg = i;
				neg ++;
			}
	}

	if(neg%2) {

		ll next_neg = -1, next_pos = -1,z = 0;

		for(ll i = n-1; i >= k; i--){
			if(a[i] > 0) {
				next_pos = i;
			}
			if(a[i] < 0 ) {
				next_neg = i;
			}
			if(a[i] == 0) {
				z += 1;
			}
		}

		//cout << next_pos <<" " << next_neg << endl;
		if(next_pos > 0 and next_neg > 0) {
			ll ans = 1;
			if(last_pos > 0) {
				if(a[last_neg]*a[next_neg] > a[last_pos]*a[next_pos]) {
					for(ll i = 0; i < k; i++ ){
					if(i == last_pos) {a[i]  = a[next_neg];}
						ans = (ans * abs(a[i]))%mod;
					}
					cout << ans << endl;
				}
				else {
					for(ll i = 0; i < k; i++ ){
					if(i == last_neg) {a[i]  = a[next_pos];}
						ans = (ans * abs(a[i]))%mod;
					}
					cout << ans << endl;
				}
			}
			else {
				 for(ll i = 0; i < k; i++ ){
					if(i == last_neg) {a[i]  = a[next_pos];}
						ans = (ans * abs(a[i]))%mod;
					}
					cout << ans << endl;
			}

		}
		else
		if(next_neg > 0) {
			if(last_pos > 0) {
				ll ans = 1;
			for(ll i = 0; i < k; i++) {
				if(i == last_pos) {a[i]  = a[next_neg];}
				ans = (ans * abs(a[i]))%mod;
			}
			cout << ans << endl;
			}
			else{
				if(z == 0) {
				reverse(all(a));
				ll ans = 1;
				for(int i = 0 ; i < k; i++) {
					ans = (ans * abs(a[i]))%mod;
				}
				ans = (-ans+mod)%mod;
				cout << ans << endl;
			}
			else {
				cout << 0 << endl;
			}
			}
		}
		else
		if(next_pos > 0) {
			ll ans = 1;
			for(ll i = 0; i < k; i++) {
				if(i == last_neg) {a[i]  = a[next_pos];}
				ans = (ans * abs(a[i]))%mod;
			}
			cout << ans << endl;
		} 
		else {
				if(z > 0 ){
					cout << 0 << endl;
				}
				else{
							ll ans = 1;
		       for(ll i = 0; i < k; i++ ){
					ans = (ans * abs(a[i]))%mod;
				}
				 ans = (-ans+mod)%mod;
					cout << ans << endl;
				}
		}
	}

	else{
		ll ans = 1;
       for(ll i = 0; i < k; i++ ){
			ans = (ans * abs(a[i]))%mod;
		}
					cout << ans << endl;
	}

}



Measured memory_bytes: 4832
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("input.txt");ofstream coutt("output.txt");

int n,a[200005],ans[200005];
vi adj[200005];
multiset<int> st;

void dfs(int cur,int par){
    
    
    auto it=st.lower_bound(a[cur]);
    int del=0;
    if(it!=st.end()){
        del=*it;
        st.erase(st.find(del));
        st.insert(a[cur]);
    }else{
        st.insert(a[cur]);
    }
    
    ans[cur]=st.size();
    
    for(int ch:adj[cur]){
        if(ch==par)continue;
        dfs(ch,cur);
    }
    
    if(del)st.insert(del);
    st.erase(st.find(a[cur]));

}

signed main(){
    FASTER;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<n;i++){
        int a,b;cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(1,-1);
    for(int i=1;i<=n;i++)cout<<ans[i]<<"\n";
}


Measured memory_bytes: 31924
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX 1000000000

int main(){
    int N, K;
    scanf("%d %d", &N, &K);
    vector<int> v;
    for (int i=0; i<N; i++) {
        int tmp;
        scanf("%d", &tmp);
        v.push_back(tmp);
    }

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

    int L=N-K+1, m=MAX;
    for (int i=0; i<L; i++) {
        int tmp = v[K-1+i] - v[i];
        if (tmp<m) {
            m = tmp;
        }
    }
    printf("%d\n", m);
    return 0;
}

Measured memory_bytes: 892
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N, M, K;
	static int[] A, B;

	public static void main(String[] args) {
		N = sc.nextInt();
		M = sc.nextInt();
		K = sc.nextInt();
		A = new int[N];
		B = new int[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N; ++i) {
			B[i] = sc.nextInt();
		}
		boolean[] used = new boolean[N];
		System.out.println(rec(0, M, used));
	}

	static int rec(int idx, int rest, boolean[] used) {
		if (idx == K) return rest;
		if (rest == 0) return 0;
		int ret = 0;
		for (int i = 0; i < N; ++i) {
			if (used[i]) continue;
			int use = Math.min(rest, B[i]);
			used[i] = true;
			ret = Math.max(ret, use * A[i] + rec(idx + 1, rest - use, used));
			used[i] = false;
		}
		return ret;
	}
}

Measured memory_bytes: 26320
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=a;i<=b;i++)
	{
		if(i<=a+k-1 || i>=b-k+1) cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
Array = [list(map(str,input())) for _ in range(h)]
dx = [1,1,0,-1,-1,-1,0,1]
dy = [0,1,1,1,0,-1,-1,-1]
for i in range(h):
  for j in range(w):
    if Array[i][j]=='#':
      continue
    num=0
    for d in range(8):
      ni = i+dy[d]
      nj = j+dx[d]
      if ni<0 or h<=ni:
        continue
      if nj<0 or w<=nj:
        continue
      if Array[ni][nj]=='#':
        num=num+1
    Array[i][j]=str(num)
    
for i in Array:
  print(*i, sep='')

Measured memory_bytes: 3572
#include<stdio.h>

int main(){
	int batas;
	long long int jumlah=0;

	scanf("%d", &batas);
	    for(int i=1; i <= batas; i++ ){
        if(i % 3 == 0 && i % 5 == 0){
            i-i;
        }
        else if(i % 3 == 0){
            i-i;
        }
        else if (i % 5 == 0){
            i-i;
        }
        else {
			jumlah+=i;
        }
    }
    printf("%lld", jumlah);
 	
	return 0;
}

Measured memory_bytes: 1732
S = input()
point = 0
l = len(S)
i = 0
while i < l:
    if int(i % 2) == 1:
        if S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
            point += 1
    else:
        if S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
            point += 1
    i += 1

if point == l:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9124
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a,const void *b){
    return *(char*)a-*(char*)b;
}
int main(void){
    char s[5];
    scanf("%s",s);
    qsort(s,4,sizeof(char),asc);
    if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]) printf("Yes");
    else printf("No");
}


Measured memory_bytes: 128
import sys
def gcd(a,b):
	if b != 0:
		return gcd(b,a%b)
	else:
		return a
def lcm(a,b,g):
	return b / g * a
for s in sys.stdin:
	ls = map(int,s.split(' '))
	print "%d %d" % (gcd(ls[0],ls[1]),lcm(ls[0],ls[1],gcd(ls[0],ls[1])))

Measured memory_bytes: 4232
#include <bits/stdc++.h> 
using namespace std; 
#define vll vector<long long>
#define mll map<long long,long long>
#define pb push_back
typedef  long long ll;
typedef long double ld;
long double pi=3.14159265358979323846;

vll al[500005];
ll vis[500005],color[500005],I[101][101];

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

bool isPrime(int n)
{
    if (n<=1) return false; 
    if (n<=3) return true; 
    if (n%2==0||n%3==0) return false; 
    for (int i=5;i*i<=n;i=i+6) if (n%i==0||n%(i+2)==0) return false; 
    return true; 
}

ll bpow(ll n, ll po)
{
	ll res=1;
	while(po>0)
	{
		if(po%2)
		{
			res*=n;
			po--;
		}
		else
		{
			n*=n;
			po/=2;
		}
	}
	return res;
}

ll binpow(ll n, ll po, ll mod)
{
	ll res=1;
	while(po>0)
	{
		if(po%2)
		{
			res=(res*n)%mod;
			po--;
		}
		else
		{
			n=(n*n)%mod;
			po/=2;
		}
	}
	return res;
}

ll swap(ll a, ll b)
{
	a=a+b;
	b=a-b;
	a=a-b;
}

ll fact(ll n) { 
   if ((n==0)||(n==1))
      return 1;
   else
      return n*fact(n-1);
}

ll C(ll n, ll r) {
    if(r > n - r) r = n - r; 
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
        ans=ans%1000000007;
    }

    return ans;
}

//bool bipartite_dfs(ll node, ll flag)
//{
//	vis[node]=1;
//	ll cflag=flag;
//	color[node]=cflag;
//	for(ll child : al[node])
//	{
//		if(!vis[child])
//		{
//			bool n=bipartite_dfs(child,1-cflag);
//			if(n==false) return false;
//		}
//		else if(color[child]==color[node]) return false;
//	}
//	return true;
//}

void mmul(ll A[][101], ll B[][101], ll dim)
{
	ll res[dim][dim];
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		res[i][j]=0;
		for(ll k=0;k<dim;k++) res[i][j]=(res[i][j]+A[i][k]*B[k][j])%1000000007;
	}
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=res[i][j];
}

void mpow(ll A[][101],ll dim, ll po)
{
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		if(i==j) I[i][j]=1;
		else I[i][j]=0;
	}
	while(po>0)
	{
		if(po%2==1)
		{
			mmul(I,A,dim);
			po--;
		}
		else
		{
			mmul(A,A,dim);
			po/=2;
		}
	}
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=I[i][j];
}


int main()
{
	ll ans=1,a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>=k) ans=k;
	else if(a+b>=k) ans=a;
	else ans=a-k+a+b;
	cout<<ans;
}

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

using namespace std;

int ctoi(const char c) {
  if ('0' <= c && c <= '9') return (c - '0');
  return -1;
}

int main() {
  string s;
  cin >> s;

  int x = stoi(s);

  int sum = 0;
  for (char i : s) {
    sum += ctoi(i);
  }

  if (x % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s, t;
  cin >> s >> t;
  
  int ans = t.size();
  for (int i = 0; i + t.size() <= s.size(); i++) {
    int keep = 0;
    for (int j = 0; j < t.size(); j++) {
      if (s[i + j] != t[j]) keep++;
    }
    ans = min(ans, keep);
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 3640
function Main(input) {
	input = input.trim();
  var list = {
    "A" : "T",
    "T" : "A",
    "C" : "G",
    "G" : "C"
  };
  console.log(list[input]);
  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7496
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = long long;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];

ll powm(ll a, ll b, ll c) {
	if (b == 0)return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	}
	else return (a * powm(a, b - 1, c)) % c;
}

int main(){
	IOS;
	ll a, b ,c ,d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	vec<ll> water, sugar;
	for(int i = 0;a * 100 * i <= f;i++){
		for(int j = 0;b * 100 * j <= f;j++){
			ll tmp = a * i * 100 + b * j * 100;
			water.push_back(tmp);
		}
	}
	for(int i = 0;c * i <= f;i++){
		for(int j = 0;d * j <= f;j++){
			ll tmp = c * i + d * j;
			sugar.push_back(tmp);
		}
	}
	int n = water.size(), m = sugar.size();
	tuple<double,ll,ll> ans = make_tuple(0,0,0);
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			ll t = water[i];
			ll s = sugar[j];
			if(s + t <= f && s <= t / 100 * e){
				double nodo = 100 * s / (double)(t + s);
				ans = max(ans,make_tuple(nodo,s + t,s));
			}
		}
	}
	cout << get<1>(ans) << " " << get<2>(ans) << endl;
} 

Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
int main(){
  uint64_t n;
  cin>>n;
  vector<int>a(n+1,0);
  vector<int>b(n+1,0);
  vector<int>A(n);
  vector<int>B(n);
  int curr_a=1;
  int curr_b=1;
  for(int i=0;i<n;i++){
    cin>>A[i];
    for(int j=curr_a;j<A[i];j++){
      a[j]=i;
    }
    curr_a=A[i];
  }
  for(int i=curr_a;i<=n;i++){
    a[i]=n;
  }
  for(int i=0;i<n;i++){
    cin>>B[i];
    for(int j=curr_b;j<B[i];j++){
      b[j]=i;
    }
    curr_b=B[i];
  }
  for(int i=curr_b;i<=n;i++){
    b[i]=n;
  }
  int x=0;
  for(int i=1;i<=n;i++){
    if(a[i]-a[i-1]+b[i]-b[i-1]>n){
      cout<<"No"<<endl;
      return 0;
    }else if(a[i]-b[i-1]>x){
      x=a[i]-b[i-1];
    }
  }
  cout<<"Yes"<<endl;
  for(int i=n-x;i<n;i++){
    cout<<B[i]<<" ";
  }
  for(int i=0;i<n-x;i++){
    if(i<n-x-1){
      cout<<B[i]<<" ";
    }else{
      cout<<B[i];
    }
  }
  cout<<endl;
}

Measured memory_bytes: 6372
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int d,t,s;
    scanf("%d %d %d", &d, &t, &s);
    if(d <= t * s){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}


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



int main(){ 
  int s,w;
  cin>>s>>w;
  if(s<=w) puts("unsafe");
  else puts("safe");
  
}

Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, M: int, S: str):

    S = S[::-1]
    data = [0]*(N+1)
    past = 0
    for i in range(N+1):
        if S[i] == "1":
            data[i] = past
        else:
            past = i
    ans = []
    curr = 0
    while True:
        ne = curr+M
        if ne >= N:
            ans.append(N-curr)
            break
        if S[ne] == "1":
            ne = data[ne]
            if ne <= curr:
                print(-1)
                return
        ans.append(ne - curr)
        curr = ne
    print(*reversed(ans), sep=" ")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, M, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 50080
def main():
    a = input()
    n = 3
    op = ['']*n
    for i in range(1 << n):
        total = int(a[0])
        for j in range(n):
            if 1 & (i >> j):
                total += int(a[j+1])
                op[j] = '+'
            else:
                total -= int(a[j+1])
                op[j] = '-'
        if total == 7:
            break
    ans = a[0]
    for i in range(n):
        ans += op[i]+a[i+1]
    ans += '=7'
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
	int a, b, c;

	cin >> a >> b >> c;

	if (a < b)
	{
		int tmp = a;
		a = b;
		b = tmp;
	}

	if (a < c)
	{
		int tmp = a;
		a = c;
		c = tmp;
	}

	if (a == b + c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = IntArray(n) { readLine()!!.toInt() }
    var btn = 1
    for (i in 1..n) {
        btn = a[btn - 1]
        if (btn == 2) {
            println(i)
            return
        }
    }
    println(-1)
}


Measured memory_bytes: 38880
N = int(input())

mylist = [int(s) for s in input().split()]
mysum = sum(mylist)
mysum2 = 0
mymin = 999
for i in range(len(mylist)):
  mysum2 += mylist[i]
  if mymin > abs((mysum - mysum2) -mysum2):
    mymin = abs((mysum - mysum2) -mysum2)
print(mymin)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
int main()
{
    i64 n,k;
    cin >> n >> k;
    double win = 0;
    for(i64 i=1;i<=n;++i){
        i64 m = i, cnt = 1;
        while(m < k){
            m *= 2;
            cnt *= 2;
        }
        win += 1.0 / (double)cnt;
    }
    printf("%.10f\n",win/(double)n);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;


int main(){
    cout << fixed << setprecision(20);
    ll n; cin >> n;
    ll ans = 0;
    map<ll,ll> m;
    vc<ll> list;
    int si = 0;
    for(ll i = 2; i*i <= n; i++){
        if(n % i == 0){
            if(m[i] == 0){
                list.eb(i);
                si++;
            }
            m[i]++;
            n /= i;
            i--;
        }
        if(n == 1) break;
    }
    if(n != 1){
        if(m[n] == 0){
            list.eb(n);
            si++;
        }
        m[n]++;
    }
    rep(i,si){
        ll x = m[list[i]];
        ll num = 1;
        while(1){
            if(x < num){
                num--;
                break;
            }
            else{
                x -= num;
                num++;
            }
        }
        ans += num;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<int> A(N),B=A;
    REP(i,N) cin>>A[i];
    REP(i,N) cin>>B[i];
    int ans=(N+1)*(N+1);
    REP(bit,1<<N) if(__builtin_popcount(bit)%2==0){
        vector<int> state(N);
        REP(i,N){
            if(bit>>i&1) state[i]=B[i];
            else state[i]=A[i];
        }
        vector<int> co=state;
        sort(All(co));
        bool judge=true;
        vector<int> used(N,-1);
        REP(i,N){
            bool ok=false;
            REP(j,N) if(used[j]==-1){
                if(co[i]==state[j]&&std::abs(j-i)%2==(bit>>j&1)){
                    ok=true;
                    used[j]=i;
                    break;
                }
            }
            if(!ok) judge=false;
        }
        int tmp=0;
        if(judge){
            REP(i,N) rep(j,i+1,N){
                if(state[i]>state[j]){
                    tmp++;
                }
                if(state[i]==state[j]){
                    if((used[j]-used[i])*(j-i)<0) tmp++;
                }
            }
            ans=min(ans,tmp);
                // cout<<tmp<<endl;
                // REP(i,N) cout<<(bit>>i&1)<<" \n"[i==N-1];
                // REP(i,N) cout<<co[i]<<" \n"[i==N-1];
                // REP(i,N) cout<<state[i]<<" \n"[i==N-1];
        }
    }
    if(ans==(N+1)*(N+1)) cout<<-1<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 256
h,w,n = map(int, input().split())
sr, sc = map(int, input().split())
s = input()
t = input()

left = 1
right = w
bot = 1
top = h

if s[-1] == "L":
    left += 1
elif s[-1] == "R":
    right -= 1
elif s[-1] == "U":
    bot += 1
elif s[-1] == "D":
    top -= 1

for i in range(n-2, -1, -1):
    if t[i] == "L":
        right = min(w, right+1)
    elif t[i] == "R":
        left = max(1, left-1)
    elif t[i] == "U":
        top = min(h, top+1)
    elif t[i] == "D":
        bot = max(1, bot-1)
    if s[i] == "L":
        left += 1
    elif s[i] == "R":
        right -= 1
    elif s[i] == "U":
        bot += 1
    elif s[i] == "D":
        top -= 1
    if left > right or bot > top:
        print("NO")
        exit()
if left <= sc <= right and bot <= sr <=top:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 48332
#include "bits/stdc++.h"
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	vector<string>A(H);
	for (int i = 0; i < H; i++) {
		cin >> A.at(i);
	}
	for (int i = 0; i < 2 * H; i++) {
		cout << A.at(i / 2) << endl;
	}
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

constexpr long long MOD = 1000000007;
constexpr long long MOD2 = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;



int n;

ull a[200019];

ull umin (ull a, ull b) {
    return (a < b) ? a : b;
}
ull umax (ull a, ull b) {
    return (a > b) ? a : b;
}

int main() {

    cin >> n;
    rep(i, n) cin >> a[i];


    ll i, j;
    ull res = 0;

    ull allxor = 0;
    for (i = 0; i < n; i++) {
        allxor ^= a[i];
    }
    for (i = 0; i < n; i++) {
        a[i] &= ~allxor; //interstingなbitだけ立たせる(最後に考慮)
    }

    //F2における掃き出し法
    ull rank = 0;
    for (i = 59; i >= 0; i--) {
        //i-bitが0でない最初の行j>=rankを探す　なかったら次のiへ
        for (j = rank; j < n; j++) {
            if (a[j] & (1 << i)) break;
        }
        if (j == n) continue;

        if (j > rank) a[rank] ^= a[j];  //a[rank] = a[rank] + a[j] in F2
        for (j = rank + 1; j < n; j++) {
            a[j] = umin(a[j], a[j] ^ a[rank]);
        }

        rank++;
    }

    ull x = 0;
    for (i = 0; i < n; i++) { //高いbitが立ってる方からgreedyに
        x = umax(x, x ^ a[i]);
    }

    res = (x * 2) + allxor;

    cout << res << endl;

}




Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<char> s(n);
  for(int i=0;i<n;i++) cin >> s.at(i);
  decltype(s)::iterator result = unique(s.begin(),s.end());
  s.erase(result,s.end());
  size_t size=s.size(); 
  cout << size << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

class Graph {
public:
	int vn;
	int sumcost = 0;
	vector<vector<pii>> g;

	Graph(int n) {
		vn = n;
		g.resize(n);
	}
	virtual void con(int a, int b, int w) = 0;
	int getWeight(int f, int t) {
		auto itr = lower_bound(ALL(g[f]), make_pair(t, INT_MIN));
		if (itr != g[f].end())
			return itr->second;
		return INT_MIN;
	}
	int Costsum() {
		return sumcost;
	}
	void scan(int edcount, bool oindexed, bool w) {
		REP(i, edcount) {
			int a, b, c = 1;
			scanf("%d %d", &a, &b);
			if (w)scanf("%d", &c);
			con(a - oindexed, b - oindexed, c);
		}
	}
};
class BiDGraph : public Graph {//無向
public:
	BiDGraph(int n) : Graph(n) {}

	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		g[b].push_back({ a, w });
		sumcost++;
	}
};
template<class T>
vector<ll> Dijkstra(T g, int st) {
	priority_queue<pii, vector<pii>, greater<pii>> que;

	que.push({ 0, st });
	int kk = 0;
	vector<ll> res(g.vn, -1);
	while (kk < g.vn && que.size()) {
		pii cur = que.top();
		que.pop();
		if (res[cur.second] != -1)
			continue;
		res[cur.second] = cur.first;
		kk++;
		for (auto itr : g.g[cur.second]) {
			if (res[itr.first] == -1)
				que.push({ cur.first + itr.second,itr.first });
		}
	}
	return res;
}
signed main() {

	int n, m;
	scanf("%d %d", &n, &m);
	BiDGraph g(n);

	g.scan(m,1,0);


	vector<ll> ans(Dijkstra(g, 0));

	printf(ans[n-1] == 2 ? "POSSIBLE\n" : "IMPOSSIBLE\n");

	return 0;
}

Measured memory_bytes: 28392
encode = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + " .,-\'?"
decode = {" ":"101","\'":"000000",",":"000011","-":"10010001",".":"010001","?":"000001",
          "A":"100101","B":"10011010","C":"0101","D":"0001","E":"110","F":"01001",
          "G":"10011011","H":"010000","I":"0111","J":"10011000","K":"0110","L":"00100",
          "M":"10011001","N":"10011110","O":"00101","P":"111","Q":"10011111","R":"1000",
          "S":"00110","T":"00111","U":"10011100","V":"10011101","W":"000010","X":"10010010",
          "Y":"10010011","Z":"10010000"}
while True:
    try:
        a = input()
        code = ""
        for inp in a:
            code += decode[inp]
        code += "0"*(-len(code)%5)
        ans = ""
        for i in range(len(code)//5):
            ans += encode[int(code[i*5:i*5 + 5], 2)]
        print(ans)
    except:
        break



Measured memory_bytes: 5588
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))

void run (void) {
  i32 a, b, c, n;
  scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32 "%" SCNi32, &a, &b, &c, &n);
  i32 ans = 0;
  for (i32 i = 0; a * i <= n; ++i) {
    i32 m = n - i * a;
    for (i32 j = 0; b * j <= m; ++j) {
      i32 l = m - b * j;
      if (l % c == 0) ans++;
    }
  }
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
//012345-AXYZWB
int map[6][6]={{0,1,1,0,0,0},
			   {0,0,0,1,0,0},
			   {0,1,0,0,0,0},
			   {0,0,0,0,1,1},
			   {0,0,1,0,0,1},
			   {0,1,1,0,0,0}};
int road[6][2]={{1,2},{-1,3},{1,-1},{4,5},{5,2},{2,1}};
int main(){
	int i,j,ct,l;
	char s[105];
	//for(i=0;i<6;i++){for(j=0;j<2;j++)printf("%3d ",road[i][j]);printf("\n");}
	while(1){
		scanf("%s",s);
		if(strcmp(s,"#")==0)break;
		ct=0;
		l=strlen(s);
		for(i=0;i<l;i++){
			//printf("%d->",ct);
			ct=road[ct][s[i]-'0'];
			if(ct==-1)break;
		}
		//printf("%d\n",ct);
		printf("%s\n",(ct==5)?("Yes"):("No"));
	}
	return 0;
}

Measured memory_bytes: 524
/**
*    author:  souzai32
*    created: 13.08.2020 18:03:34
**/

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

int main() {

    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    vector<vector<int>> c(h,vector<int>(w));

    int j=0,k=0;
    bool d=true;
    int num=1;
    for(int i=0; i<h*w; i++){
        if(k==-1){
            j++;
            k++;
            d=true;
        }
        if(k==w){
            j++;
            k--;
            d=false;
        }
        c.at(j).at(k)=num;
        a.at(num-1)--;
        if(!a.at(num-1)) num++;
        if(d)k++;
        else k--;
    }

    rep(i,h){
        rep(j,w){
            cout << c.at(i).at(j);
            if(j!=w-1) cout << ' ';
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>
using namespace std;

int main()
{
    long long int N, temp, i, len;
    vector<char> data;
    char name;
    cin>>N;
    while(N>=26)
    {
        temp = N%26;
        N/=26;
        if(temp==0)
        {
            N-=1;
            data.push_back('z');
        }
        else
        {
            temp = temp+96;
            name = (char)temp;
            data.push_back(name);
        }
    }
    if(N>0)
    {
        temp = N+96;
        name = (char)temp;
        data.push_back(name);   
    }
    reverse(data.begin(), data.end());
    len = data.size();
    for(i=0;i<len;i+=1)
    {
        cout<<data[i];
    }
}


Measured memory_bytes: 3600
import sys
from itertools import combinations_with_replacement


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


def main():
    N, M, Q = map(int, input().split())
    L = [list(map(int, input().split())) for _ in range(Q)]
    # L = sorted(L, key=lambda x: x[-1])
    answer = 0
    As = list(combinations_with_replacement([i for i in range(1, M + 1)], N))
    for A in As:
        cnt = 0
        for l in L:
            a = l[0] - 1
            b = l[1] - 1
            c = l[2]
            d = l[3]
            if A[b] - A[a] == c:
                cnt += d
        if answer < cnt:
            answer = cnt
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21528
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=924844033;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,k;
vector<vector<int> >seg;
int ans[2005];
int cnt[2005];
int fact[2005];
int dp[2][2][2005][2005];
vector<vector<int> >to_mul;
inline void add(int &x,int y){
	x+=y;if(x>=mod)x-=mod;
}
void solve(int sz){
	for(int a=0;a<2;a++)for(int b=0;b<2;b++)for(int i=0;i<sz+2;i++)for(int j=0;j<sz+2;j++)dp[a][b][i][j]=0;
	dp[1][0][1][0]=1;
	for(int i=1;i<=sz;i++){
		for(int j=0;j<=i;j++){
			for(int a=0;a<2;a++){
				for(int b=0;b<2;b++){
					if(a==0)add(dp[b][0][i+1][j+1],dp[a][b][i][j]);
					add(dp[b][1][i+1][j+1],dp[a][b][i][j]);
					add(dp[b][0][i+1][j],dp[a][b][i][j]);
				}
			}
		}
	}
	for(int i=0;i<=sz;i++){
		for(int a=0;a<2;a++){
			for(int b=0;b<1;b++){
				cnt[i]+=dp[a][b][sz+1][i];
				cnt[i]%=mod;
			}
		}
	}
}
vector<int>solve(int l,int r){
	if(l==r)return to_mul[l];
	int mid=(l+r)/2;
	vector<int>left=solve(l,mid),right=solve(mid+1,r);
	vector<int>ret;ret.resize((int)left.size()+right.size()-1,0);
	for(int i=0;i<left.size();i++)for(int j=0;j<right.size();j++){
		add(ret[i+j],(ll)left[i]*right[j]%mod);
	}
	return ret;
}
signed main(){
	cin>>n>>k;
	fact[0]=1;
	for(int i=1;i<=2000;i++)fact[i]=(ll)fact[i-1]*i%mod;
	for(int i=1;i<=k;i++){
		vector<int>v;
		for(int j=i;j<=n;j+=k){
			v.push_back(j);
		}
		seg.push_back(v);
	}
	for(int i=0;i<seg.size();i++){
		memset(cnt,0,sizeof cnt);
		solve(seg[i].size());
		vector<int>vec;
		for(int j=0;j<=seg[i].size();j++)vec.push_back(cnt[j]);
//		for(int j=0;j<vec.size();j++)cerr<<j<<" "<<vec[j]<<endl;
		to_mul.push_back(vec);
	}
	vector<int>tmp=solve(0,(int)to_mul.size()-1);
	for(int i=0;i<tmp.size();i++)ans[i]=tmp[i];
	int res=0;
	for(int i=0;i<=n;i++){
//		cerr<<"show: "<<i<<" "<<ans[i]<<endl;
		res+=(i%2?-1ll:1ll)*((ll)ans[i]*fact[n-i]%mod);
		res+=mod;res%=mod;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 125952
#include <bits/stdc++.h>
using namespace std;
int main(){
    string n;
    cin >> n;
    if (n[0] == n[1] && n[1] == n[2]){
        cout << "Yes" << endl;
    } else if (n[1] == n[2] && n[2] == n[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    /*
    for (int i = 0; i < 4; i++){
        int cnt = count(n.begin(),n.end(),n[i]);
        if (cnt >= 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    */
    return 0;
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int P = int.Parse(str[1]);
            int kakera = 3 * A + P;

            int applePie;
            if (kakera % 2 == 1)
            {
                applePie = (kakera - 1) / 2;
            }
            else
            {
                applePie = kakera / 2;
            }
            Console.Write(applePie);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x),b(y),c(z);
    rep(i,x) cin >> a[i];
    rep(i,y) cin >> b[i];
    rep(i,z) cin >> c[i];

    vector<ll> tmp;
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            tmp.push_back(a[i]+b[j]);
        }
    }

    sort(tmp.begin(),tmp.end());
    reverse(tmp.begin(),tmp.end());

    vector<ll> tmp2;
    for(int i=0;i<min(x*y,k);i++){
        for(int j=0;j<z;j++){
            tmp2.push_back(tmp[i]+c[j]);
        }
    }

    sort(tmp2.begin(),tmp2.end());
    reverse(tmp2.begin(),tmp2.end());

    rep(i,k){
        cout << tmp2[i] << endl;
    }



}

Measured memory_bytes: 43240
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a,b;
int main(){
	scanf("%d%d",&a,&b);
	int maxs=max(a,b),count=0,mins=min(a,b);
	for(int i=mins;i<maxs;i++){
		if(abs(a-i)==abs(b-i)){
			count=i;
			break;
		}
	}
	if(count==0){
		printf("IMPOSSIBLE");
	}else{
		printf("%d",count);
	}
	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(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const 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;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];

    vector<pair<ll, ll>> a;
    rep(i, 0, N)
    {
        a.push_back(make_pair(abs(A[i]), A[i]));
    }

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

    vector<ll> plus;
    vector<ll> minus;
    rrep(i, N - 1, 1)
    {
        if (a[i].second > 0)
        {
            plus.push_back(a[i].second);
        }
        else
        {
            minus.push_back(a[i].second);
        }
    }

    if (a[0].second >= 0)
    {
        if (plus.size() != N - 1)
        {
            plus.push_back(a[0].second);
        }
        else
        {
            minus.push_back(a[0].second);
        }
    }
    else
    {
        if (minus.size() != N - 1)
        {
            minus.push_back(a[0].second);
        }
        else
        {
            plus.push_back(a[0].second);
        }
    }

    ll ans = 0;
    for (const ll i : plus) ans += i;
    for (const ll i : minus) ans -= i;

    cout << ans << endl;

    if (N == 2)
    {
        cout << plus[0] << " " << minus[0] << endl;
    }
    else
    {
        if (plus.size() == 1)
        {
            cout << plus[0] << " " << minus[0] << endl;
            ll tmp = plus[0] - minus[0];

            rep(i, 1, minus.size())
            {
                cout << tmp << " " << minus[i] << endl;
                tmp = tmp - minus[i];
            }
        }
        else
        {
            cout << minus[0] << " " << plus[0] << endl;

            ll tmp = minus[0] - plus[0];

            rep(i, 1, plus.size() - 1)
            {
                cout << tmp << " " << plus[i] << endl;
                tmp = tmp - plus[i];
            }

            cout << plus.back() << " " << tmp << endl;
            tmp = plus.back() - tmp;

            rep(i, 1, minus.size())
            {
                cout << tmp << " " << minus[i] << endl;
                tmp = tmp - minus[i];
            }
        }
    }
}


Measured memory_bytes: 6128
package main

import (
	"fmt"
)

func main() {
  var a1, a2, a3 int
  fmt.Scanf("%d %d %d", &a1, &a2, &a3)
  sum := a1 + a2 + a3
  
  ans := "win"
  if sum >= 22 {
    ans = "bust"
  }
  fmt.Printf("%s\n", ans)
}

Measured memory_bytes: 1828