akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
   
using namespace std;
typedef long long int ll;
  
int main()
{
	string s[3];
	for(int i=0; i<3; i++){
		cin>>s[i];
		reverse(s[i].begin(), s[i].end());
	}
	int i=0;
	while(1){
		if(s[i].empty()){
			printf("%c\n", (char)('A'+i));
			return 0;
		}
		int j=(s[i].back()-'a');
		s[i].pop_back();
		i=j;
	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<string>

using namespace std;

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1.0)
#define scan(a) scanf("%d",&a)
#define scanll(a) scanf("%lld",&a)
#define print(a) printf("%d\n",a)
#define printll(a) printf("%lld\n",a)
#define stll(a) stoll(a,nullptr,10)
#define PII pair<ll,ll>
#define mp(a,b) make_pair(a,b)

typedef long long ll;
typedef unsigned long long ull;

double ar[10000];

int main()
{
    ll n;
    cin>>n;
    double sum=0;
    for(int i=1;i<=n;i++)
        cin>>ar[i];

    for(int i=1;i<=n;i++)
    {
        sum+= 1.0/ar[i];
    }
    sum= 1.0/sum;
    printf("%.7lf\n",sum);


}






Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int isPrime(int x){
	if(x==2)return true;
	else if(x<2 || x%2==0)return false;
	double xx=x;
	int i=3;
	while(i<=ceil(sqrt(xx))){
		if(x%i==0){
			return false;
		}
		i=i+2;
	}
	return true;
}

int main(){
	int ans=0;
	int n,number;
	cin>>n;
	for(int ii=0;ii<n;ii++){
		cin>>number;
	    ans+=isPrime(number);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int n = readNum();
		int[] ia = readNums();
		int ans = 0;
		while (true) {
			for (int i = 0; i < n; i++) {
				if (ia[i] % 2 > 0) {
					pln(ans);
					return;
				}
				ia[i] /= 2;
			}
			ans++;
		}
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 21332
def main():
    n, m, x = map(int, input().split())
    sofar = 10 ** 5 + 1
    cl = list(list(map(int, input().split())) for _ in range(n))
    # print(cl)
    ans = float('inf')
    for i in range(2 ** n):
        tmp = [0] * m
        cost = 0
        for j in range(n):
            # print(bin(j), i, bin(i >> j))
            if (i >> j) & 1:
                for k in range(m):
                    tmp[k] += cl[j][k + 1]
                cost += cl[j][0]
                # print(tmp)
        for t in tmp:
            if t < x:
                break
        else:
            ans = min(ans, cost)
    if ans == float('inf'):
        return -1
    else:
        return ans


if __name__ == '__main__':
    print(main())


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

int dp[100010]={0};

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

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

    int coin[] = {6, 9};
    for (int k=0;k<2;k++)
    for (int m = coin[k]; m <= n; m *= coin[k]) {
        for (int i=0;i+m<=100000;i++) {
                if(dp[i+m]){
                    dp[i+m] = min(dp[i+m] , dp[i] + 1);
                }else{
                    dp[i+m] = dp[i] + 1;
                }
        }
    }

    cout << dp[n] << endl;
}


Measured memory_bytes: 640
A,V = map(int,input().split())
B,W = map(int,input().split())
T=int(input())

ans = "NO"

if(A<B):
    if(A+V*T >= B+W*T):
        ans = "YES"
elif(A>B):
    if(A+(-1)*V*T <= B+(-1)*W*T):
        ans = "YES"
print(ans)


Measured memory_bytes: 9184
#include <iostream>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int x = a + b;
  int y = b + c;
  int z = a + c;
  int ans = x;
  if (y < ans)
    ans = y;
  if (z < ans)
    ans = z;
  cout << ans;
  return 0;
}


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

int main()
{
    long long N,K,a,b,c;
    cin>>N>>K;
    a=N;
    if(N%K==0){
        cout<<0<<endl;
        exit(0);
    }else{
        b=N%K;
        c=b;
        while(1){
            b=abs(b-K);
            c=min(b,c);
            if(b!=c){
                cout<<c<<endl;
                exit(0);
            }        
        }
    }
    
/*   while(1){
        N=abs(N-K);
        a=min(a,N);
        if(a!=N){
            cout<<a<<endl;
            exit(0);
        }
    }*/
    
}

Measured memory_bytes: 256
n,C = map(int,input().split())
INF = float("INF")
ch = [[0]*(200001) for _ in range(C)]
m = 0
for _ in range(n):
    s,t,c = map(int,input().split())
    s = s*2-1
    t *= 2
    c -= 1
    ch[c][s] += 1
    ch[c][t] -= 1
    m = max(m,t)

cnt = [0]*(m+1)
for c in range(C):
    for i in range(1,m+1):
        ch[c][i] += ch[c][i-1]
        if ch[c][i-1] == 0 and ch[c][i] > 0: cnt[i] += 1
        if ch[c][i-1] > 0 and ch[c][i] == 0: cnt[i] -= 1

for i in range(1,m+1): cnt[i] += cnt[i-1]
print(max(cnt))

Measured memory_bytes: 94936
#include <iostream>
#include <string>
using namespace std;
int main() 
{
    string ring,str;
    int N,res=0;
    cin>>str>>N;
    for (int i=0; i<N; i++) {
        cin>>ring;
        bool flag=false;
        for (int j=0; j<10; j++) {
            int at=j;
            string tmp="";
            for (int k=0; k<str.length(); k++) {
                if (at==10) at=0;
                tmp+=ring[at];
                at++;
            }
            if (tmp==str) {
                flag=true;
                break;
            }
        }
        if (flag) res++;
    }
    cout<<res<<endl;
}

        

Measured memory_bytes: 0
#include<stdio.h>
int main ()
{
	int i,f=0;
	char s[4];
	scanf("%s" ,s);
	for(i=0;i<3;i++)
	{
		if(s[i]==s[i+1])
		{		printf("Bad");
			f=1;
		break;
		}
	}
	if(f==0)
	printf("Good");
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n,m,k;
    cin>>n>>m>>k;
    //ll ct=0;
    VL a(n),b(m);
    fr(i,0,n)
        cin>>a[i];
    fr(i,0,m)
        cin>>b[i];
    //ll prefa[n+1],prefb[m+1];
    VL prefa(n+1,0),prefb(m+1,0);
    fr(i,0,n)
    {
        prefa[i+1]=a[i];
        prefa[i+1]+=prefa[i];
    }
    fr(i,0,m)
    {
        prefb[i+1]=b[i];
        prefb[i+1]+=prefb[i];
    }
    ll ct=0;
    ll last=0;
    ll ans=0;
    fr(i,1,n+1)
    {
        if(prefa[i]<=k)
        {
            ct++;
            last=i;
            ans=max(ans,ct);
        }
        else
        {
            break;
        }
    }
    ll j=1,i=last;
    while(j<=m)
    {
        if((prefa[last]+prefb[j])<=k)
        {
            ct++;
            j++;
            ans=max(ans,ct);
        }
        else
            break;
    }

    while(j<=m&&last>0)
    {
        last--;
        ct--;
        ll fg=1;
        // while(j<=m&&(prefa[last]+prefa[j]<=k))
        // {
        //     ct++;
        //     j++;
        //     ans=max(ans,ct);
        // }
        while(j<=m)
        {
            if((prefa[last]+prefb[j])<=k)
            {
                ct++;
                j++;
                ans=max(ans,ct);
            }
            else
                break;
        }
    }
    // if(ans==inf)
    //     cout<<"0\n";
    // else
        cout<<ans<<endl;
    return  ;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 9504
#include <stdio.h>
#include <stdlib.h>

long *tree[10001];

int cmpnum(const void * n1, const void * n2) {
	if (*(long *)n1 > *(long *)n2) {
		return -1;
	}
	else if (*(long *)n1 < *(long *)n2) {
		return 1;
	}
	else {
		return 0;
	}
}

int main(void) {

  long n,m = 0;
  scanf("%ld", &n);
  long a[n-1],b[n-1],c[n],tree_s[n+1],queue[n],visited[n+1],d[n+1];
  for (long i = 1; i <= n; i++) {
    tree_s[i] = 0;
    visited[i] = 0;
  }
  for (long i = 0; i < n-1; i++) {
    scanf("%ld %ld", &a[i], &b[i]);
    tree[a[i]] = realloc(tree[a[i]], sizeof(long)*(tree_s[a[i]]+1));
    tree[a[i]][tree_s[a[i]]] = b[i];
    tree_s[a[i]]++;
    tree[b[i]] = realloc(tree[b[i]], sizeof(long)*(tree_s[b[i]]+1));
    tree[b[i]][tree_s[b[i]]] = a[i];
    tree_s[b[i]]++;
  }
  for (long i = 0; i < n; i++) {
    scanf("%ld", &c[i]);
    m += c[i];
  }
  qsort(c, n, sizeof(long), cmpnum);
  m -= c[0];
  queue[0] = 1;
  visited[1] = 1;
  d[1] = c[0];
  long start = 0,end = 0,tail = 0,cur,next;
  while (1) {
    for (long i = start; i <= end; i++) {
      cur = queue[i];
      for (long j = 0; j < tree_s[cur]; j++) {
        next = tree[cur][j];
        if (visited[next] == 1) {
          continue;
        }
        tail++;
        queue[tail] = next;
        visited[next] = 1;
        d[next] = c[tail];
      }
    }
    if (tail == n-1) {
      break;
    }
    start = end+1;
    end = tail;
  }
  printf("%ld\n", m);
  for (long i = 1; i <= n-1; i++) {
    printf("%ld ", d[i]);
  }
  printf("%ld\n", d[n]);

  return 0;
}

Measured memory_bytes: 2880
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()

class modfact(object):
    def __init__(self, n):
        fact, invfact = [1] * (n + 1), [1] * (n + 1)
        for i in range(1, n + 1): fact[i] = i * fact[i - 1] % MOD
        invfact[n] = pow(fact[n], MOD - 2, MOD)
        for i in range(n - 1, -1, -1): invfact[i] = invfact[i + 1] * (i + 1) % MOD
        self._fact, self._invfact = fact, invfact

    def inv(self, n):
        return self._fact[n - 1] * self._invfact[n] % MOD

    def fact(self, n):
        return self._fact[n]

    def invfact(self, n):
        return self._invfact[n]

    def comb(self, n, k):
        if k < 0 or n < k: return 0
        return self._fact[n] * self._invfact[k] % MOD * self._invfact[n - k] % MOD

    def perm(self, n, k):
        if k < 0 or n < k: return 0
        return self._fact[n] * self._invfact[n - k] % MOD

def resolve():
    r1, c1, r2, c2 = map(int, input().split())
    mf = modfact(r2 + c2 + 2)
    def S(m, n):
        res = (m + 2) * mf.comb(m + n + 2, m + 2) % MOD * mf.inv(n + 1) % MOD
        res -= 1
        return res % MOD

    res = S(r2, c2) - S(r1 - 1, c2) - S(r2, c1 - 1) + S(r1 - 1, c1 - 1)
    print(res % MOD)
resolve()

Measured memory_bytes: 69872
#include<bits/stdc++.h>
using namespace std;
int n,l,ans=-1,ori=0;
int main(){
	cin>>n>>l;
	ori=n*(n+1)/2+(l-1)*n;
	for(int i=1;i<=n;i++){
		int tmp=ori-(l+i-1);
		if(abs(ori-ans)>abs(ori-tmp)||ans==-1) ans=tmp;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
#include<bitset>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int cnt(int a) {
	int s = 0;
	while (a > 0) {
		if (a & 1) s++;
		a >>= 1;
	}
	return s;
}
int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n)cin >> s[i];
	vector<char>top = { 'M', 'A', 'R', 'C', 'H' };
	map<char, int>m;
	rep(i, n)m[s[i][0]]++;
	ll sum = 0;
	int mx = 0b100000;
	rep(b, mx) {
		if (cnt(b) == 3) {
			int tb = b;
			int j = 0;
			ll tsum = 1;
			while (tb > 0) {
				if (tb & 1) {
					tsum *= m[top[j]];
				}
				tb >>= 1;
				j++;
			}
			sum += tsum;
		}
	}
	cout << sum << endl;
	return 0;
}





Measured memory_bytes: 6144
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,gcd
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
'''
#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4
 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
'''
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=[ii() for _ in range(n)]

p=sum(arr)

arr.sort()

ans=0

if p%10!=0:
    print(p)
    exit()
else:
    for i in arr:
        if (p-i)%10!=0:
            ans=max(ans,p-i)
        else:
            pass
print(ans)


Measured memory_bytes: 10532
#include <stdio.h>

int main(void)
{
	
	int a ,b ,c ,d;
	
	scanf("%d %d %d\n" ,&a ,&b ,&c);
	
	if(a>b){
		
		d = b;
		b = a;
		a = d;
		
	}
	
	if(a>c){
		
		d = c;
		c = a;
		a = d;
		
	}
	
	if(b>c){
		
		d = c;
		c = b;
		b = d;
		
	}
	
	printf("%d %d %d\n" ,a ,b ,c);
	
	return 0;
	
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std ;
long long int Min( long long int a, long long int b ){
    return a < b ? a : b ;
}

long long int sol( long long int w[] , long long int v[] , long long int N , long long int W ){
    long long int dp[100005] ;
    for( long long int i = 0 ; i < 100005 ; i++ ) dp[i] = INT_MAX ;
    dp[0] = 0 ;
    for( long long int i = 0 ; i < N ; i++ ){
        long long int pick_w = w[i], pick_v = v[i] ;
        for( long long int j = 100005 ; j >= pick_v ; j-- ){
            dp[j] = Min( dp[j] , dp[j-pick_v] + pick_w ) ;
        }

    }
    long long int ans ;
    for( int i = 0 ; i < 100005 ; i++ ){
        if( dp[i] <= W ) ans = i ;
    }
    return ans ;
}


int main(){
    long long int N , W ;
    cin >> N >> W ;
    long long int w[N], v[N] ;
    for( long long int i = 0 ; i < N ; i++ ){
        cin >> w[i] >> v[i] ;
    }
    cout << sol( w , v , N , W )  << "\n" ;
    return 0 ;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
int main(){
    int N,u,v;cin >> N >> u >> v;
    vector<int> to[100010];
    for(int i=0; i<N-1; i++){
        int a,b;cin >> a >> b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int> distA(N+1),distT(N+1);
    distA[v]=0;
    distT[u]=0;
    queue<int> q1;
    vector<bool> used1(N+1,false);
    q1.push(v);
    used1[v]=true;
    while(!q1.empty()){
        int now=q1.front();q1.pop();
        for(auto next: to[now]){
            if(used1[next]) continue;
            used1[next]=true;
            q1.push(next);
            distA[next]=distA[now]+1;
        }
    }
    queue<int> q2;
    q2.push(u);
    vector<bool> used2(N+1,false);
    used2[u]=true;
    while(!q2.empty()){
        int now=q2.front();q2.pop();
        for(auto next: to[now]){
            if(used2[next]) continue;
            used2[next]=true;
            q2.push(next);
            distT[next]=distT[now]+1;
        }
    }
    int mx=0;
    for(int i=1; i<=N; i++){
        if(distA[i]>distT[i]){
            mx=max(mx,distA[i]);
        }
    }
    int ans=mx-1;
    cout << ans << endl;
    return 0;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var l = double.Parse(Console.ReadLine());
			Console.WriteLine(((l * l * l) / 27.0d).ToString("F12"));
		}
	}
}


Measured memory_bytes: 11220
#include<stdio.h>
int main(){
	int N,A,B,C,D;
	scanf("%d%d%d%d%d",&N,&A,&B,&C,&D);
	if(Xset(N,A,B)<Yset(N,C,D))printf("%d\n",Xset(N,A,B));
	else printf("%d\n",Yset(N,C,D));
	return 0;
}
int Xset(int N,int A,int B){
	int XE=0,NKB=0;
	while(NKB<N){
		NKB+=A;
		XE+=B;
	}
	return XE;
}
int Yset(int N,int C,int D){
	int YE=0,TNG=0;
	while(TNG<N){
		TNG+=C;
		YE+=D;
	}
	return YE;
}


Measured memory_bytes: 2140
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int m = Integer.parseInt(str[1]);
    int[] a = new int[n];
    int[] b = new int[n];
    int[] c = new int[m];
    int[] d = new int[m];
    for(int i=0; i<n; i++) {
      str = in.readLine().split(" ");
      a[i] = Integer.parseInt(str[0]);
      b[i] = Integer.parseInt(str[1]);
    }
    for(int i=0; i<m; i++) {
      str = in.readLine().split(" ");
      c[i] = Integer.parseInt(str[0]);
      d[i] = Integer.parseInt(str[1]);
    }
    
    for(int i=0; i<n; i++) {
      int min = 1000000000;
      int num = 0;
      for(int j=0; j<m; j++) {
        if(min > Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j])) {
          min = Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j]);
          num = j+1;
        }
      }
      System.out.println(num);
    }
  }
}

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

