akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,K; cin>>N>>K;
  vector<ll> A(N); rep(i,N) {cin>>A[i]; A[i]--;}
  
  ll now=0;
  ll count=0;
  ll roop;
  vector<ll> vec(N,-1); vec[0]=0;
  while(true){
    now=A[now];
    count++;
    if(count==K) {cout<<now+1<<'\n'; return 0;}
    if(vec[now]==-1) vec[now]=count;
    else{K-=count; roop=count-vec[now]; break;}
  }
  K%=roop;
  rep(i,K) now=A[now];
  
  cout<<now+1<<'\n';
  
  return 0;
}

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


ll sum(int n);

void go(){
	int a,b;cin>>a>>b;
	if((a+b)%3==0||a%3==0||b%3==0) cout << "Possible";
	else cout << "Impossible";
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
 
      //入力
      int N =sc.nextInt();//数字の個数
      int p[] =new int[N];//順列
      int count =0;
      
      //順列が入力される
      for(int i =0; i<N; i++){
      	  p[i] =sc.nextInt();        
      }
      
      //0番目とN番目を除いてループする
      //2番目に小さい数字をカウントしていく
      for(int i =1; i<N-1; i++){
        
      	if(p[i-1]<p[i] && p[i]<p[i+1]){
          count++;
        }
        else if(p[i-1]>p[i] && p[i]>p[i+1]){
          count++;
        }
      }
        System.out.println(count);
    }
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define bit(x,j) ((x>>j)&1)
using namespace std;
// bitset<8>set1(p);
// __builtin_popcountll(x);
// bitset<100> b("1010");
ll int mod=1e9+7;//998244353;
int mul(ll int x, ll int y)
{
    return (x * 1ll * y) % mod;
}

int add(int x, int y)
{
    x += y;
    while(x >= mod) x -= mod;
    while(x < 0) x += mod;
    return x;
}

long long power(long long a, long long b,ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = mul(res,a);
        a = mul(a,a);
        b >>= 1;
    }
    return res%m;
    }


  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = add(C[j],C[j-1]); 
    } 
    return C[k]%mod; 
} 
  vector<int> pr;
  bool prime[10000000];
void Sieve(ll int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 

//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}

 ll int sum(ll int n) 
 { 
    ll int s; 
  
    /* Single line that calculates sum */
    for (s = 0; n > 0; s += n % 10, n /= 10); 
  
    return s; 
 } 

ll int factorial(ll int n,ll int m) 
{ 
    ll int fact = 1; 
    for(int i=2;i<=n;i++) { 
        fact = (fact * i)%m; 
    } 
    return fact%m; 
} 

int reduce(int x, int y) 
{ 
    int d; 
    d = __gcd(x, y); 
  
    x = x / d; 
    y = y / d; 
    return x; 
} 

int main() {
  ios;
  ll int a,b,c,d;
  cin>>a>>b>>c>>d;
ll int m=-1e18;
m=max(m,a*c);
m=max(m,a*d);
m=max(m,b*c);
m=max(m,b*d);
cout<<m<<endl;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
static const int M = (int)1e5+5;
int A[M];
int cnt[M];
ll sum[M];
ll ans[M];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%d",&A[i]);
	for(int i=1;i<n;++i){
		if(A[i]<A[i+1]){
			cnt[A[i]+1]++;
			sum[A[i]+1]+=A[i+1]+1;
			cnt[A[i+1]+1]--;
			sum[A[i+1]+1]-=A[i+1]+1;
			//A[i]+1<=x<=A[i+1] : A[i+1]+1-x
			sum[1]+=A[i+1]-A[i];
			sum[A[i]+1]-=A[i+1]-A[i];//1<=x<=A[i] : A[i+1]-A[i]
			sum[A[i+1]+1]+=A[i+1]-A[i];
			sum[m+1]-=A[i+1]-A[i];//A[i+1]+1<=x<=m: A[i+1]-A[i]
			//
		}else{
			cnt[A[i]+1]++;//A[i]+1<=x<=m : A[i+1]+m+1-x
			sum[A[i]+1]+=A[i+1]+m+1; 
			cnt[m+1]--;
			sum[m+1]-=A[i+1]+m+1;
			cnt[1]++;//1<=x<=A[i+1] : A[i+1]+1-x
			sum[1]+=A[i+1]+1; 
			cnt[A[i+1]+1]--;
			sum[A[i+1]+1]-=A[i+1]+1;
			//A[i+1]+1<=x<=A[i] : A[i+1]+m-A[i]
			sum[A[i+1]+1]+=A[i+1]+m-A[i];
			sum[A[i]+1]-=A[i+1]+m-A[i];
		}
	}
	for(int i=1;i<=m;++i)cnt[i]+=cnt[i-1],sum[i]+=sum[i-1];
	ll mi=-1;
	for(int i=1;i<=m;++i)if(mi==-1||mi>((sum[i]-1ll*cnt[i]*i)))mi=(sum[i]-1ll*cnt[i]*i);
	cout<<mi<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> values = new ArrayList<Integer>();
		for(int tmp = 0; tmp < n; tmp++) {
			int v = sc.nextInt();
			values.add(v);
		}
		List<Integer> costs = new ArrayList<Integer>();
		for(int tmp = 0; tmp < n; tmp++) {
			int c = sc.nextInt();
			costs.add(c);
		}
		int result = 0;
		
		for(int tmp = 0; tmp < n ; tmp++) {
			int diff = values.get(tmp) - costs.get(tmp);
			if((diff) >= 0) {
				result  += diff;
			}
		}
		System.out.println(result);	
	}
}

