akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
a = gets.split.map(&:to_i).sort

ary = []
i = a.index {|e| e >= 0}

if i.nil?
    m = a[-1]
    a[0..-2].each do |e|
        ary << "#{m} #{e}"
        m -= e
    end
elsif i == 0
    m = a[0]
    a[1..-2].each do |e|
        ary << "#{m} #{e}"
        m -= e
    end
    ary << "#{a[-1]} #{m}"
    m = a[-1] - m
else
    m = a[0]
    a[i..-2].each do |e|
        ary << "#{m} #{e}"
        m -= e
    end
    ary << "#{a[-1]} #{m}"
    m = a[-1] - m
    a[1..i-1].each do |e|
        ary << "#{m} #{e}"
        m -= e
    end
end

puts m, ary

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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,i,f=0,l=1,c=0;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)
    cin>>a[i];
  for(i=0;i<n;i++)
  {
    if(a[i]==l)
      {
        l++;
        f++;
      }
    else
      c++;
  }
  if(f==0)
    cout<<"-1";
  else
    cout<<c;
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  //TIME
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
  int x;
  scanf("%d", &x);
  
  if (x == 2 || x == 3)
  {
    printf("%d", x);
    return 0;
  }
  int i;
  int flg = 1;
  while (flg == 1)
  {
    i = 2;
    flg = 0;
    while (i < x / 2)
    {
      if (x % i == 0)
      {
        flg = 1;
        break;
      }
      i++;
    }
    x++;
  }
  printf("%d", x - 1);
  return 0;
}

Measured memory_bytes: 128
import java.util.Random;
import java.util.Scanner;

