akhauriyash/Code-Regression huggingface dataset:
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::map<int64_t, int64_t> A;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A[t]++;
    }

    int ans = 0;

    for (auto a: A) {
        if (a.first < a.second) {
            ans += a.second - a.first;
        }
        else if (a.first > a.second) {
            ans += a.second;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


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

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


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

int main() {
  
  int N; cin >> N;
  
  vector<int64_t> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec[i];
  
  sort(vec.begin(), vec.end()); reverse(vec.begin(), vec.end());
  
  int64_t longSide = 0, shortSide = 0;
  
  for (int i = 0; i < N - 1; i++) {
    
    if (vec[i] == vec[i + 1]) {
      
      if (longSide == 0) { longSide = vec[i]; i++; }
      
      else { shortSide = vec[i]; break; }
      
    }
    
  }
  
  cout << longSide * shortSide << endl;
  
}

Measured memory_bytes: 4056
x,y=map(int,input().split())
ans=0
if x==1 and y==1:
    ans+=400000
if x==3:
    ans+=100000
if x==2:
    ans+=200000
if x==1:
    ans+=300000
if y==3:
    ans+=100000
if y==2:
    ans+=200000
if y==1:
    ans+=300000
print(ans)

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

#define int long long
#define pii pair<int,int>
#define pqi priority_queue<int>
#define pb push_back()
#define INF 1000000000000000000

#define pi acos(-1)

const int modu= (1e9)+7;

void testCase(int ti){
    cout<<"Case "<<ti<<": ";
}

int bigmod(int n,int p){
    if(p==0) return 1;
    int x=bigmod(n,p/2)%modu;
    x=(x*x)%modu;
    if(p%2) return (x*n)%modu;
    return x;
}

int modInverse(int a){
    return bigmod(a,modu-2)%modu;
}

void debug(string pr,vector<int> var,bool out=true){
    #ifdef OFFLINE
        ofstream fl;
        fl.open("debug.txt");
        fl<<pr;
        for(int i=0;i<var.size();i++) fl<<" "<<var[i];
        fl<<endl;
        fl.close();
    if(out){
        cout<<pr;
        for(int i=0;i<var.size();i++) cout<<" "<<var[i];
        cout<<endl;
    }
    #endif
}

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
}

void defInit(){
    //faster();
    #ifdef OFFLINE
      freopen("in.txt", "r", stdin);
      freopen("out.txt", "w", stdout);
    #endif
}

int add(int x,int y){
    int z =(x%modu + y%modu)%modu;
    while(z<0) z=(z+modu)%modu;
    return z;
}

int mul(int x,int y){
    int z = (x%modu * y%modu)%modu;
    while(z<0) z=(z+modu)%modu;
    return z;
}
// starts here

const int MaxN = 1e5;
int n,m;
vector<int> edge[MaxN+1],indegree(MaxN+1),dist(MaxN+1);
bool visited[MaxN+1];

void dfs(int u){
    visited[u]=1;
    for(int v : edge[u]){
        dist[v]=max(dist[v],dist[u]+1);
        indegree[v]--;
        if(indegree[v]==0) dfs(v);
    }
}


int32_t main(){
    defInit();
    //Now I will start writing codes and start preparation to get errors
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        edge[u].push_back(v);
        indegree[v]++;
    }
    for(int i=1;i<=n;i++){
        if(!visited[i] && !indegree[i]){
            dfs(i);
        }
    }
    cout<<*max_element(dist.begin(), dist.end());
    return 0;
}


Measured memory_bytes: 10496
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N,X;
    cin >> N >> X;
    int L[N + 1];
    L[0] = 0;
    int ans = 1;
    for(int i = 0;i < N;i++){
       cin >> L[i + 1]; 
    }
    
    for(int i = 1;i < N + 1;i++){
        L[i] += L[i - 1];
        if(L[i] <= X){
            ans++;
        }
    }
    cout << ans << endl;
    
    
}


Measured memory_bytes: 256
#include <cassert>
#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 <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
 
// C++
#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 <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define T int t = 0; cin >> t; while(t--)
#define pr(a) for(int i = 0; i < (int)a.size(); ++i)cout << a[i] << " ";cout << endl;
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 1e9 + 7;
const ll mx = 2e5 + 1;
const ll inf = 1e9;
const int sz = 20;

