akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 10000000;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 100005;
int A[MX], B[MX];

int get(int x){
	printf("%d\n", x);
	fflush(stdout);
	string D;
	cin >> D;
	if( D == "Male") return 0;
	else if( D == "Female") return 1;
	else exit(0);
}

int main()
{
	int N;
	scanf("%d", &N);
	int s = 0, e = N-1, m, l = get(s), r = get(e);
	while(s <= e){
		int m = (s+e) / 2;
		int v = get(m);
		
		if( (m-s)%2 != (l==v) ) s = m, l = v;
		else e = m, r = v;
	}
}


Measured memory_bytes: 852
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if((a*b % 2) == 0) 
          System.out.println("Even"); 
        else 
          System.out.println("Odd");
	}
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;



/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long



void solve(){

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

	int dp[n+2];

	dp[0] = 0;
	for(int i = 1 ; i < n ; ++i){
		dp[i] = 1e12;
		for(int j = 1 ; j <= 2 ; ++j){

			if(i-j < 0)
				break;

			dp[i] = min(dp[i-j] + abs(a[i]-a[i-j]) , dp[i]);
		}
	}

	cout<<dp[n-1]<<endl; 


}
signed main(){

    fast;
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
}



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

#define FOR(i,N) for(int i=0;i<N;i++)

int main(){
    long long N,K,X,T,X1,X2,ans=0,keep1,keep2;
    cin >> N>>X>>T;
    while(ans*X < N){
        ans++;
    }
    cout << ans*T << endl;
}

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

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

using namespace std;

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> P;

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

	int k;
	cin >> k;

	// 01BFS
	// P(dist,vert)
	deque<P> q;
	q.push_back(P(0,1));


	bool vis[k] = {};

	while(!q.empty()){
		P p = q.front();
		q.pop_front();

		if(vis[p.second]) continue;

		if(p.second == 0){
			cout << (p.first + 1) << endl;
			break;
		}

		vis[p.second] = true;
		q.push_front(P(p.first, (p.second*10)%k));
		q.push_back(P(p.first+1, (p.second+1)%k));		
	}
}