int main(void){
	int n,a[100000];
	int ans[100000];
    cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
		ans[a[i]-1] = i;
	}
	for(int i=0;i<n;i++){
		cout << ans[i]+1 << " ";
	}
	cout << endl;
}

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

#define ll long long 
#define pll pair<ll,ll> 

vector<ll> A,S;

ll root(ll x){
	while(A[x]!=x){
		A[x]=A[A[x]];
		x=A[x];
	}
	return x;
}
void con(ll x, ll y){
	ll rx=root(x);
	ll ry=root(y);
	if(rx==ry)
		return ;
	if(S[rx]<S[ry])
		swap(rx, ry);
	
	S[rx]+=S[ry];
	A[ry]=rx;
	S[ry]=0;
}

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll ans=INT_MIN;
	ll n, m;
	cin>>n>>m;
	A.resize(n);
	S.resize(n, 1);
	iota(A.begin(), A.end(), 0);
	for(ll i=0;i<m;i++){
		ll x, y;
		cin>>x>>y;
		x--,y--;
		con(x,y);
	}

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

}


Measured memory_bytes: 6364
#include <stdio.h>
int main()
{
int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if(x+r<=W && x-r>=0 && y+r<=H && y-r>=0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 584
s = input()

if 1 <= int(s[0:2]) <= 12 and 1 <= int(s[2:4]) <= 12:
    print('AMBIGUOUS')
elif 0 <= int(s[0:2]) <= 99 and 1 <= int(s[2:4]) <= 12:
    print('YYMM')
elif 1 <= int(s[0:2]) <= 12 and 0 <= int(s[2:4]) <= 99:
    print('MMYY')
else:
    print('NA')

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

int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	//freopen("input.txt","r",stdin);
	string s,ss;
	cin>>s>>ss;
	int cnt=0;
	for(int i=0;i<s.size();i++){
        if(s[i]!=ss[i])cnt++;
	}
	cout<<cnt<<"\n";
	return 0;
}


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

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

using namespace std;
using ll = long long;

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

    const int INF = INT32_MAX;

    int n;
    cin >> n;
    int x, y;
    int u_min = INF, v_min = INF;
    int u_max = -INF, v_max = -INF;
    rep(i, n) {
        cin >> x >> y;
        u_min = min(u_min, x + y);
        u_max = max(u_max, x + y);
        v_min = min(v_min, x - y);
        v_max = max(v_max, x - y);
    }

    int ans = max(u_max - u_min, v_max - v_min);
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 3768
import java.util.Scanner;
public class Main{
  public static void main(String[] args)
  {
    Scanner scan =new Scanner (System.in);
    int a =  scan.nextInt();
    int b =  scan.nextInt();
    int c =  scan.nextInt();
    System.out.println(c+" "+a+" "+b);
  }
}

Measured memory_bytes: 38988
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,M,L;
    cin >> N >> M >> L;
    ll d0[N][N];
    ll d1[N][N];
    rep(i,N){
        rep(j,N){
            d0[i][j]=INF;
        }
        d0[i][i]=0;
    }
    rep(i,M){
        ll a,b,c;
      	cin >> a >> b >> c;
        a--;b--;
        d0[a][b]=d0[b][a]=c;
    }
    rep(k,N){
        rep(i,N){
            rep(j,N){
                chmin(d0[i][j],d0[i][k]+d0[k][j]);
            }
        }
    }
    rep(i,N){
        rep(j,N){
            if(d0[i][j]<=L){
                d1[i][j]=1;
            }
            else{
                d1[i][j]=INF;
            }
        }
        d1[i][i]=0;
    }
    rep(k,N){
        rep(i,N){
            rep(j,N){
                chmin(d1[i][j],d1[i][k]+d1[k][j]);
            }
        }
    }
    ll Q;
  	cin >> Q;
    rep(QQ,Q){
        ll s,t;
        cin >> s >> t;
        s--;t--;
      	if(d1[s][t]>1e5){
          	cout << -1 << '\n';
        }
      	else{
        	cout << d1[s][t]-1 << '\n';
        }
    }
}

