akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
    FOR(i,2,p) {
      if (p%i==0) return false;
    }
  return true;
}

int main(){
  string s;
  vector<string> ss;
  int k;
  cin >> s >> k;
  REP(i,s.size()){
    REP(j,6){
      if (s.size()-i>j) ss.push_back(s.substr(i,j+1));
    }
  }
  std::sort(ss.begin(), ss.end());
  ss.erase(std::unique(ss.begin(), ss.end()), ss.end());
  cout << ss[k-1];
  return 0;
}

Measured memory_bytes: 1916
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int x,y;
    cin>>x>>y;
    int a,b;
    b=y/2-x;
    a=x-b;
    //cout<<a<<" "<<b<<endl;
    if(a>=0 && b>=0 && x>=0 && y>=0 && 2*a+4*b==y && a+b==x)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3624
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

def calc_sum(s):
    if s % 10 == 0:
        return 0
    else:
        return s

N = int(input())
S = [int(input()) for _ in range(N)]

s = sum(S)

if s%10:
    print(s)
    exit()

ans = 0
for i in range(N):
    ans = max(ans, calc_sum(s-S[i]))

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
    char arr[]= { 'S', 'H', 'C', 'D'  };
    char c;
    int i,j,n,a;
    static int card[4][13];
    scanf("%d\n",&n);
    for(i=0; i<n; i++)
    {
        scanf("%c %d\n",&c,&a);
        for(j=0; j<4; j++)
        {
            if(arr[j]==c)
                card[j][a-1]=1;

        }

    }
    for(i=0; i<4; i++)
    {
        for(j=0; j<13; j++)
        {
            if (card[i][j]==0)
                printf("%c %d\n",arr[i],j+1);
        }
    }
    return 0;
}



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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

ll memo[100]={};

ll beki(ll i){
    if(memo[i]!=0) return memo[i];
    if(i==0)return 1;
    return 10*beki(i-1);
}

int main() {
    ll n;cin>>n;
    ll a;
    ll i;
    for(i=0;i<=17;i++){
        if(beki(i)-1<=n & n<beki(i+1)-1){
            a=i;
        }
    }
    ll b;
    b=beki(a)-1;
    ll c;
    bool d=true;
    for(ll x=0;x<=9;x++){
        if((x+1)*beki(a)+b>n && d){
            d=false;
            c=x;
        }
    }
    cout<<a*9+c<<endl;
    return 0;
}