Measured memory_bytes: 1152
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(nil, 100000000)

	x := nextInt()

	credit := 100
	ans := 0
	for i := 0; credit < x; i++ {
		credit += credit / 100
		ans++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';

    for (int bit = 0; bit < (1 << 3); bit++) {
        int ans = a;
        string ope;
        if (bit & (1 << 0)) {
            ans += b;
            ope += "+";
        } else {
            ans -= b;
            ope += "-";
        }

        if (bit & (1 << 1)) {
            ans += c;
            ope += "+";
        } else {
            ans -= c;
            ope += "-";
        }

        if (bit & (1 << 2)) {
            ans += d;
            ope += "+";
        } else {
            ans -= d;
            ope += "-";
        }

        if (ans == 7) {
            cout << a << ope[0] << b << ope[1] << c << ope[2] << d << "=7"
                 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
def show(nums):
    for i in range(len(nums)):
        if i!=len(nums)-1:
            print(nums[i],end=' ')
        else:
            print(nums[i])
N = int(input())
A = list(map(int,input().split()))
show(A)
for i in range(1,N):
    v = A[i]
    while i - 1 >= 0 and A[i-1] > v:
        A[i] = A[i-1]
        i -= 1
    A[i] = v
    show(A)


Measured memory_bytes: 5980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int X = scn.nextInt();
		int N = X/100;
		int ans = 0;
		for(int i = 0;i <= N;i++) {
			if((X-i*100 <= 5*i) && (X-i*100) >= 0)ans = 1;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 22996
import sys
fin = sys.stdin.readline


# time complexity: O(√n)
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# time complexity: O(√n)
def enumerate_divisors(n):
    prime_numbers = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            prime_numbers.add(i)
            if n % (n // i) == 0:
                prime_numbers.add(n // i)
        i += 1
    return prime_numbers
        

n = int(fin())
number_list = [int(elem) for elem in fin().split()]
common_gcd = number_list[0]
for number in number_list[1:]:
    common_gcd = gcd(common_gcd, number)

for divisor in sorted(enumerate_divisors(common_gcd)):
    print(divisor)



Measured memory_bytes: 5604
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp2
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int num = S.Length;

            int ans1 = 0;
            int ans2 = 0;
            for (int i = 0; i < num; i++)
            {
                if (i % 2 == 0)
                {
                    if (S[i] == '0') ans1++;
                    else ans2++;
                }
                else
                {
                    if (S[i] == '1') ans1++;
                    else ans2++;
                }
            }
            Console.WriteLine(ans1 < ans2 ? ans1 : ans2);
        }


        private static int[] Read(string input)
        {
            string[] inputs = input.Split(' ');
            int num = inputs.Length;
            int[] ints = new int[num];
            for (int i = 0; i < num; i++)
            {
                ints[i] = int.Parse(inputs[i]);
            }
            
            return ints;
        }


    }
}


Measured memory_bytes: 13244
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <climits>
#include <set>
#include <deque>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {

	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";

    return out;

}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, k, q;
	cin >> n >> k >> q;

	vector<int> points(n + 1, k - q);
	int ans;
	for (int i = 0; i < q; ++i) {
		cin >> ans;
		++points[ans];
	}

	for (int i = 1; i <= n; ++i) {
		if (points[i] > 0) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
	}

	return 0;

}

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

int appear[100];

int main(void){
  int input, max = 0, count = 0;
  while(cin >> input){
    appear[input-1]++;
    count++;
  }
  for(int i = 0 ; i < count; i++){
    if(appear[i] > max){
      max = appear[i];
    }
  }
  for(int i = 0; i < count; i++){
    if(appear[i] == max)  cout << i + 1 << endl;
  }
  return 0;
}

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


int main(int argc, char** argv){
  int N;
  cin >> N;
  int h[N];
  for(int cnt0=0; cnt0<N; cnt0++) cin >> h[cnt0];

  int st = 0;
  int ed;
  int ans = 0;
  
  for(int i=0; i<N; i++){
    if(h[i] == 0) continue;
    st = i;
    
    int j = i;
    while(j < N && h[j] != 0) j++;
    ed = j;
    for(int k=st; k<ed; k++) h[k]--;
    ans++;
    
    if(i == N-1 && j == N-1 && h[N-1] == 0) break;
    i--;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
 
#define MAXN 1000005
using namespace std;
char H[MAXN][14];
int getchar(char a)
{
    if(a=='A')return 1;
    else if(a=='C')return 2;
    else if(a=='G')return 3;
    else if(a=='T')return 4;
    else return 0;
}
 
long long getkey(char str[])
{
    long long ans=0,p=1,i;
    for(i=0;i<strlen(str);i++)
    {
        ans+=p*(getchar(str[i]));
        p*=5;
    }
    return ans;
}
 
int h1(int key){return key%MAXN;}
int h2(int key){return 1+(key%(MAXN-1));}
 
int find(char str[])
{
    long long key,i,h;
    key=getkey(str);
    for(i=0;;i++)
    {
        h=(h1(key)+i*h2(key))%MAXN;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0)return 0;
    }
    return 0;
}
 
void insert(char str[])
{
    long long key,i,h;
    key=getkey(str);
    for(i=0;;i++)
    {
        h=(h1(key)+i*h2(key))%MAXN;
        if(strcmp(H[h],str)==0)return;
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return;
        }
    }
}
 
int main()
{
    int i,n;
    char a[14],b[14];
    for(i=0;i<MAXN;i++)
        H[i][0]='\0';
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s%s",a,b);
        if(a[0]=='i')
            insert(b);
        else
        {
            if(find(b))
                printf("yes\n");
            else
                printf("no\n");
        }
    }
    return 0;
 } 


Measured memory_bytes: 16844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

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

		MyScanner sc = new MyScanner();
		PrintWriter pr = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int[] ar = new int[n];
		
		for(int i = 0; i < n; i++)
			ar[i] = sc.nextInt();
		
		long ans = 0;
		
		for(int i = 1; i < n; i++) {
			
			if(ar[i - 1] > ar[i]) {
				
				ans += ar[i - 1] - ar[i];
				ar[i] = ar[i - 1];
			}
		}
		
		pr.print(ans);
		pr.close();
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 55336
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/


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


	FOR(i,1,n){
		int ans=0;

		FOR(x,1,sqrt(i)){
			FOR(y,x,sqrt(i)){
				if(x*x+y*y+x*y>n){
					break;
				}
				int z=0;
				int ng=0,ok=n+1;
				int mid;
				while(ok-ng>1){
					mid=(ok+ng)/2;
					if(2*i<=(x+y)*(x+y)+(y+mid)*(y+mid)+(mid+x)*(mid+x)){
						ok=mid;
					}else{
						ng=mid;
					}
				}
				z=ok;
				if(2*i!=(x+y)*(x+y)+(y+z)*(y+z)+(z+x)*(z+x)){
					continue;
				}

				ans++;
				if(x<y){
					ans++;
				}
				// printf("%d %d %d\n",x,y,z);

			}
		}		


		cout<<ans<<endl;
	}



  return 0;
}


Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 1e7;
#define mod 1000000007
 
const int mxN = 1e5 + 1;
ll n, k;
ll dp[mxN], a[mxN];
 
int main()
{
FIO
 
    cin >> n >> k;
    FOR(n) cin >> a[i];
    dp[0] = 0;
    Rep(j,1,k)
    {
        Rep(i,1,n)
        {
            if(j >= a[i])
                dp[j] |= !dp[j - a[i]];
        }
    }

    cout << (dp[k] ? "First" : "Second") << endl;
}


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

using ll = long long;

