akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int t_solve(int n, int k, vector<int> h){
    int dp[n];
    dp[0] = 1e9 + 7;
    for (int i = 1; i <= n; ++i) {

        dp[i] = 1e9 + 7;
        for (int j = 1; j <= k; ++j) if (i - j > 0) dp[i] = min(dp[i], dp[i - j] + abs(h[i - 1] - h[i - 1 - j]));
        if (i == 1) dp[i] = 0;
    }

    return dp[n];
}
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h;
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        h.push_back(x);
    }
    int ans = t_solve(n, k, h);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
#define For(i,n) for(long i=0;i<(n);i++)
long gcd(long a,long b){
    return b?gcd(b,a%b):a;
}

long n,k,ans=0;
int main(){
    cin>>n;
    vector<long> a(n);
    long plus=0;
    long notplus=0;
    For(i,n){
        cin>>a.at(i);
        if(a.at(i)>0){
            plus++;
        }
        else {
            notplus++;
        }
    }
    sort(a.begin(),a.end());
    if(notplus==0){
        For(i,n){
            if(i==0){
                ans-=a.at(i);
            }
            else{
                ans+=a.at(i);
            }
        }
    }
    else if(plus==0){
        For(i,n){
            if(i==n-1){
                ans-=abs(a.at(i));
            }
            else{
                ans+=abs(a.at(i));
            }
        }        
    }
    else{
        For(i,n){
            ans+=abs(a.at(i));
        }
    }
    cout<<ans<<endl;
    
    
    if(notplus==0){
        for(long i=1;i<n-1;i++){
            cout<<a.at(0)<<" "<<a.at(i)<<endl;
            a.at(0)-=a.at(i);
        }
        cout<<a.at(n-1)<<" "<<a.at(0)<<endl;
        a.at(0)=a.at(n-1)-a.at(0);
        //cout<<a.at(0);
    }
    else if(plus==0){
        For(i,n-1){
            cout<<a.at(n-1)<<" "<<a.at(i)<<endl;
            a.at(n-1)-=a.at(i);
        }
        //cout<<a.at(n-1);
    }
    else{
        for(long i=1;i<notplus;i++){
            cout<<a.at(notplus)<<" "<<a.at(i)<<endl;
            a.at(notplus)-=a.at(i);
        }
        for(long i=notplus;i<n-1;i++){
            cout<<a.at(0)<<" "<<a.at(i)<<endl;
            a.at(0)-=a.at(i);
        }
        cout<<a.at(n-1)<<" "<<a.at(0)<<endl;
        a.at(n-1)-=a.at(0);
        //cout<<a.at(n-1);
    }
}

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

using namespace std;

int main() {
    int N, M;

    cin >> N >> M;

    vector<bool> broken(N+1, false);
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        broken[a] = true;
    }

    vector<int> num_move(N+1, 0);
    for (int i = 1; i <= N; i++) {
        if (broken[i]) continue;

        if (i == 1) {
            num_move[1] = 1;
        } else if (i == 2) {
            num_move[2] = num_move[1] + 1;
        } else {
            num_move[i] = (num_move[i-2] + num_move[i-1]) % 1000000007;
        }
    }

    cout << num_move[N] << endl;
    return 0;
}