void input(){
    IOS;
    char c;
    cin >> c;
    if((int)c >= 65 && (int)c <=90)cout << "A" << endl;
    else cout << "a" << endl;
}
int main(){
    input();
    return 0;
} 
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/

Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int H = sc.nextInt();
		a = new int[N];
		b = new Integer[N];
		for(int i=0; i<N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(b, Collections.reverseOrder()); //降順
		
		int aMax = 0;
		for(int i=0; i<N; i++) if(aMax < a[i]) aMax = a[i];
		
		int dam = 0, count = 0;
		for(int i=0; i<N; i++) {
			if(b[i] > aMax) { //投げるより振る方が得の場合ある
				dam += b[i];
				count++;
			}
			if(dam >= H) { //投げて終わり
				System.out.println(count);
				return;
			}
		}
		
		//投げて終わらない
		System.out.println(count+(H-dam+aMax-1)/aMax);
	}
}

Measured memory_bytes: 76676
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <queue>
#include <stack>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
int n,m,k;
vector<P>g[100005];
int in[100005];
int d[100005];
bool vis[100005];
bool o=true;
void dfs(int v){
    k++;
    vis[v]=true;
    for(int i=0;i<g[v].size();i++){
        if(!vis[g[v][i].F]){
            d[g[v][i].F]=d[v]+g[v][i].S;
            dfs(g[v][i].F);
        }else{
            if(d[g[v][i].F]!=d[v]+g[v][i].S)o=false;
        }
    }
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        g[a].push_back(P(b,c));
        in[b]++;
    }
    for(int i=0;i<n;i++){
        if(in[i]==0){
            dfs(i);
        }
    }
    if(o==false||k!=n)cout<<"No\n";
    else cout<<"Yes\n";
}


Measured memory_bytes: 11264
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
dp=[10**9]*n
dp[0]=0
dp[1]=abs(a[1]-a[0])
for i in range(2,n):
    for j in range(1,k+1):
        dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i])
print(dp[-1])

Measured memory_bytes: 52320
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)


def main():
    n,m = LI()
    aa = [LI() for _ in range(m)]
    l = 0
    r = inf
    for a,b in aa:
        if l < a:
            l = a
        if r > b:
            r = b

    return max(0,r-l+1)


print(main())



Measured memory_bytes: 29832
a,b,c=map(int,raw_input().split())
if a>b :
  temp=a ;
  a=b;
  b=temp;

if b>c :
  temp=b ;
  b=c;
  c=temp;

if a>b :
  temp=a ;
  a=b;
  b=temp;

print a,b,c ;

Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
 
int main (){
  string s;
  cin >> s ;
    if ( s[0] == s[1] && s[1] == s[2] ){
      cout << "Yes" << endl;
    }

    else if ( s[1] == s[2]  &&  s[2] == s[3] ){
      cout <<  "Yes" << endl;
    }

    else {
      cout << "No" << endl;
    }
    


}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var nm=Arr.shift().split(" ").map(Number);
   var n=nm[0];
   var m=nm[1];
   if(n==0 && m==0)break;
   var N=[];
   for(var i=0;i<n;i++){
      N[i]=[];
      for(var j=0;j<n;j++){
         N[i][j]=Infinity;
         if(i==j)N[i][j]=0;
      }
   }
   var arr=[];
   for(var i=0;i<m;i++){
      var abc=Arr.shift().split(" ").map(Number);
      var a=abc[0];
      var b=abc[1];
      var c=abc[2];
      N[a][b]=c;
      N[b][a]=c;
   }
   var city=[0];
   var cost=0;
   while(true){
      if(city.length==n)break;
      var min=Infinity;
      var select=-1;
      for(var i=0;i<city.length;i++){
         for(var j=0;j<n;j++){
            if(city.indexOf(j)!=-1)continue;
            if(N[city[i]][j]<min){
               select=j;
               min=N[city[i]][j];
            }
         }
      }
      if(select!=-1){
         cost+=min;
         city.push(select);
      }
   }
   console.log(cost);
}

Measured memory_bytes: 10164
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = Integer.parseInt(in.next());

            int[] C = new int[N - 1];
            int[] S = new int[N - 1];
            int[] F = new int[N - 1];

            for (int i = 0; i < N - 1; i++) {
                C[i] = Integer.parseInt(in.next());
                S[i] = Integer.parseInt(in.next());
                F[i] = Integer.parseInt(in.next());
            }

            for (int i = 0; i < N; i++) {
                int time = 0;
                for (int station = i; station < N - 1; station++) {
                    if (time <= S[station]) {
                        time = S[station];
                    } else {
                        if ((time - S[station]) % F[station] == 0) {
                            time = S[station] + (time - S[station]) / F[station] * F[station];
                        } else {
                            time = S[station] + ((time - S[station]) / F[station] + 1) * F[station];
                        }
                    }

                    time += C[station];

                }

                System.out.println(time);
            }

        }
    }
}


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