int n;
vector<pair<ll,ll>>v;

int main(){
    int H, n;
    while( cin >> H >> n ){
        v.resize(n);
        for( int i = 0; i < n; i++ ){
            cin >> v[i].first >> v[i].second;
        }
        ll cost[H+1];
        for( int i = 1; i <= H; i++ ){
            cost[i] = 1000000000000;
        }
        cost[0] = 0;
        for( int i = 1; i <= H; i++ ){
            for( int j = 0; j < n; j++ ){
                ll damage = v[j].first;
                ll remain = i-damage;
                ll currentCost = v[j].second;
                if( remain > 0 ){
                    currentCost += cost[remain];
                }
                cost[i] = min( cost[i], currentCost );
            }
        }
        cout << cost[H] << endl;
    }
}


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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MAX = 1e6+5;
constexpr ll INF = 2134567890;
constexpr ll MOD = 998244353;

ll fpow(ll b, ll a, ll MOD = MOD) {
    b %= MOD;
    ll r = 1;
    for(; a; b=b*b%MOD, a>>=1)
        a&1 && (r = r*b%MOD);
    return r;
}

signed main() {
    FAST;

    int N, K, pt[3];
    string T;
    cin >> N >> K >> pt[0] >> pt[1] >> pt[2] >> T;
    map<char, int> mp{
        { 'r', 0 },
        { 's', 1 },
        { 'p', 2 }
    };
    int *dp[3];
    Fr(j, 0, 3) dp[j] = new int[N/K+5]();
    int ans = 0, end, mx;
    Fr(k, 0, K) {
        end = N/K + (k < N%K);
        Fr(j, 0, 3) dp[j][1] = pt[j]*((j+1)%3==mp[T[k]]);
        Fr(i, 1, end) Fr(j, 0, 3) {
            dp[j][i+1] = 0;
            Fr(k, 0, 3) if (k != j)
                dp[j][i+1] = max(dp[j][i+1], dp[k][i]);
            dp[j][i+1] += pt[j]*((j+1)%3==mp[T[i*K+k]]);
        }
        mx = 0;
        Fr(j, 0, 3) mx = max(mx, dp[j][end]);
        //cerr _ k _ mx _ endl;
        ans += mx;
    }
    cout << ans << endl;

}


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

long long f(vector<long long> &arr, int i, int j,
            bool taro, vector<vector<long long> > &dp) {
	if(i+1==j) {
    	// last two elements left
      	if(taro) {
	      	return max(arr[i], arr[j]);      	
        }
      	else {
        	return min(arr[i], arr[j]);
        }
    }
  	if(dp[i][j]!=0)
      	return dp[i][j];
  
  	if (taro)
	  	dp[i][j] = max(arr[i] + f(arr,i+1, j, !taro, dp),
                   arr[j] + f(arr,i, j-1, !taro, dp));
  	else
      	dp[i][j] = min(f(arr,i+1, j, !taro, dp),
                   f(arr,i, j-1, !taro, dp));
  	return dp[i][j];
}

int main() {
  	int N;
	cin>>N;
  	vector<long long> arr(N, 0);
	long long sum=0;
  	for(int i=0;i<N;i++) {
      	cin>>arr[i];
      	sum += arr[i];
    }
  
    if(N==1) {
      	cout<< arr[0];
    	return 0;
    }
  	long long X,Y;
  	vector<vector<long long> > dp(N, vector<long long>(N,0));

  	f(arr, 0, N-1, true, dp);
  	X = dp[0][N-1];
  	Y = sum-X;
  	//cout<<"X "<<X<<endl;
  	//cout<<"Y "<<Y<<endl;
  	
  	cout<<X-Y<<endl;
  
  	return 0;
}

Measured memory_bytes: 71040
fun main() {
    val n = readLine()?.toInt() ?: return
    var total = 0L
    repeat(n) {
        val value = it + 1
        total += if (value % 15 == 0 || value % 3 == 0 || value % 5 == 0) {
            0
        } else {
            value
        }
    }
    println(total)
}


