akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

string s, t;
vector< vector<ll> > dp(3030, vector<ll>(3030, 0));

int main() {
    cin >> s >> t;
    int slen = s.length(); int tlen = t.length();

    for(int i = 0; i < slen; ++i) {
        for(int j = 0; j < tlen; ++j) {
            if(s.at(i) == t.at(j)) {
                chmax(dp[i+1][j+1], dp[i][j]+1);
            }else {
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }

    int k = slen; int l = tlen;
    string ans;
    while(k != 0 && l != 0) {
        if(s.at(k-1) == t.at(l-1)) {
            // s, tが一致したとき
            ans.push_back(s.at(k-1));
            k--; l--;
        }else {
            if(dp[k][l] == dp[k-1][l]) {
                k--;
            }else if(dp[k][l] == dp[k][l-1]) {
                l--;
            }
        }
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 72064
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8, pi = acos(-1.0);
bool eq(ld a, ld b){return (abs(b-a)<eps);}
ld dot(Point a, Point b){return real(conj(a)*b);}
ld cross(Point a, Point b){ return imag(conj(a)*b);}
int ccw(Point a, Point b, Point c){
  b-=a;c-=a;
  if(cross(b,c)>eps) return 1;//countor_crockwise
  if(cross(b,c)<-eps) return -1;//crockwise
  if(dot(b,c)<0) return 2;//c,a,b
  if(norm(b)<norm(c)) return -2;//a,b,c
  return 0;//a,c,b
}

Point p0, p1, p2;
int q;

int main(){ _;
  int x,y;
  cin>>x>>y; p0=Point(x,y);
  cin>>x>>y; p1=Point(x,y);
  cin>>q;
  REP(i,q) {
    cin>>x>>y; p2=Point(x,y);
    switch(ccw(p0,p1,p2)){
    case 1:
      cout<<"COUNTER_CLOCKWISE"<<endl;
      break;
    case -1:
      cout<<"CLOCKWISE"<<endl;
      break;
    case 2:
      cout<<"ONLINE_BACK"<<endl;
      break;
    case -2:
      cout<<"ONLINE_FRONT"<<endl;
      break;
    default:/*case 0*/
      cout<<"ON_SEGMENT"<<endl;
      break;
    }
  }

}

Measured memory_bytes: 1212
#include <stdio.h>
#define MAX 10000

int main() {
	int n;
	int a[MAX];
	int i;
	double avg;
	int count[MAX];
	int c_i = 0;

	while (1) {
		scanf("%d", &n);
		if (n == 0) { break; }

		avg = 0;
		count[c_i] = 0;

		for (i = 0; i < n; i++) {
			scanf("%d", &a[i]);
			avg += a[i];
		}
		avg /= n;

		for (i = 0; i < n; i++) {
			if (a[i] <= avg) { count[c_i]++; }
		}

		c_i++;
	}

	for (i = 0; i < c_i; i++) {
		printf("%d\n", count[i]);
	}
}


Measured memory_bytes: 2048
#include <stdio.h>

int main(void){
    char first, second, third, forth;
    scanf("%s" "%s" "%s" "%s", &first, &second, &third, &forth); 
    if(first == second && first != third && third == forth){
        printf("Yes\n");
    }
    else if(first == third && first != second && second == forth){
        printf("Yes\n");
    }
    else if(first == forth && first != second && third == second){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}

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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] xy = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            var ichi = new List<int>(){1,3,5,7,8,10,12};
            var ni = new List<int>(){4,6,9,11};
            var san = new List<int>(){2};
            if(ichi.Count(x=>x==xy[0])>0 && ichi.Count(x=>x==xy[1])>0){
                Console.WriteLine("Yes");        
            }else if(ni.Count(x=>x==xy[0])>0 && ni.Count(x=>x==xy[1])>0){
                Console.WriteLine("Yes"); 
            }else if(san.Count(x=>x==xy[0])>0 && san.Count(x=>x==xy[1])>0){
                Console.WriteLine("Yes"); 
            }else{
                Console.WriteLine("No");
            }
        }
            // 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 <bits/stdc++.h>
#define N 50000

using namespace std;

typedef long long int ll;

ll i,j,k,x,z,p,q,M,co,b,c;
double a,y;
string str,str1;
vector<ll>veca;
ll suma[N+5];

void sum()
{
    z = 0;
    for (i=1;i<=N;i++)
    {
        z += (i*i*i);
        suma[i]=z;
    }
}

int main()
{
    //z=0;
    //sum();
    cin >>x;
    for (i=0;i<x;i++)
    {
        cin >> k;
        if (i==0)
            z=k;
        if (i>0){
        if (k<=z){
            c++;
            //cout << c << "\t" << k << endl;
        z=k;
        }
        else
        {
            //cout << c << endl;
            veca.push_back(c);
            c=0;
            z=k;
        }}
    }
    veca.push_back(c);
    sort(veca.begin(),veca.end());

    cout << veca[veca.size()-1] << endl;
    //fclose(stdout);
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, a[222222], res = 0, now = 0;
    cin>>n;
    rep(i, n) {
        cin>>a[i];
    }
    reverse(a, a + n);
    rep(i, n) {
        if(a[i] < now) {
            cout<<-1<<endl;
            return 0;
        }
        if(a[i] > now) {
            res += now + 1;
            now = a[i] - 1;
        } else {
            if(now) res++, now--;
        }
    }
    cout<<(a[n - 1] ? -1 : res)<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define INPUT(X) cin >> X
#define OUTPUT(X) cout << X << endl

using namespace std;

int main(void) {

	string S;
	int N, A, B;

	INPUT(N);
	INPUT(A);
	INPUT(B);
	
	OUTPUT(min(N*A,B));

}

Measured memory_bytes: 256
ans_list = []
# m:1000, c:100. x:10, i:1
n = int(input())

mcxi = list("mcxi")[::-1]

def value(string):
    res = 0
    for i in range(4):
        index = string.find(mcxi[i])
        if index != -1:
            if string[index-1] in mcxi:
                res += pow(10,i)
            else:
                res += int(string[index-1]) * pow(10,i)
    return res

def MCXI(integer):
    res = ""
    for i in range(4):
        remain = integer % 10
        integer //= 10
        if remain == 1:
            res = mcxi[i] + res
        elif remain == 0:
            pass
        else:
            res = str(remain) + mcxi[i] + res
    return res

for _ in range(n):
    s,t = input().split()
    ans = MCXI(value(s) + value(t))
    ans_list.append(ans)

for ans in ans_list:
    print(ans)


Measured memory_bytes: 5852
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def size(self, x):
        return -self.parents[self.find(x)]

n, m = map(int,input().split())
uf = UnionFind(n)
for i in range(m):
    a,b = map(int,input().split())
    uf.unite(a-1, b-1)

ans = 0
for i in range(n):
    ans = max(ans,uf.size(i))

print(ans)

Measured memory_bytes: 14396
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  int c = 0;
  for (int i = 0; i <= N-1; i++){
    int a;
    cin >> a;
    while (a%2 == 0){
      c++;
      a = a/2;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 764
'use strict';
(function(stdin) {
  var line = stdin.toString().split('\n');
  var result = (function(data) {
    return data.filter(function(v){
      return v !== 0;
    })
    .map(function(v,index) {
      return ['Case'
              ,(index + 1) + ':'
              ,v
            ].join(' ');
    }).join('\n');
    
  }(
    line.map(Number)
  ));
  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 13352
//gacha

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / __gcd(a, b) * b
#define range(a) (a).begin(),(a).end()
const int inf = 2147483647;

int main (){
    int N;cin>>N;
    vector<string> S(N);
    map<string,int> m{};
    rep(i,0,N){
        cin >> S[i];
        m[S[i]]=1;
    }
    cout << m.size() << endl;
    return 0;
}

Measured memory_bytes: 25080
import java.util.*;public class Main {public static void main(String[] args) {Scanner yomi = new Scanner(System.in);int[] suuzi = new int[2];for (int i=0;i<2;i++){suuzi[i]=yomi.nextInt();}if (suuzi[0]<10 && suuzi[1]<10){System.out.println(suuzi[0]*suuzi[1]);}else System.out.println(-1);}}

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

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

int main() {
    int N,M;
    ll r=0;
    cin >> N >> M;
    vector<ll> x(N),y(N),z(N);
    vector<vector<ll>> s(8, vector<ll>(N,0));

    rep(i,N)
        cin >> x.at(i) >> y.at(i) >> z.at(i);

    rep(i,8) {
        ll t=0;
        rep(j,N) {
            if(i & 1)
                s.at(i).at(j) += x.at(j);
            else
                s.at(i).at(j) -= x.at(j);
            if(i & 2)
                s.at(i).at(j) += y.at(j);
            else
                s.at(i).at(j) -= y.at(j);
            if(i & 4)
                s.at(i).at(j) += z.at(j);
            else
                s.at(i).at(j) -= z.at(j);
        }
        sort(s.at(i).begin(), s.at(i).end(), greater<ll>());
        rep(j,M)
            t += s.at(i).at(j);
        r = max(r,t);
    }

    cout << r << endl;
}

Measured memory_bytes: 384
/*
 * @Author: Patchouli_
 * @Date: 2020-02-09 20:10:41
 * @Last Modified by: Patchouli_
 * @Last Modified time: 2020-02-09 20:13:44
 */
#include <bits/stdc++.h>
#define int long long
using namespace std;

inline int read(){
    int ret=0,pos=1;char c=getchar();
    while(!isdigit(c) && c!='-' )c=getchar();
    if(c=='-')	pos=-1,c=getchar();
    while(isdigit(c))ret=(ret<<3)+(ret<<1)+c-48,c=getchar();
    return pos*ret;
}
string s1,s2;
int a,b;
string d;
signed main(){
	cin>>s1>>s2;
	a=read(),b=read();cin>>d;
	if(d==s1) a--;
	if(d==s2) b--;
	printf("%lld %lld",a,b);
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

# A - Cookie Exchanges
def is_even(a, b, c):
	cookies = [a, b, c]
	return all(c % 2 == 0 for c in cookies)


a, b, c = map(int, input().split())

for i in range(1000):
	if is_even(a, b, c):
		new_a = b//2 + c//2
		new_b = a//2 + c//2
		new_c = a//2 + b//2
		a, b, c = new_a, new_b, new_c
	else:
		print(i)
		exit()

print(-1)

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

int main(){
    int n;
    cin >> n;
    int a[100000];
    int p = 0, m = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i] < 0) m++;
        if(a[i] > 0) p++;
    }
    sort(a, a+n);

    if(n == 2){
        cout << a[1] - a[0] << endl;
        cout << a[1] << " " << a[0] << endl;
    }else if(p <= 1){
        int64_t sum = 0;
        for(int i=0;i<n-1;i++) sum -= a[i];
        sum += a[n-1];
        cout << sum << endl;
        int64_t curr = a[n-1] - a[0];
        cout << a[n-1] << " " << a[0] << endl;
        for(int i=1;i<n-1;i++){
            cout << curr << " " << a[i] << endl;
            curr -= a[i];
        }
    }else if(m <= 1){
        int64_t sum = -a[0];
        for(int i=1;i<n;i++) sum += a[i];
        cout << sum << endl;
        int64_t curr = a[0] - a[n-1];
        cout << a[0] << " " << a[n-1] << endl;
        for(int i=1;i<n-2;i++){
            cout << curr << " " << a[i] << endl;
            curr -= a[i];
        }
        cout << a[n-2] << " " << curr << endl;
    }else{
        int64_t sum = 0;
        for(int i=0;i<n;i++) sum += abs(a[i]);
        cout << sum << endl;
        int curr = a[n-2] - a[1];
        cout << a[n-2] << " " << a[1] << endl;

        int i;
        for(i=2;i<n;i++){
            if(a[i] > 0) break;
            cout << curr << " " << a[i] << endl;
            curr -= a[i];
        }

        cout << a[0] << " " << curr << endl;
        curr = a[0] - curr;

        for(;i<n-2;i++){
            cout << curr << " " << a[i] << endl;
            curr -= a[i];
        }
        cout << a[n-1] << " " << curr << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2304
n = int(input())
ab = []

for tsumugi in range(n):
  in1, in2 = map(int, input().split(" "))
  temp = [in1, in2]
  ab.append(temp)
  
ab.sort(key = lambda x : x[1])

a_sum = 0
ans = "Yes"

for matsuri in range(n):
  a_sum += ab[matsuri][0]
  if a_sum > ab[matsuri][1]:
    ans = "No"
    break

print(ans)

Measured memory_bytes: 38132
# https://atcoder.jp/contests/abc172/tasks/abc172_a
def c172(x):
    x = int(x)
    return x + x**2 + x**3

def c171(x):
    if str.isupper(x): return 'A'
    else: return 'a'

def c170(x):
    x = x.split()
    return x.index('0') + 1


    
if __name__=="__main__":
    input = input()
    print(c170(input))


Measured memory_bytes: 8996
#include<stdio.h>

int main(void){
  int a,x,min,max;
  long long int sum=0;
  scanf("%d%d",&a,&x);
  sum=min=max=x;
  while(--a>0){
    scanf("%d",&x);
    sum+=x;
    if(x>max){
      max=x;
    }
    if(x<min){
      min=x;
    }
  }
  printf("%d %d %lld\n",min,max,sum);
return 0;
}



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

int main(){
  int N;
  cin >> N;
  vector <int> A(N);
  Rep(i,N){
    cin >> A.at(i);
  }
  int GCD = A.at(0); //素直に今までのすべてについてGDC取ったもの//
  int if_r_GCD = A.at(1); //i番目で除去権を行使した瞬間のGCD//
  int b_r_GCD = A.at(1); //除去権を行使した後での最大のGCD//
  
  for (int i = 1; i< N ; i++){
	b_r_GCD = max ( __gcd( b_r_GCD , A.at(i) ) , __gcd( if_r_GCD , A.at(i) ) );
    if_r_GCD = GCD;
    GCD = __gcd( GCD , A.at(i) );
  }
  
  cout << max( if_r_GCD , b_r_GCD);
}
     
    
  

Measured memory_bytes: 640
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;


const unsigned long long B=1e12+7;


int main(){
    string s,t;
    cin>>s>>t;
    if(SZ(t)-SZ(s)==1){
        bool flag=true;
        REP(i,SZ(s))if(s[i]!=t[i])flag=false;
        if(flag){
            cout<<"Yes"<<endl;return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

int solve(int i,vector<int> a){
  if(i == 1) return 1;
  
  else if(i > 1){
    int Fac = 1;
    for(int k = 1; k < i; k++) Fac *= k;
    
    int pl  = (a.at(0)-1)*Fac;
    int f = a.at(0);
    reverse(a.begin(),a.end());
    a.pop_back();
    reverse(a.begin(),a.end());
    
    for(int j = 0; j<a.size() ; j++){
    	if(a.at(j) > f) a.at(j) --;
    }
    
  	return  pl + solve(i - 1,a);
  }

}
 
int main() {
  	int N;
	cin >> N;
  
  	vector<int> p(N);
    vector<int> q(N);
  
  	for(int i = 0; i < N; i++) cin >> p.at(i);
    for(int i = 0; i < N; i++) cin >> q.at(i);
  	
	int a = solve(N,p);
	int b =	solve(N,q);
  
  cout << max(a-b,b-a) << endl;
}


Measured memory_bytes: 256
import Control.Monad
main :: IO ()
main = do
    n <- readLn :: IO Int
    xu <- replicateM n $ (\[x,u] -> (read x :: Double, u)) . words <$> getLine
    print . sum $ map (\(x,u) -> if u == "JPY" then x else x * 380000.0) xu


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


def inpl():
    return list(map(int, input().split()))


def gcd(a, b):
    # greatest common divisor
    while b > 0:
        a, b = b, a % b

    return a


K = int(input())


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

dif3 *= 6

dif2 = 0
for a in range(1, K + 1):
    for c in range(1, K + 1):
        if a == c:
            continue
        dif2 += gcd(a, c)
dif2 *= 3

dif1 = K * (K + 1) // 2

ans = dif1 + dif2 + dif3
print(ans)


Measured memory_bytes: 9228
N = int(input())
height = list(map(int, input().split()))
dai = 0
maxh = height[0]
for i in range(N-1):
  if height[i] <= height[i+1]:
    maxh = height[i+1]
  elif height[i] > height[i+1]:
    dai += height[i] - height[i+1]
    height[i+1] = height[i]
print(dai)

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

using namespace std;
mt19937_64 rng(58);

int rep[200001];
int rnk[200001];

int ds_find(int x) {
    if (rep[x] != x) {
        rep[x] = ds_find(rep[x]);
    }
    return rep[x];
}

void ds_union(int x, int y) {
    int xp = ds_find(x);
    int yp = ds_find(y);
    if (xp == yp) return;
    if (rnk[xp] < rnk[yp]) {
        rep[xp] = yp;
    } else if (rnk[xp] > rnk[yp]) {
        rep[yp] = xp;
    } else {
        rep[yp] = xp;
        rnk[xp]++;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    for (int i=0; i<n; i++) rep[i] = i;
    for (int j=0; j<m; j++) {
        int a, b;
        cin >> a >> b;
        ds_union(a-1, b-1);
    }
    int ans = 1;
    map<int, int> count;
    for (int i=0; i<n; i++) {
        int r = ds_find(i);
        count[r]++;
        ans = max(ans, count[r]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 13712
#include <iostream>

using namespace std;

string s;
int a[27];

int main() {
	cin >> s;
	for(int i = 0; i < s.length(); i++)
		a[s[i] - 'a']++;
	for(int i = 0; i < 27; i++)
		if (a[i] % 2) {
			cout << "No";
			return 0;
		}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define pi pair<ll,ll>
#define __   ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define mod 1000000007

ll Set(ll N,ll pos){ return N=N | (1<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1<<pos)); }


ll ar[]={0,0,1,-1};
ll br[]={1,-1,0,0};

string s,s1,s2;
ll n,m;
ll arr[500000];
ll brr[500000];
vector<ll>v,v1;

map<ll,ll>mp;
ll vis[500005];
int main()
{__
        ll i,j,a,b,c,d,e,f,g,x,y,z,t,k,l;

        ll ans=0;

        cin>>s;

        for(i=0;i<s.size();i++){
            cout<<'x';
        }
        cout<<endl;
}





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

bool is_prime(int n){
  for(int i=2; i*i<=n; i++){
    if(n % i == 0) return false;
  }
  return true;
}

int main(){
  int N, K;
  vector<int> V(55);

  cin >> N >> K;
  for(int i=1; i<=N; i++) cin >> V[i];

  // L[i]：V[1]~V[i]の和 R[i]:V[i]~V[N]の和
  vector<int> L(55, 0), R(55, 0);
  for(int i=1; i<=N; i++){
    L[i] = L[i-1] + V[i];
    R[N-i+1] = R[N-i+2] + V[N-i+1];
  }

  int ans = 0;
  for(int i=0; i<=min(N,K); i++){ //左からi個 右からj個取り出す 
    for(int j=0; i+j<=min(N,K); j++){
      int sum = L[i] + R[N-j+1];

      vector<int> Vmin;
      if(i == 0 && j == 0) Vmin.push_back(0);
      for(int k=1; k<=i; k++) Vmin.push_back(V[k]);
      for(int k=1; k<=j; k++) Vmin.push_back(V[N-k+1]);
      sort(Vmin.begin(), Vmin.end());
    
      for(int k=0; k<min(K-(i+j), (int)Vmin.size()); k++){
        if(Vmin[k] < 0) sum -= Vmin[k];
      }
    
      ans = max(sum, ans);
    }
  } 

  cout << ans << endl;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[][] graph = new int[n][n];
		int[] keys = new int[n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				graph[i][j] = in.nextInt();
			}
			keys[i] = 2001;
		}
		keys[0] = 0;
		TreeSet<Integer> spanSet = new TreeSet<Integer>();
		int u = 0;
		while (spanSet.size() < n) {
			u = minKey(keys, spanSet);
			for (int i = 0; i < n; i++) {
				if (graph[u][i] != -1 && keys[i] > graph[u][i] && !spanSet.contains(i)) {
					keys[i] = graph[u][i];
				}
			}
			spanSet.add(u);
		}
		int span = 0;
		for (int i = 0; i < n; i++) {
			span += keys[i];
		}
		System.out.println(span);
		in.close();
	}
	public static int minKey(int[] keys, TreeSet<Integer> spanSet) {
		int spot = 0;
		int value = 2001;
		for (int i = 0; i < keys.length; i++) {
			if (keys[i] < value && !spanSet.contains(i)) {
				spot = i;
				value = keys[i];
			}
		}
		return spot;
	}
}



Measured memory_bytes: 41264
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;


int main(void)
{
	//変数の宣言
	int a,b;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;



	//データの読み込み


	scanf("%d %d",&a,&b);
//	scanf_s("%d %d",&a,&b);

//	scanf("%s",&s);
//	scanf_s("%s",&s,5);


/*	for(i=0;i<m;i++){
//		scanf("%d %d %d",&x,&y,&z);
		scanf_s("%d %d %d",&x,&y,&z);
	}

	for(i=1;i<=n;i++){
		come[i]=-1;
	}*/

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	if(6<=a && a<=12){
		b=b/2;
	}else if(a<=5){
		b=0;
	}

	//	printf("計算部分終了\n");

	//出力

	printf("%d",b);


	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,a=1,b=10000000000;
    cin>>N;
  
  vector<long long> v(N);
  for(long long i=0;i<N;i++){
    cin>>v.at(i);
  }
  for(long long i=0;i<N;i++){
    if(v.at(i)>=a){
      a=v.at(i);
    }
  }
  for(long long i=0;i<N;i++){
    if(v.at(i)<=b){
      b=v.at(i);
    }
  }
  cout<<a-b<<endl;
}
    

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {

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

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

void Main() {
  int a;
  string s;
  cin >> a;
  cin >> s;
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;
}

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

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  
  int h[100],w[100],i,j,k,l;
  
  for(i=0;;i++){
    
    scanf("%d %d",&h[i],&w[i]);    
    
    if(h[i]==0&&w[i]==0)break;
    
  }
  
  for(j=0;j<i;j++){
    
    for(k=1;k<=h[j];k++){
      
      for(l=1;l<=w[j];l++){
	
	if((k+l)%2==0)printf("#");
	else printf(".");
	
      }
      
      printf("\n");
	
	}
  
    printf("\n");
      
      }
  
  return 0;  
  
}

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

int n, k;
double p[200010];

int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
		p[i] = p[i] * (p[i] + 1) / 2 / p[i];
	}

	double ans = 0.0, tmp = 0.0;
	for (int i = 0; i < n; ++i) {
		tmp += p[i];
		if (i - k + 1 >= 0) {
			ans = max(ans, tmp);
			tmp -= p[i - k + 1];
		}
	}

	cout << fixed << setprecision(10) << ans;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define YYDBG 

int inputs[50];
int N;
int main(void) {
    int i,j,k;
    int result = -1;

    memset(inputs, 0, sizeof(inputs));

    scanf("%d\n", &N);
    for(i=0;i<N;i++) { 
        scanf("%d ", &(inputs[i]));
    }

    int flag= 0;
    int tmp = -1;
    for(i=1;i<N;i++) {
        if (inputs[i-1] > inputs[i]) {
            if (flag == 0) {
                flag = 1;
                tmp = inputs[i-1];
                inputs[i-1] = inputs[tmp-1];
                inputs[tmp-1] = tmp;
                i = 0;
            } else {
                break;
            }
        }
    }


    if (i==N) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}



Measured memory_bytes: 128
#include <cctype>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <ostream>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#define ll long long
#define PI 3.1415926
using namespace std;
const int maxn=4e4+10;
int main() {
	int n;
	cin>>n;
	printf("%.3f\n",n*2*PI);
	return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

int binary_search(vector<int> S, vector<int> T){
  // S???sort??????
  int cnt = 0;

  for(int i=0;i<T.size();i++){
    int left=0;
    int right=S.size();
    int mid = (left + right)/2;
    while(left < right){
      mid = (left + right)/2;
      // cout << "left, right" << left << ", " << right << endl;
      if(S[mid] == T[i])
	{
	  cnt++;
	  break;
	}

      
      if(S[mid] < T[i]){
	left = mid+1;
		
      }else{
	right = mid;
      }      
    }
    // cout << "i: " << i << endl;
  }
  return cnt;
}


int main(){
  int n,q;
  vector<int> S;
  vector<int> T;

  cin >> n;
  for(int i=0;i<n;i++){
    int tmp;    
    cin >> tmp;
    S.push_back(tmp);
  }

  cin >> q;
  for(int i=0;i<q;i++){
    int tmp;
    cin >> tmp;
    T.push_back(tmp);
  }

  // sort
  // sort(S.begin(), S.end());
  

  int res = binary_search(S, T);
  cout << res << endl;
}
  

Measured memory_bytes: 2332
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> s,c;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
    vector<int> a(n,-1);
    for(int i=0;i<m;i++){
        int temp,temp1;
        cin>>temp>>temp1;
        s.push_back(temp-1);
        c.push_back(temp1);
        temp--;
        if(a[temp]==-1){
            a[temp]=temp1;
        }
        else{
            if(a[temp]!=temp1)return cout<<-1<<"\n",0;
        }
    }
    if(n==1){
        for(int i=0;i<=9;i++){
            int temp=i;
            for(int j=n-1;j>=0;j--){
                if(temp%10!=a[j]&&a[j]!=-1)break;
                if(j==0)return cout<<i<<"\n",0;
                temp/=10;
            }
        }
    }
    else if(n==2){
        for(int i=10;i<=99;i++){
            int temp=i;
            for(int j=n-1;j>=0;j--){
                if(temp%10!=a[j]&&a[j]!=-1)break;
                if(j==0)return cout<<i<<"\n",0;
                temp/=10;
            }
        }
    }
    else{
        for(int i=100;i<=999;i++){
            int temp=i;
            for(int j=n-1;j>=0;j--){
                if(temp%10!=a[j]&&a[j]!=-1)break;
                if(j==0)return cout<<i<<"\n",0;
                temp/=10;
            }
        } 
    }
    cout<<-1<<"\n";
}


Measured memory_bytes: 256
ABC = list(map(int,input().split()))
j = 0
if ABC[0] == ABC[1] == ABC[2]:
  if ABC[0]%2 == 0:
    print(-1)
    exit()
for i in range(3):
  if ABC[i]%2 == 1:
    print(0)
    exit()
while True:
  new = [0]*3
  for i in range(3):
    new[i] = ABC[(i+1)%3]/2+ABC[(i+2)%3]/2
    if new[i]%2 == 1:
      print(j+1)
      exit()
  j += 1
  ABC = new

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long h = sc.nextLong();
		long cnt = 0;
		while (h > 0) {
			h /= 2;
			cnt++;
		}
		
		long ans = (long) Math.pow(2, cnt) - 1;
		System.out.println(ans);
	}
}


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

typedef long long ll;

vector<pair<ll,ll>> g[100100];
int ans[100100];

void solve(int u,int c,int pa=-1){
    ans[u]=c;
    for(auto e:g[u]){
        int v=e.first;
        //cout << v << endl;
        ll dist=e.second;
        if(v==pa) continue;
        if(dist%2==0){
            solve(v,c,u);
        }else{
            solve(v,1-c,u);
        }
    }
}

int main(){
    int N; cin >> N;
    for(int i=0;i<N-1;i++){
        int u,v,w; cin >> u >> v >> w;
        u--;v--;
        g[u].push_back({v,w});
        g[v].push_back({u,w});
    }
    solve(0,0);
    for(int i=0;i<N;i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
int main()
{
         int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
         int n;
         cin>>n;
         cout<<a[n-1];
         return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
using namespace std;
typedef long long ll;
inline int read(){
	int n=0,f=1;char c;
	for(c=getchar();c!='-'&&(c<'0'||c>'9');c=getchar());
	if (c=='-') f=-1,c=getchar();
	for(;c>='0'&&c<='9';c=getchar()) n=(n<<3)+(n<<1)+(c&15);
	return n*f;
}
const int maxn=2e5+5;
int i,j,k,s,n,len,a[maxn];
map<int,int>p;
map<int,int>::iterator it;
int main(){
	n=read();
	fo(i,1,n) a[i]=read();
	int l=1,r=n;
	for(;l<r;){
		int m=(l+r)>>1;
		p.clear();
		len=0;
		for(i=1;i<=n;i++){
			int x=a[i];
			if (x>len){len=x;continue;}
			for(;;){
				it=p.end();
				if (it!=p.begin()) it--;else break;
				if (it->first>x) p.erase(it);else break;
			}
			if (m==1) break;
			p[x]++,len=x;
			for(;x&&p[x]==m;) p.erase(p.find(x)),p[--x]++;
			if (x<=0) break;
		}if (i>n) r=m;else l=m+1;
	}printf("%d\n",l);
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;
void add(long long& a, const long long& b, const int& mod) {
  a = (a + b) % mod;
}
int main() {
  int n, t, x;
  const int mod(1000000007);
  long long ans(0);
   cin >> n >> t;
  long long dp[2][256][101] = {};
  dp[0][0][0] = 1;
  for (int i = 0; i < n; ++i) {
      cin >> x;
      for (int j = 0; j < 256; ++j) {
        for (int k = 0; k <= i; ++k) {
          add(dp[(i+1)%2][j][k], dp[i % 2][j][k], mod);
          if (dp[i%2][j][k])
            add(dp[(i+1)%2][j^x][k+1], dp[i % 2][j][k], mod);
          dp[i%2][j][k] = 0;
        }
      }
  }
  long long f(1);
  for (int i = 1; i <= n; ++i) {
    f = (f * i) % mod;
    add(ans, dp[n % 2][t][i] * f, mod);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 640
N = int(input())
H = [int(i) for i in input().split()]

pre_wall = H[N-1]
for i in reversed(H[:N-2]):
    if i <= pre_wall:
        pre_wall = i
    elif i == pre_wall +1:
        pre_wall = i-1
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	cin>>t;
	map <string,ll> mp;
	while(t--){
		string s;
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<"\n";
	cout<<"WA x "<<mp["WA"]<<"\n";
	cout<<"TLE x "<<mp["TLE"]<<"\n";
	cout<<"RE x "<<mp["RE"]<<"\n";
}

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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ac, ad, bc, bd, m;
  ac = a*c;
  ad = a*d;
  bc = b*c;
  bd = b*d;
  m = ac;
  m = max(m, ad);
  m = max(m, bc);
  m = max(m, bd);
  cout << m << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

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

int main(void){
    // char ;
    ll h,w,ans=0;
    scanf("%lld%lld",&h,&w);
    ll a[h][w],odd=0;
    rep(i,0,h){
        rep(j,0,w){
            scanf("%lld",&a[i][j]);
            if(a[i][j]%2) odd++; 
        }
    }
    ll ansx[250000][4];
    rep(i,0,h){
        rep(j,0,w){
            if(a[i][j]%2){
                if( j+1<w ){
                    a[i][j+1]++;
                    a[i][j]--;
                    ansx[ans][0]=i+1;
                    ansx[ans][1]=j+1;
                    ansx[ans][2]=i+1;
                    ansx[ans][3]=j+2;
                    ans++;
                }else if( i+1<h ){
                    a[i+1][j]++;
                    a[i][j]--;
                    ansx[ans][0]=i+1;
                    ansx[ans][1]=j+1;
                    ansx[ans][2]=i+2;
                    ansx[ans][3]=j+1;
                    ans++;
                }
            }
        }
    }

    
    
    printf("%lld\n",ans);
    rep(i,0,ans){
        printf("%lld %lld %lld %lld\n",ansx[i][0],ansx[i][1],ansx[i][2],ansx[i][3]);
    }
    return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair
int dp[114514],m[114514];

int main() {
	int n, k,s[114514] = {};
	REPO(i, 114513) dp[i] = INF;
	cin >> n >> k;
	REP(i, n) cin >> s[i];
	REP(i, n) {
		REPO(j, k) {
			dp[i + j] = min(dp[i + j], dp[i] + max(s[i], s[i + j]) - min(s[i], s[i + j]));
		}
	}
	cout << dp[n - 1] << endl;
}

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

using namespace std;


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

ll dp[100005];

#define mp make_pair
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define swap(a,b) {a=a^b;b=a^b;a=a^b;}
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
/*
	freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
*/
    int t=1;
    ll N;

    //cin >> t;
    while(t-->0){
    	  dp[0]=0;
    	  cin>>N;
    	  ll h[N];
    	  for(int i=0;i<N;i++){
    	  	cin>>h[i];
    	  }

    	  dp[1]= abs(h[1]-h[0]);

    	  for(int i=2;i<N;i++){
    	  	dp[i]=min(abs(h[i]-h[i-1]) + dp[i-1],abs(h[i]-h[i-2])+ dp[i-2]);
    	  }

    	  cout<<dp[N-1];
    	
    }
	return 0;
}

Measured memory_bytes: 1792
// ABC159B - String Palindrome

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

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

	string T;
	bool answer = true;

	if (S.size() %2 == 0) {
		answer = false;
		cout << "No" << endl;
		return 0;
	}

	T = S;
	reverse(T.begin(), T.end());
	if (S != T) {
		answer = false;
		cout << "No" << endl;
		return 0;
	}

	T = S.substr(0, S.size()/ 2);
//	cout << T << endl;
	reverse(T.begin(), T.end());
//	cout << T << endl;
	if (S.substr(0, S.size()/ 2) != T) {
		answer = false;
		cout << "No" << endl;
		return 0;
	}

	T = S.substr((S.size() + 1)/ 2, S.size()/ 2);
//	cout << T << endl;
	reverse(T.begin(), T.end());
//	cout << T << endl;
	if (S.substr((S.size() + 1)/ 2, S.size()/ 2) != T) {
		answer = false;
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
	int m;
	int smoney,year,n;
	int ht,tesu;
	int emoney;	

	double ratio;

	int max;

	cin>>m;

	for(int i1=0;i1<m;i1++){
		cin>>smoney;
		cin>>year;
		cin>>n;

		max=0;

		for(int i2=0;i2<n;i2++){
			cin>>ht>>ratio>>tesu;

			if (ht==0){
				int sum=0;
				emoney=smoney;
				for(int i3=0;i3<year;i3++){
					sum+=(emoney*ratio);
					emoney-=tesu;
				}
				emoney+=sum;
			}
			else {
				emoney=smoney;
				for(int i3=0;i3<year;i3++){
					emoney+=(emoney*ratio-tesu);
				}

			}

			if(max<emoney){
				max=emoney;
			}
		}

		cout<<max<<endl;

	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef complex <double> cp;
#define debug(a) cout<<#a<<":"<<a<<endl;
#define fr freopen("in.txt","r",stdin);
#define for0(i,a,b) for (int i=a;(i<b);i++)
#define for1(i,a,b) for (int i=a;(i<=b);i++)
#define dec0(i,a,b) for (int i=a;(i>b);i--)
#define dec1(i,a,b) for (int i=a;(i>=b);i--)
#define Fill(x,a) memset(x,a,sizeof(x))
#define cpy(a,b) memcpy(a,b,sizeof(a))
const double PI = acos(-1);
const int INF=0x3f3f3f3f;
const int N=1e6+7;
const int mod=1e9+7;
int maxn,minn;
int T,n,m,q;

int main(){
	ll a,b,n;
	cin>>a>>b>>n;
	ll ans=(a*min(n,(b-1)))/b; 
	ans=max(ans,((a*n)/b)-(a*(n/b)));
	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 3724
import itertools
N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))

l=[i for i in range(1,N+1)]
for n,t in enumerate(itertools.permutations(l,N)):
    if(t==P):
        a=n
    if(t==Q):
        b=n

print(abs(a-b))




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

int main(){
    string s;
    ll k;
    cin>>s>>k;
    int n = s.size();
    if(s == string(n,s[0])){
        cout << n*k/2 <<endl;
        return 0;
    }
    int a1=0,a2=0;
    for(int i=1;i<n;i++){
        if(s[i]==s[i-1]){
            a1++;
            i++;
        }
    }
    s=s+s;
    for(int i=1;i<2*n;i++){
        if(s[i]==s[i-1]){
            a2++;
            i++;
        }
    }
    cout << a1 + (a2-a1)*(k-1) << endl;
    return 0;
}



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

using namespace std;

int main()
{
    long long int h, ans = 0, c = 0;
    cin>>h;
    while(h)
    {
        h /= 2;
        c++;
    }
    for(int i = 0; i < c; i++)
        ans = ans + pow((double)2, i);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<queue>
using namespace std;
const int INF=0x3f3f3f3f;
char a[1000][1000];
int n,m;
int main()
{
    int n,l;
    while(scanf("%d%d",&n,&l)!=EOF)
    {
        for(int i=1;i<=n;i++)
            scanf("%s",a[i]);
        for(int i=1;i<=n;i++)
        {
            for(int j=i+1;j<=n;j++)
            {
                if(strcmp(a[i],a[j])>0)
                {
                    char s[1000];
                    strcpy(s,a[i]);
                    strcpy(a[i],a[j]);
                    strcpy(a[j],s);
                }
            }
        }
        for(int i=1;i<=n;i++)
        {
            printf("%s",a[i]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		Map<String, Integer> map=new HashMap<String, Integer>();
		int n=in.nextInt();
		long sum=0;
		for(int i=0;i<n;i++){
			String data=in.next();
			char[] charArray = data.toCharArray();
			Arrays.sort(charArray);
			if(map.get(new String(charArray))!=null){
				sum+=map.get(new String(charArray));
				map.put(new String(charArray), map.get(new String(charArray))+1);
			}else{
				map.put(new String(charArray), 1);
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 61912
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

typedef long long LL;
const int INF = 100000000;

using namespace std;
int main()
{
#ifdef LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    long long N;
    cin >> N;

    float sum = 0;
    for(int i=0;i<N;i++){
        long long tenpA;
        cin >> tenpA;
        sum += 1.0f/tenpA;
    }

    cout << (float)1/sum << endl;

    return 0;
}

Measured memory_bytes: 256
num = gets.to_i
line1 = gets.split.map(&:to_i)
line2 = gets.split.map(&:to_i)
ans = 0
num.times do |i|
	if line1[i] > line2[i] or line1[1] == line2[i]
		ans += line2[i]
	else
		ans += line1[i]
		line2[i] -= line1[i]
		if line2[i] < line1[i+1] or line2[i] == line1[i+1]
			ans += line2[i]
			line1[i+1] -= line2[i]
		else
			ans += line1[i+1]
			line1[i+1] = 0
		end
	end
end

p ans

Measured memory_bytes: 15396
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

typedef long long lint;
int main(){
    int x;
    cin >> x;
    int sum = 0;
    sum += (x / 500) * 1000;
    x = x - ((x / 500) * 500);
    sum += (x / 5) * 5;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;

typedef long long ll;

int main(int argc, char **argv)
{
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}


Measured memory_bytes: 256