akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
 
vector<ll>cur(202020);
vector<int>e[202020];
 
void dfs(int now,int p) {
	cur[now] += ((p == -1) ? 0:cur[p]);
	fore(x, e[now]) {
		if (x != p) {
			dfs(x,now);
		}
	}
}
 
int main() {
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		e[a].pb(b);
		e[b].pb(a);
	}
 
	for (int i = 0; i < q; i++) {
		int p, x;
		cin >> p >> x;
		p--;
		cur[p] += x;
	}
	dfs(0,-1);
	for (int i = 0; i < n; i++) {
		cout << cur[i] << " ";
	}
	puts("");
	return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    int ans = 0;
    ans += x/500*1000;
    x -= x/500*500;
    ans += x/5*5;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main(h):
  count = 1
  n = 0
  for i in range (k):
    n = (n * 10 + 7) % k  
    if n == 0: 
      print(count)
      return 0
    count += 1
  print(-1)
  
if __name__ == '__main__':
  k = int(input())
  main(k)

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

int n;
const int maxn = 1e5 + 500;
long long dp[maxn][2];
int a[maxn];

long long solve (int p, bool flip) {
  if (p >= n) return 0;
  if (dp[p][flip] != -1) return dp[p][flip];
  long long tot = - 1e12; 
  if (flip == false) {    
    tot = max(tot, a[p] + solve(p + 1, false));
    if (p <= n - 2) tot = max(tot, -a[p] + solve(p + 1, true));
  } else {
    tot = max(tot, -a[p] + solve(p + 1, false));
    if (p <= n - 2) tot = max(tot, a[p] + solve(p + 1, true));
  } 
  return dp[p][flip] = tot;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  memset (dp, -1, sizeof(dp));
  cout << solve (0, 0) << '\n';
  return 0;
}

Measured memory_bytes: 6912
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = inpl()
    a,b = a-1,b-1
    g[a].append(b)
    g[b].append(a)
res = [-1] * n
res[0] = 0
q = deque()
q.append(0)
while q:
    now = q.popleft()
    for v in g[now]:
        if res[v] != -1:
            continue
        res[v] = now + 1
        q.append(v)
print('Yes')
for i in res[1:]:
    print(i)

Measured memory_bytes: 97808
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Builder     as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Internal    as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Storable         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import qualified System.IO                   as IO
import           Unsafe.Coerce

main :: IO ()
main = do
    [h, w] <- map read.words <$> getLine :: IO [Int]
    B.PS p 0 l <- C.hGetNonBlocking IO.stdin (h*(w+1))
    let mat = U.unsafeFromForeignPtr0 p l
    print $ solve h (w+1) mat

solve :: Int -> Int -> U.Vector Word8 -> Int
solve h w mat = subtract 1 . V.maximum . V.map U.maximum $ V.zipWith (U.zipWith (+)) lr ud
  where
    forward :: Int -> Int -> Int
    forward acc x
        | x == 0 = 0
        | otherwise = max acc x

    backward :: Word8 -> Int -> Int
    backward x acc
        | x /= B.c2w '.' = 0
        | otherwise = acc + 1

    lr :: V.Vector (U.Vector Int)
    lr  = V.generate h $ \i ->
          U.scanl1' forward
            . U.postscanr' backward 0
            $ U.unsafeSlice (i * w) w mat

    ud :: V.Vector (U.Vector Int)
    ud = V.scanl1' (U.zipWith forward)
        . V.postscanr' (U.zipWith backward) (U.replicate w 0)
        $ V.generate h (\i -> U.unsafeSlice (i * w) w mat)




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

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

using Graph = vector<vector<int>>;
struct Edge {
  int to;      // 辺の行き先
  int weight;  // 辺の重み
  Edge(int t, int w) : to(t), weight(w) {}
};
using WeightGraph = vector<vector<Edge>>;

#define int ll

//**********