int main() {
  int M,D; cin >> M >> D;
  int ans = 0;

  for (int m = 0; m <= M; m++) {
    for (int d = 10; d <= D; d++) {
      int d_1 = d/10, d_10 = d%10;
      if (d_1 >= 2 && d_10 >= 2 && d_1 * d_10 == m) ans++;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
int main(){
	string s; cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++){
		if(s[i]=='?'){
			if(i>0 and i<n and (s[i-1]=='D' or s[i-1]=='?') and  (s[i+1]=='D' or s[i+1]=='?')){
				s[i]='P';
				//cout<<i<<endl;
			}else{
				s[i]='D';
			}
		}
	}
	cout<<s;
}


Measured memory_bytes: 3764
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations, islice
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    B = deque(LI())
    B.appendleft(0)
    # print(B)
    ans = deque([])
    for i in range(N, 0, -1):
        tmp = deque([])
        # print(B)
        for j in range(i, 0, -1):
            # print(i, j, B[j])
            if B[j] == j:
                # print(tmp)
                tmp2 = deque(islice(B, 0, j))
                tmp2.extend(tmp)
                # print(tmp2)
                # tmp2.appendleft(0)
                B = tmp2
                ans.appendleft(j)
                break
            else:
                tmp.appendleft(B[j])
        else:
            print(-1)
            return

    printlist(list(ans), '\n')

if __name__ == '__main__':
    solve()


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


string longestRepeatedSubstring(string str) 
{ 
    int n = str.length(); 
    int LCSRe[n+1][n+1]; 
  
    // Setting all to 0 
    memset(LCSRe, 0, sizeof(LCSRe)); 
  
    string res; // To store result 
    int res_length  = 0; // To store length of result 
  
    // building table in bottom-up manner 
    int i, index = 0; 
    for (i=1; i<=n; i++) 
    { 
        for (int j=i+1; j<=n; j++) 
        { 
            // (j-i) > LCSRe[i-1][j-1] to remove 
            // overlapping 
            if (str[i-1] == str[j-1] && 
                LCSRe[i-1][j-1] < (j - i)) 
            { 
                LCSRe[i][j] = LCSRe[i-1][j-1] + 1; 
  
                // updating maximum length of the 
                // substring and updating the finishing 
                // index of the suffix 
                if (LCSRe[i][j] > res_length) 
                { 
                    res_length = LCSRe[i][j]; 
                    index = max(i, index); 
                } 
            } 
            else
                LCSRe[i][j] = 0; 
        } 
    } 
  
    // If we have non-empty result, then insert all 
    // characters from first character to last 
    // character of string 
    if (res_length > 0) 
        for (i = index - res_length + 1; i <= index; i++) 
            res.push_back(str[i-1]); 
  
    return res; 
} 
  
// Driver program to test the above function 
int main() 
{ 
    int n;
    cin>>n;
    std::string str;
    std::cin>>str;
    string res = longestRepeatedSubstring(str);
    cout<<res.length();
    return 0; 
} 

Measured memory_bytes: 97920
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;
const int dx[]={-1,1,0,0};
const int dy[]={0,0,-1,1};
void solve()
{
	int a,b,c;
	cin>>a>>b>>c;
	int d=ceil((double)a/c);
	
	if(d<=b)cout<<"Yes";
	else cout<<"No";
	
}
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
  //  cin>>t;
    while(t--)
	solve();
    return 0;
}


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

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;
bool flag[N];
int main() {
    int n, cnt = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        if (flag[x]) cnt++;
        else flag[x] = true;
    }
    printf("%d\n", n - cnt - (cnt & 1));
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int>card(N);

  for(int i = 0; i < N; i++){
    int a_i;
    cin >> a_i;

    card.at(i) = a_i;
  }

  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  
  int A = 0;
  for(int j = 0; j < N; j += 2){
    A += card.at(j);
  }

  int B = 0;
  for(int k = 1; k < N; k += 2){
    B += card.at(k);
  }

  cout << A - B << endl;




}