Measured memory_bytes: 256
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) fill_n(x, sizeof(x)/sizeof(x[0]), y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scf(x) scanf("%f", &x)
#define scd(x) scanf("%lf", &x)
#define scld(x) scanf("%Lf", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	int N;
	sci(N);
	int arr[N];
	for (int i = 0; i < N; ++i) sci(arr[i]);
	int cnt = 0;
	int last = -1;
	for (int i = 0; i < N; ++i) {
		if (last <= arr[i]) {
			++cnt;
			last = arr[i];
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k; cin >> n >> k;
	int t[n];
	int v[n-1];
	for(int i=0;i<n;i++){
		cin >> t[i];
		if(i){
			v[i-1]=t[i]-t[i-1]-1;
		}
	}
	int ans=t[n-1]-t[0]+1;
	sort(v,v+n-1);
	for(int i=n-2;i>n-2-(k-1);i--){
		ans-=v[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 3980
#include<stdio.h>
#include<algorithm>
using namespace std;
int x[10];
int y[10];
int z[10];
int ans[10];
int siz;
int val[10];
int n;
int m;
int t;
void solve(int b){
	if(n==b){
		for(int i=0;i<m;i++){
			int N=0;
			for(int j=x[i]-1;j<y[i];j++)N+=val[j];
			if(N!=z[i])return;
		}
		int S=0;
		for(int i=0;i<n;i++)S+=val[i];
		if(S>siz){
			siz=S;
			for(int i=0;i<n;i++)ans[i]=val[i];
		}
		return;
	}
	for(int i=0;i<=t;i++){
		val[b]=i;
		solve(b+1);
	}
}
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	m=c;
	t=b;
	n=a;
	for(int i=0;i<c;i++){
		scanf("%d%d%d",x+i,y+i,z+i);
	}
	ans[0]=-1;
	siz=-1;
	solve(0);
	
	if(siz==-1)printf("%d\n",siz);
	else {
		for(int i=0;i<a;i++){
			if(i)printf(" ");
			printf("%d",ans[i]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 1032
A,B,K = map(int, input().split())
ans = set()

for i in range(K):
    if A+i <= B:
        ans.add(A+i)
    if B-i >= A:
        ans.add(B-i)
    
ans = list(ans)
ans.sort()

for a in ans:
    print(a)


Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  int n, m;
  scanf("%d %d", &n, &m);
  
  int h[n];
  for(int i = 0;i < n;i++){
    scanf("%d", &h[i]);
  }
  
  
  char good[n];
  for(int i = 0;i < n;i++){
    good[i] = 1;
  }
  
  int link[2];
  for(int i = 0;i < m;i++){
    scanf("%d %d", &link[0], &link[1]);
    link[0]--;
    link[1]--;
    if(h[link[0]] < h[link[1]]){
      good[link[0]] = 0;
    }
    else if(h[link[0]] > h[link[1]]){
      good[link[1]] = 0;
    }
    else{
      good[link[0]] = 0;
      good[link[1]] = 0;
    }   
  }
  
  int cnt = 0;
  for(int i = 0;i < n;i++){
    if(good[i] == 1){
      cnt++;
    }
  }
  
  printf("%d", cnt);
  
  return 0;
}
  
  

Measured memory_bytes: 2212
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int a[N];
int main()
{
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= m; i ++)
	{
		int x, y;
		cin >> x >> y;
		a[x] ++;
		a[y + 1] --;
	}
	int ans = 0, s = 0;
	for(int i = 1; i <= n + 1; i ++)
	{
		s += a[i];
		if(s == m)
			ans ++;
	}
	cout << ans;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 640
#include<stdio.h>

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

int main (void){

    int nums[5];

    int i,j,k;

    for(i=0;i<5;i++){
        scanf("%d",&nums[i]);
    }

    for(i=0;i<5;i++){
        for(j=0;j<4;j++){
            if(nums[j]<nums[j+1])swap(&nums[j],&nums[j+1]);
        }
    }

    for(i=0;i<5;i++){
        printf("%d%c",nums[i],i==4?'\n':' ');
    }

    return 0;
}

Measured memory_bytes: 596
# -*- coding: utf-8 -*-
"""
A - AtCoder *** Contest
https://atcoder.jp/contests/abc048/tasks/abc048_a

"""
import sys


def solve(s):
    return 'A{}C'.format(s[0].upper())


def main(args):
    _, s, _ = input().split()
    ans = solve(s)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
def gcd(m,n)
	if n == 0 
		m
	else
		gcd(n,m%n)
	end
end

def lcm(m, n)
	(m * n ) / gcd(m,n)
end

n = gets.to_i
a = gets.split.map(&:to_i)
l=1
n.times do |i|
		l = lcm(l,a[i])
end
sum = 0;
n.times do |i|
	sum = sum + l/a[i]
end
puts sum % 1000000007
		


Measured memory_bytes: 56676
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
#define P(a,b) make_pair(a,b);
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

int main(){
  ll A[3];
  cin >> A[0] >> A[1] >> A[2];
  sort(A,A+3);
  if(A[0] == A[1] && A[1] != A[2]){
    cout << "Yes" << endl;
  }else if(A[1] == A[2] && A[1] != A[0]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;

set<int> m;

int main() {
    int n,a;
    cin >> n;
    for(int i = 0;i < n;i++) {
        cin >> a;
        if(m.find(a) != m.end()) {
            cout << "NO" << endl;
            return 0;
        }
        m.insert(a);
    }
    cout << "YES" << endl;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int a, b;
    cin >> a >> b;
    bool flg = false;
    for(int c = 1; c <= 3; c++){
        if(a * b * c % 2 == 1) flg = true;
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
flag = 1
for i in range(0,len(T)):
    if not 96<ord(T[i]) and ord(T[i])<122:
        flag=0

if not len(T)-len(S)==1:
    flag=0

if not T[:-1]==S:
    flag=0
print("Yes" if flag==1 else "No")


Measured memory_bytes: 9048
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
using namespace std;


int main() {
  unsigned long long L, R;

  cin >> L >> R;

  unsigned long long range_min  = L;
  unsigned long long range_max  = min(R, L+2019);
  unsigned long long min = 2019;
  unsigned long long tmp;

  for(unsigned long long i=range_min; i<range_max; i++) {
	  for(unsigned long long j=i+1; j<=range_max; j++) {
	  	tmp = (i*j) % 2019;
	  	if(min > tmp) min = tmp;
	  }
  }

  cout << min;
}

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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] xyxy = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int x1 = xyxy[0];
            int y1 = xyxy[1];
            int x2 = xyxy[2];
            int y2 = xyxy[3];
            int x = x2 - x1;
            int y = y2 - y1;
            Console.WriteLine("{0} {1} {2} {3}",x2-y,y2+x,x1-y,y1+x);
            
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <stack>
using namespace std;
int main(int argc, char *argv[]) {
	while (true) {
		int N,R;
		scanf("%d %d",&N, &R);
		if (N == 0 && R == 0) break;
		stack<int> deck;
		for (int i=0;i<N;i++) deck.push(i+1);
		for (int i = 0; i < R; i++) {
			int P,C;
			scanf("%d %d",&P,&C);
			stack<int> ps,cs;
			if (P == 1) continue;
			for (int j = 0; j < P-1; j++) {
				ps.push(deck.top());
				deck.pop();
			}
			for (int j = 0; j < C; j++) {
				cs.push(deck.top());
				deck.pop();
			}
			while (ps.size()>0) {
				deck.push(ps.top());
				ps.pop();
			}
			while (cs.size()>0) {
				deck.push(cs.top());
				cs.pop();
			}
		}
		printf("%d\n",deck.top());
	}
	return 0;
}

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

int main(){
    int q; cin >> q;
    set<int> a;
    decltype(a)::iterator itr;
    rep(i ,q){
        int m , x;
        cin >> m >> x;
        switch (m)
        {
        case 0: 
            a.insert(x);
            cout << a.size() << endl; 
            break;
        case 1:
            itr = a.find(x);
            cout << (itr!=a.end() ? 1 : 0) << endl;
            break;
        case 2:
            a.erase(x);
            break;
        }
    }
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

pair<int,int> ans[111111];
int tosi[111111];
vector<pair<pair<int,int>,int>> v;

int main(){

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

	REP(i,m){
		int a,b;cin >> a >> b;
		v.PB(MP(MP(b,a),i));
	}

	sort(ALL(v));

	REP(i,v.size()){
		tosi[v[i].FI.SE]++;
		ans[v[i].SE] = MP(v[i].FI.SE,tosi[v[i].FI.SE]);
	}

	REP(i,m){
		printf("%06d%06d\n",ans[i].FI,ans[i].SE);
	}


	return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = K; i < N; i++) {
    cout << (A[i - K] < A[i] ? "Yes" : "No") << endl;
  }
  return 0;
}


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

int main(){
   int a, b, c, d;
   cin>>a;
   cin>>b;
   cin>>c;
   cin>>d;
   int i;
   i = a + b + c + d;
   cout<<i / 60<<endl;
   cout<<i % 60<<endl;

   return 0;
}


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

int main(){
    int64_t n,a,b;
    cin >> n >> a >> b;
    int64_t ans = 0;
    
    if ((abs(a-b)-1) % 2 == 0){
        ans += min(min(n-a,n-b),min(a-1,b-1));
        ans++;
        if (a > b) a--;
        else b--;
    }
    
    ans += abs(a-b) / 2;

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
L = [[0] * 10 for _ in range(10)]

for i in range(1,N+1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    L[a][b] += 1

ans = 0
for i in range(1,N+1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    ans += L[b][a]

print(ans)

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

int main()
{
    int n;
    char s[100];
    int y, flag = 1;

    scanf("%d", &n);
    scanf("%s", s);

    y = n/2 ;

    if(n%2 ==0)
    {
        for(int i=0; i<n/2; i++)
        {
            if(s[i] != s[y])
                {
                    printf("No");
                    flag = 0;
                    break;
                }
            y++;
        }

        if(flag)
            printf("Yes");

    }
    else
        printf("No");
    return 0;
}

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

namespace agc030_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var text = Console.ReadLine();

            var prevValue = "";
            for(int i = 0; i < text.Length; i++){
                var currentValue = text.Substring(i, 1);
                if (prevValue == currentValue){
                    Console.WriteLine("Bad");
                    return;
                }

                prevValue = currentValue;
            }

            Console.WriteLine("Good");
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k - 1] = tolower(s[k - 1]);
    cout << s;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353

int main(){
	ll n, m, x; cin >> n >> m;
	ll ans = 0;
	priority_queue<ll> q;
	REP(i,n){ll a; cin >> a; q.push(a);}
	REP(i,m){x = q.top(); q.pop(); q.push(x/2);}
	REP(i,n){ans += q.top(); q.pop();}
	cout << ans << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/*---------------------template----------------------*/
/*----------------------end--------------------------*/
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
signed main(){
  int N;cin>>N;
  cout<<180*(N-2)<<endl;
}




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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

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

    int ans = 0;
    vector<int> bb(n);
    for (ll i = 0, t = 1; i < 30; ++i) {
        for (int j = 0; j < n; ++j)
            bb[j] = b[j] % (2 * t);

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

        ll cnt = 0;
        for (int j = 0; j < n; ++j) {
            const int aa = a[j] % (2 * t);

            // a_j + b_k \in [T, 2T)
            cnt += distance(lower_bound(bb.begin(), bb.end(), t - aa),
                            lower_bound(bb.begin(), bb.end(), 2 * t - aa));

            // a_j + b_k \in [3T, 4T)
            cnt += distance(lower_bound(bb.begin(), bb.end(), 3 * t - aa),
                            lower_bound(bb.begin(), bb.end(), 4 * t - aa));
        }

        // Update
        ans += (cnt % 2) * t;
        t *= 2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
const int maxn=1e5+100;
typedef long long LL;
int n;
LL T,A;
LL h[maxn],b[maxn];
int main()
{
    scanf("%d",&n);
    scanf("%lld%lld",&T,&A);
    T*=1000,A*=1000;
    for(int i=1;i<=n;i++){
        scanf("%lld",&h[i]);
        h[i]*=1000;
    }
    for(int i=1;i<=n;i++){
        b[i]=T-(h[i]*0.006);
    }
    int pos=-1;
    LL mx=INT64_MAX;
    for(int i=1;i<=n;i++){
        if(abs(b[i]-A)<mx){
            pos=i,mx=abs(b[i]-A);
        }
    }
    printf("%d\n",pos);
    return 0;
}


Measured memory_bytes: 256
ls = []
s = input()
ls = list(s)
ans = 0
if len(s) == 1:
  print("0")
else:
  for i in range(len(ls)-1):
    if ls[i] == ls[i+1]:
      if ls[i] == '0':
        ls[i+1] = '1'
        ans = ans + 1
      else:
        ls[i+1] = '0'
        ans = ans + 1
    else:
      continue
  print(ans)
    

Measured memory_bytes: 3956
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
vector<int>v;
int n,k,x,kx;
int ans=-1,sum,pos;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>k;kx=k;k=min(k,n);
	for(int i=0;i<n;i++)cin>>x,v.pb(x);
	for(int i=0;i<=k;i++){
		for(int j=0;j+i<=k;j++){
			pos=kx-i-j;sum=0;vector<int>g;
			for(int l=0;l<i;l++)g.pb(v[l]);
			for(int l=0;l<j;l++)g.pb(v[n-l-1]);
			sort(g.begin(),g.end());
			reverse(g.begin(),g.end());
			for(int l=0;l<i+j-pos;l++)sum+=g[l];
			for(int l=max(0,i+j-pos);l<i+j;l++){
				if(g[l]<0)break;
				sum+=g[l];
			}
			ans=max(ans,sum);
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< string, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


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

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

int N;
ll Y;
bool ans = false;
ll A, B, C;

int main(){
    
    cin>>N>>Y;
    
    REP( i, N+1 ){
        REP( j, N+1-i ){
            A = i;
            B = j;
            C = N-i-j;
            if( A*1000+B*5000+C*10000 == Y ){
                ans = true;
                i = N;
                break;
            }
        }
    }
    
    if( ans ){
        printf("%lld %lld %lld\n", C, B, A);
    }
    else{
        puts("-1 -1 -1");
    }
    
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) ((v).begin(), (v).end())
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    bool ha[110];
    fill(ha,ha+110,false);
    int n, k;
    cin >> n >> k;
    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin  >> a;
            ha[a-1] = true;
        }
    }
    int count = 0;
    rep(i, n) {
        if(!ha[i])count++;
    }
    cout << count << endl;
}

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

int main() {
	string s;
	cin >> s;
	int N = s.size();
	int a, z;
	int count = 0;
	
	for (int i = 0; i < N; i++) {
		if (s.at(i) == 'A') {
			a = i;
			break;
		}

	}

	for (int i = N - 1; i >= 0; i--) {
		if (s.at(i) == 'Z') {
			z = i;
			break;
		}
	}

	int k = z - a + 1;
	cout << k << endl;

}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
    int D, G, p[11], c[11];
    cin >> D >> G;
    for(int i = 0; i < D; ++i){
        cin >> p[i] >> c[i];
    }
 
    int ans = 1e9;
    for(int mask = 0; mask < (1 << D); ++mask){
        int s = 0, num = 0, rest_max = -1;
        for(int i = 0; i < D; ++i){
            if(mask >> i & 1){
                s += 100 * (i+1) * p[i] + c[i];
                num += p[i];
            }else{
                rest_max = i;
            }
        }
        if(s < G){
            int s1 = 100 * (rest_max + 1);
            int need = (G - s + s1 - 1) / s1;
            if(need >= p[rest_max]){
                continue;
            }
            num += need;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
}

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

int main() {
	int s, s_1, s_2, s_3;
	cin >> s;
	s_1 = s / 100 % 2;
	s_2 = s / 10 % 2;
	s_3 = s % 2;
    cout << s_1 + s_2 + s_3 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int A, B, C;

    scanf("%d %d %d", &A, &B, &C);
    if ((B / A) > C)
    {
        printf("%d", C);
    }
    else
    {
        printf("%d", (B / A));
    }

    return 0;
}

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

int main() {
  int N;
  cin >> N;
 //vector<int> takoyaki(N);
  string S;
  cin >> S;
  int i;
  int j;
  int count;
  count = 0;
  long ans;
  ans = 1;
   for(i=0;i<N-1;i++){
     if(S.at(i) != S.at(i+1)){ans++;}
   }
  
  cout << ans;
  
  /*
  vector<int> suujivec(10);
  int suuji = std::stoi(S);
  int c =0;
   for(int i=10-S.size();i<10;i++){
    int a = int(S.at(c)- '0');
      suujivec.at(i)=a; 
     c++;
   }
  
  vector<vector<int>> data(512, vector<int>(9,0));
 
  int ccc=0;
  long int answer =0;
  for(int i=0;i<data.size();i++){
  for(int j=0;j<data.at(0).size();j++){
    ccc++;
    if(data.at(i).at(j) == 1){ ccc=0; }
    if(j==0){ answer += suujivec.at(9); }
    cout << kaijou(ccc) << endl;
    answer += suujivec.at(8-j) * kaijou(ccc); 
    
  }
  }
   
   for(int i=0;i<data.size();i++){
     for(int j=0;j<data.at(0).size();j++){
     if(j==data.at(0).size()-1){cout << data.at(i).at(j) <<endl;}else{
     cout << data.at(i).at(j);
     }
   }
   }
  */

}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a,b,c;
    while(cin >> a >> b >> c) {
        set<int> st;
        st.insert(a); st.insert(b); st.insert(c);
        cout << st.size() << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {
	long long dp[101][21] = {};

	int n; cin >> n;

	int a; cin >> a;
	dp[1][a] = 1;

	for (int i = 2; i < n; i++) {
		int a; cin >> a;
		for (int j = 0; j <= 20; j++) {
			if (j + a >= 0 && j + a <= 20)dp[i][j + a] += dp[i - 1][j];
			if (j - a >= 0 && j - a <= 20)dp[i][j - a] += dp[i - 1][j];
		}
	}

	cin >> a;
	cout << dp[n - 1][a] << endl;
	return 0;
}

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

const int x[10] = {-1,2,5,5,4,5,6,3,7,6};
void chmax(int &a, const int &b) { if (a < b) a = b; return; }

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

    vector<int> data(m);
    for (int i = 0; i < m; i++) cin >> data[i];
    sort(data.begin(),data.end(),greater<int>());

    vector<int> keta(n+1,-1); keta[0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < m; j++) {
            if (i - x[data[j]] >= 0) chmax(keta[i], keta[i - x[data[j]]] + 1);
        }
    }

    while (n > 0) {
        for (int i = 0; i < m; i++) {
            if (n - x[data[i]] >= 0 && keta[n] == keta[n - x[data[i]]] + 1) {
                cout << data[i];
                n -= x[data[i]];
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>					
using namespace std;	
int main()	
{		int n;
cin>>n;
int ary[200001];
for(int i = 0;i<n;i++){
	cin>>ary[i];
}
sort(ary,ary+n);
for(int i = 0;i<n;i++){
	if(ary[i]==ary[i+1]){
		cout<<"NO";return 0;
	}
}							
cout<<"YES";						
	return 0; 									
 } 

Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
using base = complex<double>;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define M2 998244353
#define ll long long
#define pll pair<long, long>
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define ff first
#define ss second
#define pb push_back
#define db pop_back
#define mp make_pair
#define mt make_tuple
#define g(a, b) get<a>(b)
#define INF (ll)1e18 + 100
#define vl vector<ll>
#define vi vector<int>
#define vll vector<pair<ll, ll>>
#define vii vector<pair<int, int>>
#define all(v) v.begin(), v.end()
#define bset(a, p) ((a) | (1ll << (p)))
#define bchk(a, p) ((a) & (1ll << (p)))
#define bxor(a, p) ((a) ^ (1ll << (p)));
#define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
#define INT_SIZE 32
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
ll powM(ll x, ll y, ll m)
{
	ll ans = 1, r = 1;
	x %= m;
	while (r > 0 && r <= y)
	{
		if (r & y)
		{
			ans *= x;
			ans %= m;
		}
		r <<= 1;
		x *= x;
		x %= m;
	}
	return ans;
}
ll modI(ll a, ll m)
{
	ll m0 = m, y = 0, x = 1;
	if (m == 1)
		return 0;
	while (a > 1)
	{
		ll q = a / m;
		ll t = m;
		m = a % m;
		a = t;
		t = y;
		y = x - q * y;
		x = t;
	}
	if (x < 0)
		x += m0;
	return x;
}

ll logint(ll x, ll y)
{
	ll ans = 0;
	ll a = 1;
	for (ll i = 0; i <= x; i++)
	{
		if (x < a)
		{
			return ans;
		}
		ans++;
		a *= y;
	}
	return -1;
}
ll extended(ll a, ll b, ll &x, ll &y)
{
	if (a == 0)
	{
		x = 0;
		y = 1;
		return b;
	}
	ll x1, y1;
	ll d = extended(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
void solve() {
	ll a, b, v, w;
	cin >> a >> v >> b >> w;
	ll t;
	cin >> t;
	ll dist = abs(a - b);
	ll diff = w - v;
	if (v - w < 0) {cout << "NO"; return;}
	if ((-w + v)*t >= dist) {cout << "YES"; return;}
	else {
		cout << "NO"; return;
	}
}



int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("input.txt", "w", stdout);
	ll ntc;
	// cin >> ntc;
	ntc = 1;
	REP(tc, 1, ntc + 1)
	{
		// cout << "Case #" << tc << ": ";
		solve();
	}
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int H, W, h, w, i, j;
	cin >> H >> W >> h >> w;
	if (H%h == 0 && W%w == 0) {
		cout << "No" << endl;
		return 0;
	}
	else {
		cout << "Yes" << endl;
	}
	bool yoko;
	if (W%w) {
		yoko = true;
	}
	else {
		yoko = false;
	}

	if (!yoko) {
		swap(H, W);
		swap(h, w);
	}
	//DEBUG(H); DEBUG(W); DEBUG(h); DEBUG(w);
	vi s(W + 1, -1);
	s[0] = 0;
	for (i = 1; i < w; i++) {
		s[i] = 10000 - i;
	}
	for (i = w; i <= W; i++) {
		s[i] = s[i - w] - 1;
	}
	//DEBUG_VEC(s);
	vi a(W);
	for (i = 0; i < W; i++) {
		a[i] = s[i + 1] - s[i];
	}
	if (yoko) {
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				cout << a[j] << " ";
			}
			cout << endl;
		}
	}
	else {
		for (i = 0; i < W; i++) {
			for (j = 0; j < H; j++) {
				cout << a[i] << " ";
			}
			cout << endl;
		}
	}
}

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

int main() {
  int N; //wa
  int ans; 
  int A; //wa
  /*
  N ^ 2 = N^2
  N^2 - A = ans
  
  */
  
  cin >> N;
  cin >> A;
  ans = N * N - A;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  int W, H, N;
  cin >> W >> H >> N;

  int xl = 0, xr = W, yl = 0, yr = H;
  rep(i, N) {
    int a, x, y;
    cin >> x >> y >> a;
    switch (a) {
      case 1:
        chmax(xl, x);
        break;
      case 2:
        chmin(xr, x);
        break;
      case 3:
        chmax(yl, y);
        break;
      case 4:
        chmin(yr, y);
        break;
      default:
        break;
    }
  }
  cout << max(0, xr - xl) * max(0, yr - yl) << endl;
  cerr << xl << " " << xr << " " << yl << " " << yr << endl;
  return 0;
}

Measured memory_bytes: 3636
from math import gcd
def solve():
    K = int(input())

    ans = 0
    for a in range(1,K+1):
        for b in range(1,K+1):
            for c in range(1,K+1):
                ans += gcd(gcd(a,b), c)
    
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 69236
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int a, b;
        String op;
        for(;;){
            a = scan.nextInt();
            op = scan.next();
            b = scan.nextInt();
            if(op.equals("+")){
               System.out.println(a + b);
            }else if(op.equals("-")){
               System.out.println(a - b);
            }else if(op.equals("/")){
               System.out.println(a / b);
            }else if(op.equals("*")){
               System.out.println(a * b);
            }else if(op.equals("?")){
                break;
            }
        }
    }
}

Measured memory_bytes: 26228
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <complex>

#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define rtr(c, i) for (typeof((c).rbegin()) i = (c).rbegin(); i != (c).rend(); --i)
#define contains(c, x) ((c).find(x) != (c).end())
#define Contains(c, x) (find(all(c), x) != (c).end())
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) REP(i, 0, (n))
#define To_String to_string< char,std::char_traits<char>,std::allocator<char> >

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int a[11];
int main()
{
	ios_base::sync_with_stdio(0);
	string s;
	while (cin >> s, s != "0") {
		int n = s.size();
		rep(i, n) switch (s[i]) {
			case 'r': a[i] = 0; break;
			case 'g': a[i] = 1; break;
			case 'b': a[i] = 2; break;
		}
		int x = 0;
		rep(i, n) x = x * 3 + a[n-1-i];

		queue<int> q;
		map<int, int> m;
		q.push(x);
		m[x] = 0;
		int res = -1;
		while (!q.empty()) {
			int p = q.front(); q.pop();
			int t = p, d = p % 3;
			bool ok = true;
			rep(i, n) { a[i] = t % 3; t /= 3; ok = (ok && (a[i] == d)); }
			if (ok) { res = m[p]; break; }

			rep(i, n-1) if (a[i] != a[i+1]) {
				int t1 = a[i], t2 = a[i+1];
				a[i] = a[i+1] = 3 - t1 - t2;
				int y = 0;
				rep(j, n) y = y * 3 + a[n-1-j];
				if (!contains(m, y)) { q.push(y); m[y] = m[p] + 1; }
				a[i] = t1, a[i+1] = t2;
			}
		}
		if (res >= 0) cout << res << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<ll> factorList(ll x) {
    vector<ll> res;
    for (int p : primes) {
      while (x%p == 0) {
        res.push_back(p);
        x /= p;
      }
    }
    if (x != 1) res.push_back(x);
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {  //firstが素因数
    vector<ll> fl = factorList(x);  //secondがそれが何個あるか
    if (fl.size() == 0) return {};
    vector<pair<ll,int>> res(1, P(fl[0], 0));
    for (ll p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
    ll n;
    cin >> n;
    Sieve s(1000005); //Sieveというデータ構造を使う。名前をsとする。
    auto fs = s.factor(n); //sの中の関数factorを使う。factor(n)でnの<素因数,その数>を配列で返す。
    int ans = 0;
    for(auto p : fs){
        int x = p.second;
        int b = 1;
        while(b <= x){
            x -= b;
            b++;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7816
n, m = map(int, input().split())
cards = sorted(list(map(int, input().split())))
ope = [list(map(int, input().split())) for i in range(m)]
ope.sort(key=lambda x: x[1], reverse=True)
i, j, k = 0, 0, 0
while i < n and j < m and cards[i] < ope[j][1]:
    cards[i] = ope[j][1]
    i += 1
    k += 1
    if k >= ope[j][0]:
        j += 1
        k = 0
print(sum(cards))

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

bool memo[1010];

int main(void){
	int n,m;
	cin >> n >> m;
	rep(i,m){
		int c,d;
		cin >> c >> d;
		if(c<d) range(j,c,d)memo[j]=true;
	}
	int ans=n+1;
	rep(i,n) ans+=2*memo[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

//Accelerated Railgun
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			double d = sc.nextDouble();
			if(d==0)break;
			double px = sc.nextDouble();
			double py = sc.nextDouble();
			double vx = sc.nextDouble();
			double vy = sc.nextDouble();
			double x1 = -px;
			double y1 = -py;
			double x2 = vx;
			double y2 = vy;
			if(Math.abs(x1*y2-x2*y1)>1e-8){
				System.out.println("impossible");continue;
			}
			double k = x2!=0?x1/x2:y1/y2;
			double D = 0;
			if(k>0)D = Math.hypot(px, py);
			else D = 2-Math.hypot(px, py);
			System.out.println(D<=d?D:"impossible");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	if (n & 1) {
		printf("%d\n", (n + 1) / 2 * (n - 1) / 2);
	} else {
		printf("%d\n", n / 2 * n / 2);
	}
        return 0;
}


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

vector<int> divisor(int n) {
    vector<int> res;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i += 2) {
        if (divisor(i).size() == 8) ++cnt;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    string w;
    cin >> w;
    if (w == "Sunny") {
        w = "Cloudy";
    } else if (w == "Cloudy") {
        w = "Rainy";
    } else if (w == "Rainy") {
        w = "Sunny";
    }
    cout << w << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;
	
	
	void doIt() {
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		Map<Integer, Long> R = new HashMap<>();
		for(int i = 0; i < N; i++) {
			int r = i - A[i];
			if(R.containsKey(r)) {
				R.put(r, R.get(r) + 1);
			}
			else {
				R.put(r, 1l);
			}
		}
		long sum = 0;
		
		for(int i = 0; i < N; i++) {
			int l = i + A[i];
			if(R.containsKey(l)) {
				sum += R.get(l);
			}
		}
		System.out.println(sum);
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


Measured memory_bytes: 65532
#include<stdio.h>
#include<string.h>
int main(){
	int n,i,j,ans;
	int f[10005];
	memset(f,0,sizeof(f));
	f[0]=f[1]=1;
	for(i=3;i<10005;i++){
		if(f[i]==0){
			for(j=2;i*j<10005;j++){
				f[i*j]=1;}
		}
	}
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		if(n%2==0)n--;
		while(1){
			if(f[n]==0 && f[n-2]==0){
				printf("%d %d\n",n-2,n);
				break;
			}else n-=2;
		}
	}
	return 0;
}

Measured memory_bytes: 0