Measured memory_bytes: 21844
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int P;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=105;
int f[N][N][N][2],coef[N][N][N][2],bn[N][N];
int n,m,L,ret,cp;
int main(){
	scanf("%d%d%d%d",&n,&m,&L,&P);
	fp(i,0,max(n,m)){
		bn[i][0]=1;
		fp(j,1,i)bn[i][j]=add(bn[i-1][j],bn[i-1][j-1]);
	}
	fp(k,1,L)fp(i,0,m){
		cp=mul(ksm(L-k+1,i),dec(ksm(k,m-i),ksm(k-1,m-i)));
		ret=1;
		fp(j,0,n)coef[k][i][j][0]=ret,ret=mul(ret,cp);
	}
	fp(k,1,L)fp(i,0,n){
		cp=mul(dec(ksm(L-k+1,i),ksm(L-k,i)),ksm(k,n-i));
		ret=1;
		fp(j,0,m)coef[k][i][j][1]=ret,ret=mul(ret,cp);
	}
	f[1][0][0][0]=1;
	fp(k,1,L)fp(i,0,n)fp(j,0,m){
		ret=f[k][i][j][0];
		fp(l,0,n-i)upd(f[k][i+l][j][1],1ll*ret*bn[n-i][l]%P*coef[k][j][l][0]%P);
		ret=f[k][i][j][1];
		fp(l,0,m-j)upd(f[k+1][i][j+l][0],1ll*ret*bn[m-j][l]%P*coef[k][i][l][1]%P);
	}
	printf("%d\n",f[L+1][n][m][0]);
	return 0;
}

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

MOD = 10**9 + 7
class Mint:
    def __init__(self, value=0):
        self.value = value % MOD
        if self.value < 0: self.value += MOD

    @staticmethod
    def get_value(x): return x.value if isinstance(x, Mint) else x

    def inverse(self):
        a, b = self.value, MOD
        u, v = 1, 0
        while b:
            t = a // b
            b, a = a - t * b, b
            v, u = u - t * v, v
        if u < 0: u += MOD
        return u

    def __repr__(self): return str(self.value)
    def __eq__(self, other): return self.value == other.value
    def __neg__(self): return Mint(-self.value)
    def __hash__(self): return hash(self.value)
    def __bool__(self): return self.value != 0

    def __iadd__(self, other):
        self.value = (self.value + Mint.get_value(other)) % MOD
        return self

    def __add__(self, other):
        new_obj = Mint(self.value)
        new_obj += other
        return new_obj
    __radd__ = __add__

    def __isub__(self, other):
        self.value = (self.value - Mint.get_value(other)) % MOD
        if self.value < 0: self.value += MOD
        return self

    def __sub__(self, other):
        new_obj = Mint(self.value)
        new_obj -= other
        return new_obj

    def __rsub__(self, other):
        new_obj = Mint(Mint.get_value(other))
        new_obj -= self
        return new_obj

    def __imul__(self, other):
        self.value = self.value * Mint.get_value(other) % MOD
        return self

    def __mul__(self, other):
        new_obj = Mint(self.value)
        new_obj *= other
        return new_obj
    __rmul__ = __mul__

    def __ifloordiv__(self, other):
        other = other if isinstance(other, Mint) else Mint(other)
        self *= other.inverse()
        return self

    def __floordiv__(self, other):
        new_obj = Mint(self.value)
        new_obj //= other
        return new_obj

    def __rfloordiv__(self, other):
        new_obj = Mint(Mint.get_value(other))
        new_obj //= self
        return new_obj

ans = Mint(1)
for i in range(1, N + 1):
    ans *= i
