akhauriyash/Code-Regression huggingface dataset:
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
  int n, k;
  cin >> n >> k;
  int *h = new int[n];
  int *dp = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> h[i];
    dp[i] = 0;
  }

  for (int i = 1; i < n; i++) {
    int temp = INT32_MAX;
    for (int j = 1; j <= k and i - j >= 0; j++) {
      temp = (dp[i - j] + abs(h[i] - h[i - j])) < temp
                 ? (dp[i - j] + abs(h[i] - h[i - j]))
                 : temp;
    }
    dp[i] = temp;
  }

  cout << dp[n - 1] << endl;
  delete[] h;
  delete[] dp;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
int32_t main(){
CODE_START;
cin>>n;
if(n%10==9){
rc("Yes");
}
n=n/10;
if(n%10==9){
    rc("Yes");
}
cout<<"No";
}


Measured memory_bytes: 256
N,K = map(int,input().split())

Prolist = []

for i in range(1,N + 1):
	Value = i
	Pro = 0
	while Value < K:
		Value = Value * 2
		Pro += 1
	Prolist.append(Pro)

total = 0

for i in Prolist:
	total += (1 / N) * 2 ** (-i)
	
print(total)
	

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

int main() {
	char str1[12], str2[12], str3[12];
	
	scanf("%s%s%s", str1, str2, str3);
	
	int len1 = strlen(str1), len2 = strlen(str2), len3 = strlen(str3);
	if (str1[len1 - 1] == str2[0] && str2[len2 - 1] == str3[0]) {
			puts("YES");
		}
		else {
			puts("NO");
		}
		
	
	
	return 0;
}

Measured memory_bytes: 1636
[n,m,c] = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
counter = 0
for i in range(n):
    a = [int(t) for t in input().split()]
    sum = c
    for j in range(m):
        sum += a[j]*b[j]
    if sum > 0:
        counter += 1
print(counter)


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

int main(void)
{
  int H,W;
  while(true){
   cin >> H >> W;
   if(H==0 && W==0){
     break;
   }
   for(int j=0; j<W; j++){
       cout << '#';
   }
   cout << endl;
   for(int i=1; i<H-1; i++){
       cout << '#';
       for(int j=1; j<W-1; j++){
           cout << '.';
       }
       cout << '#' << endl;
   }
   for(int j=0; j<W; j++){
       cout << '#';
   }
   cout << endl << endl;
  }
}


Measured memory_bytes: 3096
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[n];
        int zero = 0;
        int idx = 0;
        int l = 0;
        int r = 0;
        for (int i=0; i<n; i++) {
            arr[i] = sc.nextInt();
            if (arr[i] == 0) zero++;
            if (arr[i] < 0) {
                idx++;
                l++;
            }
            if (0 < arr[i]) r++;
        }

        long res = Long.MAX_VALUE;

        if (arr[0] > 0) {
            System.out.println(arr[k-1]);
            return;
        } else if (arr[n-1] < 0) {
            System.out.println(Math.abs(arr[n-k]));
            return;
        }

//        System.out.println(idx - 1);

        List<Integer> ll = new ArrayList<>();
        List<Integer> rr = new ArrayList<>();

        for (int i=0; i<n; i++) {
            if (arr[i] < 0) ll.add(arr[i]);
            if (0 < arr[i]) rr.add(arr[i]);
        }

//        System.out.println(ll);
//        System.out.println(rr);

        if (zero == 0) {
            for (int i=0; i<=k; i++) {
                int left = i;
                int right = k - i;
                if (l < i) continue;
                if (r < right) continue;
                long tmp = Long.MAX_VALUE;
                if (i == 0) {
                    tmp = Math.abs(rr.get(right - 1));
                    res = Math.min(res, tmp);
                    continue;
                }
                tmp = Math.abs(ll.get(ll.size() - i)) + ((1 <= right) ? Math.min(Math.abs(ll.get(ll.size()-i)), rr.get(right-1))+rr.get(right-1) : 0 );
                res = Math.min(res, tmp);
            }
            System.out.println(res);
        } else {
            for (int i=0; i<=k-1; i++) {
                int left = i;
                int right = k - i - 1;
                if (l < i) continue;
                if (r < right) continue;
                long tmp = 0;
                if (i == 0) {
                    if (k != 1) {
                        tmp = rr.get(right-1);
                    }
                    res = Math.min(res, tmp);
                    continue;
                }
                tmp = Math.abs(ll.get(ll.size()-i)) + ((1 <= right) ? Math.min(Math.abs(ll.get(ll.size()-i)), rr.get(right-1))+rr.get(right-1) : 0);
                res = Math.min(res, tmp);
//                if (i == 2) {
//                    System.out.println(Math.abs(ll.get(ll.size()-i)));
//                    System.out.println(rr.get(right-1));
//                }
//                if (i == 3) System.out.println(tmp);
            }
            System.out.println(res);
        }





    }
}


Measured memory_bytes: 49272
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
s = input()

lis = list(s)

ans = 0
for i in range(1,n):
    set1 = set(lis[0:i])
    set2 = set(lis[i:])
    checkset = set1 & set2
    ans = max(ans , len(checkset))

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int M = 1e9 + 7, N = 1e4 + 7, D = 102;

int dp[N][D][2];
int a[N];

