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

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    
    vector<char> Ans(n);
    Ans[0] = 'S';
    Ans[1] = 'S';

    for(int x = 0; x < 2; x++){
        for(int y = 0; y < 2; y++){
            Ans[0] = "SW"[x];
            Ans[1] = "SW"[y];
            for(int i = 1; i < n; i++){
                if(i != n - 1){
                    if(s[i] == 'o' and Ans[i] == 'S'){
                        Ans[i + 1] = Ans[i - 1];
                    }else if(s[i] == 'o' and Ans[i] == 'W'){
                        Ans[i + 1] = (Ans[i - 1] == 'W' ? 'S' : 'W');
                    }else if(s[i] == 'x' and Ans[i] == 'S'){
                        Ans[i + 1] = (Ans[i - 1] == 'W' ? 'S' : 'W');
                    }else{
                        Ans[i + 1] = Ans[i - 1];
                    }
                }else{
                    bool f = false, f2 = false;
                    if(s[i] == 'o' and Ans[i] == 'S'){
                        if(Ans[0] == Ans[i - 1]){
                            f = true;
                        }
                    }else if(s[i] == 'o' and Ans[i] == 'W'){
                        if(Ans[0] != Ans[i - 1]){
                            f = true;
                        }
                    }else if(s[i] == 'x' and Ans[i] == 'S'){
                        if(Ans[0] != Ans[i - 1]){
                            f = true;
                        }
                    }else{
                        if(Ans[0] == Ans[i - 1]){
                            f = true;
                        }
                    }

                    if(s[0] == 'o' and Ans[0] == 'S'){
                        if(Ans[n - 1] == Ans[1]){
                            f2 = true;
                        }
                    }else if(s[0] == 'o' and Ans[0] == 'W'){
                        if(Ans[n - 1] != Ans[1]){
                            f2 = true;
                        }
                    }else if(s[0] == 'x' and Ans[0] == 'S'){
                        if(Ans[n - 1] != Ans[1]){
                            f2 = true;
                        }
                    }else{
                        if(Ans[n - 1] == Ans[1]){
                            f2 = true;
                        }
                    }

                    if(f and f2){
                        for(int i = 0; i < n; i++){
                            cout << Ans[i];
                        }
                        cout << endl;
                        
                        return 0;
                    }
                }
            }
        }
    }

    cout << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 3756
