akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#include <iostream>
#include <functional>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

using namespace std;

int main(int argc, char** argv) {
  int n;
  vector<int> p;
  vector<int> q;
  
  cin >> n;
  
  for (int i = 0; i < n; ++i) {
	int x;
    cin >> x;
    p.push_back(x);
  }
  
  for (int i = 0; i < n; ++i) {
	int x;
    cin >> x;
    q.push_back(x);
  }

  vector<int> x, y;  // x < y
  if (p > q) {
    x = q;
    y = p;
  } else {
    x = p;
    y = q;
  }

  int count = 0;
  while (x != y) {
    next_permutation(x.begin(), x.end());
    ++count;
  }
  
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
S = input()
a = []
count = 0

for i in range(0, len(S)):
    a.append(S[i])

if len(S) % 2 == 0:
    for k in range(0, len(S)):
        if k % 2 == 0:
            if S[k] == "h":
                if S[k+1] == "i":
                    count += 1
                else:
                    print("No")
                    sys.exit()
            else:
                print("No")
                sys.exit()
        else:
            pass
else:
    print("No")

if count > 0:
    print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]&&s[0]=='R') cout<<3;
    else if((s[0]==s[1]||s[1]==s[2])&&s[1]=='R') cout<<2;
    else if(s[0]==s[1]&&s[1]==s[2]&&s[0]=='S') cout<<0;
    else cout<<1;
}

Measured memory_bytes: 3592
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
class UnionFind {
public:
    vector<int> par, rank;
    int cnt;

    UnionFind(int n) : cnt(n) {
        par = vector<int>(n);
        iota(par.begin(), par.end(), 0);
        rank = vector<int>(n, 0);
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = root(par[x]);
        }
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
        cnt--;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

signed main() {
    int N, M;
    cin >> N >> M;
    int scores[N];
    for (int i = 0; i < N; i++) cin >> scores[i];

    UnionFind uf = UnionFind(N);

    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }

    map<int, vector<int>> forest_scores;
    for (int i = 0; i < N; i++) {
        forest_scores[uf.root(i)].push_back(scores[i]);
    }

    auto forest_num = (int) forest_scores.size();
    if (2 * (forest_num - 1) > N) {
        cout << "Impossible" << endl;
        return 0;
    } else if (forest_num == 1) {
        cout << 0 << endl;
        return 0;
    }

    for (auto it = forest_scores.begin(); it != forest_scores.end(); it++) {
        sort(it->second.begin(), it->second.end());
    }

    int ret = 0;
    vector<int> remain;
    for (auto it = forest_scores.begin(); it != forest_scores.end(); it++) {
        vector<int> v = it->second;
        ret += v[0];
        for (int i = 1; i < v.size(); i++) {
            remain.push_back(v[i]);
        }
    }

    sort(remain.begin(), remain.end());
    for (int i = 0; i < forest_num - 2; i++) ret += remain[i];

    cout << ret << endl;

    return 0;
}

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