print(ans)


Measured memory_bytes: 65744
#include <bits/stdc++.h>
#define INF 2e9+7
using namespace std;
using pii=pair<int,int>;
using ll=long long int;

int n; string s;
ll ans;
vector<int> pos[3];

int mid(int a,int b,int c) {
    int aa[3]; aa[0]=a; aa[1]=b; aa[2]=c;
    sort(aa,aa+3);
    return aa[1];
}

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>s;
    /*for(int i=0;i<n-3;i++) {
        for(int j=i+1;j<n-1;j++) {
            for(int k=j+1;k<n;k++) {
                if(k-j==j-i) continue;
                if(s[i]==s[j] or s[j]==s[k] or s[i]==s[k]) continue;
                ans++;
            }
        }
    }
    cout<<ans<<endl;*/
    for(int i=0;i<n;i++) {
        if(s[i]=='R') pos[0].push_back(i);
        else if(s[i]=='G') pos[1].push_back(i);
        else pos[2].push_back(i);
    }
    int a,b;
    for(auto e1:pos[0]) {
        for(auto e2:pos[1]) {
            if(e1>e2) {
                a=e1; b=e2;
            }
            else {
                a=e2; b=e1;
            }
            int cur=a+a-b;
            if(binary_search(pos[2].begin(),pos[2].end(),cur)) ans+=pos[2].size()-1;
            else ans+=pos[2].size();

            if((a-b)%2==0 and binary_search(pos[2].begin(),pos[2].end(),a-(a-b)/2)) ans--;
            if(binary_search(pos[2].begin(),pos[2].end(),b-(a-b))) ans--;
        }
    }
    cout<<ans<<endl;
}



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

for i in range(N):
    if N <= 9:
        print(N)
        break
    elif N <= 99:
        print("9")
        break
    elif N <= 999:
        print(N-99+9)
        break
    elif N <= 9999:
        print("909")
        break
    elif N <= 99999:
        print(N-9999+909)
        break
    else:
        print("90909")
        break


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int x, y, s;
    cin >> x >> y >> s;
    if (x == 0 && y == 0 && s == 0){
      break;
    }
    int ans = 0;
    for (int i = 1; i < s; i++){
      for (int j = 1; j < s; j++){
        int a1 = i * (100 + x) / 100;
        int b1 = j * (100 + x) / 100;
        if (a1 + b1 == s){
          int a2 = i * (100 + y) / 100;
          int b2 = j * (100 + y) / 100;
          ans = max(ans, a2 + b2);
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3076
N,M = map(int,input().split())
P = []
S = []
for i in range(M):
    p,s = input().split()
    p = int(p)
    P.append(p)
    S.append(s)
#print(P)
#print(S)
AC = 0
WA = 0
AC_f = [0] * (N + 1)
WA_f = [0] * (N + 1)
#print(AC_f)
for i in range(M):
    if AC_f[P[i]] == 0:
        if S[i] == "AC":
            AC += 1
            AC_f[P[i]] = 1
        else:
            WA += 1
            WA_f[P[i]] += 1
for i in range(1,N+1):
    if AC_f[i] == 0 and WA_f[i] != 0:
        WA -= WA_f[i]
print(AC,WA)


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    cout << fixed << setprecision(15);

    string s, t;
    double n,m,x,y;
    cin >>  n;



    cout << n*2*Pi     << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3772
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node{int parent,left,right;};

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
    if(u==NIL) return;
    D[u]=d;
    setDepth(T[u].left,d+1);
    setDepth(T[u].right,d+1);
}

int setHeight(int u){
    int h1=0,h2=0;
    if(T[u].left!=NIL)
        h1=setHeight(T[u].left)+1;
    if(T[u].right!=NIL)
        h2=setHeight(T[u].right)+1;
    return H[u]=(h1>h2?h1:h2);
}


int getSibling(int u){
    if ( T[u].parent == NIL ) return NIL;
    if ( T[T[u].parent].left != u && T[T[u].parent].left != NIL )
        return T[T[u].parent].left; 
    if ( T[T[u].parent].right != u && T[T[u].parent].right != NIL )
        return T[T[u].parent].right;
    return NIL;
}

void print(int u) {
    printf("node %d: ", u); 
    printf("parent = %d, ", T[u].parent); 
    printf("sibling = %d, ", getSibling(u)); 
    int deg = 0; 
    if ( T[u].left != NIL ) deg++; 
    if ( T[u].right != NIL ) deg++; 
    printf("degree = %d, ", deg); 
    printf("depth = %d, ", D[u]); 
    printf("height = %d, ", H[u]);
    
    if ( T[u].parent == NIL ) {
        printf("root\n"); 
    } else if ( T[u].left == NIL && T[u].right == NIL ) {
        printf("leaf\n"); 
    } else {
        printf("internal node\n");
    }
}

int main() {
    int v, l, r, root = 0; 
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++ ) T[i].parent = NIL;
    
    for (int i = 0; i<n; i++ ) {
        scanf("%d %d %d", &v, &l, &r); 
        T[v].left = l; 
        T[v].right = r; 
        if ( l != NIL ) T[l].parent = v; 
        if ( r != NIL ) T[r].parent = v;
    }
    
    for (int i = 0; i<n; i++ ) if ( T[i].parent == NIL ) root = i;
    
    setDepth(root, 0); 
    setHeight(root);
    
    for(int i=0;i<n;i++) print(i);
    
    return 0;
}



Measured memory_bytes: 2724
#!/usr/bin/env python3

import sys
import math

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    r = read(int)
    print(2 * r * math.pi)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9180
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vishal Burman
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BEasyLinearProgramming solver = new BEasyLinearProgramming();
        solver.solve(1, in, out);
        out.close();
    }

    static class BEasyLinearProgramming {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            long c = in.nextLong();
            long k = in.nextLong();
            if (k <= a)
                out.println(k);
            else if (k <= (a + b))
                out.println(a);
            else
                out.println(a - (k - a - b));
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int  main(){
  int N;
  cin>>N;
  vector<int> data(N);
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    data[x-1]=i+1;  
  }

  for(int i=0;i<N;i++)cout<<data[i]<<" ";
  cout<<endl;
}

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