public class Main {
	private static final int K = 26;
	private static final int COUNT = 1000000;
	private static Random rand = new Random(System.currentTimeMillis());

	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var d = sc.nextInt();
		var c = new int[K];
		var s = new int[d][K];
		for (var i = 0; i < K; i++) {
			c[i] = sc.nextInt();
		}
		for (var i = 0; i < d; i++) {
			for (var j = 0; j < K; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		sc.close();

		var count = 0;
		var t = create(c, s, d);
		for (var j = 1; count < COUNT; j++) {
			for (var i = 0; i < d; i++) {
				count++;
				var mdi = i % d;
				var mti = (t[mdi] + j - 1) % K;
				var check = check(c, s, t, d, mdi, mti);
				if (check > 0) {
					t[mdi] = mti + 1;
				}
			}
		}

		for (var i = 0; i < d; i++) {
			System.out.println(t[i]);
		}
		//System.out.println(score(c, s, t, d));
	}

	private static int check(int[] c, int[][] s, int[] t, int d, int mdi, int mti) {
		var sum = 0;
		var ti = t[mdi] - 1;
		sum += s[mdi][mti] - s[mdi][ti];

		var last1 = 0;
		var last2 = 0;
		for (var i = mdi - 1; i >= 0; i--) {
			if (t[i] == ti + 1) {
				last1 = i + 1;
				break;
			}
		}
		for (var i = mdi - 1; i >= 0; i--) {
			if (t[i] == mti + 1) {
				last2 = i + 1;
				break;
			}
		}

		var count1 = 1;
		var count2 = 1;
		for (var i = mdi + 1; i < d; i++) {
			if (t[i] == ti + 1) {
				break;
			}
			count1++;
		}
		for (var i = mdi + 1; i < d; i++) {
			if (t[i] == mti + 1) {
				break;
			}
			count2++;
		}
		sum += (mdi - last2 + 1) * c[mti] * count2 - (mdi - last1 + 1) * c[ti] * count1;
		return sum;
	}

	private static int score(int[] c, int[][] s, int[] t, int d) {
		var sum = 0;
		var last = new int[K];
		for (var i = 0; i < d; i++) {
			var ti = t[i] - 1;
			sum += s[i][ti];
			last[ti] = i + 1;
			for (var j = 0; j < K; j++) {
				sum -= ((i + 1) - last[j]) * c[j];
			}
		}

		return sum;
	}

	private static int[] create(int[] c, int[][] s, int d) {
		var t = new int[d];
		var last = new int[K];
		for (var i = 0; i < d; i++) {
			var v = new int[K];
			for (var j = 0; j < K; j++) {
				v[j] = s[i][j] + (((i + 1) - last[j]) * c[j]);
			}
			t[i] = rand(v) + 1;
			last[t[i] - 1] = i + 1;
		}
		return t;
	}

	private static int rand(int[] v) {
		var sum = 0;
		for (var i = 0; i < v.length; i++) {
			sum += v[i];
		}
		var value = rand.nextInt(sum);
		var index = 0;
		sum = 0;
		for (var i = 0; i < v.length; i++) {
			sum += v[i];
			if (value < sum) {
				break;
			}
			index++;
		}
		return index;
	}
}


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

int main() {
    string s;
    cin >> s;
    for(int i = 0; i < s.size()-1; i++) {
        if(s[i] == s[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }

    }
    cout << "Good" << endl;

    return 0;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[1000007]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
*/
using namespace std;
signed main(){
  fast;
  //usefile;
  //test
  {
    int a,b;
    cin>>a>>b;
    int l=1,r=2000;
    int mid;
    int ans=-1;
    while(l+1<r)
    { mid=(l+r)/2;
      if((floor(mid*0.08) >= a && floor(mid*0.1) >= b )){
          ans=mid;
          r=mid; 
      }
      else
      {
        l=mid;
      }
    }
    if((floor(ans*0.08) != a || floor(ans*0.1) != b ))
      ans=-1;
    cout<<ans<<endl;
  }
  //time("");
  return 0;
}

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

int main(){
  int n;
  while(cin>>n,n){
    int ans=0;
    for(int i=1;i*i<=n;i++){
      if(i*i == n){
	ans++;
	break;
      }
      for(int j=i;i*i+j*j<=n;j++){
	if(i*i + j*j == n){
	  ans++;
	  break;
	}
	for(int k=j;i*i+j*j+k*k<=n;k++){
	  if(i*i + j*j + k*k == n){
	    ans++;
	    break;
	  }
	  for(int l=k;i*i+j*j+k*k+l*l<=n;l++){
	    if(i*i + j*j + k*k + l*l == n ){
	      ans++;
	      break;
	    }
	  }
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
n,x,*a = map(int,open(0).read().split())
b = [0]*n
b[0] = min(x,a[0])
for i in range(n-1):
  b[i+1] = max(min(x-b[i],a[i+1]),0)
  b[i] = min(b[i],x-b[i+1])
ans = 0
for i,j in zip(a,b):
  ans += i-j
print(ans)

Measured memory_bytes: 14092
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var s = Console.ReadLine().Trim();
        Console.WriteLine(getAns(n, s));
    }
    static int getAns(int n, string s)
    {
        var count = 0;
        for (int i = 0; i <= 9; i++)
            for (int j = 0; j <= 9; j++)
                for (int k = 0; k <= 9; k++)
                    if (check(i, j, k, n, s)) count++;
        return count;
    }
    static bool check(int a, int b, int c, int n, string s)
    {
        var a1 = a.ToString();
        var b1 = b.ToString();
        var c1 = c.ToString();
        var ap = s.IndexOf(a1);
        if (ap == -1 | ap >= n - 2) return false;
        var bp = s.IndexOf(b1, ap + 1);
        if (bp == -1 | bp >= n - 1) return false;
        var cp = s.IndexOf(c1, bp + 1);
        if (cp == -1) return false;
        return true;
    }
}


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

class Program{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int N = int.Parse(input[0]);
    int M = int.Parse(input[1]);
    string[] A_ = Console.ReadLine().Split(' ');
    
    List<long> A = new List<long>();
    for (int i = 0; i < N; i++)
    {
      PushHeap(A, long.Parse(A_[i]));
    }
    
    for (int m = 0; m < M; m++)
    {
      long max = A[0];
      PopHeap(A);
      PushHeap(A, max / 2);
    }
    
    Console.WriteLine(A.Sum());
  }
  
  // HeapされたListに要素を追加
  static void PushHeap(List<long> array, long elem)
  {
    int n = array.Count;
    array.Add(elem);
    
    while (n != 0)
    {
      int i = (n-1) / 2; // parent's index
      if (array[n].CompareTo(array[i]) > 0) // if child is larger than parents
      {
        // switch the child and the parents
        long tmp = array[n];
        array[n] = array[i];
        array[i] = tmp;
      }
      n = i;
    }
  }
  
  // Heapから最大値を削除
  static void PopHeap(List<long> array)
  {
    // 末端の要素で置き換える. n := 新しいリストの大きさ
    int n = array.Count - 1;
    array[0] = array[n];
    array.RemoveAt(n);
    
    // i := 親の番号, j := (左側の)子の番号, j が n 未満の限り繰り返す
    for (int i = 0, j; (j = i*2 + 1) < n; ) 
    {
      // 右側の子の方が大きい場合は, 右側の子と親を入れ替える
      if ((j != n - 1) && (array[j].CompareTo(array[j + 1]) < 0))
      {
        j++;
      }
      // 親の方が小さければ，子と親の値を入れ替える
      if ((array[i].CompareTo(array[j]) < 0))
      {
        long tmp = array[j];
        array[j] = array[i];
        array[i] = tmp;
      }
      i = j;
    }
  }
  
}

Measured memory_bytes: 28508
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int n;
    cin >> n;
    int f=n%10;
    if (f==3)
        cout << "bon" << endl;
    else if (f==0 || f==1 || f==6 || f==8)
        cout << "pon" << endl;
    else
        cout << "hon" << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	string date;
	cin >> date;
	date[3] = '8';
	cout << date << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define debug(a,n) for(i=0;i<n;i++)cout<<a[i]<<" ";
#define d(x) cout<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
vector<int>adj [T];
			/*brownsands IIITA*/

void solve()
{  int a,b;
    cin>>a>>b;
    b--;a--;
    cout<<ceil((b*1.0)/a);
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
                           }		
} 
               
			
 

				
		
		




Measured memory_bytes: 23680
package main

import "fmt"

func main() {
	var A,B,C,D int
	fmt.Scan(&A, &B,&C,&D)
	res := "No"
	for {
		C = C - B
		if C <= 0{
			res = "Yes"
			break
			
		}
		A = A - D
		if A <= 0 {
			break
		}
	}

	fmt.Println(res)

}


Measured memory_bytes: 1752
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int f(int n){
    if(n%2==0){
        return n/2;
    }else{
        return 3 * n + 1;
    }
};

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

    int s;
    cin >> s;

    set<int> set;

    set.insert(s);

    int tmp_in = s;
    int tmp_out = 0;
    for(int i = 2; i < 1000000; i++){
        tmp_out = f(tmp_in);
        if(set.find(tmp_out) != set.end()){
            cout << i << endl;
            break;
        }else{
            set.insert(tmp_out);
            tmp_in = tmp_out;
        }
    }
    return 0;
}


Measured memory_bytes: 384
n = int(input())
k = int(input())
X = list(map(int, input().split()))

K_X = [abs(x-k) for x in X]

ans = 0

for i in range(n):
    if X[i] <= K_X[i]:
        ans += X[i] * 2
    else:
        ans += K_X[i] * 2

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <iomanip>
typedef long long ll;

using namespace std;

int main() {
    int goodsNum, maxWeight;
    cin >> goodsNum >> maxWeight;
    
    vector<ll> goodsWeight(goodsNum);
    vector<int> goodsValue(goodsNum);
    for(int i = 0; i < goodsNum; i++) {
        cin >> goodsWeight[i] >> goodsValue[i];
    }
    
    // 各商品、価値の時の重さを保持する
    vector<vector<ll>> dp = vector<vector<ll>>(goodsNum, vector<ll>(100001, 0));
    ll ans = goodsValue[0];
    for(int i = 0; i < goodsNum; i++) {
        dp[i][goodsValue[i]] = goodsWeight[i];
        if(i == 0) {
            continue;
        }
        
        for(ll j = 0; j < 100001; j++) {
            if(dp[i - 1][j] > 0) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j]) == 0 ? dp[i - 1][j] : min(dp[i][j], dp[i - 1][j]);
                
                if(dp[i - 1][j] + goodsWeight[i] <= maxWeight) {
                    if(dp[i - 1][j + goodsValue[i]] == 0 || dp[i - 1][j] + goodsWeight[i] < dp[i - 1][j + goodsValue[i]]) {
                        ans = max(ans, j + goodsValue[i]);
                        dp[i][j + goodsValue[i]] = dp[i - 1][j] + goodsWeight[i];
                    }
                }
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 79488
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

a, b, c, k = na()

ans = 0
ans += min(a, k)
k -= a
if k >= 1:
    k -= b
    if k >= 1:
        ans -= min(k, c)

print(ans)

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

#define llint long long int

using namespace std;

int main()
{
    int N;

    cin >> N;

    vector<int> a(N + 1);

    for (int i = 1; i <= N; i++)
    {
        cin >> a[i];
    }
    vector<vector<int>> yakusu(N + 1, vector<int>());

    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; i * j <= N; j++)
        {
            yakusu[i * j].push_back(i);
        }
    }
    vector<int> guki(N + 1, 0), ans(N + 1, 0);

    for (int i = N; i >= 1; i--)
    {
        if ((guki[i] + a[i]) % 2 == 1)
        {
            ans[i] = 1;

            for (int j = 0; j < yakusu[i].size(); j++)
            {
                guki[yakusu[i][j]] = 1 - guki[yakusu[i][j]];
            }
        }
    }
    int M = 0;

    for (int i = 1; i <= N; i++)
    {
        if (ans[i] == 1)
        {
            M++;
        }
    }
    cout << M << endl;

    for (int i = 1; i <= N; i++)
    {
        if (ans[i] == 1)
        {
            cout << i << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 26880
#include <bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;



void solve(){
    int n, m;
    cin>>n>>m;
    int k = __gcd(n,m);
    n *= m;
    n /= k;
    cout<<n;
}


int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll N;
    cin >> N;
    vector<queue<ll>> A(N);
    REP(i,N){
        REP(j,N-1){
            ll a;
            cin >> a;
            a--;
            A[i].push(a);
        }
    }

    ll ans = 0;
    set<ll> candidate;
    REP(i,N) candidate.insert(i);
    while(1){

        vector<bool> assign(N);

        set<ll> next;
        //for(int v = 0; v < N; v++){
        for(auto&& v : candidate){
            if(assign[v]) continue;
            if(A[v].empty()) continue;

            ll x = A[v].front();
            if(assign[x]) continue;
            if(A[x].empty()){
                cout << -1 << endl;
                return 0;
            }

            ll y = A[x].front();

            if(v == y){
                A[v].pop();
                A[x].pop();
                assign[v] = true;
                assign[x] = true;
                next.insert(v);
                next.insert(x);
            }
        }

        candidate = next;

        if(candidate.size() == 0)
            break;

        ans++;
    }

    bool empty = true;
    REP(i,N){
        if(!A[i].empty())
            empty = false;
    }

    if(empty)
        cout << ans << endl;
    else
        cout << -1 << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  cout << v.size() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
	int d, w, h;
	int cheese[3];
	while (cin >> d >> w >> h && d && w && h) {
		cheese[0] = d;
		cheese[1] = w;
		cheese[2] = h;
		sort(cheese, cheese+3);
		double cr = sqrt(pow(cheese[0] / 2, 2) + pow(cheese[1] / 2, 2));
		int n;
		cin >> n;
		for (int i = 0; i < n; i++) {
			double r;
			cin >> r;
			if (r > cr)
				cout << "OK" << endl;
			else
				cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1240
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

string sa;

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n;
	cin>>sa;
	for(auto &ca:sa){
		a=(int)ca-(int)'A';
		a+=n;
		a%=26;
		ca=(char)((int)'A'+a);
	}
	cout<<sa<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int N = scan.nextInt();

	int[] A_ = new int[N];
	for(int i = 0; i < N; i++){
	    A_[i] = scan.nextInt();
	}

	int now = A_[0];
	int count = 1;
	for(int i = 1; i < N;){
	    if(now < A_[i]){
		while(i < N && now <= A_[i]){
		    now = A_[i];
		    i++;
		}
	    }else if(now > A_[i]){
		while(i < N && now >= A_[i]){
		    now = A_[i];
		    i++;
		}
	    }else{
		i++;
		continue;
	    }
	    if(i < N){
		now = A_[i];
		count++;
	    }
	}

	System.out.println(count);
    }
}


Measured memory_bytes: 50488
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/13/20 20:47:40
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<int> A(n); for (auto& a:A) cin>>a;
  vector<int> B(n); for (auto& b:B) cin>>b;
  auto solve = [&]() {
    reverse(B.begin(), B.end());
    int l = 0, r = n;
    while (l < n and A[l] != B[l])
      l++;
    while (l < r and A[r-1] != B[r-1])
      r--;
    if (l == r) {
      return true;
    }
    int sames = r-l;
    int v = A[l];
    int al = l, ar = r;
    while (0 <= al and (A[al] == v or B[al] == v))
      --al;
    while (ar < n and (A[ar] == v or B[ar] == v))
      ++ar;
    int buf = al+1 + n-ar;
    if (buf < sames)
      return false;
    int i = l;
    while (i < r and 0 <= al) {
      swap(B[al], B[i]);
      ++i;
      --al;
    }
    while (i < r and ar < n) {
      swap(B[i], B[ar]);
      ++i;
      ++ar;
    }
    return true;
  };
  if (solve()) {
    cout << "Yes" << endl;
    for (auto b:B)
      cout << b << " ";
    cout << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 4764
from collections import Counter

N, K = map(int, input().split())
input_list = [[int(i) for i in input().split()] for j in range(N)]
input_list.sort()

input_counter = Counter()

for element in input_list:
    input_counter[element[0]] += element[1]

for element in input_list:
    K -= element[1]
    if K <= 0:
        print(element[0])
        break

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

int main(){
  ll n;
  cin >> n;
  vector<ll> a(100000);
  rep(i,n){
    ll num;
    cin >> num;
    a[num]++;
  }
  ll ans = 1;
  for(ll i=1;i<100000-1;++i){
    ans = max(ans,a[i-1]+a[i]+a[i+1]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

ll modpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        ll d = modpow(a, b/2) % MOD;
        return (d * d) % MOD;
    }
    else{
        return (a * modpow(a, b-1)) % MOD;
    }
}

const int MAX_N = 100010;

ll fact[MAX_N], inv[MAX_N];

void calc(int n){
    fact[0] = inv[0] = 1;
    for(int i=1; i<=n; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        inv[i] = modpow(i, MOD - 2);
    }
}

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

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

    calc(n);

    // calculate 1/1 + 1/2 + 1/3 + ... + 1/N
    for(int i=1; i<n; i++){
        inv[i+1] += inv[i];
        inv[i+1] %= MOD;
    }

    ll ans = 0;
    for(int i=0; i<n; i++){
        ans += a[i] * (inv[i+1] + inv[n-i] - 1);
        ans %= MOD;
    }

    ans *= fact[n];
    ans %= MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n,t;
    cin >> n >> t;
    VLL a(n);
    REP(i,0,n) {
        cin >> a[i];
    }
    VLL diff(n);
    int minv = a[0], index = 0;
    REP(i,1,n) {
        if (minv > a[i]) {
            minv = a[i];
            index = i;
        } else diff[index] = max(diff[index], a[i] - minv);
    }
    sort(all(diff));
    reverse(all(diff));
    int pos = 1;
    while (diff[pos] == diff[0] && pos < n) ++pos;
    cout << pos << endl;
}

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

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int K, X;
signed main() {
    cin >> K >> X;
    if (K * 500 >= X) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		String s = stdIn.next();
		
		boolean flag = true;
		
		
		for(int i = 0; i < s.length()/2; i++) {
			if(s.charAt(i)!=s.charAt(s.length()-1-i)) {
				flag = false;
			}
		}
		

		int cnt = 1;
		for(int i = 0; i < (s.length()-1)/2; i++) {
			if(s.charAt(i)!=s.charAt((s.length()-1)/2-cnt)){
				flag = false;
			}
			cnt++;
		}
		

		cnt = 0;
		for(int i = (s.length()+3)/2-1; i < s.length(); i++) {
			if(s.charAt(i)!=s.charAt(s.length()-1-cnt)){
				flag = false;
			}
			cnt++;
		}

		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


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


int main()
{
    int K;
    cin >> K;
    ll num = 7;
    rep(i,1010101)
    {
        if(num % K == 0)
        {
            cout << i+1 << endl;
            return 0;
        }
        num = (num * 10 + 7) % K;
    }
    cout << -1 << endl;

    
    return 0;
}

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

int main(){
	int W, H, w, h;
	int sum;
	int row, column;
	cin >> H >> W >> h >> w;
	sum = H*W;
	row = h*W;
	column = w*(H-h);
	cout << sum - row - column;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6,mod=998244353;
int inv[1000001];
int w[1000001];
int a[1000001];
signed main()
{
	int n,ans=0;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		int tmp;
		scanf("%lld",&tmp);
		a[tmp]+=tmp;
		a[tmp]%=mod;
		ans-=tmp;
		ans%=mod;
	}
	inv[1]=1;
	for(int i=2;i<=N;i++)
		inv[i]=(-1ll*inv[mod%i]*(mod/i)%mod+mod)%mod;
	
	for(int i=1;i<=N;i++)
	{
		int tot=0;
		w[i]+=inv[i],w[i]%=mod;
		for(int j=i*2;j<=N;j+=i)
		{
			w[j]-=w[i],w[j]%=mod;
			tot+=a[j],tot%=mod;
		}
		tot+=a[i],tot%=mod;
		ans+=1ll*tot*tot%mod*w[i]%mod;
		ans%=mod;
	}
	printf("%lld",1ll*(ans+mod)*inv[2]%mod);
	return 0;
}

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

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d)
        cout<<"Yes"<<endl;
    else if(abs(a-b)<=d && abs(b-c)<=d)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
typedef long long ll;
ll INF=1<<29;

int main(){
    ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int h[n],dp[n];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++) cin>>h[i];
	for(int i=0;i<n;i++){
		if(i>=2) dp[i]=min( dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]) );
		else if(i==1) dp[i]=dp[i-1]+abs(h[i-1]-h[i]);
		else continue;
	}
	cout<<dp[n-1]<<endl;
}



Measured memory_bytes: 1024
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        char[] S = sc.next().toCharArray();
        int ans = 1;
        for (int i = 0; i < N - 1; i++) {
            if (S[i] != S[i + 1]) ans++;
        }
        System.out.println(ans);
    }

}


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

int main(){
    int n;
    cin >> n;
    n *= 2;
    
    vector<int> x(n);
    for(int i = 0; i < n; i++)  cin >> x[i];

    sort(x.begin(), x.end());
    for(int i = 1; i < n; i+=2) x[i] = 0;

    cout << accumulate(x.begin(), x.end(), 0) << endl;
    return 0;
}

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

r = [0] * N
for i, a in enumerate(A):
    if i % 2 == 0:
        r[0] += a
    else:
        r[0] -= a
r[-1] = 2 * A[-1] - r[0]
for i in range(N - 2, 0, -1):
    r[i] = 2 * A[i] - r[i+1]
ans = " ".join(map(str, r))
print(ans)

Measured memory_bytes: 24848
a = input().split()
b = int(a[0])
c = int(a[1])

X = 2
Y = 4
for i in range(b+1):
    if b == 1 and c == 2:
        print('Yes')
        break
    elif b == 1 and c == 4:
        print('Yes')
        break
    d = b-i
    if X*i + Y*d == c:
        print('Yes')
        break
    elif i == b:
        print('No')

Measured memory_bytes: 9072
#!/usr/bin/ruby
#encoding: utf-8

# input 
n,m,c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
a = Array.new(n)
ans = 0
(0..n-1).each do |i|
  a[i] = gets.split.map(&:to_i)
end

(0..n-1).each do |i|
  sum = 0
  (0..m-1).each do |j|
    sum += a[i][j]*b[j]
  end
  sum += c
  