int main()
{
    int x;
    scanf("%d", &x);
    if(x >= 30)
    printf("Yes");
    else
    printf("No");
return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define mem0(x) memset(x, 0, sizeof(x))
#define asort(x) sort(x.begin(), x.end());
#define dsort(x, t) sort(x.begin(), a.end(), greater<t>());
#define mp make_pair
#define pb push_back

int main(){
    int S, W;
    cin >> S >> W;
    if(S <= W) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    return 0;
}

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

int main(){
   int N;
   cin >> N;
   int A[N+2];
   for(int i = 1;i < N+1;i++){
       cin >> A[i];
   }
   A[0] = 0;
   A[N+1] = 0;
   int sum = 0;
   for(int i = 1;i < N+2;i++){
       sum += abs(A[i] - A[i-1]);
   }
   for(int i = 1;i < N+1;i++){
       int ans = sum;
       ans = ans - (abs(A[i]-A[i-1]) + abs(A[i+1]-A[i])) + abs(A[i-1]-A[i+1]);
       cout << ans << endl;
   }
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a == 1) a = 14;
  if (b == 1) b = 14;
  if (a > b) cout << "Alice" << endl;
  else if (a == b) cout << "Draw" << endl;
  else cout << "Bob" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
int a[114514];
signed main(){
	int n;
	cin>>n;
	int iti=0;
	int si=0;
	int ni=0;
	rep(i,n){
		cin>>a[i];
		if(a[i]%2==1)iti++;
		else if(a[i]%4==0)si++;
		else ni++;
	}
	if(ni==0&&iti<=si+1)cout<<"Yes"<<endl;
	else if(iti<=si)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1e9 + 7;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int s;
    cin >> s;
    vector<int> dp(2020);
    dp[0] = 1;
    for (int i = 3; i <= s; i++)
        dp[i] = (dp[i - 1] + dp[i - 3]) % MOD;
    cout << dp[s] << "\n";
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
int main() {
    int n;
    cin >> n;
    auto S = vector<string>(0);
    rep(i, n) {
        string s;
        cin >>s;
        sort(ALL(s));
        S.push_back(s);
    }
    sort(ALL(S));
    auto prev = ""s;
    auto current = 0LL;
    auto ans = 0LL;
    for (auto s : S) {
        if(s==prev) {
            ans += current;
        } else {
            current = 0LL;
        }
        current++;
        prev = s;
    }
    PUTS(ans);
}

Measured memory_bytes: 5748
n = gets.to_i
a=gets.chomp.split.map(&:to_i)
c = 0
if n%2 == 0
  n = n/2 -1
else
  n = n/2
end
for i in 0..n do
  if a[i*2]==0
    next
  elsif a[i*2]%2==1
    c += 1
  end
end
puts c

Measured memory_bytes: 14236
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;

#define LL long long
#define DB double
#define MAXN 1000000
#define MOD 998244353
#define Pr pair<int,int>
#define X first
#define Y second
#define INF 1000000000000000000
#define mem(x,v) memset(x,v,sizeof(x))

LL read(){
	LL x=0,F=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*F;
}

int n,x;
LL ans,val[MAXN+5];
int a[MAXN+5];

int main(){
	n=read(),x=read(),ans=INF;
	for(int i=0;i<n;i++)a[i]=read();
	for(int i=0;i<n;i++){
		int mval=a[i];
		for(int j=0;j<n;j++){
			mval=min(mval,a[(i-j+n)%n]);
			val[j]+=mval;
		}
	}
	for(int i=0;i<n;i++)
	ans=min(ans,val[i]+1LL*i*x);
	printf("%lld\n",ans);
}

Measured memory_bytes: 3720
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    int temp;
    if(a<b){
        temp=b;
        b=a;
        a=temp;
    }
    while(1){
        temp=a%b;
        if(temp==0){
            printf("%d\n",b);
            return 0;
        }
        a=b;
        b=temp;
    }
    return 0;
}


Measured memory_bytes: 2136
N = int(input())
A = list(map(int,input().split()))
B=[]
for i in A:
    if i % 2 == 0:
        B.append(i)

for j in B:
    if j % 3 !=0 and j % 5 != 0:
        print("DENIED")
        exit()
print("APPROVED")
        


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)



int main() {
	int n, m;
	cin >> n >> m;
	vector<int>in(n);
	vector<int>e[101010];
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		e[x].pb(y);
		in[y]++;
	}

	queue<pair<int,int>>q;
	for (int i = 0; i < n; i++)if (!in[i])q.push({i,0});

	int len = -1;
	while (q.size()) {
		auto p = q.front();
		len = max(len, p.second);
		q.pop();
		fore(x, e[p.first]) {
			in[x]--;
			if (!in[x])q.push({ x,p.second+1 });
		}
	}
	puts(len);
	

	return 0;
}

Measured memory_bytes: 6144
#include <stdio.h>