Measured memory_bytes: 5040
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll a, b;
    cin >> a >>b;
    ll count = 0;
    for (int i = a; i <= b; i++) {
        ll s = i / 10000 % 10;
        ll t = i % 10;
        ll u = i / 1000 % 10;
        ll v = i / 10 % 10;
        if (s == t && u == v) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
const ll maxn = 1e5 + 101;
int main() {
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

bool change(char &c, char comp){
    if(c == '?') {
        c = comp;
        return true;
    }else{
        return c == comp || comp == '?';
    }
}


bool debug = false;
ll solve(vector<string> &in){
    vec sz(3);
    rep(i,3) sz[i] = in[i].size();
    vector<string> ab(0);
    rep(i, sz[0] + 1){
        string s = "";
        rep(j, max(sz[0], i + sz[1])){
            char c = '?';
            if(j < sz[0]){
                if(!change(c, in[0][j])) break;
            }
            if(0 <= j - i && j - i < sz[1]){
                if(!change(c, in[1][j - i])) break;
            }
            s.push_back(c);
        }
        if(s.size() ==  max(sz[0], i + sz[1])) ab.push_back(s);
    }
    int t = sz[2];
    if(t == 1){
        ll ans = sz[0] + sz[1] + sz[2];
        for(string st : ab) {
            bool ok = false;
            for(char c : st) if(c == in[2][0] || c == '?' || in[2][0] == '?') ok = true;
            ans = min(ans, ll(st.size()) + 1 - ok);
        }
        return ans;
    }
    vec table(t, 0);
    table[0] = -1;
    table[1] = 0;
    ll I = 2, J = 0;
    while(I < t){
        if(in[2].at(I-1) == in[2].at(J) || in[2].at(I-1) == '?' || in[2].at(J) == '?'){
            table.at(I) = J+1;
            ++I;
            ++J;
        }else if(J > 0){
            J = table.at(J);
        }else{
            table.at(I) = 0;
            ++I;
        }
    }
    I = 0; J = 0;
    ll ans = sz[0] + sz[1] + sz[2];
    string hatena = "";
    rep(i, sz[2] + 1) hatena.push_back('?');
    for(string st : ab) {
        if(debug) cout<<st<<endl;
        st.append(hatena);
        ll s = st.size();
        ans = min(ans, s - 1);
        vector<bool> mdl(s, false);
        while (I < s) {
            if (st.at((I + J) % s) == in[2].at(J) || st[(I + J) % s] == '?' || in[2][J] == '?') {
                if (J == t - 1) {
                    mdl.at(I) = true;
                    ans = min(ans, max(s - sz[2] - 1, I + sz[2]));
                    I = I + J - table.at(J);
                    J = table.at(J);
                } else {
                    ++J;
                }
            } else {
                I = I + J - table.at(J);
                if (J > 0) {
                    J = table.at(J);
                } else {
                    J = 0;
                }
            }
        }
    }
    return ans;
}

int main() {
    cin>>A>>B;
    ll ans = 0;
    ans += ((A + 1) / 2) * ((B + 1) / 2);
    ans += (A / 2) * (B / 2);
    cout<<(A == 1 || B == 1 ? 1 : ans)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
int main(){
   int a,b,c;
   int x;
   int ans=0;
   cin >> a >> b >> c >> x;
      for(int i = 0;i<= a;i++){
          if(x-500*i == 0){
              ans++;
          }else{
          for(int j=0;j<=b;j++){
              if(x - i*500-j*100 == 0){
                  ans++;
              }else{
              for(int k=0;k<=c;k++){
                 if(x - i*500-j*100-k*50 == 0){
                     ans++;
              }
          }
                  
              }
      }
          }
      
      }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O2")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 

class RMQv //value based RMQ
{
    public:
	struct node
    {
	  int l,r; 
      lli mn=0,mx=0;
    };
	v64 h;
	vt <node> st;
 
    bool is_intersection(int l,int r,int ll,int rr)
    {
       if(r<ll || rr<l)
         return 0;
         return 1;
    }
	RMQv(v64 a)
	{
       h=a;
       st.resize(4*h.size());
       build(0,h.size()-1);
	}
	void build(int l,int r,int k=0)
	{
		st[k].l=l,st[k].r=r;
	    if(l==r)
		   {st[k].mx=st[k].mn=h[l];
             return;
		   }
	    build(l,(l+r)/2,2*k+1);
	    build((l+r)/2+1,r,2*k+2);
        st[k].mx=max(st[2*k+1].mx,st[2*k+2].mx); 
	}
	lli maxquery(int l,int r,int k=0)
    {
       if(l>r)return -MAXN;
       int ll=st[k].l,rr=st[k].r,mid=(ll+rr)/2;
       if(ll>=l && rr<=r)
          return st[k].mx;
   	   lli ans=0;   
   	   if(!(r<ll || mid<l))
   	      ans=maxquery(l,r,2*k+1);
   	   if(!(r<mid+1 || rr<l))
   	          ans=max(ans,maxquery(l,r,2*k+2));
   	   return ans;     
    }
    void update(int id,lli val,int k=0)
    {
        int l=st[k].l,r=st[k].r,mid=(l+r)/2;
        if(l==r)
        {
            st[k].mx=val;
            return;
        }
        if(id>=l && id<=mid)
        update(id,val,2*k+1);
        if(mid+1<= id && id<=r)
        update(id,val,2*k+2);
        st[k].mx=max(st[2*k+1].mx,st[2*k+2].mx); 
    }
};
 
int main() 
{ 
  fastio;
  lli n;
  cin>>n;
  v32 h(n);
  v64 ANS(1+n,0);
  v64 a(n);
  f(i,0,n)cin>>h[i];
  f(i,0,n)cin>>a[i];
  RMQv ans(ANS);
  f(i,0,n) {
    lli p=ans.maxquery(0,h[i]-1);
    ans.update(h[i],a[i]+p);}
  cout<<ans.maxquery(0,n);
  return 0; 	
}

Measured memory_bytes: 26112
//==========================================c#
/* ===========================================
// null
// 
// 
=========================================== */
using System; //Console, IComparable
using System.IO; //StreamWriter 
using System.Linq; //Select(), Where(), OrderBy(), Count()
using System.Collections.Generic; //List<T>

class Program { 
    static void Main() { 
        StreamWriter so = new StreamWriter(Console.OpenStandardOutput());
        IOC io = new IOC();
        
        int n = io._int;
        var hash = new Dictionary<string, int>();
        
        for (int i = 0; i < n; i++){
            string s = io._string;
            if (!hash.ContainsKey(s)){
                hash.Add(s, 1);
            }
            else{
                hash[s]++;
            }
        }
        
        var max_cnt = hash.Values.Max();
        
        var ans = new List<string>();
        foreach(var fd in hash){
            if (fd.Value == max_cnt){
                ans.Add(fd.Key);
            }
        }
        
        ans.Sort(StringComparer.Ordinal);
        
        foreach(var fd in ans){
            so.WriteLine(fd);
        }
        so.Close();
    } 
}

public class IOC{
    public int _int{get{return int.Parse(Console.ReadLine());}}
    public int[] _inta{get{return Array.ConvertAll(Console.ReadLine().Split(), int.Parse);}}
    public long _long{get{return long.Parse(Console.ReadLine());}}
    public long[] _longa{get{return Array.ConvertAll(Console.ReadLine().Split(), long.Parse);}}
    public string _string{get{return Console.ReadLine();}}
    public string[] _stringa{get{return (Console.ReadLine().Split());}}
    public double _double{get{return double.Parse(Console.ReadLine());}}
    public double[] _doublea{get{return Array.ConvertAll(Console.ReadLine().Split(), double.Parse);}}
}

/* ===========================================
            int n = int.Parse(Console.ReadLine());

for(int i = 0; i < n; i++){
                int sum = Console.ReadLine().Split().Select(int.Parse).Sum();
                so.WriteLine(sum.ToString());
            }
            so.Close();
=========================================== */



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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	constexpr int W=2000*2000;

	for(int n;cin>>n&&n;){
		vi a(n);
		rep(i,n) cin>>a[i];

		bitset<W+1> s;
		s[0]=1;
		rep(i,n) s|=s<<a[i];

		vi ws;
		rep(i,W+1) if(s[i]) ws.push_back(i);
		cout<<ws[ws.size()/2]<<endl;
	}
}


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

constexpr int MOD = 998'244'353;
constexpr int MAX = 3030;

template<int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
			t = a / b;
			a -= t * b;
			std::swap(a, b);
			u -= t * v;
			std::swap(u, v);
		}
        return ModInt(u);
    }
    ModInt pow(long long e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e & 1) {a = (a * p) % mod; e--;}
            else {p = (p * p) % mod; e /= 2;}
        }
        return ModInt(a);
    }
    friend std::ostream &operator<<(std::ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend std::istream &operator>>(std::istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	vector<vector<ModInt<MOD>>> dp(MAX, vector<ModInt<MOD>>(MAX, 0));

	dp[a][b] = 1;
	for (int i = 0; i < c; i++) {
		for (int j = 0; j < d; j++) {
			dp[i + 1][j + 1] += dp[i + 1][j] * (i + 1) + dp[i][j + 1] * (j + 1);
			dp[i + 1][j + 1] -= dp[i][j] * (i * j);
		}
	}
	
	cout << dp[c][d] << '\n';
	
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int h, w, m;
  cin >> h >> w >> m;
 // h = w = m = 3e5;
  vector<pair<int, int>> x(m);
  map<pair<int, int>, int> mp;
  vector<int> hor(h), ver(w);
  for (int i = 0; i < m; i++) {
    cin >> x[i].first >> x[i].second;
    x[i].first--;
    x[i].second--;
    mp[make_pair(x[i].first, x[i].second)]++;
    hor[x[i].first]++;
    ver[x[i].second]++;
  }
  
  int hormax = 0, vermax = 0;
  for (int i = 0; i < h; i++) hormax = max(hormax, hor[i]);
  for (int i = 0; i < w; i++) vermax = max(vermax, ver[i]);
  
  vector<int> schor, scver;
  for (int i = 0; i < h; i++) {
    if (hor[i] == hormax) schor.emplace_back(i);
  }
  for (int i = 0; i < w; i++) {
    if (ver[i] == vermax) scver.emplace_back(i);
  }
  
  bool ok = false;
  int ans = hormax + vermax;
  for (auto i : schor) {
    if (hor[i] != hormax) continue;
    for (auto j : scver) {
      if (ver[j] != vermax) continue;
      if (mp.find(make_pair(i, j)) == mp.end()) {
        ok = true;
        break;
      }
    }
    if (ok) break;
  }
  
  if (ok) cout << ans << '\n';
  else cout << ans - 1 << '\n';
}

Measured memory_bytes: 30772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define END(a) {cout << (a) << "\n"; return 0;}
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(1); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n; cin >> n;
    bool ok = false;
    eFOR(i, 1, 9) {
        if (n % i == 0 && n / i < 10)ok = true;
    }
    cout << (ok ? "Yes\n" : "No\n");
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, K; cin >> N >> K;
        ll cnt = 0, cnt2 = 0;
        repeat(i, 1, N + 1) {
            cnt += i % K == 0;
            cnt2 += not(i % K == 0) and (i * 2) % K == 0;
        }
        cout << cnt * cnt * cnt + cnt2 * cnt2 * cnt2 << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>

#define ll long long

using namespace std;

int main(){
	//freopen("in","r",stdin);
	//ios_base::sync_with_stdio(false); cin.tie(0);
	//cout << fixed << setprecision(20);


	int n,k; scanf("%d%d",&n,&k);
	vector<int> a(n);
	for(int i = 0;i < n;i++) scanf("%d",&a[i]);
	ll cur = 0; for(int i = 0;i < k;i++) cur += a[i];
	ll m = cur;
	for(int i = k;i < n;i++){
		cur += a[i]-a[i-k];
		m = max(cur,m);
	}
	double res = (m+k)/2.0;
	//cout << res << endl;
	printf("%lf\n", res);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
const int MAX = 4000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(ll MOD) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll p;
  cin >> p;
  COMinit(p);
  vector<ll> a(p);
  rep(i,p){
      cin >> a[i];
  }
  ll first = a[0];
  if(a[0]){
      rep(i,p){
          if(a[i])a[i]=0;
          else a[i]=p-1;
      }
  }
  stack<ll> s;
  rep(i,p-1){
      ll sum = 0;
      rep(j,p){
          sum += a[j];
          a[j] = (a[j]*j+p)%p;
      }
      sum %= p;
      s.push((sum*inv[p-1])%p);
  }
  s.push(first);
  rep(i,p){
      cout << s.top() << " ";
      s.pop();
  }
}

Measured memory_bytes: 384
#include <iostream>
int main(void){

    int n, data[20], i, cnt, max;
    scanf("%d", &n);

    for(i=0;i<n;i++){
        scanf("%d", &data[i]);
    }

    max=data[0];
    cnt=1;
    for(i=1;i<n;i++){
        if(data[i]>=max){
            max=data[i];
            cnt++;
        }
    }

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

    return 0;
}

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

#define mp make_pair
typedef long long ll;
typedef pair<int,int>pii;
typedef pair<int,pii>piii;
typedef pair<ll,pii>plii;
const int Max = 3000;
const int N = 50;
const ll inf = 1e18;
ll dist[N+5][Max+10];
vector<piii>g[N+5];
int c[N+5],d[N+5];

int main()
{
	int n,m,s;
	scanf("%d%d%d",&n,&m,&s);
	s = min(s,Max);
	for(int i=1;i<=m;i++){
		int u,v,a,b;
		scanf("%d%d%d%d",&u,&v,&a,&b);
		g[u].push_back(mp(v,mp(a,b)));
		g[v].push_back(mp(u,mp(a,b)));
	}
	for(int i=1;i<=n;i++){
		scanf("%d%d",c+i,d+i);
	}
	for(int i=1;i<=N;i++){
		for(int j=0;j<=Max;j++){
			dist[i][j] = inf;
		}
	}
	priority_queue<plii,vector<plii>,greater<plii> >pq;
	pq.push(mp(0,mp(1,s)));
	dist[1][s] = 0;
	while(!pq.empty())
	{
		plii cur = pq.top();
		pq.pop();
		int v = cur.second.first;
		int sil = cur.second.second;
		ll t = cur.first;
		if(dist[v][sil]!=t){
			continue;
		}
		if(dist[v][min(sil+c[v],Max)]>t+d[v]){
			dist[v][min(sil+c[v],Max)] = t+d[v];
			pq.push(mp(t+d[v],mp(v,min(sil+c[v],Max))));
		}
		for(auto it:g[v])
		{
			int u = it.first;
			int sill = it.second.first;
			int tm = it.second.second;
			if(sil-sill>=0){
				if(dist[u][sil-sill]>t+tm){
					dist[u][sil-sill] = t+tm;
					pq.push(mp(t+tm,mp(u,sil-sill)));
				}
			}
		}
	}
	for(int i=2;i<=n;i++){
		ll ans = inf;
		for(int j=0;j<=Max;j++){
			ans = min(ans,dist[i][j]);
		}
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 6388
S = input()

ans = True
for i in range(len(S)):
    if i%2 == 0:
        if S[i] != 'R' and S[i] != 'U' and S[i] != 'D':
            ans = False
            break
    if i%2 == 1:
        if S[i] != 'L' and S[i] != 'U' and S[i] != 'D':
            ans = False
            break

if ans: print('Yes')
else: print('No')

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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

const int MOD = 1e9+7;

int fat[1000006];

int exp(int a, int b) {
	int r = 1;

	while(b) {
		if(b&1) r = ((ll)r*a)%MOD;
		b/=2;
		a = ((ll)a*a)%MOD;
	}

	return r;
}

int main() {
	int x,y;

	fat[0] = 1;
	for(int i = 1; i <= 1000000; i++)
		fat[i] = ((ll)fat[i-1]*i)%MOD;

	scanf("%d %d", &x, &y);

	if((x+y)%3 != 0) {
		printf("0\n");
		return 0;
	}

	int cntA = 0, cntB = 0;
	while(x > 0 && y > 0) {
		if(x > y) {cntA++; x -= 2; y--;}
		else {cntB++; x--; y-=2;}
	}

	if(x != 0 or y != 0) {
		printf("0\n");
		return 0;
	}

	int ans = ((ll)fat[cntA+cntB]*exp(fat[cntA], MOD-2))%MOD;
	ans = ((ll)ans*exp(fat[cntB], MOD-2))%MOD;
	printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 4096