  if sum > 0 
    ans += 1
  end
end

puts ans


Measured memory_bytes: 1916
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 3e3 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
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; }


#define int ll

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, t, dp[7010], ans;
pii a[N];
main() {
    file("censor");
    ios;
    cin >> n >> t;
    fo(i, 1, n, 1) cin >> a[i].F >> a[i].S;
    fo(i, 0, 6010, 1) dp[i] = -INF1;
    dp[0] = 0;
    sort(a + 1, a + n + 1);
    fo(i, 1, n, 1) {
        foo(j, t - 1, 0, 1) {
            if (dp[j] != -INF1)
            chmax(dp[j + a[i].F], dp[j] + a[i].S);
        }
    }
    fo(i, 0, 6010, 1) chmax(ans, dp[i]);
    cout << ans;
    return 0;
}
/**

*/


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

int main()
{
	int w[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	int g;
	bool flag[10];
	bool fl;
	
	while (cin >> g){
		for (int i = 0; i < 10; i++){
			flag[i] = false;
		}
		
		for (int i = 9; i >= 0; i--){
			if (g >= w[i]){
				flag[i] = true;
				g -= w[i];
			}
		}
		
		fl = false;
		for (int i = 0; i < 10; i++){
			if (flag[i] == true){
				if (fl == true){
					cout << " ";
				}
				cout << w[i];
				if (fl == false){
					fl = true;
				}
			}
		}
		cout << endl;
	}
	
	return (0);
}

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<cstring>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 55;

LL f[N][2];
int n,a[N];

int main(){
	n=get();
	int p=get();
	fo(i,1,n)a[i]=get();
	f[0][0]=1;
	fo(i,1,n)
		fo(j,0,1){
			f[i][(j+a[i])%2]=f[i][(j+a[i])%2]+f[i-1][j];
			f[i][j]=f[i][j]+f[i-1][j];
		}
	printf("%lld\n",f[n][p]);
	return 0;
}

Measured memory_bytes: 256
a, b, h, m = gets.chomp.split.map(&:to_i)
zikan = h + m.to_f / 60
kakudo = zikan.to_f / 12 * 360 - m.to_f / 60 * 360

cc = a * a + b * b - 2 * a * b * Math.cos(kakudo / 180 * Math::PI)
c = Math.sqrt(cc)
puts c

Measured memory_bytes: 14768
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N >> S;
    string apb = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for (int i = 0; i < S.size(); i++) {
        char tmp = S[i] - 'A';
        tmp = (tmp + N) % 26;
        S[i] = tmp + 'A';
    }
    cout << S << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define rep(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define ffor(i,a,b) for(int i = a ; i <= b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
const int N = 1e6;
typedef pair <int, int> pi;
typedef std::vector<int> vi;
typedef std::vector<long long> VI;

/*bool isprime(int a) {
	if (a < 2) return false;
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0)
			return false;  // 0(n) or 0(n^2) Tell me in the comment section
	}
	return true;
}*/



int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	fastIO
	int x;
	cin >> x;
	if (x >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
}



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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'o' || c == 'i' || c == 'e' || c == 'u')
     cout << "vowel" <<endl;
  else
     cout << "consonant" << endl;
}

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

int main() {
    int k, a, b;
    cin >> k;
    cin >> a >> b;
    for(int i = a; i <=b; i++) {
        if(i % k == 0) cout << "OK\n", exit(0);
    }
    cout << "NG\n";
    return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
string s;
long long ans = 0;

void solve(int head, int tail, long long val) {
	if( tail == s.length() ) {
		long long res = 0;
		while(head < tail) {
			res = res*10 + (s[head]-'0');
			head++;
		}
		ans += val + res;
		return;
	}
	solve(head, tail+1, val);
	long long res1 = 0;
	while(head < tail) {
		res1 = res1*10 + (s[head]-'0');
		head++;
	}
	solve(head, tail+1, val + res1);
}

int main() {
	cin >> s;
	solve(0, 1, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
using namespace std;
typedef long long ll;
ll a, b, c, i, j, k, n, m;

int main() {
	j = 0;
	cin >> a >> b >> c;
	for (i = a; i <= b; i++) {
		if (i % c == 0)
			j++;
	}
	cout << j;
	return 0;
}

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

using ll=long long;

int main() {
    ll A,B,K,t,a;
    cin >> A >> B >> K;

    t = A - K;
    if(t<0) {
        a = B + t;
        t = 0;
        if(a<0)
            a = 0;
    } else {
        a = B;
    }
    cout << t << " " << a << endl;
}

Measured memory_bytes: 256
Main(myin());
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//不明値:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}
function Main(input) {
  input = myconv(input,4);
  var N = input[0];
  var K = input[1];
  var S = input[2];
  var list = new Array(N);
  for(var i = 0; i < N; i++){
    if(i < K){
       list[i] = S;
    }else{
        list[i] = S+1;
        if(list[i] > 1000000000) list[i] = 1;
    }
  }
  myout(list.join(" "));
}

Measured memory_bytes: 16076
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  string S;
  cin >> S;
  
  int cnt1 = 0;
  int cnt2 = 0;
  
  char seed = '0';
  if(S[0] == '1') cnt1++;

  for(int i = 1; i < S.size(); i++){
    char c;
    c = S[i];
    if(seed == '0' && S[i] == '0'){
      cnt1++;
      seed = '1';
    }else if(seed == '0' && S[i] == '1'){
      seed = '1';
    }else if(seed == '1' && S[i] == '1'){
      cnt1++;
      seed = '0';
    }else if(seed == '1' && S[i] == '0'){
      seed = '0';
    }  
  }
  
  seed = '1';
  if(S[0] == '0') cnt2++;
  for(int i = 1; i < S.size(); i++){
    char c;
    c = S[i];
    
    if(seed == '0' && c == '0'){
      cnt2++;
      seed = '1';
    }else if(seed == '0' && c == '1'){
      seed = '1';
    }else if(seed == '1' && c == '1'){
      cnt2++;
      seed = '0';
    }else if(seed == '1' && c == '0'){
      seed = '0';
    }  
  }
  cout << min(cnt1,cnt2) <<endl;
}

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

using ll = long long int;
using P = std::pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rag(con) std::begin(con), std::end(con)

std::vector<int> node;

int m; //leafのサイズ

void init(int rsiz)
{

    m = 1;

    while (m < rsiz)
        m *= 2;

    node.resize(2 * m - 1);
} //ここで初期化して

void debug()
{

    int x = 0;

    rep(i, 2 * m - 1)
    {
        std::cerr << node[i] << ' ';
        if (x == i)
        {
            std::cerr << std::endl;
            x = x * 2 + 2;
        }
    }
}

void add(int idx, int val = 1)
{

    idx += m - 1;

    node[idx] += val;

    while (idx > 0)
    {
        idx = (idx - 1) / 2;
        node[idx] = node[2 * idx + 1] + node[2 * idx + 2];
    }
}

int get(int a, int b, int k = 0, int l = 0, int r = m)
{ //上からだんだんと下へ//[a,b) [l,r)

    if (r <= a || b <= l)
        return 0; //範囲外

    if (a <= l && r <= b)
        return node[k]; //完全に範囲内

    //部分的に範囲内

    int lv = get(a, b, 2 * k + 1, l, (l + r) / 2);
    int rv = get(a, b, 2 * k + 2, (l + r) / 2, r);

    return lv + rv;
}

int main()
{
    int n, q;

    std::cin >> n >> q;

    std::vector<int> ans(q);

    std::map<int, int> mp, npos; //r,l

    init(n);

    rep(i, n)
    {
        int c;
        std::cin >> c;
        if (npos.count(c))
        {
            mp[i] = npos[c];
        }
        npos[c] = i;
    }

    std::map<int, std::vector<P>> qries; //r,(l,i)

    rep(i, q)
    {
        int l, r;
        std::cin >> l >> r;
        qries[r - 1].emplace_back(l - 1, i);
        ans[i] = r - l + 1;
    }

    //std::cerr << "DEBUG" << std::endl;
    //for (auto p : mp)
    //std::cerr << p.first << ' ' << p.second << std::endl;

    rep(i, n)
    {
        if (mp.count(i))
        {
            add(mp[i]);
        }

        if (qries.count(i))
        {
            for (auto p : qries[i])
            {
                ans[p.second] -= get(p.first, n);
            }
        }
    }

    //debug();

    rep(i, q)
            std::cout
        << ans[i] << std::endl;

    return 0;
}

Measured memory_bytes: 65444
#include <stdio.h>

         int main() {
           for (int i = 1; i < 10; i++){
               /* code */
               for (int j = 1; j < 10; j++) {
                   /* code */
                   printf("%dx%d=%d\n", i, j, i*j);
               }
           }
           return 0;
         }



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

ll func(ll i,ll j){
    if(i==-1){return 0;}
    else{return i/j+1;}
}

int main(){
    ll a,b,x;
    cin >> a >> b >> x;

    cout << func(b,x)-func(a-1,x);
    
}

Measured memory_bytes: 384