// Graph G;
// void warshall_floyd(int n) {  // nは頂点数
//   REP(i, n) {
//     REP(j, n) {
//       REP(k, n) { G[j][k] = min(G[j][k], G[j][i] + G[i][k]); }
//     }
//   }
// }

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

  int N, W;
  cin >> N >> W;

  int w1;
  vector<int> V[4];

  int w, v;
  REP(i, N) {
    cin >> w >> v;
    if (i == 0) {
      w1 = w;
    }
    V[w - w1].pb(v);
  }

  REP(i, 4) { sort(RALL(V[i])); }

  vector<int> Vsum[4];

  REP(i, 4) { Vsum[i].pb(0); }

  REP(i, 4) {
    REP(j, V[i].size()) {
      if (j == 0) {
        Vsum[i].pb(V[i][j]);
      } else {
        Vsum[i].pb(Vsum[i][j] + V[i][j]);
      }
    }
  }
  int ans = 0;

  // int n_items_max = W / w1;
  int this_w, this_v;

  REP(i0, Vsum[0].size()) {
    REP(i1, Vsum[1].size()) {
      REP(i2, Vsum[2].size()) {
        REP(i3, Vsum[3].size()) {
          this_w = i0 * w1 + i1 * (w1 + 1) + i2 * (w1 + 2) + i3 * (w1 + 3);
          // cout << i0 << i1 << i2 << i3 << endl;
          // debug(this_w);
          if (this_w <= W) {
            this_v = Vsum[0][i0] + Vsum[1][i1] + Vsum[2][i2] + Vsum[3][i3];
            // debug(this_v);
            chmax(ans, this_v);
          }
        }
      }
    }
  }

  cout << ans << endl;
  return 0;
};


Measured memory_bytes: 256
N = int(input())
sx, sy = 0, 0
t = 0
check = True
for i in range(N):
  nt, nx, ny = list(map(int, input().split()))
  if abs(nx-sx) + abs(ny - sy) <= (nt -t) and (abs(nx-sx) + abs(ny - sy)) % 2 == (nt -t) % 2:
    sx, sy, t = nx, ny, nt
  else:
    check = False
    break
if check:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	int C = sc.nextInt();
    	int D = sc.nextInt();
    	while(A>0&&C>0) {
    		C=C-B;
    		if(C<=0)break;
    		A=A-D;
    	}
    	if(A>0) {
    		System.out.println("Yes");
    	} else {
    		System.out.println("No");
    	}
    	
    	
    	
    	
        		
    }
}


Measured memory_bytes: 35768
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		int[] a=new int[s[0]+1];
		long[][] b=new long[s[0]+1][];
		int[] c=new int[s[0]+1];
		b[0]=new long[2];
		for(int i=1;i<=s[0];i++){
			a[i]=sc.I;
			b[i]=new long[]{b[i-1][0]+a[i]-s[1],i};
		}
		Array.Sort(b,Ca);
		int p=1;
		long ans=0;
		c[b[0][1]]=1;
		for(int i=1;i<=s[0];i++){
			if(b[i][0]!=b[i-1][0]){p++;}
			c[b[i][1]]=p;
		}
		Bit bit=new Bit(p);
		bit.Ud(c[0],1);
		for(int i=1;i<=s[0];i++){
			ans+=bit.Get(c[i]);
			bit.Ud(c[i],1);
		}
		Console.WriteLine(ans);
	}
	static int Ca(long[] a,long[] b){
		if(a[0]>b[0]){return 1;}
		else if(a[0]<b[0]){return -1;}
		else{return 0;}
	}
}
public class Bit{
	private int n;
	private int[] bit;
	public Bit(int n){
		this.n=n;
		bit=new int[n+1];
	}
	public void Ud(int a,int p){while(a<=n){bit[a]+=p;a+=a&-a;}}
	public int Get(int n){
		int a=0;
		while(n>0){a+=bit[n];n-=n&-n;}
		return a;
	}
}

class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 30416
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int A, B; cin >> A >> B;
    int now = 1, i = 0;
    while(now < B) {
        i++; now--; now += A;
    }
    printf("%d\n", i);
}


Measured memory_bytes: 256
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;
typedef long long LL;
static const LL MOD = 1000000007;

