akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using p  = pair<ll, ll>;

ll dp[51][51][51 * 51];

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, A;
    cin >> N >> A;
    
    vector<ll> cards(N);
    for (auto&& c : cards) {
        cin >> c;
    }
    
    for (ll j = 0; j <= N; j++) {
        ll c = cards[j - 1];
        for (ll k = 0; k <= j; k++) {
            for (ll s = 0; s <= N * 50; s++) {
                if (j == 0 && k == 0 && s == 0) {
                    dp[j][k][s] = 1;
                } else if (1 <= j && s < c) {
                    dp[j][k][s] = dp[j - 1][k][s];
                } else if (1 <= j && 1 <= k && c <= s){
                    dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - c];
                } else {
                    dp[j][k][s] = 0;
                }
            }
        }
    }
    
    ll ans = 0;
    for (ll k = 1; k <= N; k++) {
        ans += dp[N][k][k * A];
    }
    
    cout << ans << endl;
    
    return 0;
}



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

int main(){
   int n; cin>>n;
   vector<int> a(n);
   rep(i,n) cin>>a[i];
   int pre=-999;
   rep(i,n){
      if(pre<=a[i]-1) pre=a[i]-1;
      else if(pre<=a[i]) pre=a[i];
      else{
         puts("No");
         return 0;
      }
   }
   puts("Yes");
   return 0;
}

   


Measured memory_bytes: 640
import sys

n,a,b,c,d = map(int,input().split())
s = list(input())

a = a-1
b = b-1
c = c-1
d = d-1

s[a] = "A"
s[b] = "B"


if c < d:
    while s[c] != "A" or s[d] != "B":
        if s[d] != "B":
            if s[b+1] == ".":
                s[b+1] = "B"
                s[b] = "."
                b += 1
                continue
            elif s[b+2] == ".":
                s[b+2] = "B"
                s[b] = "."
                b += 2
                continue
        if s[c] != "A":
            if s[a+1] == ".":
                s[a+1] = "A"
                s[a] = "."
                a += 1
                continue
            elif s[a+2] == ".":
                s[a+2] = "A"
                s[a] = "."
                a += 2
                continue
        print("No")
        sys.exit()
if d < c:
    while s[c] != "A" or s[d] != "B":
        if s[c] != "A":
            if s[a+1] == ".":
                s[a+1] = "A"
                s[a] = "."
                a += 1
                continue
            elif s[a+2] == ".":
                s[a+2] = "A"
                s[a] = "."
                a += 2
                continue
        if s[d] != "B":
            if s[b+1] == ".":
                s[b+1] = "B"
                s[b] = "."
                b += 1
                continue
            elif s[b+2] == ".":
                s[b+2] = "B"
                s[b] = "."
                b += 2
                continue
        print("No")
        sys.exit()

print("Yes")


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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    string O, E;
    cin >> O >> E;
    for (int i = 0; i < min(O.size(), E.size()); i++)
        cout << O[i] << E[i];
    if (O.size() > E.size())
        cout << O[O.size() - 1];
    if (O.size() < E.size())
        cout << E[E.size() - 1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);
int main(){
    ll n,w;
    cin>>n>>w;
    ll W[n], v[n];
    loop(i,0,n){
        cin>>W[i]>>v[i];
    }
    ll cache0[w+1] = {0};
    ll cache1[w+1] = {0};
    loop(i,1,n+1){
        loop(j,1,w+1){
            if(W[i-1] > j){
                continue;
            }
            cache1[j] = max(cache1[j],(max(cache0[j], cache0[j-W[i-1]] + v[i-1])));
        }
        loop(j,0,w+1){
            cache0[j] = cache1[j];
        }
        // loop(j,0,w+1){
        //     cout<<cache1[j]<< " ";
        // }
        // cout<<"\n";
    }
    cout<<cache1[w]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
    int zahyou[200], ninzuu, roop, kaisai, tairyoku, min;
    min = 0;

    scanf("%d", &ninzuu);
    for(roop = 1; roop <= ninzuu; roop++)
        scanf("%d", &zahyou[roop]);

    for(roop = 1; roop <= ninzuu; roop++) {
            tairyoku += ((zahyou[roop] - 1)*(zahyou[roop] - 1));
        }
        min = tairyoku;

    for(kaisai = 2; kaisai <= 100; kaisai++) {
        tairyoku = 0;
        for(roop = 1; roop <= ninzuu; roop++) {
            tairyoku += ((zahyou[roop] - kaisai)*(zahyou[roop] - kaisai));
        }
        if(min >= tairyoku)
            min = tairyoku;
    }

    printf("%d", min);
    return 0;
}