signed main()
{
	IO_OP;
	
	string s;
	int d;
	cin >> s >> d;
	for(int i=0;i<s.size();i++)
		a[i] = s[s.size()-i-1] - '0';
	dp[N-1][0][1] = 1;
	for(int i=N-1;i>0;i--) {
		for(int j=0;j<d;j++) {
			for(int k=0;k<2;k++) {
				if(dp[i][j][k] == 0) continue;
				if(k == 0) {
					for(int l=0;l<10;l++)
						(dp[i-1][(j+l)%d][0] += dp[i][j][k]) %= M;
				} else {
					int b = a[i-1];
					(dp[i-1][(j+b)%d][1] += dp[i][j][k]) %= M;
					for(int l=0;l<b;l++)
						(dp[i-1][(j+l)%d][0] += dp[i][j][k]) %= M;
				}
			}
		}
	}
	cout << (dp[0][0][0] + dp[0][0][1] + M - 1) % M << endl;
}





Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N, A, surplus;
  cin >> N;
  cin >> A;
  surplus = N % 500;
  
  if (surplus <= A)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    vi a(4);
    vec(bool) c(4, false);
    rep(i,4){
        cin>>a[i];
    }
    rep(i,4){
        if(a[i]==1){ 
            c[1]=true;
        }
        if (a[i]==9) {
            c[2]=true;
        }
        if (a[i]==7) {
            c[3]=true;
        }
        if (a[i]==4) {
            c[0]=true;
        }
    }
    lli cs=true;
    rep(i,4){
        if(!c[i]){ 
            cs=false;
            break;
        }
    }
    YES(cs);
}

Measured memory_bytes: 3600
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, k;
  cin >> n >> k;
  if (k * 2 - 1 <= n) cout << "YES" << '\n';
  else cout << "NO" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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


int main(){
        int A,B;
        cin >> A >> B;
        if(A<=8&&B<=8) {
                cout << "Yay!" << endl;
        }else{
                cout << ":(" << endl;

        }



        return 0;
}


Measured memory_bytes: 256
L, R = map(int, input().split())

import numpy as np
if L+2019<=R:
    ms = np.arange(2019)
else:
    ms = np.unique(np.arange(L, R+1) % 2019)

Ms = ms.reshape(-1,1)*ms.reshape(1,-1)
Ms = Ms % 2019
Ms += np.eye(Ms.shape[0], dtype=int)*2019
print(np.min(Ms))

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define pb push_back
#define sz size


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

        map <char,int> m;
        string s;
        cin>>s;
        for(auto &x : s)
        {
                m[x]++;
        }
        vector <int> a;
        for(auto &it : m)
        {
                a.pb(it.second);
        }
        if((int)a.sz()==2 && a[0]==2 && a[1]==2)
        {
                cout<<"Yes\n";
        }
        else
        {
                cout<<"No\n";
        }

        return 0;
}


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

int main() {
  int r, c;
  cin >> r >> c;
  
  int ori_table[r][c], new_table[r+1][c+1];
  
  //新しい表の初期化
  for(int i = 0;i < r + 1; i++){
    for(int j = 0;j < c + 1; j++){
      new_table[i][j] = 0;
    }
  }
  
  for(int i = 0;i < r; i++){
    for(int j = 0; j < c; j++){
      cin >> ori_table[i][j];
      new_table[i][j] = ori_table[i][j];
      new_table[i][c] += ori_table[i][j]; //列の合計
      new_table[r][j] += ori_table[i][j]; //行の合計
    }
  }
  
  for(int i = 0; i < c; i++){
    new_table[r][c] += new_table[r][i]; //r+1行目の合計
  }
  
  //出力
  for(int i = 0; i < r + 1; i++){
    for(int j = 0; j < c + 1; j++){
      if(j != 0) cout << " ";
      cout << new_table[i][j];
    }
    cout << endl;
  }
  
}



Measured memory_bytes: 3108
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	vector<int> L;
	for (int i = 0; i < N; i++) {
		int l;
		cin >> l;
		L.push_back(l);
	}

	sort(L.begin(), L.end());
	reverse(L.begin(), L.end());

	int sum = 0;
	for (int i = 0; i < K; i++) {
		sum += L[i];
	}
	cout << sum << endl;
	
}


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

