akhauriyash/Code-Regression huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k = LI()
    a = LI()
    r = 0
    for i in range(n):
        for j in range(i+1,n):
            if a[i] > a[j]:
                r += 1
    r *= k
    r %= mod
    u = [0] * (max(a)+1)
    for c in a:
        u[c] += 1
    for i in range(len(u)-1):
        u[i+1] += u[i]
    kk = (k-1) * k // 2 % mod
    for c in a:
        r += u[c-1] * kk
        r %= mod

    return r


print(main())





Measured memory_bytes: 6864
/* D-"Median of Medians" */
/*  */
//include <bits/stdc++.h>
#include <iostream>
#include <deque>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++) 
using namespace std;

template <typename T> 
void print(deque<T>& d){
    for(auto x: d){
        cout << x; 
    }
    cout << endl;
}

int main(){
    string s;
    cin >> s;
    deque <char> q;
    for(char c : s) q.push_back(c);
    ll n,t,f;
    cin >> n;
    char x;
    bool flip = false;
    rep(i,n){
        
        cin >> t;
        if(t == 1) flip = !flip;
        else{
            cin >> f >> x;
            if(flip == true) f = 3-f;
            if(f == 1) q.push_front(x);
            else q.push_back(x); 
        }
    }
    if(flip == true) reverse(q.begin(),q.end());
    string ans;
    for(char d : q) ans += d;
    cout << ans << endl; 
    
    return 0;
}
    

Measured memory_bytes: 1412
x=int(input())

def is_prime(p):
  cnt=0
  for i in range(1,int(p**0.5)+1):
    if p%i==0:
      cnt+=1
  if cnt==1:
    return True
  else:
    return False
      
#print(*[(x,is_prime(x)) for x in range(1,10+1)])
num=x
while True:
  if is_prime(num):
    ans=num
    break
  num+=1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
  void solve()
{
 string S,T;
     cin>>S>>T;
    T.pop_back();
  if(S==T)
  {
    cout<<"Yes"<<endl;
  }
    else
    {    cout<<"No"<<endl;
    }
}
int main()
{
   solve();
  return 0;
}


Measured memory_bytes: 3600
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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            int res = s.length();
            for (char ch = 'a'; ch <= 'z'; ++ch) {
                int count = 0;
                int max = 0;
                int first = -1;
                int last = -1;
                for (int i = 0; i < s.length(); ++i) {
                    if (s.charAt(i) == ch) {
                        max = Math.max(max, count);
                        last = count;
                        if (first < 0) first = count;
                        count = 0;
                    } else {
                        ++count;
                    }
                }
                {
                    max = Math.max(max, count);
                    last = count;
                    if (first < 0) first = count;
                }
                res = Math.min(res, max);
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

    }
}



Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1e9;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)