int main(int argc, char* argv[]) {

#ifdef _MSC_VER
	while (true)
#endif
	{
		LL n = -1, ans = 0, x;
		cin >> n;
		if (n < 0) return 0;
		vector<LL> a(n);
		map<LL, LL> dp;
		dp[0] = 1;
		for (int i = 0; i < n; ++i) {
			cin >> x;
			map<LL, LL> nx;
			for (auto kv : dp) {
				LL p = kv.first >> 36;
				LL q = (kv.first >> 18) & 0x1FFFF;
				LL r = kv.first & 0x1FFFF;
				if (p == x) {
					LL y = ((p + 1) << 36) | (q << 18) | r;
					nx[y] = (nx[y] + kv.second) % MOD;
				}
				if (q == x) {
					LL y = (p << 36) | ((q + 1) << 18) | r;
					nx[y] = (nx[y] + kv.second) % MOD;
				}
				if (r == x) {
					LL y = (p << 36) | (q << 18) | (r + 1);
					nx[y] = (nx[y] + kv.second) % MOD;
				}
			}
			dp = nx;
		}
		for (auto kv : dp) {
			ans = (ans + kv.second) % MOD;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
use std::io::stdin;
use std::collections::HashMap;

#[allow(dead_code)]
fn input_ints() -> Vec<i64> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.split_whitespace().map(|s| s.parse().unwrap()).collect(),
        Err(_) => Vec::<i64>::new(),
    }
}

#[allow(dead_code)]
fn input_strs() -> Vec<String> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.split_whitespace().map(|s| s.to_string()).collect(),
        Err(_) => Vec::<String>::new(),
    }
}

#[allow(unused_variables)]
fn solve() {
    let inp = input_ints();
    let n = inp[0];

    let mut prime = HashMap::<i64, i64>::new();
    prime.insert(2, 1);

    for i in 3..n + 1 {
        let mut x = i;
        let mut flg = true;
        while flg {
            for j in 2..i + 1 {
                if x == 1 {
                    flg = false;
                    break;
                }
                if x % j == 0 {
                    x /= j;
                    let num = prime.entry(j).or_insert(0);
                    *num += 1;
                    break;
                }
            }
        }
    }

    if n == 1 {
        println!("{}", 1);
    } else {
        println!("{}",
                 prime.iter().fold(1, |acc, (k, v)| acc * (v + 1) % 1000000007));
    }
}

fn main() {
    solve();
}


Measured memory_bytes: 380
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 998244353
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
ll dp[3005][3005];
void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    dp[a][b]=1;
    for(int y=b+1;y<=d;y++)
        dp[a][y]=(dp[a][y-1]*a)%mod;
    for(int x=a+1;x<=c;x++)
        dp[x][b]=(dp[x-1][b]*b)%mod;
    for(int i=a+1;i<=c;i++)
    {
        for(int j=b+1;j<=d;j++)
        {
            dp[i][j]=dp[i][j-1]*i+dp[i-1][j]*j-dp[i-1][j-1]*(i-1)*(j-1);
            dp[i][j]%=mod;
            dp[i][j]+=mod;
            dp[i][j]%=mod;
        }
    }
    cout<<dp[c][d]<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 85956