Measured memory_bytes: 640
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;

    for(int i = 0; i < 3; ++i) {
        cout << s.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>

static const int INF = 1 << 30;

template <class T> inline void chmin(T &a, const T &b) {
  if (a > b)
    a = b;
}

int main()
{
  // Input
  int numArray;
  int numJump;
  std::cin >> numArray >> numJump;
  assert(2 <= numArray and numArray <= 1.0e+5);
  assert(1 <= numJump and numJump <= 100);
  std::vector<int> height(1 + numArray);
  for (int i = 1; i <= numArray; ++i) {
    std::cin >> height[i];
    assert(1 <= height[i] and height[i] <= 1.0e+4);
  }

  // Init
  std::vector<int> dp(1 + numArray);
  for (int i = 0; i <= numArray; ++i)
    dp[i] = INF;
  dp[1] = 0;

  // DP main
  for (int i = 1; i <= numArray; ++i) {
    for (int k = 1; k <= numJump; ++k) {
      if (i + k > numArray)
        break;
      chmin(dp[i + k], dp[i] + abs(height[i] - height[i + k]));
    }
  }

  // Output
  std::cout << dp[numArray] << std::endl;


  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

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

  ll N; cin >> N;
  deque<ll> q;
  REP(i, 0, N) {
    string C; ll X; cin >> C;
    if(C == "insert" || C == "delete") cin >> X;

    if(C == "insert") {
      q.push_front(X);
    }
    if(C == "delete") {
      deque<ll> _q;
      bool f = false;
      while(q.size()) {
        if(q.front() != X || f) {
          _q.push_back(q.front());
        } else if(!f) {
          f = true;
        }
        q.pop_front();
      }
      swap(q, _q);
    }
    if(C == "deleteFirst") {
      q.pop_front();
    }
    if(C == "deleteLast") {
      q.pop_back();
    }
  }

  while(q.size()) {
    cout << q.front() << (q.size() != 1 ? " " : "\n");
    q.pop_front();
  }
}

Measured memory_bytes: 11064
#include <stdio.h>

int main(void){
  int a,b,c,s;
  while(scanf("%d %d",&a,&b) != EOF){
    s = a+b;
    c = 0;
    if(s!=0){
      while(s>0){
        s /= 10;
        c ++;
      }
      printf("%d\n",c);
    }else{
      printf("%d\n",1);
    }
  }
  return 0;
}

Measured memory_bytes: 600
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    double r, area, cir;
    r = Double.parseDouble(br.readLine());
    area = r * r * Math.PI;
    cir = 2 * r * Math.PI;
    System.out.printf("%.6f %.6f", area, cir);
  }
}

Measured memory_bytes: 24652
#include<bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll z=1000000007;
ll a[100005][4];
ll dp[100005][4];
ll n;
ll solve(ll d,ll f)
{
  ll maxa=0;

  if(d==n)
  return 0;
  if(dp[d][f]!=-1)
  return dp[d][f];

  if(f==0)
  {
    maxa=max(maxa, a[d][1] + solve(d+1,1));
    maxa=max(maxa, a[d][2] + solve(d+1,2));
    maxa=max(maxa, a[d][3] + solve(d+1,3));
  }
  else if(f==1)
  {
    maxa=max(maxa, a[d][2] + solve(d+1,2));
    maxa=max(maxa, a[d][3] + solve(d+1,3));
  }
  else if(f==2)
  {
    maxa=max(maxa, a[d][1] + solve(d+1,1));
    maxa=max(maxa, a[d][3] + solve(d+1,3));
  }
  else
  {
    maxa=max(maxa, a[d][1] + solve(d+1,1));
    maxa=max(maxa, a[d][2] + solve(d+1,2));
  }

  dp[d][f]=maxa;
  return dp[d][f];
}

int main()
{
  IOS;
  ll t=1;
//  cin>>t;
  memset(dp,-1,sizeof(dp));
  while(t--)
  {
    ll i,l,p,j,ans=0,k;
    cin>>n;
    for(i=0;i<n;i++)
    {
      for(j=1;j<=3;j++)
      {
        cin>>a[i][j];
      }
    }
    ans=solve(0,0);
    cout<<ans;

  }

    return 0;
}


Measured memory_bytes: 12800
n = int(input())
G = {}
p = 31
M1, M2 = (10 ** 9 + 7, 998244353)
for _ in range(n):
    s = input()
    s = sorted(list(s))
    yt = 0
    yt2 = 0
    for i in range(len(s)):
        yt += p ** (i + 1) * (ord(s[i]) - 95)
        yt2 += p ** (i + 1) * (ord(s[i]) - 95)
        yt %= M1
        yt2 %= M2
    if (yt, yt2) not in G:
        G[(yt, yt2)] = 0
    G[(yt, yt2)] += 1
ans = 0
for i in G:
    ans += G[i] * (G[i] - 1) // 2
print(ans)

Measured memory_bytes: 23412
Sp = list(input())
Tp = list(input())
S = [ord(Sp[i])-ord('a') for i in range(len(Sp))]
T = [ord(Tp[i])-ord('a') for i in range(len(Tp))]
lis = [-1]*26
lit = [-1]*26
ans = True
for i in range(len(S)):
    if lis[S[i]] == -1:
        lis[S[i]] = T[i]
    else:
        if lis[S[i]] != T[i]:
            ans = False
            break
for i in range(len(T)):    
    if lit[T[i]] == -1:
        lit[T[i]] = S[i]
    else:
        if lit[T[i]] != S[i]:
            ans = False
            break
if ans:
    print('Yes')
else:
    print('No')

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