int main()
{


    int n;
    cin>>n;

    int odd_cnt=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;

        if(a%2==1)
            odd_cnt++;
    }

    
    if(odd_cnt%2==1)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  long long int X = 0,K = 0,D = 0;
  cin >> X >> K >> D;
  X = abs(X);
  long long int a = 0,b = 0;
  a =X/D;
  if(K <= a){
    cout << abs(X - K*D) << endl;
  }else{
    X %= D;;
    K = K - a;
    if(K%2 == 0){
      cout << X << endl;
    }else{
      cout << abs(X - D) << endl;
    }
  }
}

/*int main(){
  long long int X = 0,K = 0,D = 0;
  cin >> X >> K >> D;
  X = abs(X);
  long long int a = 0,b = 0;
  a = X/D;
  b = X%D;
  if(a < K){
    if(b == 0){
      cout << X << endl;
    }else{
    cout << b << endl;
  }
  }else{
    cout << X - (K*D) << endl;
  }
}*/

/*int main(){
  long long int X = 0,K = 0,D = 0;
  cin >> X >> K >> D;
  X = abs(X);
  while((abs(X) >= abs(D)) && K > 0){
    X = X - D;
    K--;
  }
  cout << abs(X) << endl;
}*/


Measured memory_bytes: 3544
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <deque> 

using namespace std;


long long n;
long long sum;

int main()
{
	sum = 0;
	scanf("%lld", &n);
	
	long long d = 1;
	long long dx;
	while (d * d < n)	//平方数无效
	{
		dx = n / d;
		
		if ((n / (dx - 1)) == (n % (dx - 1)))
			sum = sum + (dx - 1);
//		printf("%d %d %d\n", dx, sum / dx, sum % dx, sum);
//		printf("%I64d\n", sum);
		d++;
	}
	
	
	printf("%lld\n", sum);
	

	return 0;
}


//设指定数为x
//那么商q = N / x;
//余数r = N % x;
//就有如下属性q*x + r = N
//由于q==r
//所以q * (x + 1) = N



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