template<class Abel> struct UnionFind {
    vector<int> par; //親ノード
    vector<int> rank; //高さ
    vector<Abel> diff_weight;

    UnionFind(int N = 1, Abel SUM_UNITY = 0){
        init(N, SUM_UNITY);
    } 

    void init(int N = 1, Abel SUM_UNITY = 0){
        par.resize(N);
        rank.resize(N);
        diff_weight.resize(N);

        for(int i = 0; i < N; ++i){
            par[i] = i;
            rank[i] = 0;
            diff_weight[i] = SUM_UNITY;
        }
    }

    int root(int x){
        if(par[x] == x) return x;
        else{
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    bool is_same(int x,int y){ 
        return root(x) == root(y); 
    }

    Abel weight(int x){
        root(x);
        return diff_weight[x];
    }

    Abel diff(int x,int y){
        return weight(y) - weight(x);
    }

    bool merge(int x,int y,int w = 0){
        w += weight(x);
        w -= weight(y);

        x = root(x);
        y = root(y);
        if(x == y) return false;

        if(rank[x] < rank[y]) swap(x,y), w = -w;
        if(rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    UnionFind<int> people(N);

    rep(i,M){
        int L,R,D;
        cin >> L >> R >> D;
        --L, --R;
        if(people.is_same(L,R)){
            if(people.diff(L,R) != D){
                cout << "No" << endl;
                return 0;
            } 
        }
        else people.merge(L,R,D);
    }

    cout << "Yes" << endl;
}

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

long long mod = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  int i;
  for (i = 0; i < m; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int breaked[n + 10] = {};
  for (i = 0; i < m; i++) {
    breaked[a[i]] = 1;
  }

  long long dp[n + 10] = {};

  dp[0] = 1;
  if (!breaked[1]) {
    dp[1] = 1;
  } else {
    dp[1] = 0;
  }
  for (i = 2; i < n + 5; i++) {
    dp[i] = 0;
    if (breaked[i]) {
      dp[i] = 0;
    } else {
      if (!breaked[i - 1]) {
        dp[i] += dp[i - 1];
      }
      if (!breaked[i - 2]) {
        dp[i] += dp[i - 2];
      }
    }
    dp[i] %= mod;
  }
  cout << dp[n] << endl;
  return 0;
}


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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
#define fileio freopen("template.in", "r", stdin), freopen("template.out", "w", stdout);
typedef long long ll;
const ll MOD = 1e9 + 7;

string solve(ll x) {
    string s = "";
    if (x < 26) {
        s += 97+x;
        return s;
    } else {
        s += 97+(x%26);
        x /= 26;
        return solve(--x) + s;
    }
}
int main() {
    fastio;
    //fileio;

    ll n;
    cin >> n;
    cout << solve(--n) << "\n";
    return 0;
}


Measured memory_bytes: 3656
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n, H, W;
vector<pair<int,int> > v;
int main()
{
	getii(H, W);
	geti(n);
	for (int i=1; i<=n; i++)
	{
		int x, y;
		getii(x, y);
		v.PB(MP(x, y));
	}
	sort(v.begin(), v.end());
	int ans = H;
	int mx = 0, l = 0;
	for (int i=0; i<v.size(); i++)
	{
		int x = v[i].FF;
		int y = v[i].SS;
		if (x>y+l)
		{
			ans = x-1;
			break;
		}
		else if(x>mx&&x==y+l)
		{
			l++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2548
import Data.Array.IO
import Data.List
import Data.IORef
import Data.Array

all_ord::Int -> [[Int]]
all_ord n = map (1:) (permutations [2..n])

main::IO()
main= do
  nmc<-getLine
  let n:m:[]=map read (words nmc)::[Int]
  con<-newArray ((1,1),(n,n)) False
  ptr<-newIORef con
  create_edge ptr m
  st_ar<-freeze con
  print (solver st_ar n)


create_edge::IORef (IOArray (Int,Int) Bool) -> Int -> IO()
create_edge _ 0 = return ()
create_edge pt n = do
  abc<-getLine
  let a:b:[]=map read (words abc) ::[Int]
  ar<-readIORef pt
  writeArray ar (a,b) True
  writeArray ar (b,a) True
  create_edge  pt (n-1)

solver::(Array (Int,Int) Bool) -> Int -> Int
solver ar n = length (filter (check ar) (all_ord n))

check::(Array (Int,Int) Bool) -> [Int] -> Bool
check _  []       =True
check _  (_:[])   =True
check ar (a:b:xs) =(ar!(a,b))&& (check ar (b:xs))


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

string s;
int st[26], gapm[26], tail[26];

int main(void){
  for(int i = 0; i < 26; i++){
    st[i] = -1;
  }
  cin >> s;
  int n = s.size();
  for(int i = 0; i < n; i++){
    int b = s[i] - 'a';
    tail[b] = n - 1 - i;
    gapm[b] = max(gapm[b], i - st[b] - 1);
    st[b] = i;
  }
  int m = 10000;
  for(int i = 0; i < 26; i++){
    if(gapm[i] > 0){
      m = min(m, max(tail[i], gapm[i]));
    }
  }
  if(m == 10000){
    cout << 0 << endl;
  }
  else{
    cout << m << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

int N;
cin>>N;
long long p[N+1];
p[0]=1;
rep(i,N){
    p[i+1]=p[i]*(i+1);
}
double x[N],y[N];
rep(i,N){
    cin>>x[i]>>y[i];
}

double sum=0;
for(int i=0;i<N;i++){
    for(int k=1;i+k<N;k++){
        sum+=sqrt((x[i]-x[i+k])*(x[i]-x[i+k])+(y[i]-y[i+k])*(y[i]-y[i+k]));
    }
}
double ans=2*sum/N;

printf("%.10f",ans);


 return 0;
}
/*
3
0 0
1 0
0 1

2.2761423749

2
-879 981
-866 890

91.9238815543

8
-406 10
512 859
494 362
-955 -475
128 553
-986 -885
763 77
449 310

7641.9817824387
*/

Measured memory_bytes: 256
use std::process;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main() {
    let (d, mut n) = get!(u64,u64);

    if n ==100 {
        n += 1;
    }
    println!("{}" , 100_u64.pow(d as u32)*n);
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <fstream>
#include <cstddef>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = (1<<30);
const ll NEGA=-INF*10000; 


ll ans = 0;
int n,m;
int cnt=0;

int p[2000000];
int main() 
{
  int n; cin>>n;
  rep(i,n) cin>>p[i];
  sort(p,p+n);
  int a=0,b=0;
  rep(i,n){
    if(i%2) b+=p[n-1-i];
    else a+=p[n-1-i];
  }
  cout<<a-b<<endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
	int n,m=0;
	cin>>n;
	while(n>0){
		m=m+n%10;
		n=n/10;
	}
	if(m==1) m=m*10;
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main()
{
int n;
cin >> n;
vector<ll> a(n);
rep(i,n) {
    cin >> a[i];
    if(a[i] == 0) {
        cout << 0 << endl;
        return 0;
    }
}
__int128_t ans = 1;
rep(i,n) {
    ans *= a[i];
    if(ans > (ll)1e18) {
        cout << -1 << endl;
        return 0;
    }
}
cout << (ll)ans << endl;
return 0;
}

Measured memory_bytes: 4028
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n,c0=0,c1=0,c2=0,c3=0;
    cin>>n;
    string v[n];
    for(int i=0;i<n;i++){
    cin>>v[i];
    }
    for(int i=0;i<n;i++){
        if(v[i]=="AC") c0++;
        if(v[i]=="WA") c1++;
        if(v[i]=="TLE") c2++;
        if(v[i]=="RE") c3++;
    }
    cout<<"AC x "<<c0<<"\nWA x "<<c1<<"\nTLE x "<<c2<<"\nRE x "<<c3;
    return 0;
}

Measured memory_bytes: 6752
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int N = 1000010;

int main() {
    int n, u, v, m;
    cin >> n >> u >> v >> m;
    vector<P> pu(N,make_pair(-1, -1)), pn(N,make_pair(-1, -1));
    REP(i,n) REP(j,n) {
        int a;
        cin >> a;
        pu[a] = make_pair(i, j);
    }
    REP(i,n) REP(j,n) {
        int a;
        cin >> a;
        pn[a] = make_pair(i, j);
    }
    VI xu(n), yu(n), ou(2), xn(n), yn(n), on(2);
    while (m-- > 0 && u > 0 && v > 0) {
        int a, i, j;
        cin >> a;
        i = pu[a].first;
        j = pu[a].second;
        if (i != -1) {
            if (++xu[i] == n) u--;
            if (++yu[j] == n) u--;
            if (i == j) if (++ou[0] == n) u--;
            if (i+j == n-1) if (++ou[1] == n) u--;
        }

        i = pn[a].first;
        j = pn[a].second;
        if (i != -1) {
            if (++xn[i] == n) v--;
            if (++yn[j] == n) v--;
            if (i == j) if (++on[0] == n) v--;
            if (i+j == n-1) if (++on[1] == n) v--;
        }
    }
    if (n == 1){
        u += 3;
        v += 3;
    }
    string ans;
    if (u <= 0 && v > 0) ans = "USAGI";
    else if (v <= 0 && u > 0) ans = "NEKO";
    else ans = "DRAW";
    cout << ans << endl;
    return 0;
}

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

int main(void)
{
	string s,t;
	int n=0,i;
	getline(cin,s);
	getline(cin,t);
	
	for(i=0;i<s.size();i++){
		if(s[i]==t[i]) n++;
	}
	
	if(n==s.size()){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
} 

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define  ren(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) ren(i,0,(n))
#define  all(a) begin(a),end(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
 
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==1)a=14;
    if(b==1)b=14;
    if(a>b)cout<<"Alice\n";
    if(a==b)cout<<"Draw\n";
    if(a<b)cout<<"Bob\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
    #define ll long long
    #define ull unsigned long long
    #define fr(i,a,b) for(int i =a ; i < b; i++)
    #define FR(i,a,b) for(int i =a ; i > b; i--) 
    #define frj(j,a,b) for(int j =a ; j < b; j++)
    #define FRE(i,a,b) for(int i =a ; i >= b; i--) 
    #define fre(i,a,b) for(int i =a ; i <= b; i++)
    #define fra(s) for(auto it = s.begin(); it != s.end() ; ++it)
 
    #define mkp make_pair 
    #define pb push_back
    #define pii pair<int,int>
    #define speed   ios::sync_with_stdio(false), cin.tie(0) , cout.tie(0)
    //#define c(a,b) cout<<a<<"--"<<b<<endl;
    #define frv(i,a,v) for(int i =  a ; i < v.size() ; ++i)
    #define cp(a,i)  cout<<a[i].first<<" "<<a[i].second<<endl;
    #define pp(a) cout<<a.first<<" "<<a.second<<endl;
    //sum array
    #define sa(n) int a[n]; int s[n];cin>>a[0];s[0]=a[0];fr(i,1,n) {cin>>a[i];s[i]=s[i-1]+a[i];}
    #define sa1(n) int a[n+1]; long long s[n+1]; a[0]=0; s[0]=0;cin>>a[1];s[1]=a[1];fr(i,2,n+1) {cin>>a[i];\
    s[i]=s[i-1]+a[i];}
 
    #define pr(a,n) fr(i,0,n){cout<<a[i]<<" ";}cout<<endl;
    #define prv(v)   for(auto it = v.begin() ; it!= v.end() ;++it){cout<<*it<<" ";}cout<<endl;
    #define prs(s)   for(auto x : s){cout<<x<<" ";}cout<<endl;
    
    #define all(x)           x.begin(), x.end()
    #define prm(m,r,c) fr(i,0,r){frj(j,0,c){cout<<m[i][j]<<" "; }cout<<endl;}
    #define fillm(m,r,c,k) fr(i,0,r)frj(j,0,c)m[i][j]=k;
    constexpr auto PI  = 3.14159265358979323846L;
    constexpr auto eps = 1e-6;
    constexpr auto mod = 1000000007;
    #define MOD 1000000007
    #define maxv 100005
    #define MAXN 100001
 
  template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
  template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
 
      ll dp[101][maxv];
 
    const long long  INF = 1e15 +5;
 
    vector<int> topsort(int v,vector<int> adj[])
    {
      int in[v+1]={0};
      fr(i,1,v+1){
      for(auto x : adj[i])
      {
          in[x]++;
      }
      }
 
      vector<int> ans;
      queue<int> q ;
      fr(i,1,v+1)
      if(in[i]==0)
        q.push(i);
      while(!q.empty())
      {
          int  k= q.front();
          q.pop();
          ans.pb(k);
          for(auto x : adj[k])
            if(--in[x]==0)
              q.push(x);
      }
      if(int(ans.size()) != v)
        exit(2);//error not a dag
 
      return ans;
    }
 
 
int main(){
      
      speed;
      int v,e;
      cin>>v>>e;
      
      vector<int> adj[v+1];
 
      int x,y;
      fr(i,0,e)
      {
        cin>>x>>y;
        adj[x].pb(y);
      }
 
      vector<int> tp = topsort(v,adj);
      int dist[v+1]={0};
      for(auto x : tp)
      {
          for(auto y : adj[x])
              if(dist[y] < dist[x] + 1)
                dist[y] = dist[x]+1;
      }
      int mx =0;
      fr(i,1,v+1)
        mx = max(mx,dist[i]);
 
      cout<<mx<<endl;
 
      return 0;
 
 
  }

Measured memory_bytes: 6780
using System;
using System.Linq;
class c
{
    static void Main()
    {
        var s = string.Join("", Console.ReadLine().Reverse());
        long w = 0;
        long ans = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == 'W') w++;
            else ans += w;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 19804
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
using namespace std;


int main() {
    int pd_counter = 0;
    int d_counter = 0;
    int point = 0;
    string T = "初期化";
    cin >> T;
    for (int i = 0; i < T.size(); i++) {
        //mujyoukennniDkitara+1
        if (T[i] == '?') {
            if (T[i - 1] == 'P') {
                T[i] = 'D';
            }
            else if (T[i + 1] == 'D') {
                T[i] = 'P';
            }
            else if (T[i + 1] == '?') {
                T[i] = 'P';
            }
            else{
                T[i] = 'D';
            }
        }
    }
    cout << T << endl;

    return 0;
}

Measured memory_bytes: 3484
/*
 * =template=.cpp
 * Copyright (C) 2017 hzw <hzw@huzhenweideMacBook.local>
 *
 * Distributed under terms of the MIT license.
 */
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<signal.h>
#include<unistd.h>
#define FR first
#define SC second
#define MP make_pair
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define pb push_back
#define ws wss
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
void read(int &x)
{
	char ch;int fu=1;
	while ((ch=getchar())<=32);
	x=0;
	if (ch=='-') fu=-1;else x=ch-48;
	while ((ch=getchar())>32) x=x*10+ch-48;
	x*=fu;
}
template<class T> void upmax(T &a,T b) { if (a<b) a=b;}
template<class T> void upmin(T &a,T b) { if (a>b) a=b;}

//---------template--------------
const int N=200100,p=1000000007;
int n,a,b;
int c[1<<18],cnt[1<<18];
void get(int q,int n,int a)
{
	if (n==1) { c[q]=0;c[q+1]=a;return;}
	if (a&(1<<(n-1)))
	{
		get(q,n-1,1);
		int t=(1<<(n-1))+1;
		get(q+(1<<(n-1)),n-1,a^t);
		for (int i=q+(1<<(n-1));i<q+(1<<n);i++)
			c[i]^=t;
	}
	else
	{
		get(q+(1<<(n-1)),n-1,a);
		get(q+1,n-1,c[q+(1<<(n-1))+1]);
		for (int i=q+1;i<q+(1<<(n-1))+1;i++)
			c[i]^=(1<<(n-1));
	}

}
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for (int i=1;i<(1<<n);i++) cnt[i]=cnt[i/2]+i%2;
	if (cnt[a^b]%2==0) 
	{
		puts("NO");
		return 0;
	}
	puts("YES");
	get(0,n,a^b);
	for (int i=0;i<(1<<n);i++) printf("%d ",c[i]^a);
}


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

typedef long long ll;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

int main(){
    ll N;
    cin >> N;
    ll A[N+1],count,now;
    rep(i,0,N) cin >> A[i];
    now = 1;
    count = 0;
    rep(i,0,N){
        if(A[i] == now){
            now +=1;
        }
        else{
            count +=1;
        }
    }
    if(count == N){
        count = -1;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int n;
    long long k;
    cin>>n>>k;
    vector<int> a(n,0);
    for(int i=0;i<n;i++) {cin>>a[i];a[i]--;}
    queue<int> qu;
    int curr=a[0];
    set<int> st;curr=0;
    while(st.find(curr)==st.end()){
        st.insert(curr);
        curr=a[curr];
    }
    qu.push(curr);curr=a[curr];
    while(curr!=qu.front()){
        qu.push(curr);
        curr=a[curr];
    }
    curr=0;
    while(curr!=qu.front() && k>0){
        k--;
        curr=a[curr];
    }
    if(k==0){
        cout<<curr+1<<"\n";
        return;
    }
    k=(k%qu.size());
    while(k--) qu.pop();
    cout<<qu.front()+1<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(obj) (obj).begin(), (obj).end()


struct edge{
    int to, cost;
    edge(int t, int c) { to = t; cost = c;}
};
struct vertex{
    int number, cost;
    vertex(int n, int c) { number = n; cost = c;}
    bool operator> (const vertex &a) const{
        return cost > a.cost;
    }
};

vector<vector<edge>> graph;
const int INF = INT_MAX;
vector<int> dist;
vector<int> prv;

void dijkstra(int n, int start){
    dist = vector<int>(n,INF); //各ノードへの距離
    prv  = vector<int>(n,-1); //前のノード
    dist[start] = 0;
    
    priority_queue<vertex, vector<vertex>, greater<vertex>> que;
    que.push(vertex(start,0));
    
    while(!que.empty()){
        vertex Vn = que.top();
        que.pop();
        int n = Vn.number;
        if(dist[n] < Vn.cost) continue;
        for(int i=0; i<graph[n].size(); i++){
            edge e = graph[n][i];
            if(dist[e.to] <= dist[n] + e.cost) continue;
            dist[e.to] = dist[n] + e.cost;
            prv[e.to] = n;
            que.push(vertex(e.to, dist[e.to]));
        }
    }
}

int main() {
    int V, E, r;
    cin >> V >> E >> r;
    graph = vector<vector<edge>>(V);
    rep(i,E){
        int s, t, d;
        cin >> s >> t >> d;
        graph[s].push_back(edge(t,d));
    }
    dijkstra(V, r);
    rep(i,V){
        if(dist[i]!=INF){
            cout << dist[i] << endl;
        }else{
            cout << "INF" << endl;
        }
    }
}


Measured memory_bytes: 13344
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>

#define rep(i,n) for(int i=0;i<(n);i++)
#define INT(n) int n;scanf("%d",&n);
#define LL(n) long long n;scanf("%lld",&n);
#define pint(n) printf("%d",n);
#define pll(n) printf("%lld",n);
#define psp printf(" ");
#define pln puts("");

int main(){
        INT(N)
        int a;
        int mod13 = 0;
        int mod0 = 0;
        int mod2 =0;
        rep(i,N){
                scanf("%d",&a);
                if (a%4 == 0)mod0++;
                if (a%4 == 2)mod2++;
                if (a%2 == 1)mod13++;
        }
        if (mod2 >= 1){
                mod13++;
        }
        if (mod13 <= mod0+1){
                std::cout <<"Yes";
        }
        else{
                std::cout << "No";
        }
        pln
        return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
N, K = map(int, input().split())
S = input()
L=[0]
#even:1
#odd:0
tmp="1"
for i in range(N):
    if tmp!=S[i]:
        L.append(1)
    else:
        L[-1]+=1
    tmp=S[i]
if tmp=="0":
    L.append(0)
M=len(L)
if M<=2*K+1:
    print(N)
    exit()
X=[0 for i in range(M+1)]
for i in range(M):
    X[i+1]=L[i]+X[i]
ans=0
for i in range(0,M-2*K,2):
    ans=max(ans,X[i+2*K+1]-X[i])
print(ans)


Measured memory_bytes: 8004
while True:
    m,f,r = map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    if m==-1 or f==-1:
        print('F')
    elif m+f >= 80:
        print('A')
    elif 65 <= m+f < 80:
        print('B')
    elif 50 <= m+f < 65:
        print('C')
    elif 30 <= m+f < 50:
        if 50 <= r:
            print('C')
        else:
            print('D')
    elif m+f < 30:
        print('F')


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

int main(void){
    string w;
    cin >> w;

    for(int i=0; i<w.size(); i++){
        int cnt=0;
        for(int j=0; j<w.size(); j++){
            if(w[i]==w[j]) cnt++;
        }
        if(cnt%2==1){
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef vector<int> vi;

#define mp make_pair
#define pb push_back

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
 
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
 
const int MOD = 1000000007;
double PI = 4*atan(1);

int ok[100][100];

int main() {
	ll X,Y; cin >> X >> Y;
	/*
	F0R(s,100) F0R(i,s+1) {
	    int j = s-i;
	    for (int i1 = 1; 2*i1 <= i; i1++) if (!ok[i-2*i1][j+i1]) ok[i][j] = 1;
	    for (int j1 = 1; 2*j1 <= j; j1++) if (!ok[i+j1][j-2*j1]) ok[i][j] = 1;
	    if (ok[i][j] == 0) cout << i << " " << j << "\n";
	}*/
	if (X == Y || X-1 == Y || X+1 == Y) cout << "Brown";
	else cout << "Alice";
}

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

if n == 1 :
    print(p)
elif p == 1 :
    print(1)
elif n >= 40:
    print(1)
else:
    ans = 1
    count = 2
    tmp = count**n
    while (tmp) <= p:
        if(p % tmp == 0):
            ans *= count
            p = int(p/tmp)
            count -= 1
        count += 1
        tmp = count**n
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef struct _data {
	int x;
	int y;
} data;

int  main()
{
	int n;
	cin >> n;
	int a = n % 10;
	string s;
	if (a == 3)
	{
		s = "bon";
	}
	else if (a == 2 || a == 4 || a == 5|| a == 7 || a == 9 )
	{
		s = "hon";
	}
	else
	{
		s = "pon";
	}
	cout << s;
	return (0);
}

Measured memory_bytes: 3624
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

N,K=rl()

if (N-1)*(N-2)//2 < K:
    print(-1)
else:
    ans = []
    for v in range(2,N+1):
        ans.append((1,v))
    for i in range(2,N):
        if K >= (N-i):
            K -= (N-i)
        elif K == 0:
            for v in range(i+1,N+1):
                ans.append((i,v))
        else:
            for v in range(i+1,N+1-K):
                ans.append((i,v))
            K = 0
    print(len(ans))
    for u,v in ans:
        print(u,v)


Measured memory_bytes: 3992
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	d := getNextInt(scanner)
	t := getNextInt(scanner)
	s := getNextInt(scanner)
	if s*t >= d {
		fmt.Fprintln(writer, "Yes")
		return
	}
	fmt.Fprintln(writer, "No")
}


Measured memory_bytes: 1816
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

int N;
int* BIT;

void add(int loc,int value){

	BIT[loc] += value;

	loc += loc & -loc;

	while(loc <= N){
		BIT[loc] += value;
		loc += loc & -loc;
	}
}

int getSum(int loc){

	int sum = BIT[loc];

	loc -= loc & -loc;

	while(loc > 0){
		sum += BIT[loc];
		loc -= loc & -loc;
	}
	return sum;
}

int calc(int left,int right){
	return getSum(right)-getSum(left-1);
}

int main(){

	int Q,command,left,right;
	scanf("%d %d",&N,&Q);

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

	for(int i = 0; i < Q; i++){

		scanf("%d %d %d",&command,&left,&right);

		if(command == 0){
			add(left,right);
		}else{
			printf("%d\n",calc(left,right));
		}
	}

	return 0;
}

Measured memory_bytes: 3020
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int W = sc.nextInt();
        int w[] = new int[n + 1];
        int v[] = new int[n + 1];
        for (int i = 1; i < n + 1; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        long dp[][] = new long[n + 1][W + 1];
        for (int i = 1; i < n + 1; i++) {
            for (int j = 1; j < W + 1; j++) {
                long tmp = 0;
                if (w[i] > j) {
                    tmp = dp[i - 1][j];
                } else {
                    if ((j - w[i]) < W + 1) {
                        // System.out.println(j - w[i]);
                        long before = dp[i - 1][j - w[i]];
                        tmp = before + v[i];
                    } else {
                        tmp = dp[i - 1][j];
                    }
                }
                dp[i][j] = Math.max(tmp, dp[i - 1][j]);
            }
        }
        long ans = 0;
        for (long i : dp[n]) {
            if (ans < i) {
                ans = i;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 126288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(void){
  int x,a,b; cin >> x >> a >> b;
  if(b-a<=0) cout << "delicious" << endl;
  else if(b-a<=x) cout << "safe" << endl;
  else cout << "dangerous" << endl;



}

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

#define INF 900000000
#define LINF 9000000000000000000

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

int n, m;
int d[101][101];
int a[1000], b[1000], c[1000];

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

	for (int i = 0; i < 101; i++) for (int j = 0; j < 101; j++) d[i][j] = (i==j?0:INF);

	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i] >> c[i]; a[i]--, b[i]--;
	}

	for (int i = 0; i < m; i++) {
		d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]);
		d[b[i]][a[i]] = min(d[b[i]][a[i]], c[i]);
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
			}
		}
	}

	int ans = m;
	for (int i = 0; i < m; i++) {
		bool srt = false;
		for (int j = 0; j < n; j++) if (d[j][a[i]]+c[i] == d[b[i]][j]) srt = true;
		if (srt) ans--;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		String[] cmd=s.split(" ");
		double a=Double.valueOf(cmd[0]);
		double b=Double.valueOf(cmd[1]);
		double c=Double.valueOf(cmd[2]);
		double d=Double.valueOf(cmd[3]);
		double x=((c*60+d)*6)%360;
		double y=c*30+(d*1.0)/2;
		double an=Math.abs(x-y);
		if(an>180)
			an=360-an;
		double a1=a*a+b*b;
		double a2=2*a*b;
		double a3=a1-a2*Math.cos((an*Math.PI)/180);
		System.out.println(Math.sqrt(a3));
	}

}


Measured memory_bytes: 33488
n = int(input())
s = input()
cnt = 0
for d in range((n-1)//2 + 1):
  for i in range(n-2*d):
    if s[i] != s[i+d] and s[i] != s[i+2*d] and s[i+d] != s[i+2*d]:
      cnt += 1
r_cnt = 0
g_cnt = 0
b_cnt = 0
for j in range(n):
  if s[j] == 'R':
    r_cnt += 1
  elif s[j] == 'G':
    g_cnt += 1
  elif s[j] == 'B':
    b_cnt += 1
ans = r_cnt * g_cnt * b_cnt - cnt
print(ans)

Measured memory_bytes: 9204
from sys import stdin

def main():
    N, M = map(int, input().split())
    A = [int(input()) for _ in [0] * M]

    stair = [0] * (N + 1)
    stair[0], stair[1] = 1, 1
    for a in A:
        stair[a] = -1

    mod = 1000000007
    for i in range(2, N + 1):
        if stair[i-1] == stair[i-2] == -1:
            print(0)
            return
        elif stair[i] == -1:
            continue
        if stair[i-1] > -1:
            stair[i] += stair[i-1]
        if stair[i-2] > -1:
            stair[i] += stair[i-2]
        stair[i] = stair[i] % mod
    print(stair[-1])

input = lambda: stdin.readline()
main()


Measured memory_bytes: 7848
#include<stdio.h>
#include<string.h>
int main(void)
{
	int len,slen,n,i,j,k,l,flg,flg2,cnt,xcnt=0;
	char s[26],str[100][101];
	scanf("%d",&n);
	scanf("%s",s);
	slen=strlen(s);
	for(i=0;i<n;i++){
		scanf("%s",str[i]);
	}
	for(i=0;i<n;i++){
		len=strlen(str[i]);
		flg=0;
		for(j=0;j<len;j++){
			for(k=1;k<len;k++){
				flg2=1; cnt=0;
				for(l=j;cnt<slen;l+=k){
					if(l>len){
						flg2=0;
						break;
					}
					if(s[cnt]!=str[i][l]){
						flg2=0;
						break;
					}
					cnt++;
				}
				if(flg2==1){
					flg=1;
					j=1000;
					k=1000;
					break;
				}
			}
		}
		if(flg==1){
			xcnt++;
		}
	}
	printf("%d\n",xcnt);
	return 0;
}

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

using namespace std;

int main(int argc,const char *argv[]){
  int n,m;
  cin >> n >> m;

  vector<int> va(m);
  int sum=0;
  for(int i=0;i<=m-1;i++){
    cin >> va[i];
    sum += va[i];
  }

  if(sum > n){
    cout << -1 << '\n';
  }else{
    cout << n - sum << '\n';
  }
  return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
     
     
typedef long long ll;
typedef vector <int> vi;
typedef pair <int,int> pi;
typedef tuple <int,int,int> ti;

#define forn(i,a,n) for(int i = a; i < n ; i++)
#define mem(str,a) memset(str, a, sizeof(str));
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(nullptr)
const int MOD = 1e9+7, N = 1e7 + 10, E = 1e-9;
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
//vector <int> show;
//for (auto x : show)
//   cout << x << " ";
getline(cin,s);


*/

int main() {
    int r,g,b;
    cin >> r >> g >> b;
    int num = r*100+g*10+b;
    if(num%4 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
ll n, m, a, r, c, h;
int main() {
	cin >> n;
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s[0] == 'M')m++;
		if (s[0] == 'A')a++;
		if (s[0] == 'R')r++;
		if (s[0] == 'C')c++;
		if (s[0] == 'H')h++;
	}
	ll ans = 0;
	ans += m * a * r;
	ans += m * a * c;
	ans += m * a * h;
	ans += m * r * c;
	ans += m * r * h;
	ans += m * c * h;
	ans += a * r * c;
	ans += a * r * h;
	ans += a * c * h;
	ans += r * c * h;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        String s = sc.nextLine();

        int min = Integer.MAX_VALUE;
        for (char ch = 'a'; ch <= 'z'; ++ch) {
            int cnt = 0;
            String ss = s;
            while (!check(ss)) {
                ss = operate(ss, ch);
                ++cnt;
            }
            if (cnt < min) {
                min = cnt;
            }
        }
        _out.println(min);
    }
    private String operate(String s, char ch) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length() - 1; ++i) {
            char ch1 = s.charAt(i);
            char ch2 = s.charAt(i + 1);
            if (ch2 == ch) {
                sb.append(ch2);
            } else {
                sb.append(ch1);
            }
        }
        return sb.toString();
    }
    private boolean check(String s) {
        for (int i = 1; i < s.length(); ++i) {
            if (s.charAt(0) != s.charAt(i)) {
                return false;
            }
        }
        return true;
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 24272
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll n; cin >> n;
    vector<ll> p(n), a(n), b(n), sum(n);

    ll count = 9e8;
    rep(i,n){
        cin >> p[i]; p[i]--;
        sum[p[i]] = count; count++;
    }

    a[0] = 1; b[0] = sum[0]-1;
    rep(i,n-1){
        if(sum[i+1] < sum[i]){ a[i+1] = a[i]+1; b[i+1] = sum[i+1]-a[i+1]; }
        else{ b[i+1] = b[i]-1; a[i+1] = sum[i+1]-b[i+1]; }
    }
    
    rep(i,n) cout << a[i] << " ";
    cout << endl;
    rep(i,n) cout << b[i] << " ";
    return 0;
}

Measured memory_bytes: 3816
n = int(input())

for _ in range(n):
    hh, mm = map(int, input().split(":"))
    short = mm / 60 * 360
    long = hh * 30 + (mm / 60 * 30)
    judge = min(abs(short - long), 360 - abs(short - long))

    if 0 <= judge < 30:
        print("alert")
    elif 30 <= judge < 90:
        print("warning")
    else:
        print("safe")



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;


int main(){
    string s;   cin >> s;
    int ans=s.size(), tc=0, sc=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='S') sc += 1;
        else if(0<sc && s[i]=='T'){
            tc += 1;
            int x = min(sc, tc);
            ans -= 2*x;
            sc -=x; tc -= x;
        }
    }
    
    //if(s.back()=='T') ans -= min(sc, tc)*2;
    cout << ans << endl;
}



Measured memory_bytes: 640
open Printf
open Scanf

let x = scanf "%d" (fun x -> x)

let rating x =
    if x < 600 then 8
    else if x < 800 then 7
    else if x < 1000 then 6
    else if x < 1200 then 5
    else if x < 1400 then 4
    else if x < 1600 then 3
    else if x < 1800 then 2
    else 1

let () = printf "%d\n" (rating x)

Measured memory_bytes: 3828
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    char s[n],t[n];
    scanf("%s%s",s,t);
    int i=0;
    while(s[i]!='\0')
    {
        printf("%c%c",s[i],t[i]);
        i++;
    }
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//1000000000

typedef struct {
    long long int A;
    long long int B;
} Array;
int main(int argc, const char * argv[]) {
    long long int N;
    scanf("%lld\n", &N);
    Array *array = malloc(sizeof(Array) * N);
    memset(array, 0, sizeof(array) * N);
    for(int i = 0; i < N; i++) {
        Array *a = array + i;
        scanf("%lld %lld", &(a->A), &(a->B));
    }
    
    long long int total = 0;
    long long int increase = 0;
    for (long long int i = N - 1; i >= 0; i--) {
        Array *a = array + i;
        long long int v = a->A + increase;
        long long int tmp = v / a->B;
        if(v % a->B > 0) {
            tmp++;
            
            tmp = tmp * a->B - v;
            total += tmp;
            
            increase += tmp;
        }
        
    }
    
    free(array);
    
    printf("%lld\n", total);
    return 0;
}


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

string s;
long long f(long long a){return a*(a+1)/2;}
int main(){
  cin>>s;
  long long cnt[26]={};
  for(int i=0;i<s.length();++i){
    cnt[s[i]-'a']++;
  }
  long long ans=f((long long)s.length())+1;
  for(int i=0;i<26;++i){
    ans-=f(cnt[i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640