Measured memory_bytes: 3640
#include <iostream>
using namespace std; 
int main(){
    int x,y,w,h,r;
    cin >>w>>h>>x>>y>>r;     
    if((x<=w-r)&&(x>=r)&&(y<=h-r)&&(y>=r))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>


using namespace std;
int main() {
  string s;
  int a = 0;
  cin >> s;

  for(int i = 0; i < (int)s.size(); ++i){
      char ch = s[i];
      if (ch == '+') {
        a++;
      } else if(ch == '-') {
        a--;
      }
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
class Array
  include Comparable
end

n = gets.to_s.to_i

cnt = 0
3.upto(n.to_s.size) do |i|
  [3, 5, 7].repeated_permutation(i) do |a|
    cnt += 1 if a.include?(3) && a.include?(5) && a.include?(7) && a.join.to_i <= n
  end
end

puts cnt

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n + 1);
  vector<long> dp(n + 1, 1000000000000L);
  for (int i = 1; i <= n; i++) cin >> h[i];
  dp[1] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= min(i + k, n); j++) {
      dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
    }
  }
  cout << dp[n];
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define mrp(i,n) for(int i=n-1;i>=0;i--)
#define mrep(i,m,n) for(int i=m;i>=n;i--)
#define mlrp(i,n) for(long long i=n;i>=0;i--)
#define mlrep(i,m,n) for(long long i=m;i>=n;i--)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
ll abs(ll a,ll b){
    return(a>b?a-b:b-a);
}

int main(){
    int n;
    cin >> n;
    cout << (n>=1200?"ARC":"ABC") << endl;
}


Measured memory_bytes: 256
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n&1){
        cout<<"No";
        return;
    }
    bool flag=0;
    rep(i,0,n/2){
        if(s[i]!=s[i+(n/2)]){
            flag=1;
            break;
        }
    }
    cout<<(flag==0?"Yes":"No");
}
    
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    // fastio;
    int t=1;
        // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    b = list(map(int, input().split()))
    ansl = []
    for i in range(n):
        f = False
        for j in range(n - i - 1, -1, -1):
            if b[j] == j+1:
                ansl.append(b.pop(j))

                f = True
                break

        if not f:
            print(-1)
            exit()
    for i in range(n - 1, -1, -1):
        print(ansl[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		StringBuilder sb = new StringBuilder();
		if (n < m) {
			for (int i = 0; i < m; i++) {
				sb.append(n);
			}
		} else {
			for (int i = 0; i < n; i++) {
				sb.append(m);
			}
		}
		System.out.println(sb);
	}

}


Measured memory_bytes: 22608
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int n,k,i;
	char s[101];
	scanf("%d",&k);
	scanf("%s",s);
	n=strlen(s);
	if(n<=k) printf("%s\n",s);	
	else{
		for(i=0;i<k;i++){
			printf("%c",s[i]);
		}
		printf("...\n");
	}
	return 0;
}


Measured memory_bytes: 1640
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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

#define v vector
#define ALL(x) x.begin(),x.end()
#define rALL(x) x.rbegin(),x.rend()
#define endl '\n'
#define DEBUG

template<typename T> void DBG(const char* name, T&& H) {
	cerr << name << " = " << H << ')' << endl;
}

template<typename T, typename... Args> void DBG(const char* names, T&& H, Args&&... args) {
	const char* NEXT = strchr(names+1, ',');
	cerr.write(names, NEXT-names) << " = " << H << " |";
	DBG(NEXT+1, args...);
}

#ifdef DEBUG
	#define dbg(...) cerr << __FUNCTION__ << ' ' <<__LINE__ << " : (", DBG(#__VA_ARGS__, __VA_ARGS__)
#else
	#define dbg(...)
#endif

using ll = long long;
using ld = long double;

const long long mod = 998244353;
const long double PI = acos(-1.0);
const long long INF = 1e18;
const int maxN = 2e5+1;

string A, B;
int ans = 10000, reqSZ[2001][2001], dif[2001];

void computeSZ() {
	vector<int> left(A.size(), -1), right(A.size(), -1);
	int ptr = 0;
	for(int i = B.size()-1; i >= 0; i --) {
		ptr --;
		if(B[i] == '1') break;
	}
	for(int i = 0; i < A.size(); i ++) {
		if(B[i] == '1') ptr = i;
		left[i] = i-ptr;
	}
	ptr = A.size()-1;
	for(int i = 0; i < B.size(); i ++) {
		ptr ++;
		if(B[i] == '1') break;
	}
	for(int i = A.size()-1; i >= 0; i --) {
		if(B[i] == '1') ptr = i;
		right[i] = ptr-i;
	}
	for(int i = 0; i < A.size(); i ++) {
		vector<pair<int, int>> consider;
		for(int j = 0; j < A.size(); j ++) {
			int idx = (i+j) % A.size();
			dif[i] += (A[j] != B[idx]);
			if((B[idx] == '0') && (A[j] == '1')) {
				consider.push_back({left[j], right[j]});
			}
		}
		consider.push_back({-1, -1});
		sort(rALL(consider));
		int rightBorder = 0;
		ptr = 0;
		for(int j = A.size(); j >= 0; j --) {
			while(consider[ptr].first > j) {
				rightBorder = max(rightBorder, consider[ptr].second);
				ptr ++;
			}
			reqSZ[i][j] = rightBorder+j;
		}
	}
}