N,A,B,C,D=map(int,input().split())
if N%A==0 and N%C==0:
    if (N//A)*B < (N//C)*D:
        print((N//A)*B)
    else:
        print((N//C)*D)
elif N%A==0 and not N%C==0:
    if (N//A)*B < ((N//C)+1)*D:
        print((N//A)*B)
    else:
        print(((N//C)+1)*D)
elif not N%A==0 and  N%C==0:
    if ((N//A)+1)*B < (N//C)*D:
        print(((N//A)+1)*B)
    else:
        print((N//C)*D)
else:
    if ((N//A)+1)*B < ((N//C)+1)*D:
        print(((N//A)+1)*B)
    else:
        print(((N//C)+1)*D)
    


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



int main(){
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	int n = int(s.size());
	int res = 0;
	for(auto i = 0; i < n; ){
		int j = i;
		while(j < n && s[j] == 'R'){
			++ j;
		}
		res = max(res, j - i);
		i = j + 1;
	}
	cout << res << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3644
def resolve():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    from collections import defaultdict, deque
    matrix = defaultdict(list)
    for i in range(N-1):
        matrix[i].append(i+1)
        matrix[i+1].append(i)
    matrix[X].append(Y)
    matrix[Y].append(X)

    ans = [0] * N
    for i in range(N):
        queue = deque([(i, 0)])
        d = [float('inf')] * N
        while queue:
            node, dist = queue.popleft()
            if d[node] != float('inf'):
                continue
            d[node] = dist
            for adj in matrix[node]:
                queue.append([adj, dist+1])
        for j in range(N):
            ans[d[j]] += 1
    for i in range(1, N):
        print(ans[i]//2)
resolve()

Measured memory_bytes: 74460
#!/usr/bin/python3
# -*- coding: utf-8 -*-

def main():
    a, b, c, d = map(int, input().split())
    left = a + b
    right = c + d
    if left > right:
        print('Left')
    elif left < right:
        print('Right')
    else:
        print('Balanced')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<stdio.h>

int main(void){
  int n,k;
  scanf("%d %d",&n,&k);
  int p[101]={},d[k];
  for(int i=0;i<k;i++){
    scanf("%d",&d[i]);
      for(int j=0;j<d[i];j++){
        int pn=0;
        scanf("%d",&pn);
        p[pn]++;
      }
  }
  
  int c=0;
  for(int i=0;i<n;i++){
    if(p[i+1]==0){
      c++;
    }
  }
  
  printf("%d\n",c);
  return 0;
}
  
  


Measured memory_bytes: 1732
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	while(cin>>N>>K) {
		VI D(K);
		REP(i, K) cin>>D[i];
		VI ok(10, 1);
		REP(i, K) ok[D[i]]=0;
		while(1) {
			string s = to_string(N);
			bool lok=1;
			for(auto c: s) if(!ok[c-'0']) lok=0;
			if(lok) break;
			N++;
		}
		cout<<N<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
io = STDIN
$n,m=io.gets.chomp.split.map(&:to_i)
$con=Hash.new{|h,k|h[k]=[]}
m.times do
  a,b=io.gets.chomp.split
  $con[a]<<b
  $con[b]<<a
end
$cnt=0
def search(n,hist)
  $cnt+=1 if hist.size==$n
  $con[n].each do |to|
    search(to,hist+[to]) unless hist.include?(to)
  end
end
search("1",["1"])
p $cnt

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;
constexpr int64_t SIZE = 2e5;

array<int64_t, SIZE+10> fac, ifac;

int64_t modpow(int64_t x, int64_t n, int64_t m = 1) {
    return n == 0 ? m : modpow(x * x % MOD, n >> 1, n & 1 ? m * x % MOD : m);
}

int64_t comb(int64_t n, int64_t k) {
    return n == 0 && k == 0 ? 1
        : n < k || n < 0 ? 0
        : fac[n] * ifac[k] % MOD * ifac[n-k] % MOD;
}

int main() {
    fac[0] = ifac[0] = 1;
    for (int64_t i = 0; i+1 < SIZE + 10; i++) {
        fac[i+1] = fac[i] * (i+1) % MOD;
        ifac[i+1] = ifac[i] * modpow(i+1, MOD-2) % MOD;
    }

    int64_t h, w, a, b;
    cin >> h >> w >> a >> b;

    int64_t ans = 0;
    for (int i = 0; i < h-a; i++) {
        ans += comb(i+b-1, i) * comb(h-1-i + w-b-1, w-b-1) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3328
N,C = map(int,input().split())
D = [list(map(int,input().split())) for _ in range(C)]
c = [list(map(int,input().split())) for _ in range(N)]

cst = [[0,0,0] for i in range(C)]

for clr in range(1,C+1):
    for i in range(N):
        for j in range(N):
            cst[clr-1][(i+j+2)%3] += D[c[i][j]-1][clr-1]

ans = 10**10

for i in range(C):
    for j in range(C):
        for k in range(C):
            if i == j or i == k or j == k:
                continue
            ans = min(ans,cst[i][0]+cst[j][1]+cst[k][2])

print(ans)


Measured memory_bytes: 45692
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n, k;
    scanf("%i%i", &n, &k);
    vector<long long> arr(n+200), dp(n+200, INT_MAX);
    for (int x = 1; x <= n; x++)
        scanf("%lli", &arr[x]);
    dp[1] = 0;
    for (int x = 1; x < n; x++)
    {
        for (int y = 1; y <= k; y++)
            dp[x+y] = min(dp[x+y], dp[x] + abs(arr[x]-arr[x+y]));
    }
    printf("%lli\n", dp[n]);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(int)a;i<(int)b;i++)
#define revloop(i,a,b) for(i=(int)a;i>=(int)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define ll long long int
#define PI acos(-1.0)
#define f first
#define s second
#define rs resize
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int n,pow,i;
   cin>>n;
   pow = 1;
   loop(i,1,n+1)
     pow = (pow *1LL* i)%mod;
   cout<<pow;
   return 0;
}


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

using namespace std;

bool vis[50];//訪れたかどうか

bool g[50][50];//graph（隣接行列）
int a[50],b[50];
int n ,m;
void dfs(int x)//頂点ｘを訪れる関数
{
    if(vis[x])return;
    vis[x]=true;
    for(int i=0;i<n;i++){
        if(g[x][i])dfs(i);
    }
}

int main()
{
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
       g[a[i]][b[i]]=true;
       g[b[i]][a[i]]=true;
    }
    int ans=0;
    for(int i=0;i<m;i++){
        g[a[i]][b[i]]=false;
        g[b[i]][a[i]]=false;
        for(int j=0;j<n;j++){
            vis[j]=false;
        }
        dfs(0);
        bool tmp=false;
        for(int j=0;j<n;j++){
            if(!vis[j])tmp=true;
        }
        if(tmp)ans++;
        g[a[i]][b[i]]=true;
        g[b[i]][a[i]]=true;
    }
    cout << ans << endl;
    return 0;
}


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

def SINGLE_INT(): return int(INPUT())
def MULTIPLE_INT_LIST(): return list(map(int, INPUT().split()))
def MULTIPLE_INT_MAP(): return map(int, INPUT().split())
def SINGLE_STRING(): return INPUT()
def MULTIPLE_STRING(): return INPUT().split()

N, A, B , A_goal, B_goal = MULTIPLE_INT_MAP()
S = SINGLE_STRING()

def surpass():

    if '...' in S[B-2:B_goal+1]:
        return 'Yes'
    else:
        return 'No'


if '##' in S[A-1: A_goal+1] or '##' in S[B-1:B_goal+1]:
    print('No')

else:
    if A_goal < B_goal:
        print('Yes')
    else:
        print(surpass())

Measured memory_bytes: 3444
n = int(input())
h = list(map(int, input().split()))
ans = 0
while True:
    if(max(h) == 0):
        break
    i = 0
    while(i < n):
        if(h[i] == 0):
            i+=1
        else:
            ans += 1
            j = i 
            while(j < n and h[j] > 0):
                h[j] -= 1
                j+=1
print(ans)


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

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

	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);

	printf("%d\n",(a<b?a:b)+(c<d?c:d));

	return 0;
}

Measured memory_bytes: 128
import sys


fin = sys.stdin.readline
N = int(fin())
A_list = [int(elem) for elem in fin().split()]
coores_info = [None] * N
coores_info[0] = (1, 0)
for i, p in enumerate(A_list[:-1], start=1):
    coores_info[i] = (-1 if i % 2 else 1, p - coores_info[i - 1][1])
# print(coores_info)
p = A_list[-1]
x = (-coores_info[-1][1] + p) // 2
result = [None] * N
result[0] = x
for i, info in enumerate(coores_info[1:], start=1):
    result[i] = x * info[0] + info[1]

result = [item * 2 for item in result]
print(*result)


Measured memory_bytes: 73060
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10 ** 5 + 1)


def dfsu(s, p):
    for t in g[s]:
        if t == p:
            continue
        du[t] = du[s] + 1
        dfsu(t, s)


def dfsv(s, p):
    for t in g[s]:
        if t == p:
            continue
        dv[t] = dv[s] + 1
        dfsv(t, s)


n, u, v = map(int, input().split())
u -= 1
v -= 1
g = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    g[a].append(b)
    g[b].append(a)

du = [0] * n
dv = [0] * n
dfsu(u, -1)
dfsv(v, -1)

mx = 0
for i in range(n):
    if du[i] < dv[i]:
        mx = max(mx, dv[i])
print(mx - 1)


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

int main(){
    int N, T;
    cin >> N >> T;
    vector<int> t(N);
    rep(i, N) cin >> t[i];
    ll ans = T;
    for (int i=1; i<N; i++) {
        if (t[i-1]+T<=t[i]) {
            ans += T;
        } else {
            ans += t[i]-t[i-1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<stack>
#include<queue>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#include<set>
#define int long long
#define INF 1e9+7
using namespace std;
signed main(){
    int x,y,a,b,c,n,sum=0; cin>>x>>y>>a>>b>>c;
    priority_queue<int>p,q,r;
    for(int i=0;i<a;++i){
        cin>>n; p.push(n);
    }
    for(int i=0;i<b;++i){
        cin>>n; q.push(n);
    }
    for(int i=0;i<c;++i){
        cin>>n; r.push(n);
    }
    n=x+y;
    for(int i=0;i<n;++i){
        int maxp=0,maxq=0,maxr=0;
        if(!p.empty()&&x>0) maxp=p.top();
        if(!q.empty()&&y>0) maxq=q.top();
        if(!r.empty()) maxr=r.top();
        if(maxp>=maxq&&maxp>=maxr){
            sum+=maxp; p.pop(); --x; 
        }else if(maxq>=maxp&&maxq>=maxr){
            sum+=maxq; q.pop(); --y;
        }else{
            sum+=maxr; r.pop();
        }
    }
    cout<<sum<<endl;
    return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int LCS(string s1, string s2){
    int c[s1.size()+1][s2.size()+1];
    rep(i,s1.size()+1) rep(j, s2.size()+1) c[i][j] = 0;
    for(int i=1; i<=s1.size(); i++){
        for(int j=1; j<=s2.size(); j++){
            if(s1[i-1] == s2[j-1]){
                c[i][j] = c[i-1][j-1] + 1;
            }else{
                c[i][j] = max(c[i-1][j], c[i][j-1]);
            }
        }
    }
    return c[s1.size()][s2.size()];
}

int main()
{
    int q; cin >> q;
    rep(i,q){
        string s1, s2;
        cin >> s1 >> s2;
        cout << LCS(s1, s2) << endl;
    }
}


Measured memory_bytes: 7128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC087BCoins solver = new ABC087BCoins();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC087BCoins {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt(), c = in.nextInt(), x = in.nextInt();
            int ans = 0;
            for (int a0 = 0; a0 <= a; a0++) {
                for (int b0 = 0; b0 <= b; b0++) {
                    for (int c0 = 0; c0 <= c; c0++) {
                        if (500 * a0 + 100 * b0 + 50 * c0 == x) {
                            ans++;
                        }
                    }
                }
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define low(x) ((x)&(-x))

using namespace std;
typedef long long ll;
const ll mod = 1e9;
const int maxn = 1e5+50;
int n,m,len;
char g1[maxn],g2[maxn];

template<typename Ty>
bool read1n(Ty &x)
{
    char ch; bool neg=false;
    for(ch=getchar();ch<'0'||'9'<ch;ch=getchar())
        if(ch=='-')
            neg=true;
        else if(ch==-1)return false;
    for(x=0;'0'<=ch&&ch<='9';ch=getchar())
        x=(x<<1)+(x<<3)+ch-'0';
    if(neg) x=-x;
    return true;
}

int main(){
   scanf("%d%d",&n,&m);
   scanf("%s%s",g1,g2);
   int i,j,a,b;
   int len = __gcd(n,m);
   a = n/len;b = m/len;
   for(i=0;i<len;i++){
        if(g1[i*a]!=g2[i*b]){
            printf("-1");
            return 0;
        }
   }
   cout<<(ll)n*m/len<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    ll q,h,s,d; cin >> q >> h >> s >> d;
    ll n; cin >> n;
    h = min (h,2*q);
    s = min (s,2*h);
    d = min (d,2*s);
    ll d_count = 0;ll s_count = 0;
    while(n-2>=0){
        d_count++;
        n-=2;
    }
    while(n-1>=0){
        s_count++;
        n-=1;
    }
    cout << s_count*s+d_count*d << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#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()
{
    ll k;
    string s;

    cin >> k >> s;
    if (s.length() <= k)
    {
        cout << s << endl;
    }
    else
    {
        s = s.substr(0, k);
        cout << s << "..." << endl;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/format.hpp>

using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
const int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
const int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> p(m), y(m);
    vector<set<pint>> city(n);
    vector<string> ans(m);
    rep(i,m) {
        cin >> p[i] >> y[i];
        p[i] --;
        city[p[i]].insert(pint(y[i], i));
    }
    rep(i,n) {
        int cnt = 0;
        for(auto cit : city[i]) {
            cnt ++;
            int id = cit.second;
            ans[id] = (boost::format("%06d%06d") %(i+1) %cnt).str();
            //sprintf(ans[id], "%6d%6d", i+1, cnt);
        }
    }
    rep(i,m)
        cout << ans[i] << "\n";
    return 0;
}


Measured memory_bytes: 16480
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N;
  cin >> N;
  string a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    vector<int> cnt(30, 0);
    cnt[a[i] - 'a']++;
    cnt[b[i] - 'a']++;
    cnt[c[i] - 'a']++;
    ans += 3 - *max_element(all(cnt));
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
using namespace std;
int a, seven, five;

int main(){
  for (int i=0; i<3; ++i) { 
    cin >> a;
    if (a==7){
      seven = seven+1;
    } else if (a==5){
      five = five+1;
    }
}
  string result;
  if (seven==1 && five==2){
    result="YES";
  } else {
    result="NO";
  }
  cout << result<< endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const ll N = 1000005;



ll n;
ll a[N];
ll ne[N], d[N];
ll K;
ll mas[N], M[N];

ll fix[N], D[N];
ll nn, A[N];
ll re[N];

void go (){
    for (ll i = 0; i < N; i++)
        mas[i] = 0;
    ll num = 0;
    for (ll i = 1; i <= nn; i++){
        if (mas[A[i]] == 0){
            re[++num] = A[i];
            mas[A[i]] = num;
            continue;
        }
        ll le = mas[A[i]];
        while (num >= le){
            mas[re[num]] = 0;
            num--;
        }
    }
    for (ll i = 1; i <= num; i++)
        cout << re[i] << " ";
    cout << endl;
}


main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin >> n >> K;
    for (ll i = 1; i <= n; i++)
        cin >> a[i];
    for (ll i = n; i >= 1; i--){
        M[a[i]] = i;
    }
    for (ll i = n; i >= 1; i--){
        ne[i] = mas[a[i]];
        mas[a[i]] = i;
        if (ne[i] == 0){
            ne[i] = M[a[i]];
            d[i] = 1;
        }
        ne[i]++;
        if (ne[i] > n){
            d[i]++;
            ne[i] -= n;
        }
    }
    ll t = 1;
    D[1] = 1;
    while (1){
        if (D[t] >= K)
            break;
        fix[t] = 1;
        ll to = ne[t];
        ll dist = D[t] + d[t];
        if (fix[to]){
            ll dif = dist - D[to];
            K %= dif;
            while (K < D[to])
                K += dif;
            break;
        }
        D[to] = dist;
        t = to;
    }
    ll st = 0;
    for (ll i = 1; i <= n; i++)
        if (D[i] == K){
            st = i;
            break;
        }
    if (st == 0){
        go ();
        return 0;
    }
    for (ll i = st; i <= n; i++)
        A[++nn] = a[i];
    go ();
    return 0;
}


Measured memory_bytes: 37248
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

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

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

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)

const double EPS = 1e-10;

int main() {
	int r, c;

	while(cin >> r >> c, r) {
		if(c%2 == 0 || r%2 == 0) {
			cout << "yes" << endl;
		} else if(c%2 == 0 && r == 1) {
			cout << "yes" << endl;
		} else if(c == 1 && r%2 == 0) {
			cout << "yes" << endl;
		} else {
			cout << "no" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = (int)1e9 + 7, INF = (int)1e9;


int main(void) {
	int n, i, j, l[70] = {}, t, kd[70] = {};
	bool cf;
	ll k, a[100003], mmax, ans;

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

	mmax = k;
	for (i = 0; i < n; i++) {
		mmax = max(mmax, a[i]);
	}

	t = 0;
	while (mmax > 0) {
		mmax /= 2;
		t++;
	}

	for (i = 0; i < t; i++) {
		kd[i] = k % 2;
		k /= 2;
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < t; j++) {
			l[j] += a[i] % 2;
			a[i] /= 2;
		}
	}

	ans = 0;
	cf = false;
	for (i = t - 1; i >= 0; i--) {
		ans *= 2;
		if (cf) {
			ans += max(l[i], n - l[i]);
		}
		else {
			if (l[i] >= n - l[i]) {
				ans += l[i];
				if (kd[i] == 1) cf = true;
			}
			else {
				if (kd[i] == 0) ans += l[i];
				else ans += n - l[i];
			}
		}
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define ll long long

int main(int argc, char** argv) {
	int n,k;
	cin>>n>>k;
	int p=0;
	while(n)
	{
		n/=k;
		p++;
		
	}
	cout<<p;;
	
	return 0;
}

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

const int divisor = 1000000007;

int main(){
	// 100000!までの数をdivisorで割った余りを格納しておく
	long long* factmodary = new long long[100001];
	long long fact = 1;
	for (int i = 1; i <= 100000; i++){
		fact *= i;
		fact %= divisor;
		factmodary[i] = fact;
	}

	int* word = new int[100000] {0};

	for (;;){
		int N, R;
		cin >> N;
		if (N == 0) break;
		cin >> R;
		
		//まず0番目の単語を入れておく
		for (int i = 0; i < N; i++) word[i] = i + 1;

		for (int i = 0; i < R; i++){
			int s, t;
			cin >> s >> t;
			/* swap */
			int tmp = word[s - 1]; word[s - 1] = word[t - 1]; word[t - 1] = tmp;
		}

		//word[i]をkey, word[i]より小さい数がそれ以前にいくつ使われていたかをvalueとして格納するmap
		map<int, int> bubblehist;
		bubblehist[word[0]] = 0;

		long long ans = factmodary[N-1] * (word[0] - 1);

		for (int i = 1; i < N; i++){
			int facttime = word[i] - 1;
			int bubblenum;
			map<int, int>::iterator it = bubblehist.lower_bound(word[i]);

			if (it != bubblehist.end()){
				bubblenum = it->second;
				it--;
			}
			else {
				it--;
				bubblenum = it->second + 1;
			}
			pair<int, int> p;
			p.first = word[i];
			p.second = bubblenum;
			map<int, int>::iterator it2 = bubblehist.insert(it, p);
			//word[i]より大きい数はすべてvalueが1増える
			for (++it2; it2 != bubblehist.end(); it2++) (it2->second)++;

			facttime -= bubblenum;
			ans += factmodary[N - (i + 1)] * facttime;
		}
		cout << ans % divisor << endl;
	}

	delete[] word;
	delete[] factmodary;
	return 0;
}

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

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

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

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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   int x,a,b;
   cin>>x>>a>>b;

   x -= a;
   x %= b;
   cout<<x<<'\n';
}

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

int main(){
    
    int n;
    cin >> n;
    vector<long long int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end(),greater<>());
    long long int ans=0;
    long long int count=0;

    for(int i=0; i<n-1; i++){
        if(a.at(i+1)-a.at(i)==0){
            if(count==0){
                count=a.at(i);
                i++;
            }
            else{
                ans=count*a.at(i);
                break;
            }
        }
    }
    cout << ans << endl;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int N;
    cin >> N;

    vector<int> A(N);
    rep(i, N) cin >> A[i];

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

    ll ans = 0;
    if (N % 2 == 0) {
        int num = N - 2;
        rep(i, num / 2) ans -= A[i] * 2;
        rep(i, num / 2) ans += A[N - 1 - i] * 2;
        ans -= A[N / 2 - 1];
        ans += A[N / 2];
    } else {
        int num = N - 2;
        rep(i, (num + 1) / 2) ans -= A[i] * 2;
        rep(i, num / 2)       ans += A[N - 1 - i] * 2;
        ans += A[N / 2];
        ans += A[N / 2 + 1];

        ll res = 0;
        rep(i, num / 2)       res -= A[i] * 2;
        rep(i, (num + 1) / 2) res += A[N - 1 - i] * 2;
        res -= A[N / 2 - 1];
        res -= A[N / 2];

        ans = max(ans, res);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
#define N 200010
using namespace std;

ll k, n, ans1 = INT_MAX, ans2 = INT_MAX, a[N];

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	k = read(), n = read();
	REP(i, 1, n) a[i] = read();
	sort(a + 1, a + n + 1);
	ans1 = a[n] - a[1];
	ans2 = k - (a[n] - a[1]) + k - a[2];
	REP(i, 2, n - 1) ans1 = min(ans1, a[i] - a[1] + a[1] + k - a[i + 1]);
	REP(i, 2, n - 1) ans2 = min(ans2, k - a[i] + a[i - 1]);
	printf("%lld\n", min(ans1, ans2));
}

int main(){
	work();
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    int i,c=0;
    char a[20];
    int max=0;
    cin>>a;
    for(i=0; a[i];i++)
    {
        while((a[i]=='A'||a[i]=='T'||a[i]=='C'||a[i]=='G'))
        {
            c++;
            i++;
        }
        if(c>max)
            max=c;
        c=0;
    }
    cout<<max;
}

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

using namespace std;

int main(void){
  int size;
  cin>>size;
  vector<int> vec(size);
  for(int i=0;i<size;i++){
    cin>>vec.at(i);
  }
  for(int i=size-1;i>0;i--){
    cout<<vec.at(i)<<" ";
  }cout<<vec.at(0)<<endl;
  return 0;
}



Measured memory_bytes: 3072
#include<stdio.h>
int main()
{
  int x,a,b,xa,xb;
  scanf("%d %d %d",&x,&a,&b);
  if(x-a>=0){
    xa=x-a;
  }else{
    xa=a-x;
  }
  if(x-b>=0){
    xb=x-b;
  }else{
    xb=b-x;
  }
  if(xa<xb){
    printf("A\n");
  }else{
    printf("B\n");
  }
  return 0;
}

Measured memory_bytes: 128
def f(n)
  count = 0
  while n.even? do
    count += 1
    n /= 2
  end
  count
end

N = gets.to_i
arr = gets.chomp.split.map(&:to_i)
arr2 = []
arr.each do |a|
  arr2 << f(a)
end
puts arr2.min

Measured memory_bytes: 3836
#include <stdio.h>

typedef long long ll;

int N;
int F[101][6][3];
int P[101][11];

int open[10];
int cnt;

ll ans=-(1ll<<60);

ll calc_score(){

	int i,j,k;

	ll score=0ll;

	for(i=1;i<=N;i++){
		int check=0;
		int c=0;
		for(j=1;j<=5;j++){
			for(k=1;k<=2;k++){
				if(F[i][j][k]==1&&open[check]==1){
				c++;
				}
				check++;
			}
		}
		score+=(ll)P[i][c];
	}
	return score;
}

void dfs(int depth){

	int i;

	if(depth==10){

		cnt++;

		if(cnt<1024){
			ll score=calc_score();
			if(ans<score){
			ans=score;
			}
		}

		return;
	}

	open[depth]=1;
	dfs(depth+1);
	open[depth]=0;
	dfs(depth+1);
}

int main(){

	scanf("%d",&N);

	int i,j,k;

	for(i=1;i<=N;i++){
		for(j=1;j<=5;j++){
			for(k=1;k<=2;k++){
			scanf(" %d",&F[i][j][k]);
			}
		}
	}
	for(i=1;i<=N;i++){
		for(j=0;j<=10;j++){
		scanf(" %d",&P[i][j]);
		}	
	}
	dfs(0);

	printf("%lld\n",ans);

return 0;
}

Measured memory_bytes: 128
s = str(input())
a = int(s[0])
b = int(s[1])    
c = int(s[2])
d = int(s[3])
if a+b+c+d==7:
    print('{}+{}+{}+{}=7'.format(a,b,c,d))
elif a+b+c-d==7:
    print('{}+{}+{}-{}=7'.format(a,b,c,d))
elif a+b-c+d==7:
    print('{}+{}-{}+{}=7'.format(a,b,c,d))
elif a+b-c-d==7:
    print('{}+{}-{}-{}=7'.format(a,b,c,d))
elif a-b+c+d==7:
    print('{}-{}+{}+{}=7'.format(a,b,c,d))
elif a-b+c-d==7:
    print('{}-{}+{}-{}=7'.format(a,b,c,d))
elif a-b-c+d==7:
    print('{}-{}-{}+{}=7'.format(a,b,c,d))
elif a-b-c-d==7:
    print('{}-{}-{}-{}=7'.format(a,b,c,d))
    

Measured memory_bytes: 3064
import itertools
n,m,q = list(map(int,input().split()))
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
    a[i],b[i],c[i],d[i] = list(map(int,input().split()))
    b[i]-=1
    a[i]-=1
ans=0

for seq in itertools.combinations_with_replacement(range(m),n):
    tmp = 0
    #print(seq)
    for i in range(q):
        if seq[b[i]]-seq[a[i]]==c[i]:
            tmp+=d[i]
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 9116
#include <stdio.h>

int main(void){
  int a,b;
  int ans= 0;
  int outlet=1;
  
  scanf("%d %d", &a,&b);
  while(outlet < b){
    --outlet;
    outlet += a;
    ++ans;
  }
  
  printf("%d", ans);
  
  return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    ll S;
    cin >> S;
    ll x1, y1, x2, y2, x3, y3;
    x1 = y1 = 0;

    ll t = sqrt(S);
    if (t * t == S) {
        x2 = t;
        y2 = 0;
        x3 = 0;
        y3 = t;
    } else {
        x2 = t + 1;
        y2 = x2 * x2 - S;
        x3 = 1;
        y3 = t;
    }

//    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;

    if (t * t == S) {
        cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
//        cout << "0 0 " << t << " " << "0 0 " << t << "\n";
        return 0;
    }
    t += 1;
    ll e = t * t - S;
    cout << "0 0 " << t << " " << e << " " << "1 " << t << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  vector<int>a;
  for(int i = 1 ; i <= 1024 ; i*=2 )a.push_back(i);
  while( cin >> n ){
    vector<int>ans;
    int p = a.size();
    for(int i = p-1 ; i >= 0 ; i-- ){
      if(n-a[i] >= 0){
	ans.push_back(a[i]);
	n-=a[i];
      }
      if(n == 0)break;
    }
    for(int i = ans.size()-1 ; i >= 0 ; i-- ){
      if(i == (int)ans.size()-1)cout << ans[i]; 
      else cout <<" "<< ans[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 1220
#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;
  
  	int a;
  	int cnt=0;
  	rep(i, n) {
      cin >> a;
      if ((i+1)%2==1 && a%2==1) cnt++;
    }
  
  	cout << cnt << endl;
  	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class L, class R> ostream& operator<<(ostream& out, map<L, R> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }


int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
  
  int a, b, c, k;
  cin>>a>>b>>c>>k;
  int res = a - b;
  if (k % 2) {
    res = -res;
  }
  cout<<res<<endl;
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  return 0;
}


Measured memory_bytes: 768
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AizuRangeSumQuery solver = new AizuRangeSumQuery();
        solver.solve(1, in, out);
        out.close();
    }

    static class AizuRangeSumQuery {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int q = in.nextInt();

            int[] a = new int[n];
            int[] b = new int[4 * n];

            build(0, 0, n - 1, a, b);

            while (q-- != 0) {
                int o = in.nextInt();
                int l = in.nextInt() - 1;
                int r = in.nextInt() - 1;

                if (o == 0) {
                    update(0, 0, n - 1, l, r + 1, a, b);
                } else {
                    out.printf("%d\n", query(0, 0, n - 1, l, r, b));
                }
            }
        }

        private void build(int n, int s, int e, int[] a, int[] b) {
            if (s == e) {
                b[n] = a[s];
            } else {
                int m = (s + e) / 2;
                build(2 * n + 1, s, m, a, b);
                build(2 * n + 2, m + 1, e, a, b);

                b[n] = b[2 * n + 1] + b[2 * n + 2];
            }
        }

        private void update(int n, int s, int e, int idx, int val, int[] a, int[] b) {
            if (s == e) {
                a[idx] += val;
                b[n] += val;
            } else {
                int m = (s + e) / 2;
                if (s <= idx && idx <= m) {
                    update(2 * n + 1, s, m, idx, val, a, b);
                } else {
                    update(2 * n + 2, m + 1, e, idx, val, a, b);
                }

                b[n] = b[2 * n + 1] + b[2 * n + 2];
            }
        }

        private long query(int n, int s, int e, int l, int r, int[] b) {
            if (r < s || e < l) {
                return 0;
            } else if (l <= s && e <= r) {
                return b[n];
            } else {
                int m = (s + e) / 2;
                long s1 = query(2 * n + 1, s, m, l, r, b);
                long s2 = query(2 * n + 2, m + 1, e, l, r, b);

                return s1 + s2;
            }
        }

    }
}




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

int main(){
	int n;
	cin >> n;
	vector<int> w(n);
	int sum = 0;
	for(int i = 0; i < n; i++){
		cin >> w[i];
		sum += w[i];
	}
	int mini =  sum;
	int prefix_sum = 0;
	for(int i = 0; i < n; i++){
		cin >> w[i];
		prefix_sum += w[i];
		mini = min(mini,abs(prefix_sum - (sum - prefix_sum)));
	}
	cout << mini << endl;
	return 0;
}



Measured memory_bytes: 3624