akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cctype>
#include<cmath>
#include<cstring>
#include<sstream>
#include<set>
#include<map>
#define maxn 100000007
using namespace std;
typedef long long ll;
int main()
{
    int n,ok;
    int a[100005];
    cin>>n;
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    ok=1;
    for(int i=1;i<n;i++)
    {
        if(a[i-1]-a[i]>1)
        {
            ok=0;
            break;
        }
        else if(a[i-1]-a[i]==1)
            a[i]++;
    }
    if(ok)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, n-1){
        if (s[i] == s[i+1]) cnt++;
    }

    cout << min(cnt + 2 * k, n - 1) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,f,g,h;
    cin>>a>>b>>c>>d>>e>>f>>g>>h;
    int ansa=0,ans=0;
    for(int i=0;i<=f/(100*a);i++){
        for(int j=0;j<=(f-100*i*a)/(100*b);j++){
            g=100*a*i+100*b*j;
            h=min(f-g,g*e/100);
            for(int k=0;k<=(h/c);k++){
                if(ansa*g<=ans*(((h-c*k)/d)*d+c*k) || ans==0){
                    ansa=((h-c*k)/d)*d+c*k;
                    ans=g;
                }
            }
        }
    }
    cout<<ans+ansa<<" "<<ansa<<endl;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int n = cin.nextInt();
			if(n==0)break;
			HashMap<String,String> map = new HashMap<String,String>();
			for(int i = 0;i<n;i++){
				map.put(cin.next(), cin.next());
			}
			n = cin.nextInt();
			for(int i = 0;i<n;i++){
				String s =cin.next();
				if(map.containsKey(s)){
					System.out.print(map.get(s));	
				}
				else{
					System.out.print(s);
				}
				
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int main(void){
   int N;
   cin>>N;
   vector<int> a(N),b(N),c(N);
   for(int i=0;i<N;i++){
      cin>>a[i]>>b[i]>>c[i];
   }
   vector<vector<int>> dp(N+1,vector<int>(3));
   for(int i=0;i<N+1;i++){
      for(int j=0;j<3;j++){
         dp[i][j]=0;
      }
   }
   for(int i=0;i<N;i++){
      dp[i+1][1]=max(dp[i+1][1],dp[i][0]+b[i]);
      dp[i+1][2]=max(dp[i+1][2],dp[i][0]+c[i]);
      dp[i+1][0]=max(dp[i+1][0],dp[i][1]+a[i]);
      dp[i+1][2]=max(dp[i+1][2],dp[i][1]+c[i]);
      dp[i+1][0]=max(dp[i+1][0],dp[i][2]+a[i]);
      dp[i+1][1]=max(dp[i+1][1],dp[i][2]+b[i]);
   }
   int ans=0;
   for(int i=0;i<3;i++){
      ans=max(dp[N][i],ans);
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 6912
import sys
from fractions import gcd

read = sys.stdin.buffer.read

n,*t = list(map(int, read().split()))

def lcm(t):
  x = t[0]
  for i in range(1, len(t)):
    x = (x*t[i]) // gcd(x, t[i])
  return x

print(lcm(t))


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

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

int main() {
  int n, h[500];
  cin >> n;
  rep (i, n) cin >> h[i];
  sort(h, h + n);
  long long res = 0;
  rep (i, n) res += h[i];
  rep (i, n) if (i > 0) res -= max(h + n - lower_bound(h, h + n, i) - i * 4, 0L);
  ++res;
  cout << res << endl;
  return 0;
}

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

using namespace std;

#define ll long long int

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	ll a,b,x; cin >> a >> b >> x;
	
	if(a == 0)cout << b/x + 1 << '\n';
	else cout << b/x - (a-1)/x << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int I=X;I<Y;I++)
#define REP(I,X,Y) for(int I=Y-1;I>=X;I--)
#define INF 1000000007
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  if(N < K || N%K)cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
p['   '];t['   '];n,x;main(i){for(;++i<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i]&&++t[i+*t];for(;p[x]|!t[x];x--);}}

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

int main () {
  int a, b, c, d, X, Y, Z;
  cin >> a >> b >> c >> d;
  
  X = a-b; Y = b-c; Z = c-a;
  if (X < 0) {X *= -1;}
  if (Y < 0) {Y *= -1;}
  if (Z < 0) {Z *= -1;}
  if (Z <= d || X <= d && Y <= d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] AB = Console.ReadLine().Split(' ');
            int A = int.Parse(AB[0]);int B = int.Parse(AB[1]);
            if(A<10 & B < 10)
            {
                Console.WriteLine(A * B);
            }
            else
            {
                Console.WriteLine("-1");
            }
        }
    }
}


Measured memory_bytes: 27460
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    ans=ans^a;
  }
  if(ans==0){cout<<"Yes";}
  else{cout<<"No";}
}

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