void computeAns() {
	for(int i = 0; i <= A.size(); i ++) {
		int permut =(i % A.size());
		int req = reqSZ[permut][0];
		for(int j = 0; j < A.size(); j ++) {
			int L = j, R = i+j;
			req = min(reqSZ[permut][L], req);
			if(req <= R) {
				ans = min(ans, dif[permut]+L+R);
			}
		}
	}
	for(int i = 0; i <= A.size(); i ++) {
		int permut = ((A.size()-i) % A.size());
		int req = reqSZ[permut][i];
		for(int j = 0; j < A.size(); j ++) {
			int L = i+j, R = j;
			if(L > A.size()) break;
			req = min(reqSZ[permut][L], req);
			if(req <= L) {
				ans = min(ans, dif[permut]+L+R);
			}
		}
	}
}

void Solve() {
	cin >> A >> B;
	int countA = 0, countB = 0;
	for(int i = 0; i < B.size(); i ++) {
		if(B[i] == '0') countB ++;
		if(A[i] == '0') countA ++;
	}
	if(countB == B.size()) {
		if(countA == A.size()) cout << 0 << endl;
		else cout << -1 << endl;
		return;
	}
	computeSZ();
	computeAns();
	cout << ans << endl;
} 

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

	int tt = 1;	
	while(tt --) {
		Solve();
	}
	
	return 0;
}

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

 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,count=0;
    cin>>n;
    string s[n];
    for(i=0;i<n;i++)
    {
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s,s+n);
    vector<ll> v;
    ll temp=0;
    for(i=1;i<n;i++)
    {
        if(s[i]==s[i-1])
        temp++;
        else
        {
        v.push_back(temp);
        temp=0;
        }
    }
    v.push_back(temp);
    for(j=0;j<v.size();j++)
    {
        if(v[j]!=0)
        {
            count+=((v[j]*(v[j]+1))/2);
        }
    }
    cout<<count;

	return 0;
}


Measured memory_bytes: 6908
A = []
for i in range(3):
  A.append(list(map(int, input().split())))
N = int(input())
b = []
for i in range(N):
  b.append(int(input()))
Bingo = [[(0,0),(0,1),(0,2)],[(1,0),(1,1),(1,2)],[(2,0),(2,1),(2,2)],
         [(0,0),(1,0),(2,0)],[(0,1),(1,1),(2,1)],[(0,2),(1,2),(2,2)],
         [(0,0),(1,1),(2,2)],[(0,2),(1,1),(0,2)]]
for L in Bingo:
  f = True
  for x,y in L:
    if A[x][y] not in b:
      f = False
  if f:
    print ("Yes")
    break
else:
  print ("No")

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

#define INF = 2147483647;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }

    int ans = 0;

    for(int i = 0; i < n; i++){
        ans += (min(k - x[i], x[i])) * 2;
    }

    cout << ans << endl;

}

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

using namespace std;

typedef unsigned long long ull;