Measured memory_bytes: 34576
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

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

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  int64_t a,b;
  cin >> a >> b;
  int t = 0;
  if (a > b){
    t += a;
    a--;
  }else{
    t += b;
    b--;
  }
  if (a > b){
    t += a;
  }else{
    t += b;
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int n;

int main(int argc,char ** argv)
{
	cin>>n;
	if (n<1200)
		puts("ABC");
	else
	if (n<2800)
		puts("ARC");
	else
		puts("AGC");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define FOR(i,k,n) for (int (i)=(k);(i)<(n);(i)++)
using namespace std;

int main()
{
  string s;
  cin >> s;
  int posA, posZ;

  // A の位置の最小値
  FOR(i, 0, s.length()) {
    if (s[i] == 'A') {
      posA = i;
      break;
    }
  }

  // Z の位置の最大値
  FOR(i, 0, s.length()) {
    if (s[i] == 'Z') posZ = i;
  }

  int n;
  n = posZ - posA + 1;
  cout << n << endl;

  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

string Solve(ll x, ll y, ll at) {
  if (at < 0) return "";
  assert(abs(x) + abs(y) <= (1 << (at + 1)) - 1);
  int r = (1 << at) - 1;
  int d = 1 << at;
  if (abs(x - d) + abs(y) <= r) return Solve(x - d, y, at - 1) + "R";
  if (abs(x + d) + abs(y) <= r) return Solve(x + d, y, at - 1) + "L";
  if (abs(x) + abs(y - d) <= r) return Solve(x, y - d, at - 1) + "U";
  if (abs(x) + abs(y + d) <= r) return Solve(x, y + d, at - 1) + "D";
  assert(false);
}

int main()
{
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
  }
  for (int i = 0; i < n; ++i) {
    if ((x[i] + y[i] + x[0] + y[0]) % 2 == 1) {
      cout << -1 << endl;
      return 0;
    }
  }

  bool odd = (x[0] + y[0]) % 2 == 0;
  cout << 31 + odd << endl;
  if (odd) cout << "1 ";
  for (int i = 0; i < 31; ++i) {
    cout << (1 << i) << " ";
  }
  cout << endl;

  for (int i = 0; i < n; ++i) {
    string result = Solve(x[i] - odd, y[i], 30);
    if (odd) result = "R" + result;
    cout << result << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if (s < t)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
/*input
20 11
33883322005544116655
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
    ll ans=1;
    while(m){
        if(m%2){
            ans*=a;
            ans%=(mod);
        }
        a=(a*a)%(mod);
        m>>=1;
    }
    return ans;
}


void init(long long* a,long long n,long long val){
    for(long long i=0;i<n;i++)
        a[i]=val;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    ll t=1,i,j;
    ll n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    ll ans=0;
    if(p==2||p==5){
        rep(i,0,n){
            if((s[i]-48)%p)continue;
            ans+=(i+1);
        }
    }else{
        ll m[p]={0},k=0;
        m[0]=1;
        repi(i,n-1,-1){
            k+=power(10,n-1-i,p)*(s[i]-48);
            k%=p;
            ans+=m[k];
            m[k]++;
        }   
    }   
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 848
#include <iostream>
using namespace std;
int main()
{
    int n, h, s=0;
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        if(i%2!=0)
        {
            h=0;
            for(int a=1; a<=i; a++)
            {
                if(i%a==0)
                {
                    h++;
                }
            }
            if(h==8)
                s++;
        }
    }
    cout << s << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int N; cin >> N;
	for (int t = 0; t < N; ++t) {
		string s1, s2; cin >> s1 >> s2;
		reverse( s1.begin(), s1.end() );
		for (int i = 0; i < s1.size(); ++i) {
			switch (s1[i]) {
				case 'A':
					reverse( s2.begin(), s2.end() );
					break;

				case 'J':
					s2 = s2[s2.size()-1] + s2.substr(0, s2.size()-1);
					break;

				case 'C':
					s2 = s2.substr(1) + s2[0];
					break;

				case 'E':
					if (s2.size() > 1) {
						if (s2.size() % 2 == 0) s2 = s2.substr(s2.size()/2) + s2.substr(0, s2.size()/2);
						else s2 = s2.substr(s2.size()/2+1) + s2[s2.size()/2] + s2.substr(0, s2.size()/2);
					}
					break;

				case 'M':
					for (int j = 0; j < s2.size(); ++j) {
						if ('0' <= s2[j] && s2[j] < '9') ++s2[j];
						else if (s2[j] == '9') s2[j] = '0';
					}
					break;

				case 'P':
					for (int j = 0; j < s2.size(); ++j) {
						if ('0' < s2[j] && s2[j] <= '9') --s2[j];
						else if (s2[j] == '0') s2[j] = '9';
					}
					break;
			}
		}
		cout << s2 << endl;
	}
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <string.h>


int main(void){
    char s[201],t[101];

    scanf("%s %s", &s, &t);

    if(s == NULL){
        printf("%s", t);
    }else if(t == NULL){
        printf("%s", s);
    }else{
        strcat(t,s);
        printf("%s\n",t);
    }

    return 0;
}

Measured memory_bytes: 128
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut result = String::new();
    for i in k..n {
        if a[i] > a[i - k] {
            result.push_str(&format!("Yes\n"));
        } else {
            result.push_str(&format!("No\n"));
        }
    }
    result.trim().to_string()
}


Measured memory_bytes: 6836
#include<stdio.h>

int main(void)
{
	int x_price, y_price, y_limit, y_add_fee,p;
	int price1=0, price2 = 0;

	scanf("%d",&x_price);
	scanf("%d",&y_price);
	scanf("%d", &y_limit);
	scanf("%d", &y_add_fee);
	scanf("%d", &p);

	price1 = x_price * p;
	if (p <= y_limit)price2 = y_price;
	else 
		price2 = y_price + (p - y_limit)*y_add_fee;
	
	if (price1 > price2)printf("%d\n", price2);
	else
		printf("%d\n",price1);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include<set>
#define ll long long 
using namespace std;
int main()
{
	int n,c1=0,c2=0,f;
	cin>>n;
	int a[n],b[n],c[n],i;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		
	}
	
	for(i=0;i<n;i++)
	{
		cin>>b[i];
	}
	for(i=0;i<n;i++)
	
	{
		c[i]=i+1;
	}
	while(1)
	{
		c1++;
		f=0;
		
		for(i=0;i<n;i++)
		{
			if (c[i]!=a[i])
			
			{
			f=1;
			break;
		}
		
		}
		
		if (f==0)
		break;
		else
		next_permutation(c,c+n);
	}
	for(i=0;i<n;i++)
	{
		c[i]=i+1;
	}
		while(1)
	{
		c2++;
		f=0;
		
		for(i=0;i<n;i++)
		{
			if (c[i]!=b[i])
			
			{
			f=1;
			break;
		}
		
		}
		
		if (f==0)
		break;
		else
		next_permutation(c,c+n);
	}
	cout<<(int)(abs(c1-c2))<<endl;
	
	
	
}


Measured memory_bytes: 256
//It’s never too late to become what you might have been....
 #include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1000000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define boost1 ios::sync_with_stdio(false);
#define boost2 cin.tie(0);
#define mem(a,val) memset(a,val,sizeof a)
#define endl "\n"
#define maxn 100001

int main()
{
	boost1;boost2;
	ll i,j,l;
	string s;
	char c1,c2,c3;
	cin>>s;
	l=s.length();
	for(i=0;i<l-2;i++)
	{
		c1=s[i];
		c2=s[i+1];
		c3=s[i+2];
		if(c1==c2 || c2==c3 || c1==c3)
		{
			cout<<i+1<<" "<<i+3<<endl;
			return 0;
		}
	}	
	if(s[l-1]==s[l-2])
	{
		cout<<l-1<<" "<<l<<endl;
		return 0;
	}
	cout<<"-1"<<" "<<"-1";
	return 0;
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    val (A, B) = readInputLine().split(" ").map { it.toInt() }
    
    var ans = 0
    
    for (i in A..B) {
        val str = i.toString()
        if (str.equals(str.reversed())) {
            ans++
        }
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 40304
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int c[110];
int d[110];
vector<pair<int,int> > g[110];
vector<pair<int,int> > rev[110];
vector<int>h[1100];
int e[110];
int ijk[51][51][1<<10];
int v[51][51][1<<10];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		d[0]=0;
		d[a-1]=1000;
		c[0]=c[a-1]=0;
		for(int i=1;i<a-1;i++){
			scanf("%d%d",c+i,d+i);
		}
		for(int i=0;i<1100;i++)h[i].clear();
		for(int i=0;i<a;i++){
			h[d[i]].push_back(i);
		}
		for(int i=0;i<1100;i++){
			for(int j=0;j<h[i].size();j++){
				e[h[i][j]]=j;
			}
		}
		for(int i=0;i<110;i++)g[i].clear();
		for(int i=0;i<110;i++)rev[i].clear();
		for(int i=0;i<b;i++){
			int p,q,r;scanf("%d%d%d",&p,&q,&r);
			p--;q--;
			g[p].push_back(make_pair(q,r));
			rev[q].push_back(make_pair(p,r));
		}
		for(int i=0;i<a;i++)for(int j=0;j<a;j++){
			for(int k=0;k<(1<<10);k++){
				ijk[i][j][k]=999999999;
				v[i][j][k]=0;
			}
		}
		ijk[0][0][0]=0;
		priority_queue<pair<pair<int,int>,pair<int,int> > >Q;
		Q.push(make_pair(make_pair(0,0),make_pair(0,0)));
		while(Q.size()){
			int cost=-Q.top().first.first;
			int bit=Q.top().first.second;
			int at1=Q.top().second.first;
			int at2=Q.top().second.second;
			Q.pop();
			if(v[at1][at2][bit])continue;
			if(at1==a-1&&at2==a-1)break;
			v[at1][at2][bit]=1;
		//	printf("%d %d %d: %d\n",at1,at2,bit,cost);
			if(d[at1]<d[at2]){
				for(int i=0;i<g[at1].size();i++){
					int to=g[at1][i].first;
					if(d[at1]>d[to])continue;
					int tob=0;
					int adc=g[at1][i].second+c[to];
					if(d[at1]<d[to]){
						if(d[to]>=d[at2]){
							tob=(1<<(e[at2]));
							if(d[to]==d[at2])tob|=(1<<e[to]);
							if(to==at2)adc-=c[to];
						}else tob=1<<e[to];
					}else{
						if(bit&(1<<e[to]))adc-=c[to];
						tob=bit;
						tob|=1<<e[to];
					}
					if(!v[to][at2][tob]&&ijk[to][at2][tob]>cost+adc){
						ijk[to][at2][tob]=cost+adc;
						Q.push(make_pair(make_pair(-ijk[to][at2][tob],tob),make_pair(to,at2)));
					}
				}
			}else{
				for(int i=0;i<rev[at2].size();i++){
					int to=rev[at2][i].first;
					if(d[at2]>d[to])continue;
					int tob=0;
					if(d[at1]==d[at2])tob=bit;
					int adc=rev[at2][i].second+c[to];
					if(d[at2]<d[to]){
						if(d[to]>=d[at1]){
							tob|=(1<<(e[at1]));
							if(d[to]==d[at1])tob|=(1<<e[to]);
							if(to==at1)adc-=c[to];
						}else tob|=(1<<e[to]);
					}else{
						if(bit&(1<<e[to]))adc-=c[to];
						tob=bit;
						tob|=1<<e[to];
					}
					if(!v[at1][to][tob]&&ijk[at1][to][tob]>cost+adc){
						ijk[at1][to][tob]=cost+adc;
						Q.push(make_pair(make_pair(-ijk[at1][to][tob],tob),make_pair(at1,to)));
					}
				}
			}
		}
		int ret=999999999;
		for(int i=0;i<(1<<10);i++)ret=min(ret,ijk[a-1][a-1][i]);
		if(ret>99999999)printf("-1\n");
		else printf("%d\n",ret);
	}
}

Measured memory_bytes: 31380
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		 int n;
           cin>>n;
           int ans=0;
           while(n>0){
            if(n%10==2)ans++;
             n/=10;
           }
           cout<<ans<<endl;
}



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

int main()
{
    map<string,int>mp;
    map<string,int>::iterator it;

    int a,mx=0;
    string s;

    cin>>a;

    for(int i=0;i<a;i++)
    {
        cin>>s;
        mp[s]++;
        mx=max(mx,mp[s]);

    }

    for(it=mp.begin();it!=mp.end();it++)
    {
        if(it->second==mx)cout<<it->first<<endl;
    }







    return 0;
}


Measured memory_bytes: 25216
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

//n -> big, a -> small
mint choose(int n,int a){
    mint x = 1, y = 1;
    rep(i,a){
        x *= n-i;
        y *= i+1;
    }
    return x / y;
}
int main(){
   int x,y;
    cin >> x >> y;
    if((x+y)%3!=0) cout<<0<<endl;
    else{
        int n1 = (2*x-y)/3;
        int n2 = (2*y-x)/3;
        if(n1<0 || n2<0){
            cout<<0<<endl;
            return 0;
        }else{
            cout<<choose(n1+n2,n1).x<<endl;
        }
    }
 
    return 0;
}

Measured memory_bytes: 256
md = 1000000007
n,m = map(int,input().split())

grid=[]
for i in range(n):
    grid.append(list(input()))

dp=[]
for i in range(n):
    dp.append([0]*m)
dp[0][0]=1
for i in range(1,n):
    if(grid[i][0]!="#"):
        dp[i][0]=dp[i-1][0]
    else:
        dp[i][0]=0

for j in range(1,m):
    if(grid[0][j]!="#"):
        dp[0][j]=dp[0][j-1]
    else:
        dp[0][j]=0

for i in range(1,n):
    for j in range(1,m):
        if(grid[i][j]=="#"):
            dp[i][j]=0
        else:
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%md
print(dp[n-1][m-1])


Measured memory_bytes: 87280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 1e9 + 7;

void solve() {
    ll a;
    cin >> a;
    cout << (a + (a * a) + (a * a * a));
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
N,Q = map(int,input().split())
S = input()
T = [0]*N
for i in range(1,N):
    T[i] = T[i-1]
    if S[i-1:i+1] == "AC":T[i] += 1
for i in range(Q):
    l,r = map(int,input().split())
    print(T[r-1]-T[l-1])

Measured memory_bytes: 6140
//This code is written by Shammi Anand
#include<bits/stdc++.h>
using namespace std;

#define ll              long long
#define Max(a,b,c)      max(a,max(b,c))
#define Min(a,b,c)      min(a,min(b,c))
#define pb              push_back
#define mp              make_pair
#define f               first
#define s               second
#define mod             1000000007
#define nl              "\n"
#define w(x)            int x; cin>>x; while(x--)


void shammi() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
const int INF = 1e9 + 5;

const int N = 100005;
ll n, k;
vector<ll> dp(N, INF);

ll height[N];


ll calculate() {
	// if (pos == n) {
	// 	return 0;
	// }
	// if (dp[pos] != INF) {
	// 	return dp[pos];
	// }
	// if (pos == n - 1) {
	// 	return dp[pos] = min(dp[pos], calculate(height, pos + 1, 0) + abs(height[pos] - height[pos + 1]));
	// } else {
	// 	ll curr = pos;
	// 	for (int i = 1; i <= k && pos + k <= n; i++) {
	// 		dp[pos] = min(dp[pos], calculate(height, pos + i, k - i) + abs(height[curr] - height[pos + i]));
	// 	}
	// 	return dp[pos];
	// }
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j <= i + k; ++j) {
			if (j < n) {
				dp[j] = min(dp[j], dp[i] + abs(height[i] - height[j]));
			}
		}
	}
	return dp[n - 1];
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> height[i];
	}
	// memset(dp, -1 , sizeof(dp));
	cout << calculate() << nl;
	return 0;
}

Measured memory_bytes: 4744
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		for (int i = 1; i <= b; i++) {
			int tmp = a * i;
			if (tmp % b == c) {
				pr.println("YES");
				return;
			}
		}

		pr.println("NO");
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <set>

int main()
{
    int64_t X, N;
    std::cin >> X >> N;

    std::set<int64_t> P;
    for (size_t n = 0; n < N; ++n)
    {
        int64_t p;
        std::cin >> p;
        P.insert(p);
    }

    int64_t x = 0;
    while (true)
    {
        if (P.find(X - x) == P.end()) {
            std::cout << X - x << std::endl;
            return 0;
        }
        if (P.find(X + x) == P.end()) {
            std::cout << X + x << std::endl;
            return 0;
        }

        ++x;
    }

    return 0;
}


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

typedef long long int ll;

int main(){
    cin.sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    ll a[n+1];
    ll ans= 0;
    for(ll i=1; i<=n; i++){
        cin >> a[i];
        if(a[i]&1 and i&1)
            ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3608
//全て整数なのでy系の最小値がx系の最大値より大きければZが存在する.
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N,M,X,Y; cin >> N >> M >> X >> Y;
  vector<int> XX;
  vector<int> YY;
  XX.push_back(X); YY.push_back(Y);
  for(int i=0;i<N;i++){
    int x; cin >> x;
    XX.push_back(x);
  }
  for(int i=0;i<M;i++){
    int y; cin >> y;
    YY.push_back(y);
  }
  int x_max = *max_element(XX.begin(),XX.end());
  int y_min = *min_element(YY.begin(),YY.end());
  if(x_max < y_min) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int N,K;
	cin>>N>>K;
	string str;
	cin>>str;
	int l=str.length();
	int hL=0,hR=0,mL=0,mR=0,happy=0;
	for(int i=0;i<l;i++){
		if(str[i]=='R'){
			if(i==0){
				hR+=1;
			}
			else if(str[i]!=str[i-1]){
				mR+=1;
			}
			else if(str[i]==str[i-1]){
				happy+=1;
			}

		}
		if(str[i]=='L'){
			if(i==0)
				hL+=1;
			else if(str[i]!=str[i-1])
				mL+=1;
			else if(str[i]==str[i-1])
				happy+=1;

		}
	}
	if(str[l-1]=='R'){
		mR-=1;hR+=1;
	}
	else{
		mL-=1;hL+=1;
	}
	//cout<<hL<<" "<<hR<<" "<<mL<<" "<<mR<<" "<<happy<<endl;
	int big=mL>mR?mL:mR;
	if(mL!=mR){
		if(K<=big)
		  happy=happy+K*2;
		if(K>big)
			happy+=big*2;
	}
	else if(mL==mR){
		if(K<=big)
			happy+=K*2;
		if(K>big)
			happy+=big*2+1;

	}
	cout<<happy<<endl;

	return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int n;
    cin >> n;
    int dp[2][3] = {}, p = 0, q;
    for (int i = 0; i < n; ++i) {
        p = 1 - p, q = 1 - p;
        cin >> dp[q][0] >> dp[q][1] >> dp[q][2];
        dp[q][0] += max(dp[p][1], dp[p][2]);
        dp[q][1] += max(dp[p][0], dp[p][2]);
        dp[q][2] += max(dp[p][0], dp[p][1]);
    }
    cout << max(dp[q][0], max(dp[q][1], dp[q][2])) << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int x,n,a[101],i,y,mx,ans,ans1;
bool b[101];
int main() {
    cin >> x >> n;
    for (i=1; i<=n; i++)
    {
        cin >> a[i];
        y=a[i];
        b[y]=true;
        mx=max(mx,a[i]);
    }
    for (i=x; i>=0; i--)
        if (b[i]==false)
        {
            ans=i;
            break;
        }

    for (i=x+1; i<=mx+1; i++)
        if (b[i]==false)
        {
            ans1=i;
            break;
        }
    if (x-ans>ans1-x && ans1-x>=0) cout<<ans1;
    else
        cout<<ans;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  vector<ll> A(N);
  ll buf;
  int op = -1;
  for(int i = 0; i<N; i++){
    cin >> buf;
    if(op < 0 && buf >= 0){
      op = i;
    }
    A.at(i) = buf;
  }

  if(K == 1){
    if(op == 0){
      cout << A.at(0) << endl;
      return 0;
    }else{
      cout << min(abs(A.at(op-1)), A.at(op)) << endl;
      return 0;
    }
  }

  ll result = 1000000000;

  for(int stat = 0; stat < N-K+1 ; stat++){
    int end = stat + K -1;
    if(A.at(end) < 0 && A.at(stat) < 0){
      result = min(result, abs(A.at(stat)));
      // cout << "1 " << A.at(stat) << endl;
    }else if(A.at(stat) < 0 && A.at(end) > 0){
      if(abs(A.at(end)) < abs(A.at(stat))){
        buf = A.at(end) * 2 + abs(A.at(stat));
      }else{
        buf = abs(A.at(stat)) * 2 + A.at(end);
      }
      // cout << "2 " << buf << endl;
      result = min(result, buf);
    }else{
      if(result > abs(A.at(end))){
        result = min(result, abs(A.at(end)));
        // cout << "3 " << A.at(end) << endl;
      }else{
        // cout << "4" << endl;
        break;
      }
    }
  }

  cout << result << endl;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a<c && c<b){
    cout << "Yes" << endl;
  }else if(b<c && c<a){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
return 0;
}

Measured memory_bytes: 256
N, K = [int(i) for i in input().split()]
steps = [int(i) for i in input().split()]
dp = [float('inf')]*N

for i in range(N):
  if i == 0:
    dp[0] = 0
    for k in range(1, K+1):
      if N > k:
          dp[k] = abs(steps[k] - steps[0])
  else:
    # 現在位置までのコスト + 隣に行くコスト　を登録済みのDPテーブルと比較し、小さい方で更新
    for k in range(1, K+1):
      if i+k < N:
          dp[i+k] = min(abs(steps[i] - steps[i+k]) + dp[i], dp[i+k])
print(dp[-1])


Measured memory_bytes: 55520
<?php
fscanf(STDIN, "%d%d", $n, $k);

$map = explode(" ", trim(fgets(STDIN)));
$max = 0;
$last = 0;
$temp = [];
foreach($map as $n => $value){
    $temp[$n] = ($value + 1)/2;
    if($n < ($k - 1)){
        continue;
    }elseif($n == $k -1){
        $last = array_sum($temp);
    }else{
        $last = $last - $temp[$n - $k] + $temp[$n];
    }
    $max = max($last, $max);
}

echo $max;

Measured memory_bytes: 29168
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
	string S;
	getline(cin, S);
	REP(i, S.length())
	{
		if (!isalpha(S[i]))
		{
			cout << S[i];
			continue;
		}

		if (isupper(S[i]))
		{
			cout << (char)tolower(S[i]);
		}
		else
		{
			cout << (char)toupper(S[i]);
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3192
// This template code suggested by KT BYTE Computer Science Academy
//   for use in reading and writing files for USACO problems.

// https://content.ktbyte.com/problem.java

import java.util.*;
import java.io.*;

public class Main {

    static StreamTokenizer in;

    static int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    public static void main(String[] args) throws Exception {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = nextInt();
        int k = nextInt();

        int[] heights = new int[n];

        for (int i = 0; i < n; i++) {
            heights[i] = nextInt();
        }

        int[] dp = new int[n + 1];

        for (int i = 0; i <= n; i++)  {
            dp[i] = 1000000000;
        }

        dp[0] = 0;
        dp[1] = 0;

        for (int i = 2; i <= n; i++) {
            for (int j = Math.max(i - k, 1); j < i; j++) {
                dp[i] = Math.min(dp[i], dp[j] + Math.abs(heights[i - 1] - heights[j - 1]));
            }
        }

        out.println(dp[n]);

        out.close();
    }
}




Measured memory_bytes: 37740
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include<vector>
#include<tuple>
using namespace std;

int main(){
  string s;
  cin >> s;
  if(s[5] == '1'){
  cout << "TBD";
  return 0;
}
  if( s[6] == '1' || s[6] == '2' || s[6] == '3' || s[6] == '4'){
    cout << "Heisei" << endl;}
    else{
      cout << "TBD";
    }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
n,m=map(int,input().split())
es=[list(map(int,input().split())) for _ in range(m)]
def check(s,t):
	q=[0]
	vis=[0]*n
	vis[0]=1
	while q:
		c=q.pop()
		for x in con[c]:
			if (c==s and x==t) or (c==t and x==s) or vis[x]:
				continue
			vis[x]=1
			q.append(x)
	return not all(vis)
con=[[] for _ in range(n)]
for s,t in es:
	con[s-1]+=t-1,
	con[t-1]+=s-1,
print(sum(check(s-1,t-1) for s,t in es))

Measured memory_bytes: 3064