Measured memory_bytes: 128
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = input()
if s[2] == s[3] and s[4] == s[5]:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 65552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int n,m;
    cin >> n >> m;
    if(n==m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(void){
  string s[3];
  cin>>s[0]>>s[1]>>s[2];
  int p[3]={},q=0;
  while(p[q]!=s[q].size()){
    p[q]++;
    q=s[q][p[q]-1]-'a';
  }
  cout<<(char)('A'+q)<<endl;
}

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

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 3;
const int MOD = 1e9 + 7;
const int N = 1e5 + 3;

int n, a[N], b[N], res;

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    fort(i, 1, n) cin >> a[i];
    ford(i, n, 1) {
        int len = upper_bound(b + 1, b + 1 + res, a[i]) - b;
        b[len] = a[i];
        res = max(res, len);
    }
    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 1024
import java.lang.Math.abs
import java.util.*
import kotlin.math.max
import kotlin.math.min

// solution is at the bottom

@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

const val _BUFFER_SIZE = 1 shl 16
@JvmField val _buffer = ByteArray(_BUFFER_SIZE)
@JvmField var _bufferPt = 0
@JvmField var _bytesRead = 0

tailrec fun readChar(): Char {
    if(_bufferPt == _bytesRead) {
        _bufferPt = 0
        _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)
    }
    return if(_bytesRead < 0) Char.MIN_VALUE
    else {
        val c = _buffer[_bufferPt++].toChar()
        if (c == '\r') readChar()
        else c
    }
}

fun readLine(): String? {
    var c = readChar()
    return if(c == Char.MIN_VALUE) null
    else buildString {
        while(true) {
            when(c) {
                '\n', Char.MIN_VALUE -> return@buildString
                else -> {
                    append(c)
                    c = readChar()
                }
            }
        }
    }
}
fun readLn() = readLine()!!

fun read() = buildString {
    var c = readChar()
    while(c <= ' ') {
        if(c == Char.MIN_VALUE) return@buildString
        c = readChar()
    }
    do {
        append(c)
        c = readChar()
    } while(c > ' ')
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }


fun main() {
    val (n, m) = readIntArray(2)
    val graph = Array(n) { mutableListOf<Int>()}

    for (i in 1..m) {
        var (a, b) = readIntArray(2)
        a--
        b--

        graph[a].add(b)
        graph[b].add(a)
    }

    val used = BooleanArray(n) {false}
    var count = 0

    fun dfs(v: Int) {
        val queue = mutableListOf<Int>()
        queue.add(v)
        var queueIdx = 0
        while (queueIdx < queue.size) {
            val v = queue[queueIdx++]
            used[v] = true
            for (to in graph[v]) {
                if (!used[to]) {
                    queue.add(to)
                }
            }
        }
    }

    for (i in 0 until n) {
        if (!used[i]) {
            count++
            dfs(i)
        }
    }

    println(count - 1)
}