int main()
{
  int n, a, b, train, taxi;
  scanf("%d %d %d", &n, &a, &b);

  train = n * a;
  taxi = b;

  if (train > taxi)
  {
    printf("%d", taxi);
  }
  else
  {
    printf("%d", train);
  }

  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(int argc, string *argv[]){
  int A, B, C;
  cin >> A >> B >> C;

  if(A == B && B == C && C == A){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
/**
 * 境界部分には気をつける(そこだけ別で処理するというのもあり)
 * 逆再生することで簡単になることもある
 */
public class Main {
	public int cnt = 0;
	public static final BigDecimal TWO = new BigDecimal(2);
	public static final BigDecimal THREE = new BigDecimal(3);

    public Main() {
    }

    public static void main(String[] args ) {
            Main main = new Main();
            main.exec();
    }

    public void exec() {
        BufferedReader bf = null;
        try{
            bf = new BufferedReader(new InputStreamReader(System.in));
            exec_body(bf);
        } catch (IOException e) {
            e.printStackTrace();
        }
        finally{
            if( bf != null ) {
                try {
                    bf.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public int[] toList( String str ) {
        String[] elements = str.split(" ");
        int[] ret = new int [elements.length];
        for( int i = 0; i < elements.length; i++ ) {
            ret[i] = Integer.valueOf(elements[i]);
        }

        return ret;
    }

    public void print( int[] ary ) {
    		if( ary == null || ary.length == 0 ) {
    			return;
    		}

    		StringBuilder bd = new StringBuilder();
    		for( int i = 0; i < ary.length; i++ ) {
    			if( i != 0 ) {
    				bd.append(" ");
    			}
    			bd.append(ary[i]);
    		}

    		System.out.println(bd.toString());
    }

    public void merge( int[] ary, int left, int right, int middle ) {
    		int[] leftAry = new int[middle-left+1+1];
    		for( int ii = 0; ii < leftAry.length-1; ii++ ) {
    			leftAry[ii] = ary[ii+left];
    		}
    		leftAry[leftAry.length-1] = Integer.MAX_VALUE;

    		int[] rightAry = new int[right-middle+1];
    		for( int ii = 0; ii < rightAry.length-1; ii++ ) {
    			rightAry[ii] = ary[ii+middle+1];
    		}
    		rightAry[rightAry.length -1]  = Integer.MAX_VALUE;

    		int curLeft = 0;
    		int curRight = 0;
    		for( int ii = left; ii <= right; ii++ ) {
    			cnt++;
    			int curLeftVal = leftAry[curLeft];
    			int curRightVal = rightAry[curRight];
    			if( curLeftVal <= curRightVal ) {
    				ary[ii] = curLeftVal;
    				curLeft++;
    			} else {
    				ary[ii] = curRightVal;
    				curRight++;
    			}
    		}
    }

    public void mergeSort( int[] ary, int left, int right ) {
    		// ここで終了
    		if( left >= right ) {
    			return;
    		}

    		int medium = (right + left)/2;
    		mergeSort(ary,left,medium);
    		mergeSort(ary,medium+1,right);
    		merge(ary,left,right,medium);
    }

    public void exec_body( BufferedReader bf ) throws IOException {
    		bf.readLine();
    		int[] ary = toList(bf.readLine());
    		mergeSort(ary,0,ary.length-1);
    		print(ary);
    		System.out.println(cnt);
    }
}


Measured memory_bytes: 155500
#include<bits/stdc++.h>
#define Abra_Ka_Dabra ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

const long long mod = 1e8 + 7;
const double PI = acos(-1);
const double EPS = 1e-9;


int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	Abra_Ka_Dabra

	string x, y;
	cin >> x >> y;
	int ans = INT_MAX;
	for (int i = 0; i < x.size() - y.size() + 1; i ++) {
		int tmp = 0;
		for (int j = 0, k = i; j < y.size(); j++, k++) {
			if (x[k] != y[j]) tmp++;
		}
		ans = min(ans, tmp);
	}
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 3604
import java.util.Scanner;

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

		int i , j , h , w , n;
		h = scan.nextInt();
		w = scan.nextInt();
		n = scan.nextInt();
		int x = 1 , y = 1;
		boolean right = true;
		for (i = 0;i < n;i ++) {
			int value = scan.nextInt();
			for (j = 0;j < value;j ++) {
				colors[x][y] = i + 1;
				if (right) {
					if (y + 1 <= w) {
						y ++;
					} else {
						x ++;
						right = false;
					}
				} else {
					if (y - 1 >= 1) {
						y --;
					} else {
						x ++;
						right = true;
					}
				}
			}	
		}
		for (i = 1;i <= h;i ++) {
			StringBuilder builder = new StringBuilder();
			for (j = 1;j <= w;j ++) {
				if (j > 1) {
					builder.append(" ");
				}
				builder.append(colors[i][j]);
			}
			System.out.println(builder.toString());
		}
		
	}
	
	
}



















Measured memory_bytes: 30532
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    char c;
    while (cin >> c) {
        if (c >= 'A' && c <= 'Z') cout << "A" << endl;
        else cout << "a" << endl;
    }
}

















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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var agbn = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = agbn[3];
        var agb = agbn.Take(3).OrderByDescending(x => x).ToArray();
        var a = agb[0];
        var g = agb[1];
        var b = agb[2];

        var k = 0;
        var m = 0;
        for (int i = 0; m <= n; i++)
        {
            var ai = a * i;
            m = ai;
            for (int j = 0; m <= n; j++)
            {
                m = ai + g * j;
                if ((n - m) % b != 0 || m > n)
                {
                    continue;
                }

                k++;
            }
            m = ai;
        }
        Console.WriteLine(k);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;


int main()
{
	float R;
	const double PI=3.14159265358979323846;

	cin >> R;

	cout << fixed << setprecision(10) << 2 * PI * R; 
	
	cin >> R;

	return 0;
	
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define F first
#define S second
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
 
int main() {
    ll  n,p,k;
    cin>>n;
    vl h(n),dp(n,0);
    for(int i=0;i<n;i++) cin>>h[i];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1]+abs(h[i] -h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
p = list(map(int, input().split()))
cnt = 0

for i in range(1, n-1):
    if (p[i - 1] < p[i]) and (p[i] < p[i + 1]):
        cnt += 1
    elif (p[i - 1] > p[i]) and (p[i] > p[i + 1]):
        cnt += 1

print(cnt)


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

int main()
{
   string s;
   cin>>s;
   int* a = new int[26]();
   for(int i=0;i<s.length();i++)
   {
       a[s[i] -'a' ] ++;
   }
   char  ans = '1';
   for(int i=0;i<26;i++)
   {
       if( a[i] ==0 )
       {
           ans = i+'a';
           break;
       }
   }
   if( ans == '1' )
   {
       cout<<"None";
   }
   else
   {
       cout<<ans;
   }
}


Measured memory_bytes: 3724
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)
//Map<String, Integer> map = new HashMap<String, Integer>(n);
//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")

public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	//static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	static int Y,N;
	public static void main(String[] args) {
	int N=sc.nextInt();
	String S=sc.next();
	int ctn=0;
	for(int i=0;i+2<N;i++) {
	//	p(i);
		if(S.charAt(i)==65&&S.charAt(i+1)==66&&S.charAt(i+2)==67) {
			ctn++;
		}
	}
	System.out.println(ctn);
 }
}


Measured memory_bytes: 22868
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int ball = scanner.nextInt();
        final int people = scanner.nextInt();

        if(people == 1){
            System.out.println(0);
            return;
        }

        System.out.println(ball - people);
    }
}


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

int main(){
	string s;cin >> s;
  	int a,b,c,d;
  	a=s[0]-'0';b=s[1]-'0';
  	c=s[2]-'0';d=s[3]-'0';
  	string op="+-";
  	int sum=a;
  	for(int i=0;i<2;i++){
    	for(int j=0;j<2;j++){
        	for(int k=0;k<2;k++){
              	sum=a;
            	if(i==0){sum+=b;}
              	else{sum-=b;}
              	if(j==0){sum+=c;}
              	else {sum-=c;}
              	if(k==0){sum+=d;}
              	else {sum-=d;}
              	if(sum==7){
                	cout << a << op[i] << b << op[j] << c << op[k] << d << "=7";
                  	return 0;
                }
            }
        }
    }
  	return 0;
}

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

using namespace std;

int lsb(int a){
    for(int i=0;;i++){
        if(a&(1<<i)) return i;
    }
    return -1;
}

int main(){
    int N;
    while(cin >> N){
        unsigned int whole = 0;
        vector<int> cnt(31, 0);
        for(int i=0;i<N;i++){
            int a; cin >> a;
            whole ^= a;
            cnt[lsb(a)]++;
        }
        int res = 0;
        for(int i=30;i>=0;i--){
            if(whole&(1UL<<i)){
                if(cnt[i]){
                    ++res;
                    whole ^= (1UL << (i+1)) - 1;
                }
            }
        }
        cout << (whole ? -1 : res) << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, m, i, j, a, b;
    int c = 0;

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

    int A[n][m];
    int B[m];
    int C[m];

    for (j = 0; j < n; j++)
    {
        for (i = 0; i < m; i++)
        {
            scanf("%d", &a);
            A[j][i] = a;
        }
    }
    for (i = 0; i < m; i++)
    {
        scanf("%d", &b);
        B[i] = b;
    }
    for (j = 0; j < n; j++)
    {
        for (i = 0; i < m; i++)
        {
            C[i] = A[j][i] * B[i];
            c += C[i];
        }
        printf("%d\n", c);
        c = 0;
    }
    return 0;
}


Measured memory_bytes: 2740
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int x;cin>>x;
  int ans=1;
  for(int i=2;i<=int(sqrt(x));i++){
    int b=2;
    while(true){
      if(pow(i, b)>x)break;
      ans=max(ans, (int)pow(i, b));
      b++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
from random import *
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
X=[0]*26
XX=[0]*26
P=[]
Y,Z=0,0
V,W=0,0
T,U=0,0
for i in range(D):
  for j in range(26):
    X[j]+=C[j]
    XX[j]+=X[j]
  Y,Z=-1,-10**20
  V,W=Y,Z
  T,U=V,W
  for j in range(26):
    if Y==-1:
      Y,Z=0,X[0]+S[i][0]
      continue
    if Z<X[j]+S[i][j]:
      T,U=V,W
      V,W=Y,Z
      Y,Z=j,X[j]+S[i][j]
    elif W<X[j]+S[i][j]:
      T,U=V,W
      V,W=j,X[j]+S[i][j]
    elif U<X[j]+S[i][j]:
      T,U=j,X[j]+S[i][j]
  XX[Y]-=X[Y]
  X[Y]=0
  P.append([Y,V,T])
  if randrange(0,50)==0:
    P[i][1]=randrange(0,26)
  if randrange(0,5)==0:
    P[i][2]=randrange(0,26)
  P[i]=tuple(P[i])
SCORE=0
X=[0]*26
for i in range(D):
  SCORE+=S[i][P[i][0]]
  for j in range(26):
    X[j]+=C[j]
  X[P[i][0]]=0
  SCORE-=sum(X)
SCORE2=0
YY=[]
for i in range(D):
  for k in range(2):
    d,q=i,P[i][k+1]
    SCORE2=SCORE
    YY=XX[:]
    SCORE2-=S[d][P[d][0]]
    SCORE2+=S[d][q]
    for j in range(26):
      X[j]=0
    YY[P[d][0]],YY[q]=0,0
    for j in range(D):
      if j==d:
        Z=q
      else:
        Z=P[j][0]
      X[P[d][0]]+=C[P[d][0]]
      X[q]+=C[q]
      X[Z]=0
      YY[P[d][0]]+=X[P[d][0]]
      YY[q]+=X[q]
    if SCORE2-sum(YY)>SCORE-sum(XX):
      z=[P[i][k+1]]
      for l in range(3):
        if l!=k:
          z.append(P[i][l])
      P[i]=tuple(z)
      XX=YY[:]
      SCORE=SCORE2
for i in range(D):
  print(P[i][0]+1)

Measured memory_bytes: 85148
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        int[] num = {1, 2, 3};
        num[A-1] = 0;
        num[B-1] = 0;

        int max = num[0];
        for (int i = 0; i < num.length; i++) {
            if (max < num[i])
                max = num[i];
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 35516
W=[]
K=[]
i = 1
while i<=10:
    wi = int(input())
    W.append(wi)
    i += 1

m = 1
while m <= 10:
    km = int(input())
    K.append(km)
    m += 1

W3 = sorted(W, reverse=True)
a = W3[:3]
K3 = sorted(K, reverse =True)
b = K3[:3]

print(sum(a), sum(b))


Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
#include <stack>
using namespace std;
int a, b;
int main() {
    cin >> a >> b;
    for(int i=1; i<=999; ++i){
        if((i+2)*(i+1)-i*(i+1) == 2*(b-a)){
            cout << i*(i+1)/2-a << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;

int n, l[50];
int sum[51];
bool ok[51];

bool check(int H, int h) { // max H - min H - h
  for (int i = 1; i <= n; i++) ok[i] = false;
  ok[0] = true;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < i; j++) {
      int len = sum[i] - sum[j];
      if (i == n && j == 0) continue;
      if (ok[j] && H - h <= len && len <= H) {
        ok[i] = true;
        break;
      }
    }
  }
  return ok[n];
}

int search(int H) {
  int lb = 0, ub = 5000;
  while (lb + 1 < ub) {
    int md = (lb + ub) / 2;
    if (check(H, md)) ub = md;
    else lb = md;
  }
  if (check(H, lb)) return lb;
  return ub;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &l[i]);
  sum[0] = 0;
  for (int i = 0; i < n; i++) sum[i + 1] = sum[i] + l[i];
  int ans = 500000;
  for (int i = 0; i < 50000; i++) ans = min(ans, search(i));
  printf("%d\n", ans);
}



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

int main(){
	int a, b, c;

	cin >> a;
	cin >> b;
	cin >> c;

	if(a < b){
		if(b < c){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N;
    cin>>N;
    map<ll,ll> m;
    rep(i,N){
        ll a;
        cin>>a;
        m[a-1]++;
        m[a]++;
        m[a+1]++;
    }
    ll MAX=-1*INF;
    for(auto p:m){
        ll A=p.second;
        chmax(MAX,A);
    }
    cout<<MAX<<endl;
}


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

int main()
{
  typedef long long ll;
  ll N;
  cin >> N;
  if (0 != N%2)
    cout << 0;
  else
  {
    N -= N%10;
    ll den = 10;
    ll cnt = 0;
    for (; 0 != N/den; den *= 5)
      cnt += N/den;
    cout << cnt;
  }
  return 0;
}


Measured memory_bytes: 256
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime> 
using namespace std;

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

const int MX = 200005;
int H, W;
int A[MX], B[MX];
map<int, int> mp;
multiset<int> st;

int main(){
   // freopen("in.txt", "r", stdin);
    cin>>H>>W;
    for(int i=0; i<H; i++){
        cin>>A[i]>>B[i];
        A[i]--;
        B[i]--;
    }

	for(int i=0; i<W; i++){
		mp[i] = 0;
		st.insert(0);
	}

	for(int i=0; i<H; i++){
		while(!mp.empty()){
			auto it = mp.lower_bound(A[i]) ;
			if(it == mp.end() || it->first > B[i]) break;
			int v = it->second, k = it->first;
			if(B[i] + 1 < W){
				int b = B[i] + 1;
				int vv = b - k + v;
				if(mp.find(b) == mp.end()){
					mp[b] = vv;
					st.insert(vv);
				}else{
					int v0 = mp[b];
					if(v0 > vv){
						st.erase(st.find(v0));
						mp[b] = vv;
						st.insert(vv);
					}
				}
			}
			mp.erase(k);
			st.erase(st.find(v));
		}

		if(st.empty()){
			cout<<-1<<endl;

		}else{
			cout<<(*st.begin() + i + 1)<<endl;
		}
	}
   
}

Measured memory_bytes: 23896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 5000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<int> v(n),c(n);
    rep(i,n)cin>>v.at(i);
    rep(i,n)cin>>c.at(i);
    int ans=0;
    rep(i,n){
        if(v.at(i)>=c.at(i)){
            ans+=v.at(i)-c.at(i);
        }
    }
    cout<<ans<<endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> b(n);
    b = a;
    sort(b.begin(), b.end());
    int m1 = b[n - 1];
    int m2 = b[n - 2];
    rep(i, n) {
        if(a[i] == m1) cout << m2 << endl;
        else cout << m1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

void transpose(vector<vector<char>> &b)
{
    if (b.size() == 0)
        return;

    vector<vector<char>> trans_vec(b[0].size(), vector<char>());

    for (int i = 0; i < b.size(); i++)
    {
        for (int j = 0; j < b[i].size(); j++)
        {
            trans_vec[j].push_back(b[i][j]);
        }
    }

    b = trans_vec; // <--- reassign here
}
int main()
{

    ll wa = 0, target, n, sa = INF;

    cin >> n;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    target = accumulate(all(a), 0LL);
    rep(i, n)
    {
        wa += a[i];
        sa = min(sa, abs(wa * 2 - target));
    }

    cout << sa << endl;
    return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int main()
{
	int n, d, a, x, h;
	cin >> n >> d >> a;
	vector<pair<int, int>> e(n);
	rep(i, 0, n) {
		cin >> x >> h;
		e[i] = {x, h};
	}
	sort(all(e));
	vector<int> damage(n);
	int k;
	ll ans = 0;;
	rep(i, 0, n) {
		if(i)damage[i] += damage[i - 1];
		if (e[i].second - damage[i] > 0) {
			auto it = upper_bound(all(e), make_pair(e[i].first + 2 * d, INF));
			k = (e[i].second - damage[i] - 1) / a + 1;
			damage[i] += a * k;
			if(it != e.end())damage[it - e.begin()] -= a * k;
			ans += k;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5556
int main(){
	int n,i;
	scanf("%d",&n);
	int a[n];
	for (i=0;i<n;i++)
		scanf("%d",&a[i]);
	for (i=n-1;i>-1;i--){
		printf("%d",a[i]);
		printf(i!=0 ? " ":"\n");
	}
	return 0;	
}

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

void vprint(vector<ll> A){
    if(A.size()==0){
        p("");
    }else{
        cout << A[0];
        FOR(i, 1, A.size()){
            cout << " " << A[i];
        }
        cout << endl;
    }
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A[i];
    }

    ll Q;
    cin >> Q;
    
    while(Q--){
        ll b, e;
        cin >> b >> e;
        reverse(A.begin()+b, A.begin()+e);
    }

    vprint(A);
    
    return 0;
}


Measured memory_bytes: 3224
# -*- coding: utf-8 -*-
x = int(input())

if x<=6:
    print(1)
    exit()
if x<=11:
    print(2)
    exit()

r = x%11
ret = x//11
if r==0:
    print(2*ret)
elif r<=6:
    print(2*ret+1)
elif r<=11:
    print(2*ret+2)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;


void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> a(n);
	rep(i,n){
		int s;
		cin >> s;
		a[i] = make_pair(s, i + 1);
	}
	sort(all(a));
	rep(i,n){
		cout << a[i].second << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1664
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 100005
#define M 200005
#define LL long long
#define ULL unsigned long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mid + 1, r
#define VI vector<int>
#define db double
#define PII pair<int, int>
#define PLL pair<unsigned long long, unsigned long long>
#define MP make_pair
#define PB push_back
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
int n, a[N];
bool ok1(LL x){
    FF(i, 1, n){
        x = x - x % a[i];
    }
    if(x < 2) return 0;
    return 1;
}
bool ok2(LL x){
    FF(i, 1, n){
        x = x - x % a[i];
    }
    if(x <= 2) return 1;
    return 0;
}
int main(){
//    IN;
    SC(n);
    FF(i, 1, n) SC(a[i]);
    LL down, up;
    LL l = 1, r = 9000000000000000000;
    while(l <= r){
        LL mid = l + (r - l) / 2;
        if(ok1(mid)) r = mid - 1;
        else l = mid + 1;
    }
    down = l;
    l = 1, r = 9000000000000000000;
    while(l <= r){
        LL mid = l + (r - l) / 2;
        if(ok2(mid)) l = mid + 1;
        else r = mid - 1;
    }
    up = r;
    if(up < down) puts("-1");
    else printf("%lld %lld\n", down, up);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<double, double> pd;
typedef pair<ll, ll> pl;

int dp[100001];
int memory[100001]; //0 rock, 1 scissor, 2 paper
int scores[3];

int win(char c)
{
  if (c == 'r')
    return 2;
  else if (c == 's')
    return 0;
  else
    return 1;
}

int draw(char c)
{
  if (c == 'r')
    return 0;
  else if (c == 's')
    return 1;
  else 
    return 2;
 
}

int main()
{
  int n, k;
  char t[100005];
  
  scanf("%d %d %d %d %d", &n, &k, &scores[0], &scores[1], &scores[2]);
  
  scanf("%s", t);
  
  memory[0] = win(t[0]);
  dp[0] = scores[memory[0]];
  
  for(int i = 1; i < n; i++)
  {
    memory[i] = win(t[i]);
    if(i < k)
      dp[i] = dp[i-1] + scores[memory[i]];
    else
    {
      if (memory[i] == memory[i-k])
      {
        dp[i] = dp[i-1];
        memory[i] = -1;
      }
      else
        dp[i] = dp[i-1] + scores[memory[i]];
    }
    
    //printf("%daa%d\n", i, dp[i]);
  }
  
  printf("%d\n", dp[n-1]);
  
  return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int m,n,x,sum=0;
    cin >> n >> m;
    while(m--)
    {
        cin >> x;
        sum+=x;
    }
    if(sum > n)cout << "-1";
    else cout << n-sum;
    return 0;
}


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

int x=0;
string a,b;
char i;



int main(){
    cin>>a>>b;
    for(i=0;i<=a.length()-1;i++){
        if(a[i]!=b[i]){
            x=x+1;
        }
    }
    if(x>=1){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void) {
	int a[3]={0}, i, n;
		for (i = 1; i <= 10; i++){
			scanf("%d",&n);
			if (a[0] < n){
				a[2] = a[1];
				a[1] = a[0];
				a[0] = n;
			}
			else if (a[1] < n){
				a[2] = a[1];
				a[1] = n;
			}
			else if (a[2] < n){
				a[2] = n;
			}
		}
	printf("%d\n%d\n%d\n", a[0], a[1], a[2]);
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
    int n,d;
    cin>>n>>d;
    int arr[n][d];
    for(int i=0;i<n;i++)
        for(int j=0;j<d;j++)
            cin>>arr[i][j];
    int sqr{},counter{};
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            sqr = 0;

            for(int k = 0;k<d;k++)
                sqr += (arr[i][k] - arr[j][k])*(arr[i][k] - arr[j][k]);
            if(floor(sqrt(sqr)) == ceil(sqrt(sqr)))
                counter++;
        }

    }
    cout<<counter;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x,y;
  cin >> n >> x >> y;
  
  map<int,long long> ans;
  int a,b,c=0;
  
  int i=1;
  
  while(i<=n-1){
    int j=i+1;
    while(j<=n){
      a=abs(y-j)+abs(x-i)+1;
      b=j-i;
      ans[min(a,b)]++;
      j++;
    }
    i++;
  } 
  int k=1; 
  while(k<=n-1){
    cout << ans[k] <<endl;
    k++;
  }
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int m=800, p =200 , n , t , f , r ;
    cin >> n ;
    r = n/15 ;
    t = n*m ;
    f = t-(200*r) ;
    if (n>15)
    cout << f ;
    else
    cout << t ;


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <functional>
#include <cmath>

constexpr long long MOD = 1000000007;

int a[200000];
int b[200000];
long long t[200000];

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	int an = 0;
	int bn = 0;
	int zeros = 0;
	for (int i = 0; i < n; ++i)
	{
		int c;
		scanf("%d", &c);
		if (c == 0)
		{
			zeros += 1;
		}
		else if (c > 0)
		{
			a[an++] = c;
		}
		else
		{
			b[bn++] = c;
		}
	}

	if (std::min(bn / 2 * 2, k / 2 * 2) + an >= k)
	{
		std::sort(a, a + an, std::greater<int>());
		std::sort(b, b + bn);

		long long ans = k % 2 == 0 ? 1 : (long long)a[0];

		int tn = 0;
		for (int i = k % 2; i < an; i += 2)
		{
			t[tn++] = (long long)a[i] * (long long)a[i + 1];
		}
		for (int i = 0; i < bn; i += 2)
		{
			t[tn++] = (long long)b[i] * (long long)b[i + 1];
		}
		std::sort(t, t + tn, std::greater<long long>());
		for (int i = 0; i < k / 2; ++i)
		{
			ans = ans * (t[i] % MOD) % MOD;
		}
		printf("%lld\n", ans);
	}
	else if (zeros > 0)
	{
		puts("0");
	}
	else
	{
		int tn = 0;
		for (int i = 0; i < an; i += 1)
		{
			t[tn++] = (long long)a[i];
		}
		for (int i = 0; i < bn; i += 1)
		{
			t[tn++] = (long long)(-b[i]);
		}
		std::sort(t, t + tn);
		long long ans = 1;
		for (int i = 0; i < k; ++i)
		{
			ans = ans * (t[i] % MOD) % MOD;
		}
		printf("%lld\n", (MOD - ans) % MOD);

	}
	return 0;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, number, count=0;
	cin >> n;

	vector<int> d(n);
	for(int i=0;i<n;i++) cin >> d.at(i);
	sort(d.begin(), d.end());
	d.erase(unique(d.begin(), d.end()), d.end());

	cout << d.size() << endl;	
}

Measured memory_bytes: 256
def main():
    H, N = map(int, input().split())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    dp = [float('inf')] * (H + max(A) + 5)
    dp[0] = 0
    for i in range(N):
        for j in range(H):
            dp[j + A[i]] = min(dp[j] + B[i], dp[j + A[i]])

    ans = float('inf')
    for i in range(H, H + max(A) + 1):
        ans = min(ans, dp[i])

    print(ans)


    
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 45148
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>

using namespace std;

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

int main()
{
  int N;
  cin >> N;
  vector<string> S(N);
  vector<string> T;
  for (int i = 0; i < N; i++)
  {
    cin >> S[i];
    T.push_back(S[i]);
  }
  sort(T.begin(), T.end());
  reverse(T.begin(), T.end());
  int ans = 1;
  for (int i = 1; i < T.size(); i++)
  {
    if (T[i] != T[i - 1])
    {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 17880
from time import time
from random import randint

def func(s, x):
    last = [0] * 26
    score = 0
    for i, v in enumerate(x, 1):
        last[v] = i
        score += s[i * 26 + v] - sum(c * (i - l) for c, l in zip(s, last))
    return score

def main():
    start = time()
    d, *s = map(int, open(0).read().split())
    x = ([*range(26)] * 15)[:d]
    M = func(s, x)
    while time() - start < 1.8:
        y = x[:]
        if randint(0, 1):
            y[randint(0, d - 1)] = randint(0, 25)
        elif randint(0, 1):
            i=randint(0, d - 16)
            j=randint(i + 1, i + 15)
            y[i], y[j] = y[j], y[i]
        else:
            i = randint(0, d - 15)
            j = randint(i + 1, i + 7)
            k = randint(j + 1, j + 7)
            if randint(0, 1):
                y[i], y[j], y[k] = y[j], y[k], y[i]
            else:
                y[i], y[j], y[k] = y[k], y[i], y[j]
        t = func(s, y)
        if t > M:
            M = t
            x = y
    for t in x:
        print(t + 1)

main()

Measured memory_bytes: 97204