int main(void){
	string s;
	cin >> s;
	string ans="";
	for(int i=0;i<s.size();i++){
		if(s[i]!='B'){
			ans= ans + s[i];
		}else{
			if(ans.size()>0){
				ans.erase(ans.size()-1);
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long

using namespace std;

signed main(){
    int n, sum=0;
    cin >> n;
    //nums.resize(n);
    for(int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0) sum +=i; 
    }

    cout << sum << endl;
    
    return 0;
}       

Measured memory_bytes: 3596
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n)]
        self.size = [1]*n

    def find(self,a):
        if self.parent[a] == a:
            return a
        else:
            return self.find(self.parent[a])

    def unite(self,a,b):
        a_root = self.find(a)
        b_root = self.find(b)
        if a_root == b_root:
            return
        else:
            if self.size_of(b_root) > self.size_of(a_root): 
                self.parent[a_root] = self.parent[b_root]
                self.size[b_root] += self.size[a_root]
            else:
                self.parent[b_root] = self.parent[a_root]
                self.size[a_root] += self.size[b_root]
                
    def size_of(self,a):
        return self.size[self.find(a)]
    
    def is_same(self,a,b):
        return self.find(a) == self.find(b)


N,M,K = map(int, input().split())
uf = UnionFind(N+1)
friends = []
blocks = [0]*(N+1)
for i in range(N+1):
    blocks.append([])
    friends.append(0)

for i in range(M):
    a,b = map(int, input().split())
    friends[a] += 1
    friends[b] += 1
    uf.unite(a,b)
    

for j in range(K):
    x,y = map(int, input().split())
    if uf.is_same(x,y):
        blocks[x] += 1
        blocks[y] += 1

for i in range(1,N+1):
    print(uf.size_of(i) - friends[i] - blocks[i] -1)

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

int n, m;

int main(){
	int i;
	scanf("%d", &n);
	if(n < 1200) printf("ABC");
	else if(n < 2800) printf("ARC");
	else printf("AGC");
	return 0;
}


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

#define ll long long 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ar array
#define vi vector<int>
#define vll vector<ll>
#define vpl vector<pair<ll, ll>> 
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()

void init() {
	
}

void solve() {
	int x; cin >> x;
	if (x >= 400 && x < 600) cout << "8";
	else if (x >= 600 && x < 800) cout << "7";
	else if (x >= 800 && x < 1000) cout << "6";
	else if (x >= 1000 && x < 1200) cout << "5";
	else if (x >= 1200 && x < 1400) cout << "4";
	else if (x >= 1400 && x < 1600) cout << "3";
	else if (x >= 1600 && x < 1800) cout << "2";
	else if (x >= 1800 && x < 2000) cout << "1";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	init();
	int t = 1; 
	// cin >> t;
	while(t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() { 
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    int j=1;
    int ans=0;
    bool flag=false;
    rep(i,n){
        if(a.at(i)!=j)ans++;
        else{
            flag=true;
            j++;
        }
    }
    if(flag) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3952
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
			int n = sc.nextInt();
			int m = sc.nextInt();
			int c = sc.nextInt();
			int[] b = new int[m];
			int[][] a = new int[n][m];
			for(int i = 0; i < m; i++){
				b[i] = sc.nextInt();
			}
			for(int i = 0; i < n; i++){
				for(int j = 0; j < m; j++){
					a[i][j] = sc.nextInt();
				}
			}
			
			int sum = 0;
			int flag = 0;
			for(int i = 0; i < a.length; i++){
				for(int j = 0; j < a[i].length; j++){
					sum = sum + (a[i][j] * b[j]);
					if( j == a[i].length-1){
						if( sum + c > 0 ){
							flag++;
						}
						sum = 0;
					}
				}
				
			}
			System.out.println(flag);
	}
}

Measured memory_bytes: 22740
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    ll n, q;
    string s;
    cin >> n >> s >> q;
    for (ll i = 0; i < q; i++) {
        ll t;
        cin >> t;
        ll d = 0, m = 0, sum = 0, ans = 0;
        for (ll j = 0; j < n; j++) {
            if (j > t-1) {
                if (s[j - t] == 'D')d--, sum -= m;
                if (s[j - t] == 'M')m--;
            }
            if (s[j] == 'D')d++;
            if (s[j] == 'M')m++, sum += d;
            if (s[j] == 'C')ans += sum;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
//------------------------------------------------------------
ll x,y,ans=0,tmpans=0;

void solve() {
  cin>>x>>y;

  // rep(i,x,round(y/2)+1)
  // {
    ll n=x;
    tmpans=1;
    while(1)
    {
      if(n*2<=y)
      {
        tmpans++;
        n = n*2;
      }
      else {break;}
    }

  //   ans = max(ans, tmpans);
  // }

  print(tmpans);  return;
}


Measured memory_bytes: 256
# 入力　英小文字
test = input()

#出力　c が母音であるとき、vowel と、そうでないとき consonant と出力せよ。
vowel_list = ["a", "e", "i", "o", "u"]

if test in vowel_list :
    print("vowel")
else :
    print("consonant")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
//const int N = 100;

mt19937_64 mt(128);//seed
class UnionFind{
	vector<int> par,siz;
	//0-indexed
	void init(int n) {
		par.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i;
		siz.resize(n,1);
	}
public:
	UnionFind(int n_){init(n_);}
	int root(int x){
		if(par[x]==x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x,int y){
		x = root(x);
		y = root(y);
		if(x==y)return;
		siz[y] += siz[x];
		siz[x] = 0;
		par[x] = y;
	}
	int size(int x){
		return siz[root(x)];
	}
};



int main(){
	ll N , M;
	cin >> N >> M;
	vector<ll> A(M+1,0),B(M+1,0),ans;
	FOR(i,0,M)cin>>A[i+1]>>B[i+1];
	ll ansp = (N-1)*N/2;
	UnionFind uf(N+1);
	FORR(i,1,M+1){
		ans.push_back(ansp);
		ll x = uf.size(A[i]);
		ll y = uf.size(B[i]);
		if(uf.root(A[i])!=uf.root(B[i])){
			ansp -= y*x;
		}
		uf.unite(A[i],B[i]);
	} 
	FORR(i,0,M){
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 4596
#include<stdio.h>	//ヘッダファイルの宣言

typedef struct
{
	int iti;	//面の位置
	int suuti;	//サイコロに代入される数
} SAIKORO;	//構造体の宣言


int main(void)
{
	int kaisuu1, kaisuu2, kaisuu3;	//処理に利用するローカル変数
	char hougaku[128] = {0};	//方角の値を代入するローカル関数
	char kari1;	//仮で使うローカル関数
	SAIKORO date[6];	//サイコロのデータを格納する構造体の配列
	SAIKORO kari2;	//仮で使うローカル関数

	kaisuu2 = 0;	//初期化

	for (kaisuu1 = 0; kaisuu1 < 6; kaisuu1++)	//繰り返しによる初期化
	{
		date[kaisuu1].iti = kaisuu1 + 1;
		//printf("%d ", date[kaisuu1].iti);
	}
	scanf("%d %d %d %d %d %d ", &date[0].suuti, &date[1].suuti, &date[2].suuti, &date[3].suuti, &date[4].suuti, &date[5].suuti);	//サイコロの面に数値を代入
	scanf("%s", hougaku);	//方角を代入
	while (kaisuu1 != 0)	//方角を全部終わるまで処理をする
	{
		kari1 = hougaku[kaisuu2];	//仮に代入
		kaisuu2++;
		if (kari1 == 0)	//配列の中身が0になった場合
		{
			for (kaisuu3 = 0; kaisuu3 < 128; kaisuu3++)	//中身を初期化して処理を終える
			{
				hougaku[kaisuu3] = 0;
			}
			break;
		}
		else
		{
			if (kari1 == 'E')	//文字がEだった場合の処理
			{
				kari2 = date[2];
				date[2] = date[0];
				date[0] = date[3];
				date[3] = date[5];
				date[5] = kari2;
			}
			if (kari1 == 'W')	//文字がWだった場合の処理
			{
				kari2 = date[3];
				date[3] = date[0];
				date[0] = date[2];
				date[2] = date[5];
				date[5] = kari2;
			}
			if (kari1 == 'S')	//文字がSだった場合の処理
			{
				kari2 = date[4];
				//printf(" %d ", kari2.suuti);
				date[4] = date[5];
				//printf(" %d ", date[4].suuti);
				date[5] = date[1];
				//printf(" %d ", date[5].suuti);
				date[1] = date[0];
				//printf(" %d ", date[1].suuti);
				date[0] = kari2;
				//printf(" %d ", date[0].suuti);
			}
			if (kari1 == 'N')	//文字がNだった場合の処理
			{
				kari2 = date[1];
				date[1] = date[5];
				date[5] = date[4];
				date[4] = date[0];
				date[0] = kari2;
			}
			/*for (kaisuu3 = 0; kaisuu3 < 6; kaisuu3++)
			{
				printf(" %d ", date[kaisuu3].suuti);
			}
			printf("\n");*/
		}
	}
	printf("%d\n", date[0].suuti);	//サイコロの上面の値を出力

	return 0;	//プログラム終了
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define int long long  
#define INF 1145141919810893
signed main(){
    int N,x;
    int suma=0;
    int a[114514];
    cin >> N >> x;
    REP(i,N){cin >> a[i];suma+=a[i];a[i]=min(a[i],x);}
    REP(i,N-1){
        if(a[i]+a[i+1]>x){
            a[i+1]=x-a[i];
        }
    }
    REP(i,N){suma-=a[i];}
    cout << suma << endl;
    
    
	return 0;
}


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

int main() {
 
  int N;
  cin>> N;
  
 if(N%2==0){
 cout<< (N+1)*N/2;
 }
 else{
 cout<< (N+1)*(N/2)+(N+1)/2;
}
  
}


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

using namespace std;
#define N 100100
#define MOD 1000000007LL

long long d[13][N];
string s;
int n, i, j, k, digit;
int main()
{
    cin >> s;
    n = s.size();
    for (i = 0; i < 13; ++i) d[i][0] = 0;
    d[0][0] = 1;
    for (i = 0; i < n; ++i){
        if (s[i] != '?'){
            for (j = 0; j < 13; ++j)
                d[(j * 10 + s[i] - '0') % 13][i + 1] = d[j][i];
        }
        else{
                for (digit = 0; digit < 10; ++digit){
                for (j = 0; j < 13; ++j){
                    k = (j * 10 + digit) % 13;
                    d[k][i + 1] += d[j][i];
                    if (d[k][i + 1] > MOD)
                        d[k][i + 1] -= MOD;
                }
            }
        }
    }
    cout << d[5][n];
    return 0;
}


Measured memory_bytes: 13904
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, M, Q, l, r;
    cin >> N >> M >> Q;
    vector<vector<int>> a(N, vector<int>(N));
    for (int i = 0; i < M; i++) {
        cin >> l >> r;
        l--, r--;
        a[l][r]++;
    }
    vector<vector<int>> s(N+1, vector<int>(N+1));
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            s[i+1][j+1] = s[i+1][j] + s[i][j+1] - s[i][j] + a[i][j];

    for (int i = 0; i < Q; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        cout << s[y+1][y+1] - s[x][y+1] - s[y+1][x] + s[x][x] << '\n';
    }
}


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main()
{
  int n;
  cin>>n;
  lli a[87];
  a[0]=2;
  a[1]=1;
  for(int i=2;i<87;i++)
    a[i]=a[i-1]+a[i-2];
  cout<<a[n]<<"\n";
 return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int main(){
  int x,n;
  cin >> x >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++) cin >> p[i];

  int ans;
  int now;
  if(n == 0){
    ans = x;
  }else{
    ans = x;
    now = 100;
    set<int> st;
    for(int i=0;i<n;i++){
      st.insert(p[i]);
    }
    for(int i=0;i<102;i++){
      if(st.find(i) == st.end()){
        if(abs(x-i)<now){
          ans = i;
          now = abs(x-i);
        }
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
using namespace std;
const int N_MAX = pow(10, 5);
int main (void) {
    int N;
    int p[N_MAX];
    int ans = 0;

    cin >> N;
    for (int i = 0; i < N; i++) cin >> p[i];

    for (int i = 0; i < N; i++) {
        if (p[i] == i + 1) {
            swap(p[i], p[i + 1]);
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    vector<Pll> B(N);
    rep(i,N){
        B[i] = Pll(A[i],i);
    }
    sort(B.begin(), B.end());
    cout << 2*(N-1) << endl;
    if(abs(B[0].fi) <= abs(B[N-1].fi)){
        rep(i,N){
            if(B[N-1].se == i) continue;
            cout << B[N-1].se + 1 << " " << i+1 << endl;
        }
        if(B[N-1].fi < 0){
            for(ll i = N-1; i>0; i--){
                cout << i+1 << " " <<  i << endl;
            }
        }else{
            rep(i,N-1){
                cout << i+1 << " " << i+2 << endl;
            }
        }
    }else{
        rep(i,N){
            if(B[0].se == i) continue;
            cout << B[0].se + 1 << " " << i+1 << endl;
        }
        if(B[0].fi < 0){
            for(ll i = N-1; i>0; i--){
                cout << i+1 << " " <<  i << endl;
            }
        }else{
            rep(i,N-1){
                cout << i+1 << " " << i+2 << endl;
            }
        }
    }
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 21 21:09:05 2020

@author: naoki
"""

def base(n,b):
    p = n
    digits = "abcdefghijklmnopqrstuvwxyz"
    s=[]
    while p >=1:
        if p >=27:
            if p%b == 0:
                s.append(digits[25])
                p = p // b - 1  
            else:    
                s.append(digits[p%b-1])
                p = p // b
        else:
            s.append(digits[p - 1])
            p = 0
    return "".join(reversed(s))
N = int(input())
print(base(N,26))

Measured memory_bytes: 9152
array = gets.chomp.split(' ')
N = array[0].to_i
L = array[1].to_i
flavor_list = []
N.times do |i|
  flavor_list.push(L + i)
end
bite = if N.abs > -L
         flavor_list.map(&:abs).min
       else
         - flavor_list.map(&:abs).min
       end
print flavor_list.inject(:+) - bite


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int MOD = 1e9 + 7;

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

  vector<int> f(n + 1);

  for (int i = 1; i <= 100; ++i) {
    for (int j = 1; j <= 100; ++j) {
      for (int k = 1; k <= 100; ++k) {
        int res = i * i + j * j + k * k + i * j + j * k + i * k;
        if (res <= n) {
          f[res]++;
        }
      }
    }
  }

  for (int i = 1; i <= n; ++i) {
    cout << f[i] << endl;
  }
  return 0;
}


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

int main() {
    int A,B,C;
    cin>>A>>B>>C;
    if(A==B&&B==C)cout<<"No"<<endl;
    else if(A!=B&&B!=C&&C!=A)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

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

using namespace std;
#define int long long
int mypower(int a, int b, int mod)
{
    int ans = 1;
    while(b)
    {
        if(b%2)
            ans = ans*a%mod;
        b=b/2;
        a=a*a%mod;
    }
    return ans;
}
signed main() {
    int k;
    cin >> k;
    if(k%2 == 0)
        cout << -1 << '\n';
    else
    {
        int s, ans = 0;
        for(s=0;s<=5000000;s++)
        {
            ans = (ans + mypower(10, s, k))%k;
            if((ans*7%k) == 0)
                break;
        }
        if(s == 5000001)
            cout << -1 << '\n';
        else
            cout << (s+1);
    }
}

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

vector<char> alphabet({
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
    'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
});

int main(){
    long long N;
    cin >> N;
    string out;
    while (N > 0){
        long long r = (N - 1) % 26;
        out = alphabet[r] + out;
        N = (N - 1) / 26;
    }

    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(){
  int x,y,s,i,j,max,a,b,box[2001],box2[2001];
  while(1){
    max=0;
    scanf("%d %d %d",&x,&y,&s);
    if(x==0&&y==0&&s==0)
      break;
    for(i=0;i<=2000;i++)
      box[i]=box2[i]=0;
    for(i=1;i<=s;i++){
      box[i]=i*(100+x)/100;
      box2[box[i]]=i;
    }
    for(i=1;i<s;i++){
      if(box2[i]!=0&&box2[s-i]!=0)
        if(box2[i]*(100+y)/100+box2[s-i]*(100+y)/100>max)
          max=box2[i]*(100+y)/100+box2[s-i]*(100+y)/100;
    }
    printf("%d\n",max);
  }
}



Measured memory_bytes: 2128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	int a[100001]={};
	int b[100001]={};
	string x,y;
	int q;
	int w,e,r,t;
	cin >> x >>y>>q;
	for(int i=1;i<=x.size();i++){
		if(x[i-1]=='A'){
			a[i]=a[i-1]+1;
		}else{
			a[i]=a[i-1]+2;
		}
	}
	for(int i=1;i<=y.size();i++){
		if(y[i-1]=='A'){
			b[i]=b[i-1]+1;
		}else{
			b[i]=b[i-1]+2;
		}
	}
	for(int i=0;i<q;i++){
		cin >> w >> e >> r >> t;
		if((a[e]-a[w-1]-b[t]+b[r-1])%3==0){
			cout << "YES"<<endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main(void) {
	long long int n, k, i;
	long long int num = 0;
	scanf("%lld %lld", &n, &k);
	for (i = k; i < n + 2; i++) {
		num = num + (i * (n - i + 1) + 1);
	}
	printf("%lld",num%(1000000007));
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  ll Asum = 0;
  ll Bsum = 0;
  rep(i, N){
    cin >> A.at(i);
    Asum += A.at(i);
  }
  rep(i, N){
    cin >> B.at(i);
    Bsum += B.at(i);
  }
  if(Asum < Bsum){
    cout << -1 << endl;
    return 0;
  }
  
  vector<int> sub(N);
  ll micnt = 0;
  ll shortage = 0;
  rep(i, N){
    sub.at(i) = A.at(i) - B.at(i);
    if(sub.at(i) < 0){
      shortage += sub.at(i);
      micnt++;
    }
  }
  ll cnt = 0;
  sort(sub.begin(), sub.end(), greater<int>());
  while(shortage < 0){
    shortage += sub.at(cnt);
    cnt++;
  }
  cout << micnt + cnt << endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}

int main() {
    int n; cin >> n;
    int ans = 0;
    erep(i, n) if(i%2==1 && divisor(i).size() == 8) ans++;
    cout << ans << endl;
}



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

//---------template--------------
const int N=210000,p=1000000007;
int n,m,k,sx,sy;
char a[N],b[N];
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	scanf("%d%d",&sx,&sy);
	scanf("%s",a);scanf("%s",b);
	int l=0,r=m+1;
	//L R
	for (int i=k-1;i>=0;i--)
	{
		if (b[i]=='L'&&r<=m) r++;
		if (b[i]=='R'&&l>=1) l--;
		if (a[i]=='L') l++;
		if (a[i]=='R') r--;
		if (l+1>=r) 
		{
			puts("NO");
			return 0;
		}
	}
	if (sy<=l||sy>=r)
	{
		puts("NO");
		return 0;
	}

	l=0,r=n+1;
	for (int i=k-1;i>=0;i--)
	{
		if (b[i]=='U'&&r<=n) r++;
		if (b[i]=='D'&&l>=1) l--;
		if (a[i]=='U') l++;
		if (a[i]=='D') r--;
		if (l+1>=r) 
		{
			puts("NO");
			return 0;
		}
	}
	if (sx<=l||sx>=r)
	{
		puts("NO");
		return 0;
	}

	puts("YES");
}
/*
   f[i][j]=f[i+1][j+a[i]+b[i]] and f[i+1][j+a[i]] or f[i+1][j] and f[i+1][j+b[i]]
   b[i]==0	f[i][j]=f[i+1][j+a[i]] or f[i+1][j]
   a[i]==0	f[i][j]=f[i+1][j] and f[i+1][j+b[i]]
   a[i]=b[i]=1	f[i][j]=f[i+1][j+1] and f[i+1][j+2] or f[i+1][j] and f[i+1][j+1]
   111
  111 
 */


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

int main() {
  int n;
  int area[21][21];
  vector<string> texts;
  while (cin >> n && n) {
    rep(i, 21) {
      rep(j, 21) { area[i][j] = 0; }
    }
    rep(i, n) {
      int point[2];
      cin >> point[0] >> point[1];
      area[point[0]][point[1]] = 1;
    };
    area[10][10] = 0;
    int op, pos[] = {10, 10};
    cin >> op;
    rep(i, op) {
      string arrow;
      int dis;
      cin >> arrow >> dis;
      rep(j, dis) {
        if (arrow == "N")
          pos[1]++;
        else if (arrow == "S")
          pos[1]--;
        else if (arrow == "E")
          pos[0]++;
        else
          pos[0]--;
        area[pos[0]][pos[1]] = 0;
      }
    }
    string text = "Yes";
    rep(i, 21) {
      rep(j, 21) {
        if (area[i][j] == 1) text = "No";
      }
    }
    texts.push_back(text);
  }
  rep(i, texts.size()) { cout << texts[i] << endl; }
  return 0;
}



Measured memory_bytes: 3080
X,N = map(int,input().split())
if N > 0:
    A = list(map(int,input().split()))
    d = {}
    for i in range(102):
        d[i] = 0
    for a in A:
        d[a] = 1
    for i in range(0,100):
        x = X - i
        y = X + i
        if d[x] == 0:
            print(x)
            quit()
        if d[y] == 0:
            print(y)
            quit()
else:
    print(X)

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

// int *dp, *hrr, n;

// int main(){
//     cin>>n;
//     hrr = new int[n], dp = new int[n];
//     for(int i=0;i<n;i++){
//         cin>>hrr[i];
//     }

//     dp[0] = 0;
//     dp[1] = abs(hrr[1]-hrr[0]) + dp[0];
//     for(int i=2;i<n;i++){
//         dp[i] = min(dp[i-1]+abs(hrr[i]-hrr[i-1]), dp[i-2]+abs(hrr[i]-hrr[i-2]));
//     }
//     int ans = dp[n-1];
//     delete[] hrr;
//     delete[] dp;
//     cout << ans;

//     return 0;
// }

#include<bits/stdc++.h>
using namespace std;

int *hrr, *dp, n;

int MinHealthUpto(int c){
    if(c>=n)return INT_MAX;
    if(dp[c]!=-1)return dp[c];
    int ans = 0;
    if(c==0)ans=0;
    else if(c==1)ans=abs(hrr[1]-hrr[0]);
    else{
        ans = min(abs(hrr[c]-hrr[c-1])+MinHealthUpto(c-1), abs(hrr[c]-hrr[c-2])+MinHealthUpto(c-2));
    }
    dp[c] = ans;
    return ans;
}

int main(){
    cin>>n;
    hrr=new int[n];
    for(int i=0;i<n;i++){
        cin>>hrr[i];
    }
    dp=new int[n];
    for(int i=0;i<n;i++){
        dp[i]=-1;
    }
    int ans = MinHealthUpto(n-1);
    delete[] hrr;delete[] dp;
    cout << ans;
}

Measured memory_bytes: 6340
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> s;
    int ans = 0;
    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        ans += tmp;
        if(tmp % 10 != 0) s.push_back(tmp);
    }
    if(s.empty()){
        cout << 0 << endl;
        return 0;
    }

    sort(s.begin(), s.end());

    if(ans % 10 != 0){
        cout << ans << endl;
        return 0;
    }
    ans -= s[0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
int n,dp[2][3002][4],b[3002][3002],head[10002],cnt,ans,m,x,k,p[100002],val[5002],mx[5002],f[3002][3002];
inline int read(){
	re int t=0,f=0;re char v=getchar();
	while(v<'0')f|=(v=='-'),v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return f?-t:t;
}
signed main(){
	n=read(),m=read(),k=read();
	for(re int i=1;i<=k;++i){
		re int x=read(),y=read(),z=read();
		b[x][y]=z;
	}
	for(re int i=1;i<=n;++i){
		for(re int j=1;j<=m;++j){
			for(re int k=0;k<=3;++k){
				dp[i&1][j][k]=max(dp[i&1][j-1][k],f[i-1][j]);
				if(k)dp[i&1][j][k]=max(dp[i&1][j][k],max(dp[i&1][j-1][k-1],f[i-1][j])+b[i][j]);
				f[i][j]=max(f[i][j],dp[i&1][j][k]);
			}
		}
	}
	printf("%lld",f[n][m]);
}


Measured memory_bytes: 144672
//BISMILLAHHIR RAHMANIR RAHIM
#include<bits/stdc++.h>
using namespace std;
typedef long long int            ll;
typedef unsigned long long int   ull;
#define min3(a,b,c)              min(a,min(b,c))
#define F                        first
#define S                        second
#define PB                       push_back
#define MP                       make_pair
#define PI                       2*acos(0.0)
#define MOD                      998244353
int main()
{
   string s;
   cin>>s;
   if(s[2]==s[3] && s[4]==s[5]){
    cout<<"Yes"<<endl;
   }
   else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 256
// In The Name Of Allah
// Mehrkish Makuei

#include <bits/stdc++.h>

#define pb push_back
#define debug1(x) cerr << #x << " : " << x << endl;
#define debug2(x, y ) cerr << #x << " : " << x << "  " << #y << " : " << y << endl;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef vector <ll> vll;
typedef set <char> sch;
typedef set <ll> sll;

const ll MOD = 1e9 + 7;
const ll MAXN = 1e3 + 19;

str s1, s2, s3;

int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s1 >> s2 >> s3;
	if ( s1[s1.size() - 1] == s2[0] and s2[s2.size() - 1] == s3[0] )
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;


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

    int o = n * (n - 1) / 2;
    int e = m * (m - 1) / 2;
    cout << o + e << endl;
}





Measured memory_bytes: 256
/*
  kadai5_3 grid compression
  unomi
*/
#include <stdio.h>
#include <string.h>

int main(void){
    int row=0,column=0,i=0,j=0;
    int flag_row[1000],flag_column[1000];
    char grid[1000][1000];

    // 行数と列数 の入力を取得
    scanf("%d %d", &row, &column);
    // grid[row][column] で入力を取得
    for(i=0; i<row; i++){
        for(j=0; j<column; j++){
            scanf(" %c", &grid[i][j]);
        }
    }

    for(i=0; i<row; i++){
        for(j=0; j<column; j++){
            // 黒のマスがあった場合
            if(grid[i][j]=='#'){
                // そのマスがある行と列に対してフラグを建てる
                flag_row[i] = 1;
                flag_column[j] = 1;
            }
        }
    }

    for(i=0; i<row; i++){
        for(j=0; j<column; j++){
            // 対象のマスの行か列に黒のマスがあるなら、表示
            if(flag_row[i]==1 && flag_column[j]==1) printf("%c",grid[i][j]);
        }
        // 現在の行に黒のマスがあるなら、改行
        if(flag_row[i]==1) printf("\n");
    }

    return 0;
}

Measured memory_bytes: 256
import sys
import collections
from math import ceil
ma = lambda : map(int,input().split())
ni = lambda : int(input())
def divisor(n):
    d = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            d.append(i)
            if i != n//i:
                d.append(n//i)
    #d.sort()
    return d
n,m = ma()
gcd = 1
D = divisor(m)
for d in D:
    q,r = divmod(m,d)
    if q>=n and r==0:gcd = max(gcd,d)
print(gcd)


Measured memory_bytes: 3316
#include <stdio.h>

int main(void) {
	int N, M;
	long H[100000];
	int w[100000] = {0};
	int a,b;
	int sum = 0;
	
	scanf("%d %d", &N, &M);
	
	for(int i = 0; i < N; i++) {
		scanf("%ld", &H[i]);
	}
	
	for(int i = 0; i < M; i++) {
		scanf("%d %d", &a, &b);
		a--;
		b--;
		
		if(H[a] >= H[b]) {
			if(w[b] == 0) {
				w[b] = 1;
			}
		}
		if(H[a] <= H[b]) {
			if(w[a] == 0) {
				w[a] = 1;
			}
		}
	}
	
	for(int i = 0; i < N; i++) {
		sum += w[i];
	}
	sum = N - sum;
	
	printf("%d\n", sum);
	
	return 0;
}


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

int main() {
	int n,k,q;
	cin >> n >> k >> q;
	int a[100001];
	int b;
	for(int i=1; i<=n; i++){
		a[i] = 0;
	}
	for(int i=1; i<=q; i++){
		cin >> b;
		a[b] += 1;
	}
	for(int i=1; i<=n; i++){
		if(q - a[i] < k){
			cout << "Yes\n";
		}else{
			cout << "No\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#coding:utf-8
n = int(input())
e = [[int(i) for i in input().split()] for i in range(n-1)]

for i in range(n-1):
    x = 0
    for j in range(i, n-1):
        # x < s_j
        if x < e[j][1]:
            x = e[j][0] + e[j][1]
        elif x%e[j][2] != 0:
            x = x + e[j][0] - x%e[j][2] + e[j][2]
        else:
            x = x + e[j][0]
    print(x)

print(0)


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> v(n, vector<int>());
  bool used[n][3] = {};
  int f,t;

  for(int i=0;i<m;i++){
    cin >> f >> t;
    v[--f].push_back(--t);    
  }
  int start, end;
  cin >> start >> end;
  start--;end--;
  queue<P> q;
  q.push(make_pair(start, 0));
  while(!q.empty()){
    ll dst, cost;
    tie(dst, cost) = q.front();
    q.pop();
    if(dst == end && cost %3 == 0){
      cout << cost / 3 << endl;
      return 0;
    }
    if(used[dst][cost%3]) continue;
    used[dst][cost%3] = true;
    for(auto to: v[dst]){
      if(used[to][(cost+1)%3]) continue;
      q.push(make_pair(to, cost+1));
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  rep(i, N) cin >> p.at(i);

  double tmp = 0.0;
  rep(i, K) {
    tmp += p.at(i);
  }
  double x = tmp;
  for (int i = K; i < N; i++) {
    tmp += p.at(i);
    tmp -= p.at(i - K);
    x = max(x, tmp);
  }

  cout << fixed << setprecision(12) << (x + K) / 2 << endl;

  return 0;
}


Measured memory_bytes: 4056
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3fll
using namespace std;
typedef long long ll;
const int N=55;
int n,m,s,a[N][N],b[N][N];
ll dp[N*N*2][N],c[N],d[N],ans[N];
bool vis[N*N*2][N];
struct node
{
    int s,id;
    ll v;
    node(int s=0,ll id=0,ll v=0):s(s),id(id),v(v){}
    bool operator<(const node&o)const
    {
        if(s==o.s) return s>o.s;
        return v>o.v;
    }
};
queue<node>q;
int main()
{
    memset(ans,inf,sizeof(ans));
    memset(a,-1,sizeof(a));
    memset(b,-1,sizeof(b));
    scanf("%d%d%d",&n,&m,&s);
    for(int i=1;i<=m;i++)
    {
        int u,v,A,B;scanf("%d%d%d%d",&u,&v,&A,&B);
        a[u][v]=a[v][u]=A;
        b[u][v]=b[v][u]=B;
    }
    for(int i=1;i<=n;i++) scanf("%lld%lld",&c[i],&d[i]);
    memset(dp,inf,sizeof(dp));
    s=min(s,n*50*2);
    dp[s][1]=0;
    q.push(node(s,1,dp[s][1]));
    vis[s][1]=true;
    while(!q.empty())
    {
        int s=q.front().s,i=q.front().id;q.pop();
        ans[i]=min(ans[i],dp[s][i]);
        vis[s][i]=false;
        int up=min(s+(int)c[i],n*50*2);
        if(dp[up][i]>dp[s][i]+d[i])
        {
            dp[up][i]=dp[s][i]+d[i];
            if(!vis[up][i])
                q.push(node(up,i,dp[up][i])),vis[up][i]=true;
        }
        for(int j=1;j<=n;j++)
        {
            if(a[i][j]==-1||s<a[i][j]) continue;
            int up=s-a[i][j];
            if(dp[up][j]>dp[s][i]+b[i][j])
            {
                dp[up][j]=dp[s][i]+b[i][j];
                if(!vis[up][j]) vis[up][j]=true,q.push(node(up,j,dp[up][j]));
            }
        }
    }
    for(int i=2;i<=n;i++) printf("%lld\n",ans[i]);
}


Measured memory_bytes: 7476