akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define MOD 1000000007
#define ll long long

int cmpfunc(const void *a, const void *b){
    return *(int *)b - *(int *)a;
}

int main(int argc, char **argv){
    int n,k;
    scanf("%d %d",&n,&k);
    int l[n];
    int i;
    for(i=0;i<n;i++) scanf("%d",&l[i]);
    qsort(l,n,sizeof(int),cmpfunc);
    int ans=0;
    for(i=0;i<k;i++) ans+=l[i];
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>
#include <map>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1e9+7;

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

	REP(i, n)cin >> p[i];

	int ans = 0;
	FOR(i, 1, n - 1) {
		if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1]))
			ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    if(A.at(i)%2==0&&A.at(i)%3!=0&&A.at(i)%5!=0){
      cout<<"DENIED"<<endl;
      return 0;
    }
  }
  cout<<"APPROVED"<<endl;
}
      


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int P[30000];
ll A[30000];
ll B[30000];

int main(){
    int N;
    cin >> N;
    REP(i,N){
        int p;
        cin >> p;
        P[i] = p;
    }

    for(int i = 0; i < N; i++){
        A[i] = N*(i+1);
        B[i] = N*(N+1-i);
    }

    for(int i = 0; i < N; i++){
        int p = P[i];
        p--;
        A[p] += i;
    }

    REP(i,N){
        cout << A[i] << " ";
    }
    cout << endl;
    REP(i,N){
        cout << B[i] << " ";
    }
    cout << endl;
    return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define MAX 1000000


ll  fastpower(ll a, ll n)
{
	ll res = 1;
	while(n > 0)
	{
		if(n % 2 != 0)
		{
			res = (res * a) % MOD;
		}
		n /= 2;
		a=(a * a) % MOD;
	}
	return res;
}

void getprime(vector<bool>&prime)
{
	prime[0] = false;
	prime[1] = false;
	
	for(ll i = 2;i <= MAX; i++)
	{
		if(prime[i])
		{
			for(ll j = i*i; j <= MAX; j += i)
				prime[j] = false;
		}
	}
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
	fact[0] = 1;
	ifact[0] = 1;
	
	for(ll i = 1; i <= MAX; i++)
	{
		fact[i] = (fact[i-1] * i)%MOD;
		ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t,n,k,q;
	//cin>>t;
  	vector<ll>fact(MAX+1),ifact(MAX+1);
  	getfact(fact, ifact);
	//while(t--)
	{
      ll r,c,x,y;
      cin>>r>>c>>n;
      ll total = ((fact[r+c-2] * ifact[r-1])%MOD * ifact[c-1])%MOD;
      vector< pair< ll, ll > >wall;
      for(ll i=0;i<n;i++)
      {  
        cin>>x>>y;
        wall.push_back({x, y});
      }
      //wall.push_back({1, 1});
      //wall.push_back({r, c});
      sort(all(wall));
      //n += 2;
      vector<ll>dp(n);
      for(ll i=0;i<n;i++)
      {
        x = wall[i].first;
        y = wall[i].second;
        
        ll left = ((fact[x+y-2] * ifact[x-1])%MOD * ifact[y-1])%MOD;
        ll mid = 0;
        for(ll j=0;j<i;j++)
        {
          if(wall[i].first >= wall[j].first && wall[i].second >= wall[j].second)
          {
            ll dx = wall[i].first - wall[j].first;
            ll dy = wall[i].second - wall[j].second;
            
            ll rt = ((fact[dx+dy] * ifact[dx])%MOD * ifact[dy])%MOD;
            
            mid = (mid + (dp[j]*rt)%MOD)%MOD;
          }
        }
        left = (left - mid + MOD)%MOD;
        
        dp[i] = left;
        ll right = ((fact[r+c-x-y] * ifact[r-x])%MOD * ifact[c-y])%MOD;
        total = (total - (left * right)%MOD + MOD)%MOD;
      }
      cout << total <<"\n";

	}
	
	return 0;
}

Measured memory_bytes: 16000
#include <cstdio>
#include <set>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

char buf[10];
int main(void) {
  int n;
  scanf("%d", &n);
  set<char> s;
  bool four = false;
  REP(i, n) {
    scanf("%s", buf);
    four = four || buf[0] == 'Y';
  }
  puts(four ? "Four" : "Three");
  return 0;
}


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

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
//#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  int n;
  cin >> n;
  vi p(n);
  int ma = 0, sum = 0;
  rep (i, n) {
    cin >> p[i];
    chmax(ma, p[i]);
    sum += p[i];
  }

  if (ma < sum - ma) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
string s,t="AKIHABARA";
int i,j;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>s;
	for(i=0;i<9;i++)
	{
		if(j<s.size() && s[j]==t[i])j++;
		else if(t[i]!='A')rc("NO");
	}
	if(j!=s.size())rc("NO");
	rc("YES");
}

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

typedef long long ll;
const int INF = 1e+9;

int main() {
	int n, d, ans = 0;
	double sum = 0;
	cin >> n >> d;
	vector<vector<int>> x(n, vector<int>(d));
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < d; ++j)
			cin >> x[i][j];
	for (int i = 0; i < n; ++i) {
		for (int j = 1; i + j < n; ++j) {
			sum = 0;
			for (int k = 0; k < d; ++k) {
				sum += pow(x[i][k] - x[i + j][k], 2);
			}
			sum = sqrt(sum);
			if (ceil(sum) == floor(sum)) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''
#import copy
n, a, b = map(int, input().split())

if a % 2 == b % 2 == 0 or a % 2 == b % 2 == 1:
    print((b-a)//2)
else:
    print(min(a-1,n-b)+(b-a)//2+1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LL long long
using namespace std;
vector<int> g[100005];
vector<int> ans;
bool visited[100005] = {false};
int dist[100005] = {0};
void topo(int s)
{
  visited[s] = true;
  for (int i = 0; i < g[s].size(); ++i)
    if (!visited[g[s][i]])
      topo(g[s][i]);
  ans.push_back(s);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int N, M;
  cin >> N >> M;
  int a, b;
  for (int i = 0; i < M; ++i)
    {
      cin >> a >> b;
      g[a - 1].push_back(b - 1);
    }
  for (int i = 0; i < N; ++i)
    if (!visited[i])
      topo(i);
  reverse(ans.begin(), ans.end());
  int maxx = 0;
  for (int i = 0; i < ans.size(); ++i)
    {
      //cout << ans[i] << " ";
      int v = ans[i];
      for (int j = 0; j < g[v].size(); ++j)
        {
          int w = g[v][j];
          dist[w] = max(dist[w], dist[v] + 1);
        }
    }
  for (int i = 0; i < N; ++i) maxx = max(maxx, dist[i]);
  cout << maxx << endl;
  return 0;
}


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

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

    priority_queue<int> Aque;
    int val;
    for(int i=0; i<N; i++){
        cin >> val;
        Aque.push(val);
    }
    int max_val = Aque.top();
    
    priority_queue<int> DistanceQue;
    while (Aque.size() > 1){
        int val1 = Aque.top();Aque.pop();
        int val2 = Aque.top();
        DistanceQue.push(val1 - val2);
    }

    int minVal = Aque.top();
    DistanceQue.push(K-max_val+minVal);
    DistanceQue.pop();

    int ans = 0;
    while(!DistanceQue.empty()){
        int val1 = DistanceQue.top();DistanceQue.pop();
        ans += val1;
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 5632
package main

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

func fiveDishes(ar []int32) int32 {
    sum := int32(0)
    minRem := int32(10)
    for i := 0; i < 5; i++ {
        rem := ar[i] % 10
        sum += ar[i] - rem
        if (rem > 0) {
            sum += 10
            if minRem > rem {
                minRem = rem
            }
        }
    }
    if minRem < 10 {
        sum += minRem - 10
    }
    return sum
}

func main() {
    reader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)

    var ar = make([]int32, 5)
    for i, _ := range(ar) {
        item, err := strconv.ParseInt(readLine(reader), 10, 32)
        checkError(err)
        ar[i] = int32(item)
    }

    res := fiveDishes(ar)
    fmt.Println(res)
}

func readLine(reader *bufio.Reader) string {
    str, _, err := reader.ReadLine()
    if err == io.EOF {
        return ""
    }

    return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
    if err != nil {
        panic(err)
    }
}

Measured memory_bytes: 640
import sys
import math
import collections
from collections import deque
import heapq
n = int(input())
#n, k = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

a = 0
for i in range(1, n+1):
    if i % 3 == 0:
        continue
    if i % 5 == 0:
        continue

    a += i

print(a)




    


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

int main(void)
{
    using namespace std;
    char ch;

    int a[26] = {0};

    while (cin >> ch) {
        int j1 = ch - 'a';
        int j2 = ch - 'A';
        if (0 <= j1 && j1 < 27) {
            a[j1]++;
        }
        if (0 <= j2 && j2 < 27) {
            a[j2]++;
        }
    }

    for (int i = 0; i < 26; i++) {
        printf("%c : %d\n", 'a' + i, a[i]);
    }
    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define ll long long int
#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define test() ll tc;cin>>tc;while(tc--)
using namespace std;
int mod=1e9+7;  ///A simpler way to write 1,000,000,007

int main()
{
    int n,k;
    cin >> n >> k;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    int dp[n+1][k+1];
    dp[0][0]=1;
    for(int i=1;i<=k;i++)  /// Set the initial values
    {
        dp[0][i]=0;
    }
    for(int i=1;i<=n;i++)
    {
        int sums[k+1];
        sums[0]=dp[i-1][0];
        for(int j=1;j<=k;j++)
        {
            sums[j]=(sums[j-1]+dp[i-1][j])%mod;  ///Calculate the prefix sums for i-1
        }
        for(int j=0;j<=k;j++)
        {
            int tr=sums[j];  ///Sum of dp[i-1][0...j]
            int unreachable=j-a[i]-1;  ///We need to subtract the sum of the first "unreachable" elements (dp[i-1][0...unreachable])

            if(unreachable>=0)
            {
                tr=(tr-sums[unreachable]+mod)%mod;  ///Add mod to make sure that "tr-sums[unreachable]" is not negative.
            }
            dp[i][j]=tr;
        }
    }

  	cout << dp[n][k];
    return 0;
}


Measured memory_bytes: 40064
#include<stdio.h> 
int main(void)
{
	double i,N,s;
	double t=0;
	scanf("%lf",&N);
	for(i=1;i<=N;i+=2.0){
		t+=1.0;
	} 
	s=t/N;
	printf("%.10f",s);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  string str;
  cin>>str;
  int flag=1;
  int cnt=1;
  for(int i=1;i<4;i++){
    if(str[i]==str[i-1]){
      cnt++;
    }else{
      cnt=1;
    }
    if(cnt>=3){
      cout<<"Yes"<<endl;
      flag=0;
      break;
    }
  }
  if(flag)
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.* ;

import java.util.* ;

public class Main {

	static FastReaderR in = new FastReaderR(System.in) ;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try{
			int N = in.nextInt() ;
			int K = in.nextInt() ;
			if(N/K!=0)
				System.out.println(N-K+1);
			else
				System.out.println("0");
		}catch(Exception e){
			System.exit(0) ;
		}
	}

}

class FastReaderR {
    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;
 
    FastReaderR(InputStream is) {
        in = is;
    }
    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }
    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan());
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan());
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }
}



Measured memory_bytes: 22612
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 = new int[N];
		
		for(int i = 0; i < N; i++) {
			int x = sc.nextInt();
			if(i > 0) {
				W[i] = W[i - 1] + x;
			} else {
				W[i] = x;
			}
		}
		
		int ans = 100000;
		
		for(int i = 0; i < N - 1; i++) {
			ans = Math.min(ans, Math.abs(W[N - 1] - 2 * W[i]));
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 22100
"""
x -> y -> x^y ->
x -> y -> x^y

3つ周期。
N%3 != 0 x=y=x^yなので、全部0
N%3 == 0 x,y,x^yが同数存在
"""

N = int(input())
As = list(map(int, input().split()))
numset = sorted(list(set(As)))
n = len(numset)
if n == 1:
    if sum(As) == 0: print("Yes")
    else:print("No")
elif n == 2:
    n1 = As.count(numset[0])
    n2 = As.count(numset[1])
    if 2*n1 == n2 and numset[0] == 0: print("Yes")
    else:print("No")
elif n == 3:
    n1 = As.count(numset[0])
    n2 = As.count(numset[1])
    n3 = As.count(numset[2])
    if n1 == n2 == n3 and (numset[0]^numset[1]^numset[2])==0: print("Yes")
    else: print("No")
else:
    print("No")

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

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

    int A;
    set<int> number;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        if (number.count(A) > 0)
        {
            number.erase(A);
        }
        else
        {
            number.insert(A);
        }
    }
    cout << number.size() << endl;
}


Measured memory_bytes: 4864
import sys

N, Y = map(int,input().split())

for x in range(N+1):
    for y in range(N+1-x):
        z = N - (x + y)
        if (x*10000 + y*5000 + z*1000) == Y:
            print(x,y,z)
            sys.exit()

print(-1,-1,-1)


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

using namespace std;
int main() {
  int a, b, k;
  cin >> a >> b >> k;
  int lower = a+k;
  int upper = b-k;

  for (int i = a; i <= b; i++) {
    if (i < lower) cout << i << endl;
    else if (upper < i) cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int a[200005],sum[200005];
int main()
{
	map<unsigned long long int ,long long int >mp;
	int n,k;
	long long int ans=0;
	cin>>n>>k;
	sum[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
	}
	for(int i=0;i<=n;i++)
	{
		if(i>=k) {
			mp[(sum[i-k]-(i-k))%k]--;
		} 
		if(mp.count((sum[i]-i)%k))
		{
		ans+=mp[(sum[i]-i)%k];
	    }
		mp[(sum[i]-i)%k]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15872
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  int N, X;
  cin >> N >> X;
  vl x(N);
  rep(i, N) cin >> x[i];
  if (N == 1) {
    cout << abs(x[0] - X) << endl;
    return 0;
  }
  ll ans = __gcd(abs(x[0] - X), abs(x[1] - X));
  for (int i = 2; i < N; i++) {
    ans = __gcd(ans, abs(x[i] - X));
  }
  cout << ans << endl;
  return 0;
}


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

int main () {
  int n, a;
  string ans = "APPROVED";
  cin >> n;
  
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a%2 == 1) {
      continue;
    }
    if (a%3== 0 || a%5 == 0) {
      continue;
    }
    ans = "DENIED";
    break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> c(n - 1), s(n - 1), f(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> c[i];
    cin >> s[i];
    cin >> f[i];
  }
  for (int i = 0; i < n; i++) {
    int t = 0;
    for (int j = i; j < n - 1; j++) {
      t = max(((t - 1) / f[j] + 1) * f[j], s[j]);
      t += c[j];
    }
    cout << t << endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class C
{
	static void Main()
	{
		Console.ReadLine();
		string s = Console.ReadLine(), t;

		foreach (var c in s.Distinct())
			for (; (t = s.Replace($"{c}{c}", $"{c}")) != s; s = t) ;
		Console.WriteLine(s.Length);
	}
}


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

#define all(x) (x).begin(), (x).end()
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)

template<class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}



void _main() {
        int sum = 0;
        int n; cin >> n;
        map<int, int> freq;
        while (n--) {
                int a; cin >> a;
                freq[a]++;
                sum += a;
        }

        int q; cin >> q;
        while (q--) {
                int b, c; cin >> b >> c;
                sum -= freq[b] * b + freq[c] * c;
                freq[c] += freq[b];
                freq[b] = 0;
                sum += c * freq[c];
                cout << sum << '\n';
        }
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

char s[252521];
int it;

pii f_or();
pii f_and();
pii f_term();

pii f_or(){
    pii v = f_and();
    pii ret(-1, v.second);
    int sum = v.first;
    while(s[it]=='|'){
        it++;
        pii v = f_and();
        CHMIN(ret.second, sum+v.second);
        sum += v.first;
    }
    ret.first = sum;
    return ret;
}
pii f_and(){
    pii v = f_term();
    pii ret(v.first, -1);
    int sum = v.second;
    while(s[it]=='&'){
        it++;
        pii v = f_term();
        CHMIN(ret.first, sum+v.first);
        sum += v.second;
    }
    ret.second = sum;
    return ret;
}
pii f_term(){
    if(s[it]=='('){
        it++;
        pii ret = f_or();
        it++;
        return ret;
    }else{
        it++;
        return pii(1,1);
    }
}

int main(){
    scanf("%s",s);
    it = 0;
    pii ans = f_or();
    printf("%d %d\n",ans.first,ans.second);
    return 0;
}



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

const int N = 100010;

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

    int t[N], x[N], y[N];
    for (int i = 0; i < n; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }

    int old_t, old_x, old_y;
    old_t = old_x = old_y = 0;
    bool can = true;
    for (int i = 0; i < n; i++) {
        int diff_t = t[i] - old_t;
        int abs_diff_x = x[i] - old_x;
        int abs_diff_y = y[i] - old_y;
        int abs_diff_xy = abs_diff_x + abs_diff_y;

        if (diff_t < abs_diff_xy) {
            can = false;
            break;
        } else {
            if ((diff_t % 2 == 0 && abs_diff_xy % 2 == 1) ||
                (diff_t % 2 == 1 && abs_diff_xy % 2 == 0)) {
                can = false;
                break;
            }
        }
    }

    if (can) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll k,n;
  cin >> n >> k;
  ll a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  sort(a,a+n);
  ll ans=0;
  for(int i=0;i<n-k;i++) ans+=a[i];
  cout << ans;
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int ds = 0;
  int n;
  int i;

  while ( scanf ( "%d", &n ) == 1 )
  {
    const int d[ 5 ]
      = { ( n / 10000 ) % 10, ( n / 1000 ) % 10
        , ( n / 100 ) % 10, ( n / 10 ) % 10, n % 10 };
    const int e[ 5 ]
      = { ( n / 10000 ) % 5, ( n / 1000 ) % 5
        , ( n / 100 ) % 5, ( n / 10 ) % 5, n % 5 };

    if ( ds ) puts ( "" );

    for ( i = 0; i < 5; ++i ) putchar ( d[ i ] >= 5 ? ' ' : '*' );
    puts ( "" );
    for ( i = 0; i < 5; ++i ) putchar ( d[ i ] >= 5 ? '*' : ' ' );
    puts ( "" );
    puts ( "=====" );
    for ( i = 0; i < 5; ++i ) putchar ( e[ i ] >= 1 ? '*' : ' ' );
    puts ( "" );
    for ( i = 0; i < 5; ++i ) putchar ( e[ i ] == 1 ? ' ' : '*' );
    puts ( "" );
    for ( i = 0; i < 5; ++i ) putchar ( e[ i ] == 2 ? ' ' : '*' );
    puts ( "" );
    for ( i = 0; i < 5; ++i ) putchar ( e[ i ] == 3 ? ' ' : '*' );
    puts ( "" );
    for ( i = 0; i < 5; ++i ) putchar ( e[ i ] == 4 ? ' ' : '*' );
    puts ( "" );

    ++ds;
  }

  return ( 0 );
}

Measured memory_bytes: 0
def d_equals(N, M, P, S):
    class UnionFind(object):
        def __init__(self, N):
            self.p = list(range(N))  # 初期状態ではi番の頂点の親(parent)はi番
            self.rank = [0] * N  # 初期状態では全頂点がランク0(何もつながってない)
            self.size = [1] * N  # 初期状態ではどの頂点も連結成分の大きさは1

        def find(self, x):  # 頂点xが属する連結成分の代表(根の番号)を求める
            if self.p[x] != x:  # 頂点xの代表は他の頂点だった
                self.p[x] = self.find(self.p[x])  # 経路圧縮(xを代表につなぐ)
            return self.p[x]

        def is_same(self, x, y):  # 頂点x,yは同じ連結成分に属するか？
            return self.find(x) == self.find(y)

        def union(self, x, y):  # x,yを同じ連結成分に属させる
            u = self.find(x)
            v = self.find(y)
            if u == v:  # x,yは既に同じ連結成分に属していた
                return
            if self.rank[u] < self.rank[v]:
                self.p[u] = v  # ランクの大きな方につなげる
                self.size[v] += self.size[u]  # つながっている要素数だけ足す
                self.size[u] = 0  # ランクが小さかった連結成分は「解散」
            else:
                # 上と同様にやる
                self.p[v] = u
                self.size[u] += self.size[v]
                self.size[v] = 0
                if self.rank[u] == self.rank[v]:
                    # 根の分だけ1個「ずれる」
                    self.rank[u] += 1

    ans = 0
    uf = UnionFind(N)
    for a, b in S:
        uf.union(a - 1, b - 1)  # Pのa番とb番は繋がっている(0-indexed)
    for i in range(N):
        if uf.is_same(P[i] - 1, i):
            # 2つが同じ連結成分にあるなら、何回かswapしてp_i=iにできる
            # 最初からp_i=iの場合、unionしてなくてもこの条件は成立
            ans += 1
    return ans

N,M = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
S = [[int(i) for i in input().split()] for j in range(M)]
print(d_equals(N, M, P, S))

Measured memory_bytes: 30672
#include <bits/stdc++.h>
using namespace std;
using u64 = uint64_t;

int main() {
	u64 N;
	u64 A, B, C;
	cin >> N >> A >> B >> C;

	vector<string> S(N);
	for(u64 i=0; i<N; i++) cin >> S[i];

	vector<char> co(N);

	for(u64 i=0; i<N; i++) {
		if(S[i] == "AC") {
			if(A == 0 && C == 0) {
				cout << "No" << endl;
				return 0;
			} else if(A > C) {
				A--; C++; co[i] = 'C';
			} else if(C > A) {
				A++; C--; co[i] = 'A';
			} else if(i < N - 1 && S[i+1] == "BC") {
				A--; C++; co[i] = 'C';
			} else {
				A++; C--; co[i] = 'A';
			}
		} else if(S[i] == "AB") {
			if(A == 0 && B == 0) {
				cout << "No" << endl;
				return 0;
			} else if(A > B) {
				A--; B++; co[i] = 'B';
			} else if(B > A) {
				A++; B--; co[i] = 'A';
			} else if(i < N - 1 && S[i+1] == "AC") {
				A++; B--; co[i] = 'A';
			} else {
				A--; B++; co[i] = 'B';
			}
		} else {
			if(B == 0 && C == 0) {
				cout << "No" << endl;
				return 0;
			} else if(B > C) {
				B--; C++; co[i] = 'C';
			} else if(C > B) {
				B++; C--; co[i] = 'B';
			} else if(i < N - 1 && S[i+1] == "AB") {
				B++; C--; co[i] = 'B';
			} else {
				B--; C++; co[i] = 'C';
			}
		}
	}
	

	cout << "Yes" << endl;
	for(u64 i=0; i<N; i++) {
		//cout << co[i] << ":" << ABC[0][i] << " " << ABC[1][i] << " " << ABC[2][i] << endl;
		cout << co[i] << endl;
	}
	return 0;
	
}


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

int main(){
  string S;
  string T;
  string Temp;
  cin >>S>>T;
  Temp=S;
  for (int i=0;i<S.length();i++){

    for(int j=0;j<S.length();j++){
      
      S.at(j)=Temp.at((j+i)%(S.length()));
      
    }
    if(S==T){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
}; 

int main(){
    Stream io;
    
    string S;
    ll K;
    io.read(S, K);
    int len1 = 0;
    while(S[len1] == '1') len1++;
    char ans = S[0];
    if(len1 > 0 && K > len1) ans = S[len1];
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int a,b;
	std::cin >> a >> b;
	int ans;
	if (a >= 13)
		ans = b;
	else if (a >= 6 && a <= 12)
		ans = b / 2;
	else
		ans = 0;
	std::cout << ans << '\n';
}

Measured memory_bytes: 256
r1, c1, r2, c2 = map(int, input().split())

#############

mod = 10**9 + 7
max = 3 * 10**6
fac, finv, inv = [0]*max, [0]*max, [0]*max

def comInit(max):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( (n<0) | (k < 0)):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

#############
ans = (com(r2+c2+2,r2+1) - com(r2+c1+1, c1) - com(r1+c2+1, r1) + com(r1+c1, r1)) % mod

print(ans)

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

int main() {
    int n, a, b, maxv, minv;
    cin >> n >> a >> b;
    if (a + b < n)
    {
        minv = 0;
    }
    else if (a + b >= n)
    {
        minv = a + b - n;
    }
    maxv = min(a, b);
    cout << maxv << " " << minv << endl;
    
}

Measured memory_bytes: 256
//
//  4.cpp
//  Algorithms and Data Structures
//
//  Created by kawauso on 2018/04/06.
//

#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <sstream>

void c_4_2() {
	std::string line;
	std::string s;

	// input
	std::getline(std::cin, line);
	std::istringstream iss(line);
	std::vector<std::string> a;
	while (iss >> s) {
		if (s == "+") {
			const auto result = std::stoi(a[1]) + std::stoi(a[0]);
			a.erase(a.begin(), a.begin() + 2);
			a.insert(a.begin(), std::to_string(result));
		} else if (s == "-") {
			const auto result = std::stoi(a[1]) - std::stoi(a[0]);
			a.erase(a.begin(), a.begin() + 2);
			a.insert(a.begin(), std::to_string(result));
		} else if (s == "*") {
			const auto result = std::stoi(a[1]) * std::stoi(a[0]);
			a.erase(a.begin(), a.begin() + 2);
			a.insert(a.begin(), std::to_string(result));
		} else {
			a.insert(a.begin(), s);
		}
	}
	std::cout << a[0] << std::endl;
}

int main(int argc, const char * argv[]) {
	std::ios::sync_with_stdio(false);
	c_4_2();
	return 0;
}



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

int main(){

	int a,b,c,count=0;

	cin >> a >> b >> c;

	//for?????§a??????b?????§??????
	//????????°??????c????´???°???????????????????????????
	//c????´???°??§???????????¶????????£????????????0

	for (; a <= b; a++){

		if (c%a == 0){
			count++;
		}

	}
	cout << count << endl;


	return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	string S;
	cin >> S;
	for(int i=1;i<S.size();++i)
	if (S[i-1] == 'A'&&S[i] == 'C') {
		cout << "Yes\n"; return 0;
	}
	cout << "No\n";
	return 0;
}



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

struct StList
{
  int  m_iKey;
  StList *m_poPrev;
  StList *m_poNext;
  
  StList() :
    m_iKey(0), m_poPrev(nullptr), m_poNext(nullptr)
  { }

  StList(int a_iNumber, StList &a_roHead) :
    m_iKey(a_iNumber), m_poPrev(&a_roHead), m_poNext(a_roHead.m_poNext)
  { }

  ~StList() { }
};

void fnLinkedListSet(StList &a_roHead, StList &a_roTrail)
{
  char acCommand[80];
  int iMaxCommand, iNumber;

  cin >> iMaxCommand;
  for (int i = 0; i < iMaxCommand; i++)
  {
    cin >> acCommand;
    if (acCommand[0] == 'i')
    {
      cin >> iNumber;
      StList *poList = new StList(iNumber, a_roHead);
      a_roHead.m_poNext->m_poPrev = poList;
      a_roHead.m_poNext = poList;
    }
    else if (acCommand[6] == 'F')
    {
      StList *poList = a_roHead.m_poNext;
      if (poList != &a_roTrail)
      {
        poList->m_poNext->m_poPrev = poList->m_poPrev;
        a_roHead.m_poNext          = poList->m_poNext;
        delete poList;
      }
    }
    else if (acCommand[6] == 'L')
    {
      StList *poList = a_roTrail.m_poPrev;
      if (poList != &a_roHead)
      {
        a_roTrail.m_poPrev         = poList->m_poPrev;
        poList->m_poPrev->m_poNext = poList->m_poNext;
        delete poList;
      }
    }
    else if (acCommand[0] == 'd')
    {
      cin >> iNumber;
      StList *poList = a_roHead.m_poNext;
      while (poList != &a_roTrail)
      {
        if (poList->m_iKey == iNumber)
        {
          poList->m_poNext->m_poPrev = poList->m_poPrev;     
          poList->m_poPrev->m_poNext = poList->m_poNext;
          delete poList;
          break;
        }
        poList = poList->m_poNext;
      }
    }
  }
}

void fnLinkedListGet(StList &a_roHead, StList &a_roTrail)
{
  StList *poList = a_roHead.m_poNext;
  while (poList != &a_roTrail)
  {
    if (poList != a_roHead.m_poNext) cout << " ";
    cout << poList->m_iKey;
    poList = poList->m_poNext;
    delete poList->m_poPrev;
  }
  cout << endl;
}

int main()
{
  StList oHead, oTrail;
  oHead.m_poNext  = &oTrail;
  oTrail.m_poPrev = &oHead;
 
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  fnLinkedListSet(oHead, oTrail);
  fnLinkedListGet(oHead, oTrail);

  return 0;
}

Measured memory_bytes: 32460
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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


    int K; cin >> K;

    vvi es(K);
    map<pii, int> cost;
    REP(i,K) {
        int j = (i + 1) % K;
        es[i].push_back(j);
        cost[pii(i, j)] = 1;
        int k = (i * 10) % K;
        es[i].push_back(k);
        cost[pii(i, k)] = 0;
    }

    deque<int> dq;
    dq.push_back(1);
    vi dist(K, INF);
    dist[1] = 0;
    vb vis(K, false);
    while(!dq.empty()) {
        int x = dq.front(); dq.pop_front();
        vis[x] = true;

        for(int nx : es[x]) {
            if (vis[nx]) continue;

            if (cost[pii(x,nx)]==0) {
                dq.push_front(nx);
                dist[nx] = dist[x];
            } else if (cost[pii(x,nx)]==1) {
                dq.push_back(nx);
                dist[nx] = dist[x] + 1;
            }
        }
    }

    int ans = dist[0] + 1;
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 18944
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

#define int long long
#define ll long long
#define double long double
#define pii pair<int, int>
#define vec vector
#define u_map unordered_map
#define u_set unordered_set
#define str string
#define all(el) el.begin(), el.end()
#define allr(el) el.rbegin(), el.rend()
#define sz(el) (int)el.size()
#define f first
#define s second
#define pb push_back
#define in insert
#define mp make_pair
#define endl "\n"
#define forn(i, n) for (int i = 0; i < n; ++i)

inline int maxi(int &a, int b) { if (b > a) { a = b; return 1; } return 0; }

inline int mini(int &a, int b) { if (b < a) { a = b; return 1; } return 0; }

inline int maxi(double &a, double b) { if (b > a) { a = b; return 1; } return 0; }

inline int mini(double &a, double b) { if (b < a) { a = b; return 1; } return 0; }

struct st {
    int size;
    vec<int> t;
    st() {
        size = 0;
        t.assign(0, 0);
    }
    void upd(int i, int l, int r, int pos, int val) {
        if (pos >= r || pos < l) {
            return;
        }
        if (r - l == 1) {
            t[i] = val;
            return;
        }
        int mid = (l + r) / 2;
        upd(i * 2 + 1, l, mid, pos, val);
        upd(i * 2 + 2, mid, r, pos, val);
        t[i] = max(t[i * 2 + 1], t[i * 2 + 2]);
    }
    int get(int i, int l, int r, int qL, int qR) {
        if (r <= qL || l >= qR) {
            return -1e18;
        }
        if (l >= qL && r <= qR) {
            return t[i];
        }
        int mid = (l + r) / 2;
        return max(get(i * 2 + 1, l, mid, qL, qR), get(i * 2 + 2, mid, r, qL, qR));
    }
};

st hv[26];

signed main() {

    int n;
    str s;
    int q;
    cin >> n >> s >> q;

    for (int i = 0; i < 26; i++) {
        hv[i].size = 4 * n;
        hv[i].t.assign(4 * n, 0);
    }

    for (int i = 0; i < n; i++) {
        int num = s[i] - 'a';
        hv[num].upd(0, 0, n, i, 1);
    }

    for (int i = 0; i < q; i++) {
        int type;
        cin >> type;
        if (type == 1) {
            int ind;
            char nchar;
            cin >> ind >> nchar;
            ind--;
            int num = nchar - 'a';
            int prev_num = s[ind] - 'a';
            s[ind] = nchar;
            hv[prev_num].upd(0, 0, n, ind, 0);
            hv[num].upd(0, 0, n, ind, 1);
        } else {
//            cout << s << endl;
            int l, r;
            cin >> l >> r;
            l--;
            int ans = 0;
            for (int i = 0; i < 26; i++) {
                ans += hv[i].get(0, 0, n, l, r);
            }
            cout << ans << endl;
        }
    }

    return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<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; }

const int maxV = 211111;
vector<int> G[maxV]; // 頂点情報のみのグラフ

// treeDFS(親, 現在地, 根から現在地までの距離, 根からの最大の距離, 根から最大の距離となる頂点
void treeDFS(int from, int current, int dist, int &maxDist, int &maxVertex) {
    // 距離と終点を更新
    if (dist > maxDist) {
        maxDist = dist;
        maxVertex = current;
    }

    for (auto to : G[current]) {
        // 逆流を防ぐ
        if (to == from) continue;
        treeDFS(current, to, dist + 1, maxDist, maxVertex);
    }
}

lli getTreeDiameter() {
    int start = 0, end = 0, maxDist = 0;
    treeDFS(-1, start, 0, maxDist, end);
    start = end, end = 0, maxDist = 0;
    treeDFS(-1, start, 0, maxDist, end);
    return maxDist;
}

void func(long long N, std::vector<long long> a, std::vector<long long> b){

    lli dia = getTreeDiameter();
    dia++;
    LOG(dia);
    if(dia==1){
        cout<<"First"<<endl;
    }
    else if(dia==2){
        cout<<"Second"<<endl;
    }
    else if(dia%3==2){
        cout<<"Second"<<endl;
    }
    else{
        cout<<"First"<<endl;
    }
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        a[i]--,b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    func(N, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 30208
import java.util.*;
import java.math.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String ans = "";
    String s = String.valueOf(N);
    for(int i=0;i<s.length();i++) {
      if(s.charAt(i)=='1') ans = ans+'9';
      if(s.charAt(i) == '9') ans = ans+'1';
      
    }
    System.out.println(ans);
    }
  }


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int dp[3300][3300];
string s;
string t;



int main()
{
    cin >> s;
    cin >> t;
    rep(i,s.size()+1)rep(j,t.size()+1){
        if(i == 0 || j == 0)continue;
        if(s[i-1] == t[j-1])dp[i][j] = dp[i-1][j-1] +1;
        else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);

    }
    int i = s.size();
    int j = t.size();
    string ans = "";
    while(i > 0 && j > 0){
        if(s[i-1] == t[j-1]){
            ans = s[i-1]+ans;
            i--;
            j--;
        }
        else if(dp[i-1][j] >= dp[i][j-1])i--;
        else j--;
    }
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 39168
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

void enq(P x);
P deq(void);
int min(int ,int);

P Q[LEN];
int head,tail,n;

void enq(P x)
{
  Q[tail]=x;
  tail=(tail+1)%LEN;
}
P deq()
{
  P x = Q[head];
  head=(head+1)%LEN;
  return x;
}
int min(int a,int b)
{
  if(a<b)return a;
  else return b;
}

int main(){
  int elaps=0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);
  for(i=1;i<=n;i++)
    {
      scanf("%s",Q[i].name);
      scanf("%d",&Q[i].t);
    }
  head=1; tail=n+1;

  while( head != tail )
    {
      u=deq();
      c=min(q,u.t);
      u.t -= c;
      elaps += c;
      if(u.t>0)enq(u);
      else{
        printf("%s %d\n",u.name,elaps);
      }
    }
  return 0;
}



Measured memory_bytes: 11864
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ps = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();

		for (var i = 0; i <= 100; i++)
			for (var j = 0; j <= 100; j++)
			{
				var p0 = ps.First(p => p[2] != 0);
				var h = Math.Abs(i - p0[0]) + Math.Abs(j - p0[1]) + p0[2];
				if (ps.All(p => p[2] == Math.Max(h - Math.Abs(i - p[0]) - Math.Abs(j - p[1]), 0))) { Console.WriteLine($"{i} {j} {h}"); return; }
			}
	}
}


Measured memory_bytes: 13652
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int count = 0;
		String S = sc.next();  
        String T = sc.next();  
        String[] SS = S.split("");
        String[] TT = T.split(""); 
        for (int i = 0; i < SS.length; i++) {
          if(!SS[i].equals(TT[i])){
            SS[i] = TT[i];
            count = count + 1;
          }
        }
        
		System.out.println(count);
	}
}

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

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")



using namespace std;

int main()
{
    int a;
    string s;
    cin>>a;
    cin>>s;
    if(a>=3200)
        cout<<s<<'\n';
    else
        cout<<"red"<<'\n';
    return 0;
}


Measured memory_bytes: 256
import math
K, A, B = map(int, input().split())
ans = K+1
if B > 2 + A:
  N = K - A
  if N == 1:
    ans = B
  elif N%2==1:
    ans=B+(B-A)*math.floor((K-A)/2)
  elif N%2==0:
    ans=B+(B-A)*math.floor((K-A)/2-1)+1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

string s;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> s;
	for(int i = 1; i < 4; i++)
		if(s[i] == s[i - 1]){
			cout << "Bad\n";
			return 0;
		}
	cout << "Good\n";
	return 0;
}

Measured memory_bytes: 256