Measured memory_bytes: 67648
#include<stdio.h>
#include<algorithm>
#include<string>
using namespace std;
char in[20];
int t[110];
string s[110];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%s%d",in,t+i);
		s[i]=in;
	}
	int bb=0;
	int bs=0;
	for(int i=0;i<a;i++){
		int at=0;
		while(at<s[i].size()){
			printf("? ");
			for(int j=0;j<s[i].size();j++){
				if(j<at)printf("_");
				else printf("%c",s[i][j]);
			}
			printf("\n");fflush(stdout);
			scanf("%s",in);
			bb++;
			if(in[0]==(s[i][at]|32)){
				at++;
				bs++;
			}else{
				if(t[i]==0){
					b--;break;
				}
				t[i]--;
			}
		}
		if(b==0){
			printf("! Game Over\n");return 0;
		}
	}
	printf("! Game Clear %.1f\n",(double)(bs*1000/bb)/10);
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<ll> a = vector<ll>(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	ll sum = a[n-1];
	int idx = n-2;
	bool b = false;
	for(int i = n-2; i > 0; i--){
		sum += a[idx];
		if(b){
			idx--;
		}
		b = !b;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define M 1000000007
#define all(v) (v).begin(),(v).end()
const int N = 3e5 + 5;
int main(){
	int n , a[110] , cnt = 0;
	cin >> n ;
	for (int i = 1; i <= n; ++i){
		cin >> a[i];
		if((a[i]&1) && (i&1)) ++cnt;
	}
	cout << cnt <<endl;
	
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main(){
  int N;
  cin>>N;
  ll A[N];
  FOR(i,0,N) cin >> A[i];
  ll ans = 0;
  ll sum = 0;
  FOR(i,0,N)
  {
    if(A[i]==0)
    {
      ans += sum / 2;
      sum = 0;
    }
    else
    {
      sum += A[i];
    }
  }
  ans += sum / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
import math
while 1:
    N = int(input())
    if N == 0:
        break

    PS = []
    for i in range(N):
        x, y = map(float, input().split(','))
        PS.append((int(x * 100000), int(y * 100000)))

    D2 = 100000**2
    ans = 0
    for i in range(101):
        py = i * 10000
        for j in range(101):
            px = j * 10000
            cnt = 0
            for x, y in PS:
                if (px - x) ** 2 + (py - y) ** 2 <= D2:
                    cnt += 1
            ans = max(ans, cnt)
    print(ans)


Measured memory_bytes: 5668
//
//  main.cpp
//  leetcode
//
//  Created by caokai on 2016/11/23.
//  Copyright © 2016年 caokai. All rights reserved.
//

#include <cstdlib>
#include <algorithm>
#include <list>
#include <string>
#include <vector>
#include <cstdio>
using namespace std;
int main(int argc, const char * argv[]) {
    vector<int> nums(3, 0);
    for (int i =0; i < 3; i++) {
        scanf("%d", &nums[i]);
    }
    sort(nums.begin(), nums.end());
    printf("%s\n", (nums[2] == nums[1] + nums[0])? "Yes": "No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main() {
    int N;
    cin >> N;
    int l[N];
    for (int i = 0;i< N;i++){
        cin >> l[i]; 
    }
    sort(l,l+N);
    int a = l[N-1];
    int b = 0;
    for (int i = 0;i < N-1;i++){
        b = b + l[i];
    }
    if (a < b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
def main():
  import sys
  input = sys.stdin.readline
  
  X, Y, Z, K = map(int,input().split())
  A = list(map(int,input().split()))
  B = list(map(int,input().split()))
  C = list(map(int,input().split()))
  A.sort(reverse = True)
  B.sort(reverse = True)
  C.sort(reverse = True)
  AB = [a+b for a in A for b in B]
  AB.sort(reverse = True)
  res = [c+ab for ab in AB[:min(K, len(AB))] for c in C]
  res.sort(reverse = True)
  for r in res[:K]:
    print(r)

if __name__ == "__main__":
  main()

Measured memory_bytes: 207180
#include <stdio.h>

int main(void)
{
    char s[4];
    int i, a, b, c;

    scanf("%s", s);

    a = b = c = 0;
    for (i=0; i<3; i++) {
        if (s[i]=='a')      a++;
        else if (s[i]=='b') b++;
        else if (s[i]=='c') c++;
    }

    if (a==1 && b==1 && c==1)   printf("Yes\n");
    else                        printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pqgreater(x) x, vector<x>, greater<x>
#define abs(x) (x>0?x:-x)
#define gc getchar//_unlocked
#define pc putchar//_unlocked
const ll mod=998244353;
int solve(); void precomp();

#define multitest 0
#define usecase 0
int main(){ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t=1;
	if(multitest) cin>>t;
	precomp();
	for(int tc=1; tc<=t; tc++){
		if(multitest && usecase)
			cout<<"Case #"<<tc<<": ";
		solve();
	}
}
void precomp(){	
	return;
}
int solve(){
	ll n; cin>>n; int ans=1e9+69;
	for(ll i=1ll; i*i<=n; i++){
		if(n%i==0){
			ll t=i, j=n/i;
			int cnt1=0, cnt2=0;
			for(; t>0; t/=10, cnt1++);
			for(; j>0; j/=10, cnt2++);
			ans=min(ans, max(cnt1, cnt2));
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include <queue>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
const ll MOD = 1000000007;

int N,M,K,a,b,ans=0,temp=0;
bool node[10][10]={0};
bool vis[10]={0};
int DFS(int p,bool *flag,int temp);
int main(){
    scanf("%d %d",&N,&M);
    EREP(i,M){
        scanf("%d %d",&a,&b);
        node[a][b]=node[b][a]=true;
    }
    vis[1]=vis[0]=true;
    printf("%d",DFS(1,vis,ans));
}

int DFS(int p,bool *flag,int temp){
    // cout<<p<<":"<<temp<<endl;
    int count=0;
    EREP(i,N){
        if(flag[i])count++;
// cout<<i<<":"<<count<<endl;
        if(count==N){
// cout<<"P="<<p<<" ans="<<ans<<" count "<<count<<endl;
            temp++;
            return temp;
        }
    }
    EREP(i,N){
//cout<<p<<" p:i "<<i<<" i:temp "<<temp<<endl;
        if(node[p][i]&&!flag[i]){
            flag[i]=true;
            temp=DFS(i,flag,temp);
            flag[i]=false;
        }
    }
    return temp;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
signed main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	f(i,s.size()){
		cout<<char((s[i]-'A'+n)%26+'A');
	}
	cout<<endl;
	return 0;
}


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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

int ans = INF;
ll N, tmp;

int calcDigit(ll A, ll B){
    if(A < B) swap(A, B);

    string res = to_string(A);

    return res.size();
}

void solve(){
    for(int k = 1; k <= sqrt(N); ++k){
        if(N % k != 0) continue;

        tmp = N / k;

        ans = min(ans, calcDigit(k, tmp));
        // cout <<  k << " " << tmp << " " <<  ans << endl;
    }

    cout << ans << endl;
}

int main(){
    cin >> N;

    solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
str s;
int main(){
  cin>>s;
  int ss=s.size();
  rep(i,ss-1){
    if(s[i]==s[i+1]){
      prin2(i+1,i+2);
      return 0;
    }
  }
  rep(i,ss-2){
    if(s[i]==s[i+2]){
      prin2(i+1,i+3);
      return 0;
    }
  }
  prin2(-1,-1);
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,m;
    
    int i,j;
    
    scanf("%d %d",&n,&m);
    
    int a[n][m];
    int b[m];
    int c[n];
    
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    
//    for(i=0;i<n;i++){
//        for(j=0;j<m;j++){
//            printf("%d ",a[i][j]);
//        }
//        printf("\n");
//    }
//
    
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
//    for(i=0;i<m;i++){
//        printf("%d\n",b[i]);
//    }
    
    for(i=0;i<n;i++){
        c[i]=0;
        for(j=0;j<m;j++){
//            printf("%d=%d+%d*%d\n",c[i],c[i],a[i][j],b[j]);
            c[i]=c[i]+a[i][j]*b[j];
        }
    }
    
    for(i=0;i<n;i++){
        printf("%d\n",c[i]);
    }
    
    return 0;
}


Measured memory_bytes: 2112
A, B, K = map(int, input().split())
if A == 0 and B == 0:
    A = 0
    B = 0
elif K > A:
    mod = K - A
    A = 0
    B -= mod
else:
    A -= K

if B < 0:
    B = 0
print(A, B)

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

vector<bool> primelist(pow(10,8),true);

//エラトステネスの篩版素数判定
void eratos(int size) {

	primelist[0] = primelist[1] = false;

	for (int i = 2;  i <= sqrt(size); i++) {
		if (primelist[i]) {
			int j = i + i;
			while (j <= size) {
				primelist[j] = false;
				j += i;
			}
		}
	}
}

bool isPrime(int x) {
	return primelist[x];
}




signed main() {
	ios::sync_with_stdio(true);
	int n,ans = 0;
	cin >> n;
	vector<int> x(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	std::vector<int>::iterator iter = std::max_element(x.begin(), x.end());
	size_t index = std::distance(x.begin(), iter);
	eratos(x[index]);

	for (int i = 0; i < n; i++) {
		if (isPrime(x[i])) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 14776
#include <iostream>

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

using namespace std;

int main(){
	int N;
	while(cin >> N, N){
		int ans=0;
		rep(i,N){
			if( i == 0 ) continue;
			int sum = 0;
			rep(j,N){
				sum += i+j;
				if( sum >= N ) break;
			}
			if( sum == N ) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
let () =
  ignore @@ read_int () ;
  let x = ref 0 in
  let ans = ref 0 in
  String.iter
    (fun c ->
       if c = 'I' then (
         incr x ;
         if !x > !ans then ans := !x )
       else decr x)
    (read_line ()) ;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 384
use proconio::input;

fn main() {
    input!(n: usize);
    fn dfs(n: usize) -> (usize, Vec<(usize, usize, usize)>) {
        if n == 1 {
            (1, vec![])
        } else {
            let mut ans = dfs(n / 2);
            ans.1.iter_mut().for_each(|(_, _, w)| *w *= 2);
            ans.0 += 1;
            ans.1.push((ans.0 - 2, ans.0 - 1, 0));
            ans.1.push((ans.0 - 2, ans.0 - 1, 1));
            if n % 2 == 1 {
                ans.1.push((0, ans.0 - 1, n - 1));
            }
            ans
        }
    }
    let (sz, ans) = dfs(n);
    println!("{} {}", sz, ans.len());
    for (u, v, w) in ans {
        println!("{} {} {}", u + 1, v + 1, w);
    }
}


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

int main() {
    long long int n,k;cin>>n>>k;
    long long int h[n+1];for(long long int i=0;i<n;i++)cin>>h[i];
    sort(h,h+n,greater<int>());
    long long int res=0;
    for(long long int i=k;i<n;i++)res+=h[i];
    cout<<res;
}

Measured memory_bytes: 1792
#include<iostream>
#include<set>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int main()
{
	set<int> cpp;
	int m, n, i, o;

	cin >> n;
	r(i, n)
	{
		cin >> o;
		cpp.insert(o);
	}

	cin >> m;
	r(i, m)
	{
		cin >> o;
		if (!cpp.count(o)) continue;
		else  cpp.erase(o);
	}

	set<int>::iterator iter = cpp.begin();
	for (; iter != cpp.end(); iter++)
		cout << *iter << endl;

	return 0;
}


Measured memory_bytes: 12476
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=999999999;

int main() {
   int64_t N;
   cin>>N;
   vector<int64_t>A(N);
   int64_t sum=0;
   for(int64_t i=0;i<N;i++){
       cin>>A[i];
       sum+=A[i];
   }
   int64_t left=0;int64_t ans=sum;
   for(int64_t i=0;i<N;i++){
   left+=A[i];int64_t right=sum-left;
   ans=min(abs(left-right),ans);
   }
   cout<<ans<<endl;
return 0;}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
    int card,len1,len2,ten1=0,ten2=0;
    cin >> card;

    for(int i=0;i<card;i++){
        string n1,n2;
        cin >> n1 >> n2;

        if(n1>n2){
            ten1+=3;
        }
        else if(n2>n1){
            ten2+=3;
        }
        else {
            ten1++;
            ten2++;
        }
    }

    cout << ten1 << " " <<  ten2 << endl;
    
    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<ll,ll>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

int main() {
  string s; cin>>s;
  cout<<s.substr(0,4)<<" "<<s.substr(4,8)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

int main(){
    std::string texts[] = {"dream", "dreamer", "erase", "eraser"};
    for(int i = 0; i < 4; i++){
        std::reverse(texts[i].begin(), texts[i].end());
    }
    std::string str;
    std::cin >> str;
    std::reverse(str.begin(), str.end());
    
    int answer = true;
    
    int w = 0;
    while(w < str.size()){
        answer = false;
        for(int i = 0; i < 4; i++){
            if(texts[i] == str.substr(w, texts[i].size())){
                answer = true;
                w += texts[i].size();
                break;
            }
        }
        if(!answer) break;
    }
    if(answer){
        std::cout << "YES";
    }else{
        std::cout << "NO";
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <string>

using namespace std;

int main(){
    int n;
    cin >> n;
    map<long long, int> mp;
    bool ok = true;
    for(int i=0; i<n; i++){
        long long a;
        cin >> a;
        mp[a]++;
        if(mp[a] != 1){
           ok = false;
           break;
        }
    }

    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 12800
#include<stdio.h>

int main(){
    int i=0;
    char s[19];

    scanf("%s", s);
  
    for(;i<19;i++){
      if(s[i] == ','){
        s[i] = ' ';
      }
    }

    printf("%s\n", s);

    return 0;
}

Measured memory_bytes: 1660
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA(My_College_Sucks)
*/
#include <bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define nl printf("\n")
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli, lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005

#define binary_search bs
#define lower_bound lb
#define upper_bound ub

lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli i,j,n,m;
    cin>>n>>m;
    char ch[2+n][2+m];
    rep(i,1,1+n)
    {
        rep(j,1,1+m)
        {
            cin>>ch[i][j];
        }
    }
    rep(i,0,2+n)
    {
        rep(j,0,2+m)
        {
            if(i==0 or j==0 or i==n+1 or j==m+1)
            {
                ch[i][j]='#';
            }
        }
    }
    rep(i,0,2+n)
    {
        rep(j,0,2+m)
        {
            cout<<ch[i][j];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream> // {{{
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <cstdio> // }}}

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

#define N 200

using namespace std;

int main() {
    int n;
    int a[N];
    cin >> n;
    rep(i,n)scanf("%d",&a[i]);

    int cnt = 0;
    while(1){
        rep(i,n){
            if(a[i] % 2 != 0){
                cout << cnt << endl;
                return 0;
            }
            a[i] = a[i] / 2;
        }
        cnt++;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  string s; cin >> s;
  int cntW = 0,cntB = 0;
  int indexW,indexB;

  for ( int i = 0; i < s.length(); i++ ) {
    if ( s[i] == 'W' ) cntW++;
    else if ( s[i] == 'B') cntB++;
  }

  if ( cntW == 0 || cntB == 0 ) {
    cout << 0 << endl;
    return 0;
  }

  for ( int i = 0; i < s.length(); i++ ) {
    if ( s[i] == 'B') {
      indexW = i;
      break;
    }
  }

  for ( int i = s.length()-1; i>=0; i-- ) {
    if ( s[i] == 'W' ) {
      indexB = i;
      break;
    }
  }
  int index = indexW;
  ll ans = 0;
  for ( int i = indexW; i <= indexB; i++ ) {
    if ( s[i] == 'W' ) {
      ans += abs(index-i);
      index++;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

int n;
vector<tuple<int, int, int>> p;

int check(int x, int y){
    int h = get<2>(p[0]) + abs(x - get<0>(p[0])) + abs(y - get<1>(p[0]));
    for(int i = 1; i < n; i++){
        if(max(0, h - abs(x - get<0>(p[i])) - abs(y - get<1>(p[i]))) != get<2>(p[i])){
            return 0;
        }
    }
    return h;
}

int main(){
    cin >> n;
    p.resize(n);
    for(auto&& i : p){
        int x, y, h;
        cin >> x >> y >> h;
        i = make_tuple(x, y, h);
    }
    int point = 0;
    while(!get<2>(p[point])) point++;
    swap(p[0], p[point]);
    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            int score = check(i, j);
            if(0 < score){
                cout << i << " " << j << " " << score << "\n";
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
from math import ceil
from math import floor
A, B = map(int, input().split())
a1 = ceil(A/0.08)
b1 = ceil(B/0.10)
a2 = floor((A+1)/0.08)-1
b2 = floor((B+1)/0.10)-1
if b2 < a1 or a2 < b1:
  print(-1)
else:
  print(max(a1, b1))

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

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

    int H, W;
    cin >> H >> W;

    int h, w;
    cin >> h >> w;

    cout << (H - h) * (W - w) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int X;
  cin>>X;
  int a=X/100, b=X%100;
  if(b%5==0) {
    if(b/5<=a) cout<<1<<endl;
    else cout<<0<<endl;
  }
  else {
    if(b/5+1<=a) cout<<1<<endl;
    else cout<<0<<endl;
  }
}


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

using namespace std;

int main(){
    int x;
    cin >> x;
    int ans = 0;
    if(x >= 400 && x <= 599){
        ans = 8;
    }else if(x <= 799){
        ans = 7;
    }else if(x <= 999){
        ans = 6;
    }else if(x <= 1199){
        ans = 5;
    }else if(x <= 1399){
        ans = 4;
    }else if(x <= 1599){
        ans = 3;
    }else if(x <= 1799){
        ans = 2;
    }else if(x <= 1999){
        ans = 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7,N = 1e5 + 1;
int dp[2][N],s,t,n,m;
long long dis[2][N];
struct edges{
	int x,y,w;
}e[N<<1];
struct node{
	int x,w;
	node(int a = 0,int b = 0){
		x = a;w = b;
	}
};
void add(int &a,int b){
	a+=b;
	a%=M;
	if(a >= M)a-=M;
	if(a < 0)a+=M;
}
vector<node>g[N];
bool vis[N];
void dijk(int s,bool at){
	long long *dis = ::dis[at];
	memset(vis,0,sizeof vis);
	int *dp = ::dp[at];
	dis[s] = 0;
	dp[s] = 1;
	priority_queue<pair<long long,int>>q;
	q.push({0,s});
	while(!q.empty()){
		int x = q.top().second;
		long long w = -q.top().first;
		q.pop();
		if(vis[x])continue;
		vis[x] = 1;
		for(auto i : g[x]){
			int y = i.x;
			long long cur = w + i.w;
			if(cur == dis[y])add(dp[y],dp[x]);
			if(cur >= dis[y])continue;
			dp[y] = dp[x];
			dis[y] = cur;
			q.push({-dis[y],y});
		}
	}
}
int main(){
	//freopen("input.txt","r",stdin);
	scanf("%d%d%d%d",&n,&m,&s,&t);	
	for(int i = 0;i < m;i++){
		scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].w);
		int a = --e[i].x,b = --e[i].y,c = e[i].w;
		g[a].push_back({b,c});
		g[b].push_back({a,c});
	}
	for(int i = 0;i < n;i++)dis[0][i] = dis[1][i] = 1e18;
	dijk(--s,0);
	dijk(--t,1);
	long long mndis = dis[0][t];
	int ans = dp[0][t]*1LL*dp[0][t]%M,sz = 0;
	for(auto i : e){
		if(sz == m)break;
		++sz;
		long long mn = min(dis[0][i.x],dis[0][i.y]);
		long long mx = min(dis[1][i.x],dis[1][i.y]);
		if(mn == dis[0][i.y])swap(i.x,i.y);
		if(mn + mx + i.w == mndis && mn < (mndis + 1)/2 && mx < (mndis + 1)/2)add(ans,-(dp[0][i.x]*1LL*dp[0][i.x]%M)*(dp[1][i.y]*1LL*dp[1][i.y]%M)%M);
	}
	for(int i = 0;i < n;i++)
		if(dis[0][i] == dis[1][i])add(ans,-(dp[0][i]*1LL*dp[0][i]%M)*(dp[1][i]*1LL*dp[1][i]%M)%M);
	printf("%d\n",ans);
}

Measured memory_bytes: 16724
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

ll N;
ll a[25][25];

ll dp[1 << 21];

ll rec(ll mask) {
    if (dp[mask] >= 0) {
        return dp[mask];
    }
    if (mask == 0) {
        return 1;
    }
    ll bits = 0;
    REP(i, 0, N) {
        if (mask & (1 << i)) {
            bits++;
        }
    }
    ll ans = 0;
    REP(i, 0, N) {
        if ((mask & (1 << i)) && a[bits - 1][i] == 1) {
            ans = (ans + rec(mask ^ (1 << i))) % mod;
        }
    }

    return dp[mask] = ans;
}

int main() {
    cin >> N;
    REP(i, 0, N) {
        REP(j, 0, N) {
            cin >> a[i][j];
        }
    }
    fill(dp, dp + (1 << N), -1);
    ll ans = rec((1 << N) - 1);
    cout << ans << endl;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll c[51][51];
void comb(ll n){
    for(int i=0;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(j==0||j==i){
                c[i][j]=1ll;
            }
            else c[i][j]=c[i-1][j-1]+c[i-1][j];
        }
    }
}
int main(){
    ll n,a,b;cin>>n>>a>>b;
    vl v(n);rep(i,n)cin>>v[i];
    comb(n);
    sort(v.rbegin(),v.rend());
    ld mx=0;
    rep(i,a){
        mx+=v[i];
    }
    mx/=a;
    ll num=0,pos=0;
    rep(i,n){
        if(v[i]==v[a-1]){
            num++;
            if(i<a) pos++;
        }
    }
    ll ans=0;
    if(pos==a){
        for(pos=a;pos<=b;pos++){
            ans+=c[num][pos];
        }
    }
    else ans+=c[num][pos];
    cout.precision(10);
    cout<<fixed<<mx<<endl;
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	int N, M, a, b, ans = 0, T = 1;
	static pair<int, int> P[100000];
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		P[i] = { b, a };
	}
	sort(P, P + M);
	for (int i = 0; i < M; i++) {
		if (T <= P[i].second) {
			ans++;
			T = P[i].first;
		}
	}
	cout << ans;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define A 100
 
int main(){
   
  int b,c,d=0,e,f;
  int a[A];
  int s;
   
  scanf("%d",&e);
   
  for(b = 1;b <= e;b++){
    scanf("%d",&a[b]);
  }
   
   
 
   
  for(b = 1;b <= e;b++){
    s = b;
     
    for(c = b;c <= e;c++)
      if(a[s] > a[c])
    s = c;
     
    if(a[s] < a[b]){
    f = a[b];
    a[b] = a[s];
    a[s] = f;
    d++;
      }
  }
   
  for(b = 1;b <= e;b++){
      if(b == e)
    printf("%d",a[b]);
      else
    printf("%d ",a[b]);
    }
    printf("\n%d\n",d);
    return 0;
     
}

Measured memory_bytes: 600
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
typedef long long ll;
ll n,k;
ll solve()
{
	if(!k)return n*n;//a、b任取,余数都大于等于0 
	ll ans=0;
	for(int i=1;i<=n-k;++i)
	{
		ll b=k+i;//大于k的数才有余数k
		//[1,b][b+1,2b][(n/b-1)*b+1,n/b*b]每个区间里
		//这样的完整区间有n/b个,看右端点即可
		//%b余数在[k,b-1]内是>=k的,而[k,b=(k+i-1)]长为i 
		ans+=(n/b)*i;
		//不完整区间[(n/b)*b+1,n],[k,n%b] 
		if(n%b>=k)
		ans+=n%b-k+1; 
	}
	return ans;
}
int main()
{
	scanf("%lld%lld",&n,&k);
	printf("%lld\n",solve());
	return 0;
}

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

namespace problem
{
  class Test
  {
    static void Main()
    {
      int i = int.Parse(Console.ReadLine());
      var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
      for (int b = 1; b <= s.Min(); b++)
      {
        if (s[0] % b == 0 && s[1] % b == 0)
        {
          if (i == 2) { Console.WriteLine(b); continue; }
          if (s[2] % b == 0) { Console.WriteLine(b); }
        }
      }
    }
  }
}


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

using namespace std;

int main(){
  int a;
  int b;
  cin >> a;
  cin >> b;
  int ans=0;
  ans =a-2*b;
  if(ans<0){
    ans=0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,X,Y;
  cin>>N>>X>>Y;
  vector<int>A(N-1,0);
  for(int x=1;x<N;x++){
  for(int y=x+1;y<=N;y++){
  int k=min(y-x,abs(y-Y)+abs(x-X)+1);
    A.at(k-1)++;
  
  }
  
  }for(int i=0;i<N-1;i++)
    cout<<A.at(i)<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector <int> lv(n), rv(n);
    vector <int> l, r;
    for (int i = 0; i < n; i++)
    {
        while (!l.empty() && a[i] < a[l.back()])
        {
            l.pop_back();
        }
        lv[i] = (l.empty() ? 0 : l.back() + 1);
        l.push_back(i);
    }
    for (int i = n - 1; i >= 0; i--)
    {
        while (!r.empty() && a[i] < a[r.back()])
        {
            r.pop_back();
        }
        rv[i] = (r.empty() ? n - 1 : r.back() - 1);
        r.push_back(i);
    }
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += (rv[i] - i + 1) * (ll) (i - lv[i] + 1) * a[i];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3832
#include <iostream>
#include <map>

using namespace std;

int main() {
    int n, l;
    string s;
    map<string, int> m;
    cin >> n >> l;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        m[s]++;
    }
    for (const auto &p : m) for (int i = 0; i < p.second; ++i) cout << p.first;
    cout << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static final long TIME_LIMIT = System.currentTimeMillis() + 1900L;
    //-------------------------------------------------------------//
    public static final void main(String[] args) { new Main().solve(); }
    //-------------------------------------------------------------//
    Scanner sc = new Scanner(System.in);
    void solve() {
        int N = sc.nextInt();
        long W = sc.nextInt();
        List<Long>[] v = new ArrayList[4];
        Long[][] m = new Long[4][N + 1];
        for (int i = 0; i < 4; i++) v[i] = new ArrayList<>();
        long W0 = sc.nextLong();
        v[0].add(sc.nextLong());
        for (int i = 1; i < N; i++) {
            long w = sc.nextLong();
            int idx = (int)(w - W0);
            v[idx].add(sc.nextLong());
        }
        for (int i = 0; i < 4; i++) {
            Collections.sort(v[i], new Comparator<Long>() {
                @Override
                public int compare(Long o1, Long o2) {
                    return Long.compare(o2, o1);
                }
            });
            m[i][0] = 0L;
            for (int j = 1; j <= v[i].size(); j++) {
                m[i][j] = v[i].get(j - 1) + m[i][j - 1];
            }
        }

        if (W0 > W) {
            System.out.println(0);
            return;
        }

        long W1 = W0 + 1, W2 = W0 + 2, W3 = W0 + 3;
        long ans = 0;
        for (int i = 0; i <= v[0].size(); i++) {
            for (int j = 0; j <= v[1].size(); j++) {
                for (int k = 0; k <= v[2].size(); k++) {
                    long CW = W0 * i + W1 * j + W2 * k;
                    if (CW > W) continue;
                    int l = (int)Math.min(v[3].size(), Math.max(0, (W - CW) / W3));
                    ans = Math.max(m[0][i] + m[1][j] + m[2][k] + m[3][l], ans);
                }
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23892
n,q=map(int,raw_input().split())
ans=[0]*n
key=value=0
for i in range(q):
    a,v=map(int,raw_input().split())
    a-=1
    ans[a]+=v
    if a==key and v<0:
        value=max(ans)
        key=ans.index(value)
    elif ans[a]>value:
        key=a
        value=ans[a]
    elif ans[a]==value and a<key:
        key=a
    print key+1,value

Measured memory_bytes: 17108
#include <iostream>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;

using ll = long long;

ll v(ll p, ll n) { // return v_p(n!)
	ll a = p;
	ll res = 0;
	ll x = 1;
	while (a <= n) {
		res += n / a;
		a *= p;
	}
	return res;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	ll n; cin >> n;
	if (n & 1LL) cout << 0;
	else {
		cout << v(5, n / 2);
	}
}

Measured memory_bytes: 256
s = input()
n = len(s)
# RLに集まる、RRLLで偶数なら等分される、RLLで奇数なら少ない方に＋1
right = []
left = []
cnt = 0
for i in range(n):
    if s[i] == "R":
        cnt += 1
    else:
        cnt = 0
    right.append(cnt)
cnt = 0
for i in reversed(range(n)):
    if s[i] == "L":
        cnt += 1
    else:
        cnt = 0
    left.append(cnt)
left = left[::-1]
ans = []
for i in range(n-1):
    if len(ans)-1 == i:
        continue
    if s[i] == 'R' and s[i+1] == "L":
        total = right[i] + left[i+1]
        if total % 2 == 0:
            ans.append(total//2)
            ans.append(total//2)
        else:
            if left[i+1] % 2 == 0:
                ans.append(total//2+1)
                ans.append(total//2)
            else:
                ans.append(total//2)
                ans.append(total//2+1)
    else:
        ans.append(0)
if len(ans) != n:
    ans.append(0)
if s[0] == "L":
    ans[0] = left[0]
if s[-1] == "R":
    ans[-1] = right[-1]
print(*ans)


Measured memory_bytes: 15400