int main(void) {
  string a, b, out = "No";
  cin >> a >> b;
  int num = stoi(a + b);
  for (int i = 1; i * i < 100000; i++) {
    if (num == i * i) {
      out = "Yes";
      break;
    }
  }
  cout << out << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int n,m,i,r,I[1000010],O[1000010],t;
int main()
{
	for(;~scanf("%d%d\n",&n,&m),n;)
	{
		for(i=r=0;i<m;i++)
		{
			t=getchar();
			if(t==73){I[i]=i>1?I[i-2]+1:1;O[i]=0;}
			else{O[i]=i>1?O[i-2]+1:1;I[i]=0;}
		}
		for(i=2*n;i<m;i++)if(O[i-1]>=n&&I[i]>=n+1)r++;
		printf("%d\n",r);
		getchar();
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1<<30;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll h, w;
vector<vector<string>> a;
/******* define variable end *******/
typedef pair<ll, ll> P;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int solve() {
	cin >> h >> w;
	vector<vector<ll>> d(h, vl(w));
	queue<P> que;
	vector<vector<bool>> seen(h, vector<bool>(w));
	a.resize(h, vector<string>(w));
	REP(i, h){
		string tmp;
		cin >> tmp;
		REP(j, w){
			d[i][j] = INF;
			a[i][j] = tmp.substr(j, 1);
			if(a[i][j] == "#"){
				que.push(make_pair(i, j));
				seen[i][j] = true;
				d[i][j] = 0;
			}
		}
	}
	ll ans = 0;
	while(que.size()){
		P p = que.front(); que.pop();
		seen[p.first][p.second] = true;
		for(ll i = 0; i < 4; i++){
			ll nx = p.first + dx[i], ny = p.second + dy[i];
			if(0 <= nx && nx < h && 0 <= ny && ny < w && d[nx][ny] == INF){
				que.push(make_pair(nx, ny));
				d[nx][ny] = min(d[nx][ny], d[p.first][p.second] + 1);
			}
		}
	}
	for(auto &height : d){
		for(auto &v : height){
			ans = max(v, ans);
		}
	}
	cout << ans << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 79412
sx, sy, tx, ty = map(int, input().split())
x = tx-sx
y = ty-sy

ans = ""
go = "U"*y+"R"*x
back = "D"*y+"L"*x
a1 = "LU"
a2 = "RDRD"
a3 = "LU"
print(go+back+a1+go+a2+back+a3)

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

int main()
{
    int64_t N, K;
    cin >> N >> K;

    vector<pair<int64_t, int64_t>> v(N);
    for (int i = 0; i < N; i++)
    {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());

    int64_t total = 0;
    for (int i = 0; i < N; i++)
    {
        total += v[i].second;
        if (total >= K)
        {
            cout << v[i].first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
string str[110], res[210];
int h, w;
int main(void){
    // Your code here!
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        cin >> str[i];
        cout << str[i] << endl;
        cout << str[i] << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}
using namespace std;
int main(){
   ll r,D,x;
   cin >> r >> D >> x;

   vector<ll> xx(10);

   xx[0] = (r * x) - D;
   cout << xx[0] <<endl;
   FOR(i,1,10){
       xx[i] = xx[i-1]*r - D;
       cout << xx[i] <<endl;
   }

}

Measured memory_bytes: 256
///Water Hyacinth
///Hakuna Matata
///WAKE THE FUCK UP SAMURAI;WE HAVE A CODE TO RUN <3
///Any Verdict
///(Aes)  Dekhe (Tic) lagche = Aesthetic <3
///**********************************************************///

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define D double
int main()
{
    int a,b;
    cin >> a >> b;
    int sum=a+(b);
    int sum1=a-(b);
    int sum2=a*b;
    if(sum >= sum1 && sum >= sum2)
        cout << sum << endl;
    else if(sum1 >= sum && sum1 >= sum2)
        cout << sum1 << endl;
    else
        cout << sum2 << endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

vector<long long> a(52,1),p(52,1);

long long f(int x, long long N) {
	if (x < 1) return 1;
	else if (N<=1) return 0;
	else if (1 < N&&a[x - 1]+1 >= N) return f(x - 1, N - 1);
	else if (N == 2 + a[x - 1])return 1 + p[x - 1];
	else if (2 + a[x - 1] <N && 2 + 2 * a[x - 1] >= N) return p[x - 1] + 1 + f(x - 1, N - 2 - a[x - 1]);
	else return p[x];
}


int main() {
	int N; long long X; cin >> N >> X;
	for (int i = 0; i <= 50; i++) {
		a[i + 1] = 2*a[i] + 3;
		p[i + 1] = 2*p[i] + 1;
	}
	cout << f(N, X) << endl;;
}



Measured memory_bytes: 256
import java.util.Scanner;

object Main extends App {
  val sc = new Scanner(System.in);
  val s, t = sc.next();

  val answer = (0 to (s.length - t.length)).map { d =>
    t.length - (0 until t.length).count { i =>
      s(i + d) == t(i)
    }
  }.min;

  println(answer);
}

Measured memory_bytes: 56852
#include "bits/stdc++.h"

using namespace std;

void solve()
{
	int N, K;
	cin >> N >> K;
	vector<long> ts(N), ds(N);
	priority_queue<pair<long, int>> pq;
	priority_queue<pair<long, int>, vector<pair<long, int>>, greater<pair<long, int>>> pq2;
	for (int i = 0; i < N; i++)
	{
		cin >> ts[i] >> ds[i];
		pq.push({ds[i], ts[i]});
	}
	long ans = 0, col = 0;
	map<long, int> used;
	for (int i = 0; i < K; i++)
	{
		auto p = pq.top();
		pq.pop();
		ans += p.first;
		pq2.push(p);
		col += used[p.second] == 0;
		used[p.second]++;
	}
	ans += col * col;
	long res = ans;
	while (!pq.empty() && !pq2.empty())
	{
		auto p = pq.top();
		pq.pop();
		if (used[p.second] > 0) continue;
		auto p2 = pq2.top();
		pq2.pop();
		if (used[p2.second] < 2)
		{
			pq.push(p);
			continue;
		}
		long ncol = col + (used[p.second] == 0);
		long diff = ncol*ncol - col*col + p.first - p2.first;
		//cout << ncol << ' ' << col << ' ' << p.first << ' ' << p2.first << endl;
		col = ncol;
		used[p2.second]--;
		used[p.second]++;
		res += diff;
		ans = max(ans, res);
	}
	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 8944
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <ctime>
#include <map>
#include <random>
#include <iomanip>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <bitset>
#include <deque>
#include <utility>

using namespace std;

vector<int> z_func(string &s) {
    int n = (int) s.size();
    vector<int> ret(n, 0);
    int l = 0;
    int r = -1;
    for (int i = 1; i < n; ++i) {
        if (l <= i && i <= r) {
            ret[i] = min(r - i + 1, ret[i - l]);
        }
        while (ret[i] + i < n && s[i + ret[i]] == s[ret[i]]) {
            ret[i]++;
        }
        if (i + ret[i] - 1 >= r) {
            l = i;
            r = i + ret[i] - 1;
        }
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    set<string> q;
    string s;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        q.insert(s);
    }
    cout << q.size() << '\n';
    return 0;
}


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

/**
 * N人、K種類
 *        お菓子1, お菓子2
 * snuke1 true,   true
 * snuke2 false,  false
 * snuke3 true,   false
 */

int main() {
  int N, K, i, j, n, d, a, ans = 0;
  bool is_target;
  cin >> N >> K;

  vector<vector<bool>> v(N, vector<bool>(K, false));

  for (i = 0; i < K; i++) {
    cin >> d;

    for (j = 0; j < d; j++) {
      cin >> n;
      v.at(n - 1).at(i) = true;
    }
  }

  for (i = 0; i < N; i++) {
    for (j = 0; j < K; j++) {
      if (v.at(i).at(j)) {
        is_target = false;
        break;
      }
      is_target = true;
    }

    if (is_target) {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<map>
//#include<math.h>
//#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

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

    int cnt = 0;
    bool ok = false;
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        if(a==b) {
            cnt++;
        } else {
            cnt = 0;
        }
        if(cnt == 3) {
            ok = true;
        }
    }
    if(ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
} /*atcoder*/


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
int main() {
	string s;
	cin >> s;
	int t = s.find("AC");
	if (t == string::npos)  cout << "No" ;
	else cout << "Yes";
	
}

Measured memory_bytes: 256
n = int(input())
paper = list(map(int,input().split()))

paper_even = [i for i in paper if i % 2 == 0 ]

count = 0
for i in range(len(paper_even)):
    if paper_even[i] % 3 == 0:
        count += 1
    elif paper_even[i] % 5 == 0:
        count += 1

if count == len(paper_even):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 入力の受け取り
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int N = sc.nextInt();
		int[] P = new int[N];
		for (int i = 0; i < N; i++) {
			P[i] = sc.nextInt();
		}
		int[] array = new int[103];
		for (int i = 0; i < 103; i++) {
			array[i] = i - 1;
		}
		for (int i = 0; i < N; i++) {
			array[P[i] + 1] = -100;
		}
		
//		for (int i = 0; i < array.length; i++) {
//			System.out.println(array[i]);
//		}
		

		int dis = X - array[0];
		int ans = array[0];
		for (int i = 1; i < array.length; i++) {
			if (Math.abs(X - array[i]) < dis) {
				dis = X - array[i];
				ans = array[i];
			}
		}
		System.out.println(ans);

		sc.close();
	}
}


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

int main(){
 int N,K,Q;
 cin>>N>>K>>Q;
 int a[Q+1],B[N+1];
 for(int i = 1;i <= N;i++)B[i] = K-Q;
 for(int i = 1;i <= Q;i++){
     cin>>a[i];
     B[a[i]] += 1;
 }
 for(int i = 1;i <= N;i++){
     if(B[i] > 0)cout<<"Yes"<<endl;
     else cout<<"No"<<endl;
 }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define txt                        \
    freopen("ip.txt", "r", stdin); \
    freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define quickie                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define div2(a) (!(a & 1))
#define deb(x) cout << (#x) << " " << (x) << "\n";
#define newl cout << "\n"
#define pi 3.14159265358979323846
#define mod 1000000007
#define all(s) s.begin(), s.end()
#define fp(x) fixed << setprecision(x) <<
template <class T>
int digit(T a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
template <class T>
void split(char c, T s)
{
    int n = s.size();
    int i = 0;
    while ((cout << s[i], i += 1) && (i < n) && (cout << c << ' '))
        ;
}
int digit(int a)
{
    int r;
    r = (a >= 1000000000) ? 9 : (a >= 100000000) ? 8 : (a >= 10000000) ? 7 : (a >= 1000000) ? 6 : (a >= 100000) ? 5 : (a >= 10000) ? 4 : (a >= 1000) ? 3 : (a >= 100) ? 2 : (a >= 10) ? 1 : 0;
    return r + 1;
}
int main()
{
    //txt;
    int k, s;
    cin >> k >> s;
    int count = 0;
    for (int i = 0; i <= k; i++)
    {
        for (int j = 0; j <= k; j++)
        {
            int term = s - i - j;
            if(term >= 0 && term <= k){
                count++;
            }
        }
    }
    cout<<count;
    return 0;
}

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

int main() {
	int n;
	cin>>n;
	int a[n];
	int cnt=0;
	for(int i=0;i<n;i++){
	    cin>>a[i];
	    if(a[i]%2==0){
	        cnt++;
	    }
	    
	}
	
	int z=0;
	for(int i=0;i<n;i++){
	    if(a[i]%2==0 && (a[i]%3==0 || a[i]%5==0)){
	       z++;
	       
	       
	    }
	}
	if(z==cnt){
	  cout<<"APPROVED"<<endl;
	}else{
	   cout<<"DENIED"<<endl; 
	}
	return 0;
}

Measured memory_bytes: 384
while True:
    n = int(input())
    slist = []
    for i in range(n):
        s = int(input())
        slist.append(s)
    
    if n==0:
        break
    
    for j in range(n):
        for k in range(n-1,0,-1):
            if slist[k-1]>slist[k]:
                slist[k-1],slist[k] = slist[k],slist[k-1]
    
    slist.pop(0)
    slist.pop(n-2)
    
    ave = sum(slist)//len(slist)
        
    print(ave)


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

int main(){
    int n;
    std::string s;
    std::cin >> n;
    std::cin >> s;
    int m = 0;
    for( int i=1; i<=n; ++i ){
        int c = 0;
        for ( int j='a'; j<='z'; ++j ){
            for( int k=0; k<i; ++k ){
                if ( s[k] == j ){
                    for( int k=i; k<n; ++k ){
                        if ( s[k] == j ){ c++; break; }
                    }
                    break;
                }
            }
        }
        m = m<c ? c : m;
    }
    std::cout << m << std::endl;
    return 0;
}


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

int main(){
    
    int N,P;
    cin >> N >> P;
    
    int m = 0;
    for(int i = 0; i < N;i++){
        int A;cin >> A;
        if(A % 2 == 1)++m;
    }
    if(m==0)cout << (P == 0 ? (1LL<<N):0) << endl;
    else cout << (1LL << (N-1)) << endl;
    
    
}



Measured memory_bytes: 256
import bisect
from itertools import accumulate
n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
b_to_c = [0]*n
for i in range(n):
  b_to_c[i] = n - bisect.bisect_right(C, B[i])
Q = list(accumulate(b_to_c[::-1]))[::-1]
  
for i in A:
  t = bisect.bisect_right(B, i)
  if t < n:
    ans += Q[t]
print(ans)

Measured memory_bytes: 25544
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        long res = n / (a + b) * a;
        long m = n % (a + b);
        if(m>=a) res+=a;
        else res+=m;
        System.out.println(res);
    }
}

Measured memory_bytes: 21844
#include <iomanip>
#include "algorithm"
#include "cmath"
#include "iostream"
using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;

  for (ll i = 1; i <= 9; i++) {
    for (ll j = 1; j <= 9; j++) {
      if (N == i * j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r ,g, b , n;
  int ans = 0;
  cin >> r >> g >> b >> n;
  for(int i = 0; i<=n/r ;i++){
    for(int j = 0 ; j<=n/g ;j++){
      int k ;
      k =  n - r*i - g*j;
      if( k >= 0 && k % b == 0){
        ans += 1;
      }
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

ll lcm(ll n, ll m) { return (n / __gcd(n, m)) * m; }

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  ll l = lcm(n, m);
  ll np = l / n;
  ll mp = l / m;
  ll chk = lcm(np, mp);

  rep(i, l / chk) {
    ll idx = i * chk;
    if (s[idx / np] != t[idx / mp]) {
      puts("-1");
      return 0;
    }
  }

  cout << l << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define INF 1e10
using namespace std;
struct edge{
  int to,limit;
  double dist;
};
vector<edge> G[100];
double d[40][40][40];//speed,pos,prev
bool used[40][40][40];
typedef pair<int,int> pii; //speed,prev
typedef pair<int,pii> PII;//to,speed,prev
typedef pair<double,PII> P;//cost,to,speed

double dikstra(int s,int g){
  int ds[3]={-1,0,1};
  priority_queue<P,vector<P>,greater<P> > que;
  for(int i=0;i<40;i++)
    for(int j=0;j<40;j++)
      for(int k=0;k<40;k++)
	d[i][j][k]=INF;
  memset(used,0,sizeof(used));
  d[0][s][0]=0;
  que.push(P(0,PII(s,pii(0,0))));
  while(!que.empty()){
    P p=que.top();que.pop();
    int speed=p.second.second.first;
    int prev=p.second.second.second;
    int v=p.second.first;
    double cost=p.first;
    //cout << v << ":" << speed <<":" << cost << endl;
    if(d[speed][v][prev]<cost)continue;
    if(speed==1 && v==g)return cost;
    for(int i=0;i<G[v].size();i++){
      for(int j=0;j<3;j++){
	edge e=G[v][i];
	int ns=speed+ds[j];
	if(1<=ns && ns<= e.limit &&
	   used[ns][e.to][v]==false &&
	   e.to!=prev && d[ns][e.to][v]>cost+e.dist/ns){
	  used[ns][e.to][v]=true;
	  que.push(P(cost+e.dist/ns,PII(e.to,pii(ns,v))));
	  d[ns][e.to][v]=cost+e.dist/ns;
	  //cout << "d[" << ns << "][" << e.to << "]:" << d[ns][e.to] << endl;
	  //cout << "d[" << v << "]:" << d[speed][v] << " speed:" << speed<< endl;
	}
      }
    }
  }
  return -1;
}

int main(){
  int n,m,s,g;
  while(cin>>n>>m,n){
    for(int i=0;i<100;i++)G[i].clear();
    cin>>s>>g;
    for(int i=0;i<m;i++){
      int x,y,d,c;
      cin>>x>>y>>d>>c;
      G[x].push_back((edge){y,c,d});
      G[y].push_back((edge){x,c,d});
    }
    double ans=dikstra(s,g);
    if(ans==-1)cout << "unreachable" << endl;
    else printf("%.5lf\n",ans);
    // for(int i=0;i<=n;i++)
    // 	cout << i << " " << d[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 2344
gets.chomp
lengths = gets.chomp.split(" ").map(&:to_i).group_by { |n| n }.sort_by { |n, ns| - n }.select { |_, ns| ns.size >= 2 }
if lengths.size < 2
  puts 0
else
  a = lengths.take(2).map { |(n, ns)| n }.inject(&:*)
  b = lengths.find { |_, ns| ns.size >= 4 }
  puts [a, b ? b.first ** 2 : 0].max
end

Measured memory_bytes: 27528
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int a[100001] = {};
int b[100001] = {};

int main(void)
{

	int n;
	cin >> n;
	FOR(i, n) {
		cin >> a[i];
	}
	FOR(i, n) {
		cin >> b[i];
	}

	//check
	if (a[0] > b[0]) {
		cout << 0 << endl;
		return 0;
	}
	if (a[n - 1] < b[n - 1]) {
		cout << 0 << endl;
		return 0;
	}

	FOR(i, n - 1) {
		if (a[i] > a[i + 1]) {
			cout << 0 << endl;
			return 0;
		}
		if (b[i] < b[i + 1]) {
			cout << 0 << endl;
			return 0;
		}
		if (a[i] < a[i + 1] && a[i + 1] > b[i + 1]) {
			cout << 0 << endl;
			return 0;
		}
		if (b[i] > b[i + 1] && a[i] < b[i]) {
			cout << 0 << endl;
			return 0;
		}
	}

	//count
	ll answer = 1;
	for (int i = 1; i < n - 1; i++) {
		if (!(a[i - 1] < a[i] || b[i] > b[i + 1])) {
			answer *= min(a[i],b[i]);
			answer %= mod197;
		}
	}

	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 1024
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 134056