a,b,c,d,e,f=map(int,input().split())
w=[a*i+b*j for i in range(31) for j in range(31) if 0<a*i+b*j<=f//100]
m=max(w)*e//min(c,d)+1
s=[c*i+d*j for i in range(m) for j in range(m) if 0<c*i+d*j<=max(w)*e]
w=sorted(list(set(w)))
s=sorted(list(set(s)))
mx=0
res=(min(a,b),0)
for p in w:
	for q in s:
		if p*100+q>f or q/p>e:
			continue
		r=100*q/(100*p+q)
		if mx<r:
			mx=r
			res=(p,q)
p,q=res
print(100*p+q,q)

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

int n,a[55],b[55];
bool v[55][55];
ll ans=0;

inline bool can(){
	memset(v,0,sizeof(v));
	for(int i=1;i<=50;i++) if((1ll<<i)&ans)
		for(int j=0;j<=50;j++) v[j][j%i]=1;

	for(int i=0;i<=50;i++) v[i][i]=1;

	for(int k=0;k<=50;k++)
		for(int i=0;i<=50;i++)
		    for(int j=0;j<=50;j++) if(v[i][k]&&v[k][j]) v[i][j]=1;

	for(int i=0;i<n;i++) if(!v[a[i]][b[i]]) return 0;
	return 1;
}

int main(){
	scanf("%d",&n),ans=1ll<<51,ans-=2;
	for(int i=0;i<n;i++) scanf("%d",a+i);
	for(int i=0;i<n;i++) scanf("%d",b+i);

	if(!can()){ puts("-1"); return 0;}

	for(int i=50;i;i--){
		ans^=1ll<<i;
		if(!can()) ans|=1ll<<i;
	}

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

Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var K = Scanner.Scan<int>();
            var answer = "";
            for (var i = 0; i < K; i++)
            {
                answer += "ACL";
            }
            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28220
//
//  main.swift
import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readTwoInts() -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: " ").map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

func prime_factor(n: Int) -> [Int] {
    var ret: [Int] = []
    var k = n
    for i in 2..<Int(sqrt(Double(n)))+1 {
        while k % i == 0 {
            ret.append(i)
            k = Int(floor(Double(k / i)))
        }
    }
    
    if k != 1 {
        ret.append(k)
    }
    
    return ret
}

var A = readInts()
let K = readInt()
for _ in 0..<K {
    A = A.sorted()
    A[A.count-1] *= 2
}
print(A.reduce(0, +))


Measured memory_bytes: 13736
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

a -= t
a *= 1000

ans = 0
diff = abs(a + h[0] * 6)

for i in range(1, n):
    if abs(a + h[i] * 6) < diff:
        ans = i
        diff = abs(a + h[i] * 6)

print(ans + 1)

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

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

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

#define FACSIZE 200002

ll invfac[FACSIZE];
ll fac[FACSIZE];

template <class T>
bool chmax(T &, const T &);
template <class T>
bool chmin(T &, const T &);
ll gcd(ll, ll);
ll powLL(ll x, ll y);

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
ll comb(ll, ll);
void make_fact(ll);
void make_invfact(ll);
void fact_init();

int main(void)
{
  ll n, a;
  cin >> n >> a;
  cout << n * n - a << endl;
  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return mod_mul(t, t);
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = mod_mul(t, t);
    return (k % mod) * (x % mod);
  }
}
ll mod_add(ll a, ll b)
{
  return ((a % mod) + (b % mod)) % mod;
}

ll mod_mul(ll a, ll b)
{
  return ((a % mod) * (b % mod)) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void fact_init()
{
  make_fact(FACSIZE - 1);
  make_invfact(FACSIZE);
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

ll comb(ll n, ll r)
{

  return mod_mul(mod_mul(fac[n], invfac[r]), invfac[n - r]);
}
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

ll qp(ll a, ll b)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * mod_mul(ans, a) % mod;
    a = 1LL * mod_mul(a, a) % mod;
  } while (b >>= 1LL);
  return ans;
}
ll qp(ll a, ll b, ll mo)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * (ans % mo) * (a % mo);
    a = 1LL * (a % mo) * (a % mo);
  } while (b >>= 1LL);
  return ans;
}
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
ll powLL(ll x, ll y)
{
  ll ans = 1LL;
  for (ll i = 0LL; i < y; i++)
    ans *= x;
  return ans;
}

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

kaijo = 1
for i in range(1,n+1):
    kaijo *= i

a = 0
for i in range(n):
    kaijo //= (n-i)
    a += (p_l[i]-1)*kaijo
    for j in range(n):
        if p_l[j] > p_l[i]:
            p_l[j] -= 1

kaijo = 1
for i in range(1,n+1):
    kaijo *= i

b = 0
for i in range(n):
    kaijo //= (n-i)
    b += (q_l[i]-1)*kaijo
    for j in range(n):
        if q_l[j] > q_l[i]:
            q_l[j] -= 1