int main (void)
{
	// variables for main process
	unsigned int register buffer_input;
	unsigned int register maxval_1st;
	unsigned int register maxval_2nd;
	unsigned int register maxval_answer;
	unsigned int          N;
	std::vector<unsigned int>A;

	// STEP.01
	// read out the given data
	// (the length of the given sequence)
	std::cin >> N;

	// STEP.02
	// read out the given data
	// (the values of the given sequence)
	for (register size_t itr = 0; itr < N; itr++)
	{
		std::cin >> buffer_input;
		A.push_back(buffer_input);
	}

	// STEP.03
	// initialize the variables to store the maximum values of given sequence
	maxval_1st = 0U;
	maxval_2nd = 0U;

	// STEP.04
	// search the maximum values of given sequence
	for (auto itr = A.begin(); itr != A.end(); itr++)
	{
		if (maxval_1st < *itr)
		{
			maxval_2nd = maxval_1st;
			maxval_1st = *itr;
		}
		else if (maxval_2nd < *itr)
		{ maxval_2nd = *itr; }
		else
		{ continue; }
	}

	// STEP.05
	// output the answer of this task
	for (auto itr = A.begin(); itr != A.end(); itr++)
	{
		if (*itr != maxval_1st) { maxval_answer = maxval_1st; }
		else                    { maxval_answer = maxval_2nd; }

		std::cout << maxval_answer << std::endl;
	}

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 2548
#include <iostream>
#include <algorithm>
int main()
{
      long long T;
      std::cin>>T;
      while(T--)
      {
            long long a,b,c,d,p=0;
            std::cin>>a>>b>>c>>d;
            
            if(b>a||a%b>c||d<b)p=1;
            if(!p&&c+1>=b)
            {
                  std::cout<<"Yes\n";
                  continue;
            }
            
            long long d1=d%b;a%=b;
            if(d1==0)
            {
                  if(p)std::cout<<"No\n";
                  else std::cout<<"Yes\n";
                  continue;
            }
            long long m=10000;
            while(m--)
            {
                  a+=(c-a)/d1*d1;
                  a=(a+d1)%b;
                  if(a>c)p=1;
            }
            
            
            if(p)std::cout<<"No\n";
            else std::cout<<"Yes\n";
      }
}

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

#ifdef DEBUG
#include ".inc/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    string s;
    cin >> s;

    int ans = 0;
    string prev = "", t = "";
    for (int i = 0; i < (int)s.size(); ++i) {
        t += s[i];
        if (prev != t) {
            ans++;
            prev = t;
            t = "";
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 720
#include<iostream>
#include<math.h>
#include<vector>
#define INF 1e9 + 5
using namespace std;

int calMinCost(vector<int>& height, int i, vector<int>& cache, int k) {

if (i == height.size() - 1)
  return 0;

if (cache[i] != INF)
  return cache[i];

for (int j = 1; j<=k; j++) {
    if (i + j < height.size())
        cache[i] = min(calMinCost(height, i+j, cache, k) + abs(height[i]-height[i+j]), cache[i]); 
    else
    {
        break;
    }
}                
return cache[i];
}
int main() {
  
  int n, k;
  //cout << "Enter the number " << endl;
  cin >> n;
  cin >> k;
  vector<int> height(n, 0);
  for (int i = 0; i<n; i++) {
    cin >> height[i];
  }

  vector<int> cache(n, INF);

  cout << calMinCost(height, 0, cache, k) << endl;
}

Measured memory_bytes: 10008
// C - Pyramid
#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
#define rp(i,n) for(int i=0;i<(n);i++)
#define manhattan(x1,y1,x2,y2) (abs((x1)-(x2))+abs((y1)-(y2)))
#define pb(x) push_back(x)
#define XMAX 100
#define YMAX 100

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

	VI AX,AY,AH;
	VI BX,BY,BH;
	int x,y,h;
	rp(i, N){
		cin>>x>>y>>h;
		if(h > 0){ AX.pb(x);AY.pb(y);AH.pb(h); }
		else{ BX.pb(x);BY.pb(y);BH.pb(h); }
	}

	rp(y0, YMAX+1){
		rp(x0, XMAX+1){

			int h0 = AH[0] + manhattan(x0,y0, AX[0],AY[0]);

			bool exist = true;
			for(int a=1; a<AH.size(); ++a){
				x = AX[a], y = AY[a], h = AH[a];
				if(h <= 0) continue;
				if(h0 != h + manhattan(x0,y0, x,y)){
					exist = false;
					break;
				}
			}
			if(!exist) continue;

			rp(b, BH.size()){
				x = BX[b], y = BY[b], h = BH[b];
				if(h > 0) continue;
				if(h0 - manhattan(x0,y0, x,y) > 0){
					exist = false;
					break;
				}
			}
			if(exist){
				cout<<x0<<" "<<y0<<" "<<h0<<"\n";
				return 0;
			}

		}
	}

}

Measured memory_bytes: 256
from collections import defaultdict


def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    odd = a[::2]
    even = a[1::2]
    if n % 2:
        ans = odd[::-1] + even
    else:
        ans = even[::-1] + odd
    print(*ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 25412
#include <bits/stdc++.h>
#define INT long long int
#define MOD 1000000007
#define oo (INT)(6e18)
using namespace std;
INT n, a, b;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>a>>b;
    if( abs(a-b)%2 ) cout<<"Borys\n";
    else cout<<"Alice\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Set<Integer> set = new HashSet<>();
		for(int i = 0;i < N;i++) {
			set.add(sc.nextInt());
		}
		sc.close();
		System.out.println(set.size());
	}
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int n;
    cin>>n;
    long long int a[n],c[n+1]={0};
    for(long long int i=0;i<n;i++){cin>>a[i];c[a[i]]=i+1;}
    for(long long int i=1;i<n+1;i++)cout<<c[i]<<" ";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    int N;
    cin >> N;
    vector<int> b(N);
    for (int i = 0; i < N; i++) cin >> b[i];
    vector<int> ans;
    for (int i = 0; i < N; i++) {
        bool check = true;
        for (int j = b.size() - 1; j >= 0; j--) {
            if (b[j] == (j + 1)) {
                ans.push_back(b[j]);
                // cout << ans << endl;
                b.erase(b.begin() + j);
                check = false;
                break;
            }
        }
        if (check) {
            cout << -1 << endl;
            return 0;
        }
    }

    for(int i = ans.size() - 1; i >= 0; i--) cout << ans[i] << endl;
}


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

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>
#include <iomanip>

using namespace std;

int main() {
	int n, k;
	int p,q;
	cin >> n >> k;

	vector<int> arr(n+1);

	for (int i = 0; i < k; i++) {
		cin >> p;
		for (int j = 0; j < p; j++) {
			cin >> q;
			arr[q]++;
		}
	}

	int ans = 0;
	for (int i = 1 ; i <= n; i++) {
		if (arr[i] == 0)ans++;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  ll n; cin >> n;
  vector<ll> ans(n + 1,1);
  FOR(i,2,n) {
    int now=i;
    ans[now] ++ ;
    /* cout << "now num is " << now << endl; */
    while (true) {
      now += i;
      if (now > n) break;
      /* cout << now << endl; */
      ans[now]++;
    }
  }


  ll res = 0;
  FOR(i,1,n) {
    /* cout << "now number is " << i << " num item " << ans[i] << " sum is  " << i * ans[i] << endl; */
    res += i * ans[i];
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 81400
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double w,h,x,y;
    scanf("%lf%lf%lf%lf",&w,&h,&x,&y);
    double s=w*h/2;
    if(x==w/2&&y==h/2)
        printf("%lf 1\n",s);
    else
        printf("%lf 0\n",s);
    return 0;
}



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

int main() {
  string S;
  cin >> S;
  string out = "No";
  vector<char> a(4);
  for(int i = 0; i < 4; i++){
    a.at(i) = S.at(i);
  }
 
  if(a.at(0) == a.at(1)){
    if(a.at(2) == a.at(3)){
      out = "Yes";
    }
  }else if(a.at(0) == a.at(2)){
    if(a.at(1) == a.at(3)){
      out = "Yes";
    }
  }else if(a.at(0) == a.at(3)){
    if(a.at(1) == a.at(2)){
      out = "Yes";
    }
  }
 if(a.at(0) == a.at(1)){
    if(a.at(1) == a.at(2)){
      if(a.at(2) == a.at(3)){
        out = "No";
      }
    }
 }
  cout << out << endl;
}


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

int su[200001];
int su2[200001];

int main(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    int x;
    scanf("%d",&x);
    su[i] = su2[i] = x;
  }
  sort(su2, su2+n);
  for(int i=0;i<n;i++){
    if(su[i] < su2[n/2]) printf("%d\n", su2[n/2]);
    else printf("%d\n", su2[n/2-1]);
  }
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,cnt=0;
    cin>>n;
    while(n>=1){
        n=n/2;
        cnt++;
    }
    ll ans=2,sum;
     for(int i=1;i<cnt;i++){
        ans*=2;
     }
     sum=(ans-1);
     cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
const int MAX = 2e6;
int ex[MAX]={};

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

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

  //与えられた数列の数字をインクリメント
  for(int a:as) ex[a]++;

  for(int i=1;i<MAX;i++){
    //ex[i]に min(ex[i],2) を代入 <- なんのため？
    //chmin(ex[i],2);
    //iの倍数jについて
    for(int j=i+i;j<MAX;j+=i)
    //ex[j]に
      ex[j]+=ex[i];
  }

  int ans=0;
  for(int a:as)
    if(ex[a]==1) ans++;
  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 11908
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
total = 0
ans = 0
free = []
for a, b in zip(A,B):
    if b > a:
        total += b-a
        ans += 1
    else:
        free.append(a-b)
free.sort(key=lambda x: -x)
for i in free:
    if total <= 0:
        break
    total -= i
    ans += 1
if total > 0:
    print(-1)
else:
    print(ans)



Measured memory_bytes: 18356
from heapq import heappush,heapify,heappop
INF = 10**10

n,m,r = map(int,input().split())

es=[[] for _ in range(n)] # es[i] = (頂点iの(隣接する頂点,コスト)の組)
d = [INF]*n # 頂点sからの最短距離

# 入力
for i in range(m):
    a,b,c = map(int,input().split())
    es[a].append((b,c))


def dijkstra(s):
    v = -1
    que = [(0,s)]
    heapify(que)
    d[s] = 0
    while que:
        p = heappop(que)
        v = p[1]
        if d[v] < p[0]:
            continue
        for e in es[v]:
            if d[e[0]] > d[v] + e[1]:
                d[e[0]] = d[v] + e[1]
                heappush(que, (d[e[0]], e[0])) 
dijkstra(r)

for i in d:
    if i==INF:
        print("INF")
    else:
        print(i)


Measured memory_bytes: 89280
#include <iostream>


int main(){
    int A,B,C;
    int K;
    //入力
    std::cin>>A>>B>>C;
    std::cin>>K;
    while(K>0){
        if(A<B&&B<C){
            break;
        }else if(A>=B){
            B*=2;
        }else if(B>=C){//A<B
            C*=2;
        }
        //std::cout<<A<<B<<C<<std::endl;
        K--;
    }
    if(A<B&&B<C){
    std::cout<<"Yes";    
    }else{
    std::cout<<"No";    
    }
    return 0;
}


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


const int v_MAX = 100000;

int main()
{
    int N, W;
    cin >> N >> W;
    vector<long> w(N+1), v(N+1);
    for( int i = 1; i <= N; ++i ) cin >> w[i] >> v[i];
    

    // dp[i][j]: i 番目までの品物から価値の和が j 以下になるように
    //           選んだときの重さの最小値
    long dp[101][v_MAX+1];
    for( int i = 0; i <= N; ++i ){
        for( int j = 0; j <= v_MAX; ++j ){
            dp[i][j] = 1e+11;
        }
    }
    dp[0][0] = 0;
    
    for( int i = 1; i <= N; ++i ){
        for( int j = 0; j <= v_MAX; ++j ){
            if( j >= v[i] ) dp[i][j] = min( dp[i-1][j], dp[i-1][j-v[i]] + w[i] );
            else            dp[i][j] = dp[i-1][j];
        }
    }
    for( int j = v_MAX; j >= 0; --j ){
        if( dp[N][j] <= W ){
            cout << j << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 79104
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        final int baseCount = 111;
        final int input = new Scanner(System.in).nextInt();
        int result;
        if (input % baseCount == 0) {
            result = input;
        } else {
            result = (input / baseCount + 1) * baseCount;
        }
        System.out.println(result);
    }
}

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

int main() {
  int A, B, ans;
  string op;
  cin >> A >> op >> B;
  
  if(op == "+"){
    ans = A + B;
  }else{
    ans = A - B;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,ext;
    cin >> n >> ext;
    vector<int> t(n);
    for(int i = 0; i < n; i++) {
        cin >> t[i];
    }
    ll ans=ext;
    for(int i = 0; i < n-1; i++) {
        int tmp=min(ext,t[i+1]-t[i]);
        ans+=tmp;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
// Aizu 0264: Finite Field Calculator
// 2017.9.10 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <ctype.h>

char str[100004], *p;
char ans[100004], *q;
int m;

int getInt()
{
	int n = 0;
	while (isspace(*p)) p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	while (isspace(*p)) p++;
	return n;
}

int int2str(char *b, int val)
{
	char buf[30], *bp = buf+20;
	int i, k = 0;

	do *(--bp) = val % 10 + '0', k++; while ((val = val/10));
	for (i = 0; i < k; i++) *b++ = *bp++;
	return k;
}

int egcd(int a, int b, int *x, int *y)
{
    int d;

    if (b == 0) { *x = 1, *y = 0; return a; }
    d = egcd(b, a % b, y, x);
    *y -= a/b*(*x);
    return d;
}

int factor()
{
	int x;
	int calc();

	if (*p == '(') { p++; if ((x = calc()) < 0) return -1; p++; }
	else x = getInt() % m;
	return x;
}

int term()
{
	int x, y, op;

	if ((x = factor()) < 0) return -1;
	while (1) {
		if (*p == '*') op = 1;
		else if (*p == '/') op = 0;
		else break;
		p++;
		if ((y = factor()) < 0) return -1;
		if (op) x *= y, x %= m;
		else {
			int t1, t2;
			if (egcd(y, m, &t1, &t2) != 1) return -1;
			x *= t1, x %= m; if (x < 0) x += m;
		}
	}
	return x;
}

int calc()
{
	int x, y, op;
	
	if ((x = term()) < 0) return -1;
	while (1) {
		if      (*p == '+') op = 1;
		else if (*p == '-') op = 0;
		else break;
		p++;
		if ((y = term()) < 0) return -1;
		if (op) x += y; else x -= y;
		if (x < m) x += m;
		if (x >= m) x -= m;
	}
	return x;
}

int main()
{
	int k;

	while (1) {
		fgets(p = str, 100002, stdin); if (*p == '0') break;
		q = ans, m = getInt(), p++;
		while (*p) { while (isspace(*p)) p++; if (*p) *q++ = *p++; }
		*q = 0; p = ans;
		if ((k = calc()) < 0) { puts("NG"); continue; }
		*q++ = ' ', *q++ = '=', *q++ = ' ', q += int2str(q, k);
		strcpy(q, " (mod "), q += 6, q += int2str(q, m), *q++ = ')', *q = 0;
		puts(ans);
	}
	return 0;
}

Measured memory_bytes: 1816
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
using namespace std;
int main(){
	int n, k, d0, i,j,l,len,a,sum;
	int aa[6];
	bool f;
	vector<int> d,e;
	cin >> n >> k;
	for (i = 0; i < k; i++) {
		cin >> d0;
		d.push_back(d0);
	}
	len = d.size();
	for (i = n; i < 100000; i++) {
		for (j = 0; j < 6; j++) {
			aa[j] = -1;
		}
		a = i;
		sum = 0;
		while (a > 0) {
			a /= 10;
			sum++;
		}
		a = i;
		while (sum > 0) {
			aa[sum-1] = a / (int)pow(10, sum-1);
			a %= (int)pow(10,sum - 1);
			sum--;
		}
		f = true;
		for (j = 0; j < len; j++) {
			for (l = 0; l < 6; l++) {
				if (aa[l] == d[j])f = false;
			}
		}
		if (f)break;
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,c,ans,p,i,j;
  scanf("%d%d%d",&n,&m,&c);
  int b[m];
    for(i=0;i<m;i++){
      scanf("%d",&b[i]);
    }
  int a[i];
    ans=0;
  p=0;
  for(j=0;j<n;j++){
  	for(i=0;i<m;i++){
      scanf("%d",&a[i]);
      p+=a[i]*b[i];
 	 }
    p+=c;
    if(0<p){
      ans+=1;
    }
    p=0;
  }
  printf("%d",ans);
}

Measured memory_bytes: 128
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

VI g[100010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n; cin >> n;
  REP(i, n-1) {
    int u, v; cin >> u >> v;
    u--, v--;
    g[u].PB(v);
    g[v].PB(u);
  }

  VI d(n);
  function<void(int,int,int)> dfs = [&](int v, int p, int cost) {
    d[v] = cost;
    for(int i: g[v]) if(i != p) {
      dfs(i, v, cost+1);
    }
  };

  dfs(0, -1, 0);
  int ma = -1, idx1 = -1;
  REP(i, n) {
    if(ma < d[i]) {
      ma = d[i];
      idx1 = i;
    }
  }

  dfs(idx1, 0, 0);
  int idx2 = -1; ma = -1;
  REP(i, n) {
    if(ma < d[i]) {
      ma = d[i];
      idx2 = i;
    }
  }

  // idx1 -> idx2 のパスが胴体になる
  int now = idx2;
  VI v, able(n, true);
  while(now != idx1) {
    v.PB(now); able[now] = false;
    for(int i: g[now]) {
      if(d[i]+1 == d[now]) {
        now = i;
        break;
      }
    }
  }
  v.PB(idx1); able[now] = false;
  reverse(ALL(v));

  // i番目の頂点から生えてる足の本数
  VI vec;
  for(int i: v) {
    // 頂点iから探索をして深さ2以上の足が生えてたらだめ
    int sz = 0;
    for(int j: g[i]) if(able[j]) {
      sz++;
      if(g[j].size() >= 2) {
        cout << "-1" << endl;
        return 0;
      }
    }
    vec.PB(sz);
  }

  // 順列を2種類生成
  VI ans1, ans2;
  now = 1;
  for(int i: vec) {
    REP(j, i) ans1.PB(now+j+1);
    ans1.PB(now);
    now += i+1;
  }
  reverse(ALL(vec));
  now = 1;
  for(int i: vec) {
    REP(j, i) ans2.PB(now+j+1);
    ans2.PB(now);
    now += i+1;
  }

  if(ans1 < ans2) {
    REP(i, n) cout << ans1[i] << (i==n-1?"\n":" ");
  } else {
    REP(i, n) cout << ans2[i] << (i==n-1?"\n":" ");
  }

  return 0;
}


Measured memory_bytes: 20596
package main

import (
	"bufio"
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

func (p *problem) solve() {
	t := p.Next()
	prev := '_'
	for _, c := range t {
		if prev == c {
			p.Printfln("Bad")
			return
		}
		prev = c
	}
	p.Printfln("Good")
}

var (
	debug  bool
	output string
)

func main() {
	flag.BoolVar(&debug, "debug", false, "Print debug logs")
	flag.BoolVar(&debug, "d", false, "Print debug logs")
	flag.StringVar(&output, "output", "stdout", "Specify output target (Default: stdout)")
	flag.StringVar(&output, "o", "stdout", "Specify output target (Default: stdout)")
	flag.Parse()

	if debug {
		out := os.Stdout
		if output != "stdout" {
			logfile, err := os.OpenFile(output, os.O_CREATE|os.O_WRONLY, 0666)
			if err != nil {
				panic(err)
			}
			defer logfile.Close()
			out = logfile
		}
		log.SetOutput(out)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) PrintInt(d int) {
	p.Printf("%d\n", d)
}

func (p *problem) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) Printfln(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, fmt.Sprintf("%v\n", format), a...); err != nil {
		panic(err)
	}
}

func (p *problem) NextInt() int {
	return stoi(p.Next())
}

func (p *problem) NextInts() []int {
	line := p.NextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) NextSSLine() []string {
	return strings.Split(p.Next(), " ")
}

// Next reads line and return string.
func (p *problem) Next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <math.h>

using namespace std;

int main(){
    long long a, b, k;
    cin >> a >> b >> k;
    if(k > a){
        k -= a;
        a = 0;
        if(k > b){
            b = 0;
        }
        else b -= k;
    }
    else{
        a -= k;
    }
    cout << a << " " << b;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int E[5001], n[5001], C[5001], H[2501];
bool vis[2501];
void dfs(int v) {
	vis[v] = true;
	for (int p = H[v]; p; p = n[p]) {
		int to = E[p];
		if (!vis[to]) dfs(to);
	}
}

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


	int N, M, P;
	cin >> N >> M >> P;
	rep1(i, M) {
		int a;
		cin >> a >> E[i] >> C[i];
		n[i] = H[a];
		H[a] = i;
	}
	int D[2501];
	rep1(i, N) D[i] = -1e9;
	D[1] = 0;
	int q[2501] = {};
	q[1] = 1;

	//こんな明らかに正しくない提出をさらに繰り返して何をしたいというのか
	//結果さえ良ければ手段は何でもいいのかこのごみくずめ！なんの実りもないな！

	int cnt[2501] = {};

	rep1(k, N) {
		rep1(i, N) {
			if (q[i] == k) {
				for (int p = H[i]; p; p = n[p]) {
					int to = E[p];
					int d = D[i] + C[p] - P;
					if (D[to] < d && cnt[to] < 520) {
						D[to] = d;
						q[to] = k + 1;
						cnt[to]++;
					}
				}
			}
		}
	}

	rep1(i, N) {
		if ((q[i] == N + 1 || cnt[i] == 520) && !vis[i]) dfs(i);
	}

	if (vis[N]) co(-1);
	else co(max(0, D[N]));

	Would you please return 0;
}

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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

int cnt(int k, int n) {
  while (n % k == 0) {
    n /= k;
  }
  return (n % k == 1);
}

signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t;

  t = 1;

  while (t--) {
    int n;
    cin >> n;
    if (n == 2)
      return cout << 1 << endl, 0;

    int ans = 1;
    for (int i = 1; i * i <= (n - 1); ++i) {
      if ((n - 1) % i == 0) {
        int l = i, r = (n - 1) / i;
        ans += 2 - (l == r || l == 1);
      }
    }

    for (int k = 2; k * k <= n; ++k) {
      if (n % k == 0) {
        ans += cnt(k, n);
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 256
N=int(input())
S=input()
l=len(S)

flag=""
count=0

for i in range(l):
    if S[i]=="O" and flag=="X":
        count+=1
        flag=""
    elif S[i]=="O" and flag=="":
        flag="O"
    elif S[i]=="X" and flag=="O":
        count+=1
        flag=""
    elif S[i]=="X" and flag=="":
        flag="X"
print(count)



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

def search(x: int) -> (int, int):
    for a in range(-1000, 1001):
        for b in range(-1000, 1001):
            if a ** 5 - b ** 5 == x:
                return (a, b)
    return (-2000, -2000)

a, b = search(x)
print(f"{a} {b}")


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll H, W;
    cin >> H >> W;
    cout << string(W + 2, '#') << endl;
    for(ll h = 0;h < H;h++) {
        string temp;
        cin >> temp;
        cout << '#' << temp << '#' << endl;
    }
    cout << string(W + 2, '#') << endl;
    return 0;
}


Measured memory_bytes: 256
import itertools

N, K = map(int, raw_input().split())

def foo(N, K):
    
    if K > (N-1)*(N-2)/2:
        print -1
        return
    edges = [(1, j) for j in range(2, N+1)]
    count = (N-1)*(N-2)/2
    it = itertools.combinations(range(2, N+1), 2)

    while count > K:
        edges.append(next(it))
        count -= 1
    print len(edges)
    for i, j in edges:
        print i, j

foo(N, K)


Measured memory_bytes: 2948
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;



//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr;	} cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int i = 1; i < N; i++) cout << ", " << v[i]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define all(x) (x).begin(), (x).end()



typedef pair<int, int> edge;
vector<edge> edges;

int problemC()
{
	int N, M, ans = 0;
	cin >> N >> M;

	int v, w;
	for (int i = 0; i < M; i++) {
		cin >> v >> w;
		edges.push_back(edge(v, w));
	}

	// i : off にする辺
	for (int i = 0; i < M; i++) {

		vector<vector<int> > li(N + 1);
		// 辺 i を除いて隣接リストを作る
		for (int j = 0; j < M; j++) {
			if (j == i) continue;
			edge e = edges[j];
			li[e.first].push_back(e.second);
			li[e.second].push_back(e.first);
		}

		queue<int> qu;
		set<int> st;
		int vcount = 0;

		qu.push(1);

		while (!qu.empty()) {
			int v = qu.front();
			qu.pop();
			st.insert(v);
			vcount++;

			for (int k = 0; k < li[v].size(); k++) {
				if (st.find(li[v][k]) == st.end()) qu.push(li[v][k]);
			}
		}

		if (st.size() != N) ans++;
	}

	cout << ans << endl;

	return 0;
}

int main()
{
	//clock_t start, end;
	//start = clock();

	problemC();
	
	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> dp(N+1, 0);
    dp[0] = 1;
    dp[1] = 1;
    rep2(i, 2, N+1) {
        dp[i] = dp[i-1] + dp[i-2];
    }
    cout << dp[N] << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 3204
def main():
  n,m=map(int,input().split())
  a=[0 for i in range(m)]
  b=[0 for i in range(m)]
  c=[[] for i in range(m)]
  for i in range(m):
    a[i],b[i]=map(int,input().split())
    c[i]=list(map(int,input().split()))
  
  dp=[float("inf") for i in range(2**n)]
  dp[0]=0
  for i in range(m):
    now=0
    for j in c[i]:
      jj=1<<j-1
      now=now|jj
    for k in range(2**n):
      kk=k|now
      dp[kk]=min(dp[kk],dp[k]+a[i])
    

  if dp[-1]==float("inf"):
    print(-1)
  else:
    print(dp[-1])
    
if __name__ == '__main__':  
  main()
    

Measured memory_bytes: 3424
#include <iostream>
using namespace std;
 
int main() {
	int a,b,c,d,tr,bu;
	cin>>a>>b>>c>>d;
	tr=0;
	bu=0;
	if(a>=b){
		tr=b;
	}
	else if(a<=b){
		tr=a;
	}
 
	if(c>=d){
		bu=d;
	}
	else if(d>=c){
		bu=c;
	}
	cout<<tr+bu<<endl;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


d,g = list(map(int, input().split()))
pc = [None]*d
for i in range(d):
    pc[i] = tuple(map(int, input().split()))
pc = pc[::-1]
ans = float("inf")
for b in range(1<<d):
    nokori = g
    val = 0
    for i in range(d):
        if b>>i&1:
            nokori -= (pc[i][0]*100*(d-i) + pc[i][1])
            val += pc[i][0]
    
    if nokori>0:
        for j in range(d):
            if b>>j&1:
                continue
            if pc[j][0]*100*(j+1)>=nokori:
                tmp = nokori//(100*(d-j)) + int(nokori%(100*(d-j))>0)
                val += tmp
                nokori -= tmp*(100*(d-j))                    
            else:
                nokori -= (pc[j][0]*100*(d-j) + pc[j][1])
                val += pc[j][0]
            if nokori<=0:
                break
    ans = min(ans, val)
print(ans)

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int table[365][26];
int main()
{
	int D;
	cin >> D;
	vec(C);
	vec(Las);
	fx(26) {
		vecp(C);
		Las.push_back(0);
	}

	fx(D) {
		fy(26) {
			cin >> table[x][y];
		}
	}

	vec(T);
	fx(D) {
		vecp(T);
	}
	int M;
	cin >> M;

	fx(M) {
		int d, q;
		cin >> d >> q;
		T[d - 1] = q;
		ll ans = 0;
		fy(26) {
			Las[y] = 0;
		}
		fw(D) {

			ans += table[w][T[w] - 1];
			Las[T[w] - 1] = w + 1;
			fz(26) {
				ans -= C[z] * (w + 1 - Las[z]);
			}
			
		}

		ce(ans)
	}

	
    return 0;
}



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


int main(){
   string s;
   cin >>s;
   int n=s.length();
   int ans=0;
   for(int i=0;i<n;i++){
       for(int j=i;j<n;j++){
           int a=0;
           for(int k=i;k<=j;k++){
               if((s[k]=='A'||s[k]=='T'||s[k]=='G'||s[k]=='C')) a++;
               else a=0;
           }
           ans=max(ans,a);
       }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
ll f(ll n,ll k){
  if(n<k) return n;
  if(n%k==0){
    return f(n/k,k);
  }else{
    return f(n%k,k);
  }
}
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);
    }
  }
  return (ret);
}
signed main(){
  init_io();
  ll n,ans=0;
  cin >> n;
  vector<ll> d0 = divisor(n),d1=divisor(n-1);
  for(auto i:d0){
    if(i==1) continue;
    if(f(n,i)==1){
      ans++;
    }
  }
  for(auto i:d1){
    if(i==1) continue;
    if(n%i!=0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
long long int a=0LL;
  long long int n;cin>>n;
  for(long long int i=0LL;i<=n;i++){
  	if(i%3!=0 and i%5!=0){
  a+=i;
  }
  }
cout<<a<<endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void) {
  int A;
  int B;
  int C;
  int D;
  scanf("%d%d%d%d", &A, &B, &C, &D);
  while (1) {
    C = C - B;
    if (C <= 0) {
      printf("Yes\n");
      return 0;
    }
    A = A - D;
    if (A <= 0) {
      printf("No\n");
      return 0;
    }
  }
}

Measured memory_bytes: 1660
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
      int h = sc.nextInt();
      int a  = sc.nextInt();
      int ans =0;
      if(h%a==0){
        ans = h/a;
      }else{
        ans= (h/a) +1;
      }
      System.out.println(ans);
  }
}


Measured memory_bytes: 20820
import java.util.*;
import java.math.BigInteger;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    System.out.println(kaijou(N));
  }
  
  public static BigInteger kaijou(int num) {
    BigInteger result = BigInteger.ONE;
    for (int i = 2; i <= num; i++) {
      result = result.multiply(BigInteger.valueOf(i));
      result = result.remainder(BigInteger.valueOf(1000000007));
    }
    return result;
  }
}

Measured memory_bytes: 42184
import sys

icase=0
if icase==0:
    n=int(input())
    a=[[0]*n for i in range(n)]
    for i in range(n):
        a[i]=list(map(int,input().split()))
elif icase==1:
    n=3
    a=[[0, 1, 3], [1, 0, 2], [3, 2, 0]]
#    a=[[0, 1, 3], [1, 0, 1], [3, 1, 0]]

dp=[[0]*n for i in range(n)]
for i in range(n):
    dp[i]=a[i].copy()
    
c=[[0]*n for i in range(n)]

for k in range(n):
    for i in range(n):
        for j in range(n):
            if dp[i][j]>dp[i][k]+dp[k][j]:
                dp[i][j]=dp[i][k]+dp[k][j]
            if dp[i][j]==dp[i][k]+dp[k][j] and i!=k and j!=k:
                c[i][j]=1                
                

icnt=0
for i in range(0,n-1):
    for j in range(i+1,n):
        if a[i][j]!=dp[i][j]:
            print(-1)
            sys.exit()
        elif c[i][j]==0:
            icnt+=dp[i][j]
print(icnt)

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


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


Measured memory_bytes: 4400
#include<stdio.h>
int main(void)
{
	int flg[30+1];
	int data[30+1],bangou[30+1];
	int i,j;
	for(i=1;i<=30;i++){
		bangou[i]=i;
		flg[i]=0;
	}
	for(i=1;i<=30;i++){
		scanf("%d",&data[i]);
	}
	for(i=1;i<=30;i++){
		for(j=1;j<=30;j++){
			if(bangou[i]==data[j]){
				flg[i]=1;
			}
		}
	}
	for(i=1;i<=30;i++){
		if(flg[i]==0){
			printf("%d\n",i);
		}
	}
	return 0;
}

Measured memory_bytes: 1020
import math

n = int(input())
#a, b = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
#list = [int(i) for i in input().split()]
#num = [int(i) for i in range(n)]
#s = input()
#list = list(s)
#temp = [[0 for _ in range(13)] for _ in range(13)]

print(3*n*n)

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


ll i,h,n,ans;
ll x[10005];


bool solve(){
	cin >> n;
	if(n == 0)return false;
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	ans = 99999999;
	sort(x,x+n);
	for(i=0;i<n-1;i++){
		ans = min(ans,x[i+1]-x[i]);
	}
	cout << ans << endl;
	return true;
}

int main(){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>

using namespace std;

int main(){

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

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

    vector<vector<int>> G(n);

    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    int s=0;

    for(int i=0;i<n;i++){
        int c=0;
        for(int j=0;j<G[i].size();j++){
            if(h[i]>h[G[i][j]])c++;
        }
        if(c==G[i].size())s++;
    }

    cout << s << endl;


}

Measured memory_bytes: 9016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N){
    cin >> A.at(i);
    A.at(i)--;
  }
  if(K < N){
    ll ima = 0;
    rep(i, K){
      ima = A.at(ima);
    }
    cout << ima+1 << endl;
    return 0;
  }
  vector<ll> reach(1, 0);
  set<ll> S;
  S.insert(0);
  ll now = 0;
  ll ls = 0;
  rep(i, N){
    now = A.at(now);
    if(S.count(now)){
      ls = now;
      break;
    }
    S.insert(now);
    reach.push_back(now);
  }
  ll lf = 0;
  rep(i, sz(reach)){
    if(reach.at(i) == ls){
      lf = i;
      break;
    }
  }
  ll lsz = sz(reach)-lf;
  now = 0;
  rep(i, lf){
    now = A.at(now);
  }
  rep(i, (K-lf)%lsz){
    now = A.at(now);
  }
  cout << now+1 << endl;
}

Measured memory_bytes: 13284