int main()
{
    string s;
    cin >> s;

    int ans = 0;
    int half = s.size() / 2;
    for (int i = 0; i < half; i++)
    {
        if (s[i] != s[s.size() -1 - i])
        {
            //cout << s[i] << " " << s[s.size() -1 - i] << endl; 
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,j;
    char s[25];
    gets(s);
    for(i=0;s[i]!='\0';i++)
    {if(s[i]==',')
    {
        printf(" ");
    }
    else
    {printf("%c",s[i]);}
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <deque>
#include <map>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

#define INF 1<<30

int main(){
  long long X, K, D;
  cin >> X >> K >> D;
  X = abs(X);
  if (X / D > K)
  {
    cout << X - K * D << endl;
  }
  else{
    if((K-X/D)%2==0){
      cout << X - X/D * D << endl;
    }
    else{
      cout << -(X - (X/D+1) * D) << endl;
    }
  }
  return 0;
}

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n;
ll a, b;
ll x[100010];

int main(void){
	cin>>n>>a>>b;
	for (int i = 0; i < n; i++) cin>>x[i];

	ll minv = 0;
	for (int i = 0; i + 1 < n; i++) {
		if (a * (x[i + 1] - x[i]) > b) {
			minv += b;
		}
		else {
			minv += a * (x[i + 1] - x[i]);
		}
	}

	printf("%lld\n", minv);
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n; cin >> n;
	vector<int> scores(n);
	for (auto& score : scores) {
		cin >> score;
	}

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

	cout << scores[n / 2] - scores[n / 2 - 1] << endl;

	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

using namespace std;

struct Process
{
	char name[10];
	int time;
};

int main(){
	int n, q, t = 0;
	Process p[100000];
	queue<Process>que;

	scanf("%d %d", &n, &q);
	REP(i, n){
		scanf("%s %d", p[i].name, &p[i].time);
		que.push(p[i]);
	}

	int j = 0;
	while (que.size() > 0){
		if (que.front().time <= q){
			t += que.front().time;
			printf("%s %d\n", que.front().name, t);
			que.pop();
		}
		else{
			t += q;
			que.front().time -= q;
			que.push(que.front());
			que.pop();
		}
	}


	return 0;
}


Measured memory_bytes: 4528
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long H, W, h, w;
    string t;
    cin >> H >> W >> h >> w;
    cout << H * W - (h * W) - (w * H) + h * w << endl;
}

Measured memory_bytes: 256
program abc048c
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,x,ans=0,i
    integer(int64), allocatable:: a(:)

    read*, n,x
    allocate(a(n))
    read*, a(:)

    if (a(1) > x) then
        ans=ans+a(1)-x
        a(1) = x
    end if

    do i=2,n
        if (a(i) > x - a(i-1)) then
            ans=ans+sum(a(i-1:i))-x
            a(i) = x - a(i-1)
        end if
    end do
    print'(i0)', ans
end program abc048c

Measured memory_bytes: 1536
import glob

IS_TEST = False

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\138\\C'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'


class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        if IS_TEST:
            self.index += 1
            return self.problem[self.index-1]

        else:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        if IS_TEST:
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        else:
            self.resolve()


class C(Common):

    def resolve(self):
        item_num = int(self.input_data())
        items = [int(i) for i in self.input_data().split()]

        items.sort()
        result = items[0]

        for value in items:
            result = (result + value) / 2

        print(str(result))


solver = C(REL_PATH)
solver.exec_resolve()


Measured memory_bytes: 3828
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
cntA = Counter(A)
valA= list(set(A))
valA.sort()

if valA[-1] % 2 == 1:
    if valA[0] != -(-valA[-1] // 2) or cntA[valA[0]] != 2:
        print('Impossible')
        exit()

    for a in range(valA[0], valA[-1] + 1):
        if cntA[a] < 2:
            print('Impossible')
            exit()
else:
    if valA[0] != valA[-1] // 2 or cntA[valA[0]] != 1:
        print('Impossible')
        exit()

    for a in range(valA[0] + 1, valA[-1] + 1):
        if cntA[a] < 2:
            print('Impossible')
            exit()

print('Possible')


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG



int main() {
  ll A, B, ans;
  cin >> A >> B;


  ll x, y;
  for(ll i=0; i <= 1009 ; i++){
    x = i * 0.08;
    y = i * 0.1;
    if (x == A && y == B){
      cout << i << endl;
      return 0;
    }

  } 

  cout << "-1" << endl;

  return 0;
}


Measured memory_bytes: 3604
import math
while True :
    n = int(input())
    if n == 0 :
        break
    
    s = list(map(int, input().split()))
    m = sum(s) / len(s)
    
    a = 0
    for i in range(n) :
        a += (s[i] - m) ** 2
    a /= n
    a = math.sqrt(a)
    print(a)
    
        


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    string s;
    cin >> s;
    map<char,int> m;
    for (char i = 'a'; i <= 'z'; i++){
        m[i] = 0;
    }
    for (int i = 0; i < (int)s.size(); i++){
        m[s[i]]++;
    }
    bool ok = true;
    for (char i = 'a'; i <= 'z'; i++){
        if (m[i] >= 2) ok = false;
    }
    if (ok){
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }



        


    return 0;
}


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

int A, B, C;

int main() {
    cin >> A >> B >> C;

    if (A+B >= C) cout << B + C << endl;
    else {
        cout << 2*B + A + 1 << endl;
    }    

    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,A,B,base;
    cin>>n>>A>>B>>base;
    int topping[100];
    for(int i=0;i<n;i++)cin>>topping[i];
    int ans=base/A;
    sort(topping,topping+n);
    for(int i=n-1;i>=0;i--)ans=max(ans,(base+=topping[i])/(A+B*(n-i)));
    cout<<ans<<endl;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define fore(i,a,b) for(int i=a;i<b;i++)
#define maxe(a,b,c) max(a,max(b,c))
#define pb push_back
#define eb emplace_back
#define em emplace
#define print(x) cout<<x<<endl;
typedef long long int ll;
const ll mod=1e9+7;
int main()
{
    fastio;
    int h,w;
    cin>>h>>w;
    ll d[h][w];
    memset(d,0,sizeof(d));
    char c[h][w];
    fore(i,0,h)
    {
        fore(j,0,w)
        cin>>c[i][j];
    }
    fore(i,0,h)
    {
        if(c[i][0]=='#')
        break;
        d[i][0]=1;
    }
    fore(i,0,w)
    {
        if(c[0][i]=='#')
        break;
        d[0][i]=1;
    }
    fore(i,1,h)
    {
        fore(j,1,w)
        {
            if(c[i][j]!='#')
            d[i][j]=(d[i-1][j]+d[i][j-1])%mod;
        }
    }
    cout<<d[h-1][w-1];
  return 0;
}

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

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  vector<vector<int>> s(h, vector<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (i < b && j < a) {
        s[i][j] = 0;
      }
      else if (i < b && j >= a) {
        s[i][j] = 1;
      }
      else if (i >= b && j < a) {
        s[i][j] = 1;
      }
      else if (i >= b && j >= a) {
        s[i][j] = 0;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << s[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 5120
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    int n,m;
    int a,b;
    int i,j;
    int num[200010]={};
    int flage[200010]={};
    while (cin>>n>>m)
    {
        memset(num,0,sizeof(num));
        memset(flage,0,sizeof(flage));
        while (m--)
        {
            cin>>a>>b;
            if(a==1)
                num[b]=1;
            if(b==n)
                flage[a]=1;
        }
        j=0;
        for (i=1;i<n;i++)
        {
            if (flage[i]&&num[i])
            {
                j=1;
                break;
            }
        }
        if(j==1)
            cout<<"POSSIBLE\n";
        else
            cout<<"IMPOSSIBLE\n";
    }
    return 0;
}

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

int main()
{
    long long int n;
    cin>>n;
    unordered_map<long long int,long long int> mp;
    long long int sum =0;
    for(long long int i=0;i<n;i++)
    {
        int c;
        cin>>c;
        sum = sum +c;
        mp[c]++;
    }
    long long int q;
    cin>>q;
    unordered_map<long long int,long long int>::iterator itr,it;
    for(long long int i=0;i<q;i++)
    {
        long long int b,c;
        cin>>b>>c;
        itr = mp.find(b);
        if(itr!=mp.end())
        {
            if(mp[b]>0)
            {
                sum = sum - itr->second*(itr->first - c);

                mp[c] = mp[c] + itr->second;
                mp[b] =0;
            }
        }
        cout<<sum<<endl;

    }

}


Measured memory_bytes: 6536
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nm[0];
			int m = nm[1];

			

			var ab = new Tuple<int, int>[m];
			for (int i = 0; i < m; i++) {
				int[] temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				ab[i] = new Tuple<int, int>(temp[0] - 1, temp[1] - 1);
			}

			int ans = 0;
			for (int i = 0; i < m; i++) {
				var to = new List<int>[n];
				for (int j = 0; j < n; j++) {
					to[j] = new List<int>();
				}

				for (int j = 0; j < m; j++) {
					if (i == j) {
						continue;
					}

					int a = ab[j].Item1;
					int b = ab[j].Item2;
					to[a].Add(b);
					to[b].Add(a);
				}

				bool[] done = new bool[n];
				done[0] = true;

				var q = new Queue<int>();
				q.Enqueue(0);
				while (q.Count > 0) {
					int cur = q.Dequeue();
					foreach (int next in to[cur]) {
						if (done[next] == false) {
							done[next] = true;
							q.Enqueue(next);
						}
					}
				}

				if (done.Any(x => x == false)) {
					++ans;
				}
			}
		
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 13524
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.sort()
y.sort()
if x[N-1] < y[0] and X < Y and x[N-1] > X and y[0] < Y:
    print('No War')
else:
    print('War')

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

using namespace std;

#define PI (3.14159265358979323846)
#define MP make_pair
#define n1 first
#define n2 second
#define ALL(x) (x).begin(), (x).end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MS multiset
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define SZ(x) ((int)x.size())

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

const db eps = 0.00001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 550555;
const int M = 1125;

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

    x = x / 200 * 200;

    cout << (2000 - x) / 200;


}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3644
public class Main {

  private static void solve() {
    int k = ni();
    int n = ni();
    int[] a = na(n);
    int[] b = new int[n * 2];
    for (int i = 0; i < n; i++) {
      b[i] = a[i];
      b[i + n] = a[i] + k;
    }

    int ret = Integer.MAX_VALUE;
    for (int i = 0; i < n; i++) {
      ret = Math.min(ret, b[i + n - 1] - b[i]);
    }
    System.out.println(ret);



  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 49824
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (A, B): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = if A + B >= 10 {
        "error".to_string()
    } else {
        (A + B).to_string()
    };

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


Measured memory_bytes: 4352
N = int(input())
Edge = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    Edge[a].append(b)
    Edge[b].append(a)
stack = [1]
dist = [0]*(N+1)
visited = set([1])
while stack:
    vs = stack.pop()
    for e in Edge[vs]:
        if e in visited:
            continue
        visited.add(e)
        dist[e] = 1 + dist[vs]
        stack.append(e)
s = dist.index(max(dist))
stack = [s]
dist = [0]*(N+1)
visited = set([s])
while stack:
    vs = stack.pop()
    for e in Edge[vs]:
        if e in visited:
            continue
        visited.add(e)
        dist[e] = 1 + dist[vs]
        stack.append(e)
dia = max(dist) + 1
f = 'First'
s = 'Second'
if dia == 0:
    print(s)
elif dia == 1:
    print(f)
elif dia == 2:
    print(s)
else:
    if dia % 3 == 2:
        print(s)
    else:
        print(f)

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

int main(void){
    int N;
    cin >> N;
    vector<int> nums(N + 1);
    int n;
    for (int i = 1; i <= 10000; i++) {
        for (int j = 1; j <= 10000; j++) {
            for (int k = 1; k <= 10000; k++) {
                n = pow(i + j + k, 2) - i*j - j*k - k*i;
                if (n > N) break;
                nums[n]++;
            }
        }
    }
    for (int i = 1; i <= N; i++) cout << nums[i] << endl;
}


Measured memory_bytes: 3608
#include<stdio.h>

int main(){
  int i,j,n,num1,num2,n_2,g[101][101];
  scanf("%d",&n);
  for(i=1;i<101;i++){
    for(j=1;j<101;j++){
      g[i][j]=0;
    }
  }
  
  for(i=1;i<=n;i++){
    scanf("%d%d",&num1,&num2);
    for(j=1;j<=num2;j++){
      scanf("%d",&n_2);
      g[i][n_2]++;
    } 
  }

  for(i=1;i<=n;i++){
    for(j=1;j<n;j++){
      printf("%d ",g[i][j]);
    }
    printf("%d\n",g[i][n]);
  }
  
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int H[]= new int[N];
		for(int i=0;i<N;i++) {
			H[i]=sc.nextInt();	
		}
		int ans=0;
		int cnt=0;
		for(int i=0;i<N-1;i++) {
			if(H[i]>=H[i+1]) {
				cnt++;
			}else {
				ans = Math.max(ans, cnt);
				cnt = 0;
			}
		}
		ans = Math.max(ans, cnt);
		System.out.println(ans);
	}
}


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

int main()
{
  char N[4];
  
  cin >> N;

  if(((N[0] == N[1]) && (N[1] == N[2])) || ((N[1] == N[2]) && (N[2] == N[3])))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
string s;
int dp[300000][2];
signed main() {
	cin >> n >> s;
	n *= 2;
	int sum = 0;
	if (s[0] == 'W' || s[n - 1] == 'W') {
		cout << 0 << endl;
		return 0;
	}
	int ans = 1;
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			sum++; continue;
		}
		if (s[i] == 'B') {
			if (sum % 2 == 1) {
				(ans *= (sum--)) %= Mod;
			}
			else {
				sum++;
			}
		}
		else {
			if (sum % 2 == 0) {
				(ans *= (sum--)) %= Mod;
			}
			else {
				sum++;
			}
		}
	}
	if (sum > 0) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i <= n / 2; i++) {
		(ans *= i) %= Mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 644
#include <string>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>
 
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
 
	int n,a,b;
    int sum = 0;
	cin >> n >> a >> b;
    for(int i=0;i<=n;i++){
    int c=0;
    int t = i;
      for(int j=0;j<5;j++){
        c += t%10;
        t /= 10;
      }
      if(a<= c&& c<=b){
        sum += i;
      }
    }
      cout << sum << "\n";
    
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 110;

int n,cnt;
ll W,mi,ans;
int cn[10];
ll val[10][maxn],w[maxn],cw[maxn],wei[10],v[maxn],pre[10][maxn];

bool cmp(ll a,ll b){
	return a>b;
}

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	mi = 1e9 + 7;
	ans = 0;
	n = read(),W = read(); 
	for(int i=1;i<=n;i++){
		w[i] = read(); cw[i] = w[i];
		mi = min(mi, w[i]);
		v[i] = read();
	}
	
	sort(cw+1,cw+1+n);
	
	for(int i = 1;i <= n;i++){
		if(cw[i] != cw[i-1]){
			wei[++cnt] = cw[i];
		}
	}
	
	for(int i=1;i<=n;i++){
		int nt = w[i]-mi+1;
		val[nt][++cn[nt]] = v[i];
	}
	
	for(int i=1;i<=cnt;i++){
		sort(val[i]+1,val[i]+1+cn[i],cmp);
	}
	
	for(int i=1 ;i <= cnt;i++){
		for(int j = 1 ;j<=cn[i]; j++){
			pre[i][j]=val[i][j];
			pre[i][j]+=pre[i][j-1];
		}
	}
	
	if(cnt==4){
		for(int i=0 ;i <= cn[1];i++){
			for( int j= 0;j <= cn[2] ;j++){
				for( int k=0 ;k <= cn[3] ;k++){
					for(int p = 0; p <= cn[4] ; p++){
						if(i*wei[1]+j*wei[2]+k*wei[3]+p*wei[4]<=W){
							ans =max( pre[1][i] + pre[2][j] + pre[3][k] + pre[4][p],ans);
						}
						
					}
				}
			}
		}
	}
		
	if(cnt==3){
		for(int i=0 ;i <= cn[1];i++){
			for( int j= 0;j <= cn[2] ;j++){
				for( int k=0 ;k <= cn[3] ;k++){
					if(i*wei[1]+j*wei[2]+k*wei[3]<=W){
						ans =max( pre[1][i] + pre[2][j] + pre[3][k],ans);
					}
				}
			}
		}
	}
	
		
	if(cnt==2){
		for(int i=0 ;i <= cn[1];i++){
			for( int j= 0;j <= cn[2] ;j++){
				if(i*wei[1]+j*wei[2]<=W){
					ans =max( pre[1][i] + pre[2][j] ,ans);	
				}
			}
		}
	}
	
	if(cnt==1){
		for(int i=0 ;i <= cn[1];i++){
			if(i*wei[1]<=W){
				ans =max( pre[1][i] ,ans);
			}
		}
	}
	
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 3776
/*
 * DATE : 2017-07-07
 * Algo :
*/
#include<bits/stdc++.h>
using namespace std;
/*------- Constants---- */

#define LL                      long long
#define Ulong                   unsigned long long
#define FOR(I,A,B)              for(long long i=0; i < n ; i++ )
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-9
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x) {
    register char c = getchar();x = 0;
    int neg = 0;
    for(; ((c<48 || c>57) && c != '-'); c = getchar());
    if(c=='-'){neg = 1;c = getchar();}
    for(; c>47 && c<58 ; c = getchar()){x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M){
    long long ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/

const int N = 2e5+6;

long long a[N], p[N];
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++ ) cin >> a[i] , p[i] = a[i] + p[i-1];
    long long ans =LONG_LONG_MAX;
    for(int i = 1; i <= n - 1; i ++ ) {
        long long x = p[i] , y = p[n] - p[i];
        ans  = min(ans , abs(x- y));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(i=a;i<n;i++)
#define test(a) cout << "*" << a << endl;
int main(){
  int n,nTmp;
  int i;
  bool exist = false;
  
  cin >> n;
  nTmp = n;
  
  rep(i,0,n/7+1){
    n -= i*7;
    if(n%4==0){
      exist = true;
      break;
    }
    n = nTmp;
  }
  if(exist==true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll n; cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    ll q; cin >> q;
    ll b[q], c[q];
    rep(i, q){
        cin >> b[i] >> c[i];
    }

    map<ll, ll> mp;

    rep(i, n){
        mp[a[i]]++;
    }
    
    ll sum = accumulate(a, a+n, 0LL);

    rep(i, q){
        ll val = b[i];
        ll cnt = mp[b[i]];

        ll delta = (c[i] - val) * cnt;
        sum += delta;

        cout << sum << endl;

        mp[b[i]] = 0;
        mp[c[i]] += cnt;
    }

    return 0;
}

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

int main()
{
    std::string s;
    std::cin >> s;

    if (s == "SUN") std::cout << 7 << std::endl;
    if (s == "MON") std::cout << 6 << std::endl;
    if (s == "TUE") std::cout << 5 << std::endl;
    if (s == "WED") std::cout << 4 << std::endl;
    if (s == "THU") std::cout << 3 << std::endl;
    if (s == "FRI") std::cout << 2 << std::endl;
    if (s == "SAT") std::cout << 1 << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int mod = 1e+7;

int64_t attack(int64_t h) {
  if(h == 1) return 1;
  return attack(h/2LL)*2LL+1LL;
}

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

  int64_t h;
  cin >> h;
  cout << attack(h) << endl;
  return 0;
}


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


int main() {
int n=0; cin>>n;
vector<int>x(n);
for(int i=0;i<n;i++){cin>>x.at(i);}
int min=1000000;
int tmp=0;
for(int i=0;i<=100;i++){
  tmp=0;
    for(int j=0;j<n;j++){
      tmp+=(i-x.at(j))*(i-x.at(j));
    }
  if(min>tmp){min=tmp;}
}
cout<<min<<endl;
}


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

using namespace std;

int main() {
#ifdef  DEBUG
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
#endif  // for local.
  int rot;
  string in;
  cin >> rot >> in;

  for (int i = 0, c = 0; i < in.length(); i++) {
    c = (int)in[i] + rot;
    if (c > (int)'Z') {
      c -= 26;
    }
    cout << (char)c;
  } cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug != false) {
            return;
        }
        System.out.println(str);
    }

    public static void main(String[] args) {

        long A;
        long B;

        try (Scanner sc = new Scanner(System.in)) {
            A = sc.nextLong();
            B = sc.nextLong();
        }
        long p = A+B;
        long m = A - B;
        long k = A*B;
        long result = Math.max(p, m);
        result = Math.max(result, k);

        System.out.println(result);
        return;

    }
}


Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;

int main(){
  long long int n;
  cin>>n;
  vector<long long int> a(5,0);
  for(long long int i=0;i<n;i++){
    string s;
    cin>>s;
    if(s[0]=='M')a[0]++;
    if(s[0]=='A')a[1]++;
    if(s[0]=='R')a[2]++;
    if(s[0]=='C')a[3]++;
    if(s[0]=='H')a[4]++;
  }
  long long int ans=0;
  for(int i=0;i<3;i++){
    for(int j=i+1;j<4;j++){
      for(int k=j+1;k<5;k++)ans+=a[i]*a[j]*a[k];
    }
  }
  cout<<ans<<endl;
}


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

int LCSLength(char *,char *);

int main(){
  int i,n;
  char X[1000],Y[1000];

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%s",X);
    scanf("%s",Y);
    printf("%d\n",LCSLength(X,Y));
  }

  return 0;
}

int LCSLength(char *X,char *Y){
  int i,j,m,n;
  m = strlen(X);
  n = strlen(Y);
  int A[m+1][n+1];
  for (i = 1;i <= m;i++){
    A[i][0] = 0;
  }
  for (j = 0;j <= n;j++){
    A[0][j] = 0;
  }
 for (i = 1;i <= m;i++){
   for (j = 1;j <= n;j++){
     if(X[i-1] == Y[j-1]){
       A[i][j]= A[i-1][j-1]+1;
     }
     else if(A[i-1][j]>=A[i][j-1]){
        A[i][j]= A[i-1][j];
     }
     else  A[i][j]= A[i][j-1];
   }
 }
 return A[m][n];
}
   
  
  
  
        
  






Measured memory_bytes: 5768
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a < 10 && b < 10)cout << a * b << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
//Judgeテつ嘉δー(by kioa)
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
import static java.lang.String.format;

public class Main{
    final static int MAX = 1000 + 5;
    static int n, m;
    static int[] a = new int[MAX];
    
    static void solve(){
        int[] task = new int[MAX];
        for(int i=0;i<n;i++) task[i] = m / a[i] * a[i];
        //                out.println(Arrays.toString(task));
        int min = 1<<29, idx=-1;
        for(int i=0;i<n;i++) {
            if(task[i] < min) { min = task[i]; idx = i; }
            else if(idx>=0){
                if(task[i] == min && a[i] < a[idx]) { idx = i; }
                else if(task[i] == min && a[i] == a[idx]) { idx = -2; }
            }
        }
        if(idx == -2) out.println(n);
        else out.println(idx+1);
    }
    
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        while(true){
            n = sc.nextInt();
            m = sc.nextInt();
            if(n == 0 && m == 0) break;
            for(int i=0;i<n;i++) a[i] = sc.nextInt();
            solve();
        }
    }
}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;



int main() {
  int n;
  cin >>n;
  vector<int> a(n);
  for (int i = 0; i <n; i++) 
  {
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());

  int sum=0;
  int su=0;


  for(int i=0;i<n;i++){
    if(i%2==0){
      sum+=a.at(i);


    }
    else{
      su+=a.at(i);

    }
  }
  cout<<(sum-su)<<endl;
  
 
  
}
  

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll t[n], a[n];
    REP(i,n){
        cin >> t[i] >> a[i];
    }
    ll ans1 = t[0], ans2 = a[0];
    for(int i = 1; i < n; i++){
        ans1 = t[i] * max((ans1 - 1) / t[i] + 1, (ans2 - 1) / a[i] + 1);
        ans2 = a[i] * max((ans1 - 1) / t[i] + 1, (ans2 - 1) / a[i] + 1);
    }
    cout << ans1 + ans2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,k;
int a[200010];
int sum;
signed main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1,greater<int>());
	for(int i=k+1;i<=n;i++)sum+=a[i];
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <limits>

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

using namespace std;
const int INF = numeric_limits<int>::infinity();

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

    int A, B, ans;
    cin >> A >> B;
    if (abs(A-B) <= 1)
        ans = A + B;
    else {
        if (A > B) ans = 2*A - 1;
        else ans = 2*B - 1;
    }

    cout << ans << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
	char s[105];
	long long int k;
	bool flag=true;
	cin>>s>>k;
	int n=strlen(s);
	for(int i=0;i<n-1;i++){
		if(s[i]!=s[i+1]) flag=false;
	}
	if(flag){
		printf("%lld",n*k/2);
	}
	else{
		if(s[0]==s[n-1]){
			long long int a=1,b=1;
			for(int i=0;i<n;i++){
				if(s[i]==s[i+1]) a++;
				else break;
			}
			for(int i=n-1;i>=0;i--){
				if(s[i]==s[i-1]) b++;
				else break;
			}
			long long int c=0;
			for(int i=0;i<n;i++){
				if(s[i]==s[i+1]){
					s[i+1]='.';
					c++;
				}
			}
			printf("%lld",c*k-(a/2+b/2-(a+b)/2)*(k-1));
		}
		else{
			long long int ans=0;
			for(int i=0;i<n;i++){
				if(s[i]==s[i+1]){
					ans++;s[i+1]='.';
				} 
			}
			printf("%lld",ans*k);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

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

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e5 + 5, LG = 19, MOD = 1e9 + 7;
const int SQ =225;
const long double EPS = 1e-7;

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif


    int h, n;
    cin >> h >> n;
    vector<int>a(n);
    for(auto & x : a)cin >> x;

    if(accumulate(a.begin(),a.end(),0) >= h)
      cout << "Yes\n";
    else
      cout << "No\n";


  return 0;
}


Measured memory_bytes: 640