print(abs(a-b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 102;
const ll MOD = 1000000007;

int n, dp[MAXN][11];
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n;

    int iNF = 0x3f3f3f3f;
    memset(dp, -iNF, sizeof(dp));
    dp[0][0] = 0;
    REP1 (i, n) {
        int d;
        cin >> d;
        REP (j, 10) {
            dp[i][j] = max(dp[i-1][j], dp[i-1][(j-d%10+10)%10] + d);
        }
    }

    int ans = 0;
    REP1 (i, 9) {
        debug(i, dp[n][i]);
        ans = max(ans, dp[n][i]);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    Graph G(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vi ans(n,-INF); // 1 => red  0 => blue
    queue<int> q;
    q.push(0);
    ans[0] = 1; // red
    while(q.size()){
        int t = q.front();
        q.pop();
        for(auto to : G[t]){
            if(ans[to]!=-INF) continue;
            ans[to] = (ans[t] + 1) % 2;
            q.push(to);
        }
    }
    int c_red = 0,c_blu = 0;
    for(auto t : ans) (t==1? c_red++ : c_blu++);
    if(c_blu <= n/3 || c_red <= n/3){ 
        if(c_blu <= n/3){   // exchange red <=> blue
            rep(i,n){
                if(ans[i]) ans[i] = 0;
                else ans[i] = 1;
            }
        }
        int three = 3;
        rep(i,n){
            if(ans[i]==1){
                ans[i] = -three;
                three += 3;
            }
        }
        int o2 = 1;
        rep(i,n){
            if(ans[i]==0 && three<=n){
                ans[i] = -three;
                three += 3;
            }else if(ans[i]==0){
                if(o2%3==0) o2++;
                ans[i] = -o2;
                o2++;
            }
        }
    }else{
        int one = 1,two = 2, three = 3;
        rep(i,n){
            if(ans[i]==1 && one <= n){
                ans[i] = -one;
                one += 3;
            }else if(ans[i]==0 && two <= n){
                ans[i] = -two;
                two += 3;
            }else{
                ans[i] = -three;
                three += 3;
            }
        }
    }
    rep(i,n){
        cout << -ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 14452
N=[i for i in range(1,1001)]
A,B=map(int,input().split())
for j in range(len(N)):
  m=int(N[j]*0.08)
  if m>A:
    break
  elif m==A:
    M=int(N[j]*0.1)
    if M==B:
      print(N[j])
      exit()
    elif M>B:
      break
print(-1)

Measured memory_bytes: 38384
using System;

namespace B___Roller_Coaster
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var k = int.Parse (input[1]);
            var ans = 0;
            input = Console.ReadLine ().Split (' ');
            foreach (var p in input)
            {
                if (int.Parse (p) >= k)
                {
                    ans++;
                }
            }
            Console.WriteLine (ans);
        }
    }
}

Measured memory_bytes: 17120
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR_(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI_()
    return res
def SR(n):
    res = [None] * n
    for i in range(n):
        res[i] = S()
    return res
def LSR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LS()
    return res
mod = 1000000007
inf = float('INF')

#solve
def solve():
    k = II()
    ans = 0
    for i in range(k + 1):
        ans += 7 * pow(10, i, k)
        ans %= k
        if ans:
            continue
        else:
            print(i + 1)
            return
    print(-1)
    return


#main
if __name__ == '__main__':
    solve()


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

int main() {
  int s; cin >> s;
  int n = 1;
  vector<bool> a(1000001, 0);
  a[s] = true;
  while(1){
    n++;
    if(s % 2 == 0) s /= 2;
    else s = 3 * s + 1;
    if(a[s]) break;
    a[s] = true;
  }
  
  cout << n << endl;
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

	static class TaskC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			long T = in.nextInt();
			long ans = 0;
			long prev = -1;
			for (int i = 0; i < n; i++) {
				int t = in.nextInt();
				if (prev >= 0) {
					if (prev + T < t) {
						ans += T;
					} else {
						ans += t - prev;
					}
				}
				prev = t;
			}
			ans += T;
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



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

s_sub = list()
for j in range(N):
    s_sub.append(input())

S_all = ["S 1","S 2","S 3","S 4","S 5","S 6","S 7","S 8","S 9","S 10","S 11","S 12","S 13",
        "H 1","H 2","H 3","H 4","H 5","H 6","H 7","H 8","H 9","H 10","H 11","H 12","H 13",
        "C 1","C 2","C 3","C 4","C 5","C 6","C 7","C 8","C 9","C 10","C 11","C 12","C 13",
         "D 1","D 2","D 3","D 4","D 5","D 6","D 7","D 8","D 9","D 10","D 11","D 12","D 13"]

#ans = list()
for i in range(52):
    if S_all[i] in s_sub:
        pass
    else:
        print(S_all[i])


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

#define int long long
#define double long double

using namespace std;

#define REP(i, a, b) for (int(i) = (a); i < (b); (i)++)
#define rep(i, n) REP(i, 0, n)
#define PER(i, a, b) for (int(i) = (a - 1); i >= (b); (i)--)
#define per(i, n) PER(i, n, 0)
#define each(i, n) for (auto &i : n)
#define clr(a) memset((a), 0, sizeof(a))
#define mclr(a) memset((a), -1, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define dum(val) cerr << #val " = " << val << " ";
#define dump(val) cerr << #val " = " << val << endl;
#define FILL(a, v) fill(a, a + sizeof(a) / sizeof(*a), v)

typedef pair<int, int> P;

const int mod = 1e9 + 7;
const int INF = 1e18;

signed main() {

  int n;
  cin >> n;

  char a[301][301];
  rep(y, n) rep(x, n) { cin >> a[y][x]; }

  int ans = 0;
  map<P, bool> mp;
  rep(A, n) {
    rep(B, n) {
      bool ok = [&]() {
        auto p = P((A - B + n) % n, (B - A + n) % n);
        if (mp.count(p)) {
          return mp[p];
        }
        rep(y, n) rep(x, n) {
          int tx = (x + B) % n;
          int ty = (y + A) % n;
          int ax = (x + A) % n;
          int ay = (y + B) % n;
          if (a[ty][tx] != a[ax][ay]) {
            return mp[p] = false;
          }
        }
        return mp[p] = true;
      }();
      if (ok) {
        ans++;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        int a,b,d,r;
        double f;
    	//?¨??????\??????????????????????????§????????????
		Scanner scanner = new Scanner(System.in);

		a = scanner.nextInt();
    	b = scanner.nextInt();

    	d = a/b;
    	r = a%b;
    	//?????°????¨?????????????int???????????£??????
    	f = (double)a/b;

    	System.out.printf("%d %d %f",d,r,f);
    	scanner.close();
    }
}

Measured memory_bytes: 26332
package main

import "fmt"

const (
	LARGE_NUM = 1000000007
)

func fractal(N int) int {
	if N == 1 {
		return 1
	}
	return (N * fractal(N-1)) % LARGE_NUM
}

func main() {
	var N int
	fmt.Scan(&N)
	fmt.Println(fractal(N))
}

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

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

    int n, m;
    cin >> n >> m;

    int x=1, y=n;
    for (int dist=(n-1)/2; m && dist>0; --m, --dist) {
        if (dist&1)     cout << y << " " << y-dist << "\n", --y;
        else            cout << x << " " << x+dist << "\n", ++x;
    }

    return 0;
}


Measured memory_bytes: 3608
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head

const int N = 305;
const int MOD = 998244353;
bitset<N> a[N]; 
vector<bitset<N>> base;
LL q_pow(LL n, LL k) {
	LL res = 1;
	while(k) {
		if(k&1) res = (res*n) % MOD;
		k >>= 1;
		n = (n*n) % MOD; 
	}
	return res;
}
int main() {
	int n, m, t;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; ++i) {
		a[i].reset();
		for (int j = m-1; j >= 0; --j) {
			scanf("%d", &t);
			if(t) a[i].flip(j);
		}
	}
 	for (int i = 0; i < n; i++) {
 		for (bitset<N> b : base) {
 			bitset<N> bb = b^a[i];
 			for (int j = m-1; j >= 0; j--) {
 				if(bb[j] < a[i][j]) {
 					a[i] = bb;
					break;
				}
				else if(bb[j] > a[i][j]) break;
			}
		 }	
		 if(a[i].any()) base.pb(a[i]);
	}
	int cnt = (int)base.size();
	printf("%lld\n", ((q_pow(2, n+m-1) - q_pow(2, n+m-1-cnt)) % MOD+ MOD) % MOD);
	return 0;
}

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

long solve(long n) {
    long m = 1 + n;
    int cl = ceil(sqrt(n));

    long tmp;
    for (int i = 1; i <= cl; ++i) {
        tmp = i + n/i;
        if (n%i == 0 && m > tmp) {
            m = tmp;
        }
    }

    return m;
}


int main () {
    long n;
    scanf("%ld", &n);
    long m = solve(n);

    printf("%ld\n", m - 2);
}

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

int main()
{
    int m,r,g,b;
    while(scanf("%d%d%d",&r,&g,&b)!=EOF)
    {
        m=r*100+g*10+b;
        if (m%4==0) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 256
//    ŦĦ€Ř€'Ş ŇØŦĦƗŇǤ ĦØŁĐƗ'Ň Μ€ βΔĆҜ ΔŁŴΔ¥Ş ΔŇĐ ₣ØŘ€V€Ř 😈🤩😇😈💪🤜👊🤛🤟😉🤩:

#include<bits/stdc++.h>

#define mod 1000003
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define B(a) a.begin()
#define E(a) a.end()
#define For(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define M_P make_pair
#define P_B push_back
#define endd "\n"

using namespace std;

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

    ll n;cin>>n;

    if(n==0)
        cout<<"1"<<endd;

    else
        cout<<"0"<<endd;







    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=n-1;i > m;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,N,M,K,odd=0,sum=0;
  cin >> N >> M;
  vector<int>P(N+1,1),DP(N+1,0);
  rep(i,0,M){
    cin >> A;
    P[A]=0;
  }
  DP[0]=1;
  rep(i,1,N+1){
    if(!P[i])continue;
    DP[i]=(DP[i-1]+DP[i-2])%mod;
  }
  Out(DP[N]);
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        
        if(N<1000){
            System.out.println("ABC");
        }else{
            System.out.println("ABD");
        }
        
    }
    
} 

Measured memory_bytes: 35368
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define y1 wzpakking
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
using namespace std;
int f[5005][5005];
int n,ans;
char s[5005];
int main(){
	scanf("%d%s",&n,s+1);
	Rep(i,n,1) Rep(j,n,1) if (s[i]==s[j]){
		f[i][j]=f[i+1][j+1]+1;
		if (i!=j) ans=max(ans,min(f[i][j],abs(i-j)));
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 98048
N, K = map(int, input().split())
A = list(map(int, input().split()))
answer = 'Yes'
score = 0
for i in range(K):
    score += A[i]

for i in range(N - K):
    next_score = score + A[K + i] - A[i]
    print('Yes' if next_score > score else 'No')
    score = next_score



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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int n=tx-sx,m=ty-sy;
    rep(i,m)cout<<'U';
    rep(i,n)cout<<'R';
    rep(i,m)cout<<'D';
    rep(i,n)cout<<'L';
    cout<<'L';
    rep(i,m+1)cout<<'U';
    rep(i,n+1)cout<<'R';
    cout<<'D';
    cout<<'R';
    rep(i,m+1)cout<<'D';
    rep(i,n+1)cout<<'L';
    cout<<'U';
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int P[10010];

void init(int N)
{
    for (int i = 0; i < N; i++) P[i] = i;
}

int root(int a)
{
    if (P[a] == a)  return a;
    return (P[a] = root(P[a]));
}

bool is_same_set(int a, int b)
{
    return root(a) == root(b);
}

void unite(int a, int b)
{
    P[root(a)] = root(b);
}

int main()
{   
    int n, q;
    cin >> n >> q;
    
    init(n);

    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;

        if (com == 0) {
            unite(x, y);
        }

        if (com == 1) {
            if (is_same_set(x, y))  cout << 1 << endl;
            else                    cout << 0 << endl;
            
        }
    }
}


Measured memory_bytes: 3236
n = int(input())
s = input()
ans = 0
for i in range(1, n - 1):
    cnt = 0
    left = set(s[:i])
    right = set(s[i:])
    for alphabet in left:
        if alphabet in right:
            cnt += 1
    ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3060
from collections import Counter
n = int(input())
cl = {chr(i):0 for i in range(97,123)}
s = input()
for k in Counter(s).keys():
  cl[k] = Counter(s)[k]
for i in range(n-1):
  s = input()
  for k in cl.keys():
    if cl[k]!=0:
      cl[k] = min(cl[k],Counter(s).get(k,0))
ans = []
for k,v in cl.items():
  if v!=0:
    for i in range(v):
      ans.append(k)
print(''.join(sorted(ans)))

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

using namespace std;

typedef long long int64;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int oo = 0x3f3f3f3f;
const double pi = acos(-1);
const double eps = 1e-9;

#define endl '\n'

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

	int a, b;

	cin >> a >> b;

	for (int i = 1; i < max(a, b) * 20; ++i){
		if (int(i * 8.0 / 100) == a && int(i * 1.0 / 10) == b){
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>x>>y;
	if(x*y%2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
 
LL n, m, l = 0, r = 1e12, mid;
 
bool check(LL x){
	if (n >= x) return m >= 2*x;
	return m-2*(x-n) >= 2*x;
}
 
int main(){
	scanf("%lld%lld", &n, &m);
	while (l < r){
		mid = (l+r+1) >> 1;
		if (check(mid)) l = mid;
		else r = mid-1;
	}
	printf("%lld", l);
	return 0;
}

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

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

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

    vector<int64_t> cost(n, 0);
    cost[0] = 0;
    cost[1] = abs(h[0] - h[1]);
    for(int i = 2; i < n; i++) {
        cost[i] = min(cost[i - 2] + abs(h[i - 2] - h[i]), cost[i - 1] + abs(h[i - 1] - h[i]));
    }
    cout << cost[n - 1] << endl;
    return 0;
}

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

int n, a[15], x[15][15], y[15][15];

int cnt(int i)
{
    if (!i) return 0;
    return (i & 1) + cnt(i >> 1);
}

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

    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++)
    {
        int ok = 1;
        for (int i = 0; i < n; i++)
        {
            if ((bit >> i) & 1)
            {
                for (int j = 0; j < a[i]; j++)
                {
                    if (((bit >> (x[i][j] - 1)) & 1) ^ y[i][j]) ok = 0; 
                }
            }
        }
        if (ok) ans = max(ans, cnt(bit));
    }
    cout << ans << "\n";
}

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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
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; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

const int m=2019;
string S;

int main(){
    cin>>S;
    reverse(S.begin(),S.end());
    int x=1,tot=0;
    int n=S.size();
    //cnt(2019):累積和(mod2019)が何個有るかを数える。(0-2018)
    //同じ値のものが２つあれば、そのセットでmod2019が0になる
    vec<ll> cnt(m);
    ll ans=0;
    rep(i,n){
        cnt[tot]++;
        tot+=(S[i]-'0')*x;//各桁の数を取得
        tot%=m; //modにする
        ans+=cnt[tot];
        x=x*10%m; 
    }
    cout<<ans<<endl;
    return 0;

}


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

int main(){
  int n,ans = 0;cin >> n;
  int a[n];for(int i=0;i<n;i++)cin >> a[i];
  int b[n];for(int i=0;i<n;i++){
    cin >> b[i];
    ans += b[i];
  }
  int c[n-1];for(int i=0;i<n-1;i++)cin >> c[i];
  for(int i=0;i<n;i++){
    if(a[i]-a[i-1] == 1){
      ans += c[a[i-1]-1];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256