ull euclidean_gcd(ull a, ull b) {
  if(a < b) return euclidean_gcd(b, a);
  ull r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

set<ull> S;

set<ull> enum_div(ull n)//nの約数を列挙
{
	set<ull> ret;
	for(ull i=1 ; i*i<=n; ++i)
	{
		if(n%i == 0)
		{
			ret.insert(i);
			if(i!=1 && i*i!=n)
			{
				ret.insert(n/i);
			}
		}
	}
    if(n != 1){
        ret.insert(n);
    }
	return ret;
}

int main()
{
    ull a, b;
    cin >> a >> b;
    set<ull> array;
    if(a < b){
        ull temp = b;
        b = a;
        a = temp;
    }
    ull r = euclidean_gcd(a, b);
    array = enum_div(r);
    bool flag;
    for(ull e: array){
        flag = 1;
        for(ull e2 : S){
            if(euclidean_gcd(e2, e) != 1){
                flag = 0;
                break;
            }
        }
        if(flag) S.insert(e);
    }
    cout << S.size() << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
/* Data Structure */
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <stack>
#include <queue>

using namespace std;

#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3fLL
#define debug cerr << "======= GOT_HERE ======\n"
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef map<int,int> mii;
typedef map<long long,long long> mll;
typedef set<int> si;
typedef set<long long> sll;

long long n,k;

string s;

bool flag = false;

void addOne(string& a, int idx)
{
	if(idx<0)
	{
		flag = true;
		return;
	}
	int carry = 1;
	for(int i=idx;i>=0;--i)
	{
		int now = a[i]-'0'+carry;
		if(now!=10)
		{
			a[i] = now+'0';
			carry = 0;
			break;
		}
		else
		{
			a[i] = '0';
			carry = 1;
		}
	}
	if(carry)
	{
		flag = true;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>s;
	n = s.length();
	ll ans = 0;
	for(int i=n-1;i>=0;--i)
	{
		if(s[i]-'0'<=4){
			ans+=s[i]-'0';
		}
		else if(s[i]-'0'>=6){ 
			ans+=10-(s[i]-'0');
			addOne(s,i-1);
		}
		else
		{
			if(i==0) ans+=5;
			else if(s[i-1]-'0'<5) ans+=5;
			else
			{
				ans+=5;
				addOne(s,i-1);
			}
		}
	}
	if(flag) ans++;
	cout << ans << endl;
	return 0;
}

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

int main()
{
    long n,i;
    cin>>n;
    long A[n+1];
    A[0]=0;
    for(i=1;i<=n;i++)
        cin>>A[i];

    long long dp[n+1];
    dp[0]=0;
    dp[1]=0;
  	dp[2]=abs(A[2]-A[1]);
    for(i=3;i<=n;i++)
        dp[i]=min(dp[i-1]+abs(A[i]-A[i-1]),dp[i-2]+abs(A[i]-A[i-2]));
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
import sys
import math
from collections import deque
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline

N = I()
up_l = LI()
under_l = [0 for i in range(N)]
for i in up_l:
    under_l[i-1] += 1
[print(i) for i in under_l]


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

void fastio() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}

int main(int argc, char const *argv[])
{
	#define int long long
	int n, w;
	cin >> n >> w;
	vector<int> weights(n), values(n);
	for (int i = 0; i < n; ++i) {
		cin >> weights[i] >> values[i];
	}
	const int MAX = 100010;
	vector<vector<int> > dp(n, vector<int>(MAX, INT_MAX)); // weight matrix
	for (int i = 0; i < n; ++i) dp[i][0] = 0;
	for (int i = 0; i < n; ++i) {
		dp[i][values[i]] = weights[i];
		for (int j = 1; j <= MAX; ++j) {
			// take
			if (i > 0 && j >= values[i] && dp[i-1][j-values[i]] != INT_MAX) {
				dp[i][j] = min(dp[i][j], weights[i] + dp[i-1][j-values[i]]);
			}
			// don't take
			if (i > 0) dp[i][j] = min(dp[i][j], dp[i-1][j]);
		}
	}
	int ans = 0;
	for (int j = MAX - 1; j >= 0; --j) {
		if (dp[n-1][j] <= w) {
			ans = max(ans, j);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(void) {
    int a, b;
    cin >> a >> b;
    
    if(a>b) swap(a, b);

    for(int i=0;i<b;i++) cout << a;

    cout << endl;

    return (0);
}


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

int main() {
	int n,m,i,j,k,ans,cur;
	string s;
	cin >> s;
	if(s[2]==s[3] && s[4]==s[5]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2019/12/29.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int n;
    cin >> n;
    vi t(n + 1);
    vector<double> a(n + 1);
    t[0] = a[0] = 0;
    rep(i, n){
        cin >> t[i + 1] >> a[i + 1];
        a[i + 1] = log(1 - 0.1 * a[i + 1]) + a[i];
    }
    int q;
    cin >> q;
    CST(10);
    rep(_, q){
        int l, r;
        cin >> l >> r;
        int idxl = lower_bound(all(t), l) - t.begin() - 1;
        int idxr = lower_bound(all(t), r) - t.begin() - 1;
        cout << 1e9 * exp(a[idxr] - a[idxl]) << endl;
    }
    return 0;
}


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

int main() {
	int n,m,k;
	cin>>n>>m>>k;
	int a=0;
	for(int i=0;i<m+1;i++){
		for(int j=0;j<n+1;j++){
			if(n*i+m*j-2*i*j==k)a=1;
			if(a)break;
		}
	}
	if(a)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int n;
  scanf("%d",&n);
  long long int a[n],b[n];
  b[0]=a[0];
  long long int k=b[0];
  for(int i=0;i<n;i++)
 { scanf("%lld",&a[i]);
  if(i>0)
  {b[i]=k+a[i];
  k=b[i];
    
  }
  
 }
  
  long long int m=1000000007,sum=0,c=b[n-1];
  for(int i=0;i<n;i++)
  {
   sum=(sum+((a[i]%m)*((c-b[i])%m))%m)%m;
  }
  printf("%lld\n",sum);
  return 0;
}


Measured memory_bytes: 4852
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  string s;
  cin>>s;
  if( SZ(s)==2 ) cout<<s<<endl;
  else{
    reverse(ALL(s));
    cout<<s<<endl;
  }
}


Measured memory_bytes: 256
n,m= map(int,input().split())
s =[list(map(int,input().split())) for i in range(n)]
s.sort()
c = 0
for i in range(n):
        if s[i][1] >= m:
                c += s[i][0] * m
                break
        else:
                m = m - s[i][1]
                c += s[i][0] * s[i][1]
print(c)

Measured memory_bytes: 27884
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
   int r, g;
   cin >> r >> g;
   cout << 2 * g - r << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	int* a =new int[n];
  	int* b =new int[n];
  	int* c =new int[n];
  	for(int i=0;i<n;i++){
      cin>>a[i]>>b[i]>>c[i];
    }
  	int** dp=new int*[n];
  	for(int i=n-1;i>=0;i--){
      dp[i]=new int[3];
      for(int j=0;j<3;j++){        
      	  dp[i][j]=1000000000;
          if(i==n-1){
            if(j==0)
            	dp[i][j]=a[i];
            else if(j==1)
              	dp[i][j]=b[i];
            else
                dp[i][j]=c[i];
          }
          else {
            if(j==0)
            	dp[i][j]=a[i]+max(dp[i+1][1],dp[i+1][2]);
            else if(j==1)
              	dp[i][j]=b[i]+max(dp[i+1][0],dp[i+1][2]);
            else
                dp[i][j]=c[i]+max(dp[i+1][1],dp[i+1][0]);
        }      
    }
    }
	cout<<max(dp[0][0],max(dp[0][1],dp[0][2]))<<endl;
}

Measured memory_bytes: 8660
# -*- coding:utf-8 -*-

def is_kaibun(s):
    left = 0
    right = len(s)-1
    while left <= right:
        if s[left] != s[right]:
            return False
        left += 1
        right -= 1
    return True

def solve():
    S = input()
    N = len(S)

    if is_kaibun(S) and is_kaibun(S[0:(N-1)//2]) and is_kaibun(S[(N+3)//2-1:]):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	int a,b,k,i;
	scanf("%d %d %d",&a,&b,&k);
	if(b-a+1>=2*k){
		for(i=a;i<a+k;i++) printf("%d\n",i);
		for(i=b-k+1;i<=b;i++) printf("%d\n",i);
	}else{
		for(i=a;i<=b;i++) printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    // Long A[] = new Long[N];
    HashMap<Long,Integer> map = new HashMap<Long,Integer>();
    Long sum = 0L;
    for(int i=0;i<N;i++){
      Long tmp = sc.nextLong();
      sum += tmp; 
      if(map.containsKey(tmp)){
        map.put(tmp,map.get(tmp)+1);
      }else{
        map.put(tmp,1);
      }
    }
    int Q = Integer.parseInt(sc.next());
    // System.out.println(Q+"q");
    Long A[] = new Long[Q];
    for(int i=0;i<Q;i++){
      // System.out.println(i+"i");
      Long B = sc.nextLong();
      Long C = sc.nextLong();
      if(map.containsKey(C) && map.containsKey(B)){
        int tmp2 = map.get(B);
        sum += (C - B)*tmp2;
        map.put(C,map.get(C)+tmp2);
        map.put(B,0);
      }else if(map.containsKey(C) && !map.containsKey(B)){
      }else if(!map.containsKey(C) && map.containsKey(B)){
        int tmp3 = map.get(B);
        sum += (C - B)*tmp3;
        map.put(C,tmp3);
        map.put(B,0);
      }
      A[i] = sum;
    }
    for(int i=0;i<Q;i++){
      System.out.println(A[i]);
    }


    // System.out.println(count);
  }
}

Measured memory_bytes: 74604
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
ll a[N];

int main(){
	int n, k; scanf("%d%d", &n, &k);
	REP(i, n) scanf("%lld", a+i);
	FOR(i, k, n){
		if(a[i] > a[i-k]) printf("Yes\n");
		else printf("No\n");
	}
}


Measured memory_bytes: 5316
import java.io.*;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt();
        int[] a = new int[n];
        int[] cmp = new int[40010];
        for(int i=0;i<n;i++){a[i]=scan.nextInt();}
        Map<Integer,Integer> map = new HashMap<Integer,Integer>();
        for(int bit=0;bit<(Math.pow(2,n));bit++){
            int sum=0;
            for(int i=0;i<n;i++){
                if((1&bit>>i)==1){
                    sum+=a[i];
                    //System.out.println(a[i]);
                    //System.out.println(sum);
                }
                //System.out.println();
            }
            cmp[sum]++;
            //System.out.println(sum);
        }
        int q=scan.nextInt();
        for(int i=0;i<q;i++){
            int m=scan.nextInt();
            if(cmp[m]>0){
                System.out.println("yes");
            }
            else{
                System.out.println("no");
            }
        }
    }
}


Measured memory_bytes: 27568
/*
By Snickeen
*/
#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VL vector<LL>
#define VII vector<PII >
#define VLL vector<PLL >
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define FF first
#define SS second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}
 
const LL MAXN=1e6+10;
LL t,n,m,ans;
LL MOD=1e9+7,inf=0x1f1f1f1f;
db eps=1e-5;

LL u,v;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0;
	cin>>n;
	cin>>u>>v;
	while(--n){
		cin>>i>>j;
		k=max(u/i,v/j);
		if(i*k>=u&&j*k>=v)u=i*k,v=j*k;
		else k++,u=i*k,v=j*k;
	}
	cout<<u+v<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;

/*
   AtCoder contest code
   coder : yoichidon
 */

public class Main {
    public static int[] solve(int N, int x){
        int[] ans = new int[2*N-1];
        if(N==2){
            return new int[]{1,2,3};
        }

        if(x==2){
            ans[N-2] = 2*N-1;
            ans[N-1] = 2;
            ans[N]   = 1;
            ans[N+1] = 2*N-2;
            int elm = 3;
            for(int index=0; index<2*N-1; index++){
                if(ans[index]==0){
                    ans[index]=elm;
                    elm++;
                }
            }
        }else{
            ans[N-2] = 1;
            ans[N-1] = x;
            ans[N]   = 2*N-1;
            ans[N+1] = 2;
            int elm = 3;
            for(int index=0; index<2*N-1; index++){
                if(elm==x) elm++;
                if(ans[index]==0){
                    ans[index]=elm;
                    elm++;
                }
            }
        }
        return ans;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int x = sc.nextInt();

        if(x==1 ||  x==2*N-1){
            System.out.println("No");
            return;
        }
        else{
            System.out.println("Yes");
        }
        int[] ans = solve(N,x);
        for(int i=0; i<ans.length; i++) System.out.println(ans[i]);


    }
}


Measured memory_bytes: 47508
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int[] arr = new int[] { a, b, c };
        Arrays.sort(arr);
        int result = arr[0] != arr[1] ? arr[0] : arr[2];

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21716
package main

import (
    "fmt"
    "os"
    "bufio"
)

func main() {
    reader := bufio.NewReaderSize(os.Stdin, 1024)
    var queue [][]int
  	var H, W int
	fmt.Scan(&H, &W)
    visited := make([][]int, H)

    for i := 0; i < H; i++ {
      line, _, _ := reader.ReadLine()

        for j, v := range line {
            visited[i] = append(visited[i], -1)

            if string(v) == "#" {
                var val []int
                val = append(val, i)
                val = append(val, j)
                queue = append(queue, val)
                visited[i][j] = 0
            }
        }
    }

    // BFS
    var dx [4]int
    var dy [4]int
    dx[0] = 0
    dx[1] = 0
    dx[2] = 1
    dx[3] = -1
    dy[0] = 1
    dy[1] = -1
    dy[2] = 0
    dy[3] = 0
    var now_x, now_y, next_x, next_y int
    var cnt int = 0

    for len(queue) > 0 {
        now_y = queue[0][0]
        now_x = queue[0][1]

        for i := 0; i < 4; i++ {
            next_y = queue[0][0] + dy[i]
            next_x = queue[0][1] + dx[i]

            if next_x >= 0 && next_x <= W - 1 &&
               next_y >= 0 && next_y <= H - 1 &&
               visited[next_y][next_x] == -1 {
               var val []int
               val = append(val, next_y)
               val = append(val, next_x)
               queue = append(queue, val)
               visited[next_y][next_x] = visited[now_y][now_x] + 1
               cnt = visited[next_y][next_x]
            }
        }

        queue = queue[1:]
    }

    fmt.Println(cnt)
}


Measured memory_bytes: 102272