akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

	vector<int> A(N);
	vector<int> B(N);

	rep(i, N) cin >> A[i] >> B[i];

	vector<vector<int>> dp(N + 1, vector<int>(H + 1, 100000000));

	reple(i, 0, N) dp[i][0] = 0;

	rep(i, N)
	{
		reple(j, 0, H)
		{
			dp[i + 1][j] = min(dp[i][j], dp[i + 1][max(j - A[i], 0)] + B[i]);
		}
	}

	cout << dp[N][H] << endl;

	return 0;
}

Measured memory_bytes: 39424
use proconio::*;

fn run() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let ans = a.into_iter().step_by(2).filter(|a| *a % 2 == 1).count();
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 2152
x,k,d = map(int, input().split())
x = abs(x)
kd = k*d

if kd<=x:
    print(x-kd)
else:
    count = x // d
    k_dash = k - count
    x -= count * d
    if k_dash % 2 == 0:
        print(x)
    else:
        print(d-x)


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;
int L[300001], R[300001];
int main() {
  int N; cin >> N;
  string s; cin >> s;
  rep(i, N) {
    if (s[i] == 'W') L[i]++;
    if (i > 0) L[i] += L[i - 1];
  }
  for (int i = N - 1; i > 0; i--) {
    if (s[i] == 'E') R[i]++;
    if (i < N - 1) R[i] += R[i + 1];
  }
  int ans = 1e9;
  rep(i, N) {
    int l = i > 0 ? L[i - 1] : 0;
    int r = i < N - 1 ? R[i + 1] : 0;
    int cand = l + r;
    ans = min(ans, cand);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3076
#include<stdio.h>
int n;
int A[20];
int solve(int,int);

int main(){
  int i,q,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(solve(0,k)==1)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int key){
  int cal;
  if(key==0)return 1;
  if(i>=n)return 0;
  cal = solve(i+1,key)|| solve(i+1,key-A[i]);
  return cal;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    cin >> N;
    map<int, int> mp;
    int res = 0;
    rep(i, N) {
        int a;
        cin >> a;
        mp[a]++;
    }

    for(auto& p: mp) {
        int a = p.fi, b = p.se;
        if(a < b) res += b-a;
        else if(a > b) res += b;
    }
    
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  int cnt = 0;
  for(int i=0; i<n-1; i++){
    if(s[i] == s[i+1]) cnt++;
  }
  int ans = min(n-1,cnt+2*k);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
<?php
fscanf(STDIN, "%d%d", $length, $num);

$houses = explode(" ", trim(fgets(STDIN)));

$last =-1 * ($length - $houses[count($houses) -1]);
$noz = 0;
foreach($houses as $ln){
$noz = max($noz, $ln - $last);
$last = $ln;
}

echo $length - $noz;


Measured memory_bytes: 19060
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define M 1000000007
#define ll long long
#define LIM 100000
using namespace std;
ll v[LIM];
int main() {
  int x, y, xx, yy;
  cin >> x >> y >> xx >> yy;
  int dx, dy;
  dx = xx - x;
  dy = yy - y;
  for (int i = 0; i < dy; i++) {
    cout << "U";
  }
  for (int i = 0; i < dx; i++) {
    cout << "R";
  }
  for (int i = 0; i < dy; i++) {
    cout << "D";
  }
  for (int i = 0; i < dx; i++) {
    cout << "L";
  }
  cout << "L";
  for (int i = 0; i < dy; i++) {
    cout << "U";
  }
  cout << "U";
  cout << "R";
  for (int i = 0; i < dx; i++) {
    cout << "R";
  }
  cout << "D";
  cout << "R";
  for (int i = 0; i < dy; i++) {
    cout << "D";
  }
  cout << "D";
  cout << "L";
  for (int i = 0; i < dx; i++) {
    cout << "L";
  }
  cout << "U";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int pre[100010],nex[100010];

int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	int b=0;
	for(int i=0;i<n;i++){
		int t;
		scanf("%d",&t);
		nex[b]=t;
		pre[t]=b;
		b=t;
	}
	nex[b]=n+1;
	pre[n+1]=b;
	
	while(q--){
		int x;
		scanf("%d",&x);
		if(pre[x]==0){
			nex[0]=nex[x];
			pre[nex[x]]=0;
			nex[x]=n+1;
			pre[x]=pre[n+1];
			nex[pre[n+1]]=x;
			pre[n+1]=x;
		}else if(nex[x]==n+1){
			pre[n+1]=pre[x];
			nex[pre[x]]=n+1;
			pre[x]=0;
			nex[x]=nex[0];
			pre[nex[0]]=x;
			nex[0]=x;
		}else{
			int aaa=pre[x];
			pre[x]=pre[n+1];
			nex[pre[n+1]]=x;
			pre[n+1]=aaa;
			nex[aaa]=n+1;
			int bbb=nex[x];
			nex[x]=nex[0];
			pre[nex[0]]=x;
			nex[0]=bbb;
			pre[bbb]=0;
		}
	}
	int pos=0;
	for(int i=0;i<n;i++)printf("%d%c",pos=nex[pos],i==n-1?10:32);
}


Measured memory_bytes: 2568
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string str;
    cin >> str;
    bool a[200500];
    ll ans = 0;
    ll sum = 0;
    REP(i,str.size()){
        if(str[i]=='B')sum++;
        if(str[i]=='W')ans += sum;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

#define int long long

const int mxN = 1e3+1;

int h, w, ch, cw, dh, dw, col[mxN][mxN], d[mxN*mxN];
char g[mxN][mxN];

set<int> adj[mxN*mxN];

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

void dfs(int i, int j, int c) {
    col[i][j] = c;
    for (int k = 0; k < 4; k++) {
        int ni = i + dx[k];
        int nj = j + dy[k];
        if (ni < 0 || ni >= h) continue;
        if (nj < 0 || nj >= w) continue;
        if (col[ni][nj] || g[ni][nj] == '#') continue;

        dfs(ni, nj, c);
    }
}

int bfs() {
    for (int i = 1; i < mxN*mxN; i++) d[i] = LINF;
    queue<int> q;
    q.push(col[ch][cw]);
    d[col[ch][cw]] = 0;

    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (auto v : adj[u]) {
            if (d[u]+1 < d[v]) {
                d[v] = d[u]+1;
                q.push(v);
            }
        }
    }

    if (d[col[dh][dw]] == LINF) return -1;
    return d[col[dh][dw]];
}

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

    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;
    for (int i = 0; i < h; i++) {
        string tmp; cin >> tmp;
        for (int j = 0; j < w; j++) g[i][j] = tmp[j];
    }

    int cind = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (col[i][j] || g[i][j] == '#') continue;
            dfs(i, j, cind);
            cind++;
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (col[i][j] == 0) continue;
            for (int x = max(0LL, i-2); x <= min(h-1, i+2); x++) {
                for (int y = max(0LL, j-2); y <= min(w-1, j+2); y++) {
                    if (col[x][y] == 0) continue;
                    adj[col[i][j]].insert(col[x][y]);
                    adj[col[x][y]].insert(col[i][j]);
                }
            }
        }
    }

    cout << bfs() << endl;

    return 0;
}

Measured memory_bytes: 91432
import java.util.*;

public class Main{
    Scanner in = new Scanner(System.in);

    void solve(){
        String s;
        while(in.hasNextLine()){
            s = in.nextLine();
            calc(s);
        }
    }
    void calc(String str){
        String a = str.substring(0, str.indexOf('+'));
        String b = str.substring(str.indexOf('+') + 1, str.indexOf('='));
        String c = str.substring(str.indexOf('=') + 1);
        for(int i = 0; i < 10; i++){
            String left = sum(a, b, i);
            String right = c.replace("X", String.valueOf(i));
            if(left.equals(right)){
                System.out.println(i);
                return;
            }
        }
        System.out.println("NA");
    }

    String sum(String a, String b, int rep){
        StringBuilder ans  = new StringBuilder();
        a = new StringBuilder(a.replace("X", String.valueOf(rep))).reverse().toString();
        b = new StringBuilder(b.replace("X", String.valueOf(rep))).reverse().toString();

        int t = 0;
        for(int i = 0; i < Math.max(a.length(), b.length()); i++){
            int x = i < a.length() ? a.charAt(i) - '0' : 0;
            int y = i < b.length() ? b.charAt(i) - '0' : 0;
            ans.append(String.valueOf((x + y + t) % 10));
            t = (x + y + t) / 10;
        }

        if(t != 0){
            ans.append(String.valueOf(t));
        }

        return ans.reverse().toString();
    }
    
    public static void main(String[] args){
        new Main().solve();    
    }
}

Measured memory_bytes: 30512
#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <list>
#include <utility>

//266666333332
//378360980

using namespace std;

int main(){
    unsigned long long int n;
    cin>> n;
    unsigned long long int a= n/3, b=n/5, c=n/15, d=b/3;
    unsigned long long int ans = (n*(n+1))/2 - (3*a*(a+1))/2 - (5*b*(b+1))/2 + (15*c*(c+1))/2;


    cout<<ans << endl;

/*    long long int f=1000000000000;
    cout<<f<<endl;

    long int n;
    cin>>n;
    long long i= n/3, j=n/5, k=n/15;
    long long ans = n*(n+1)/2;
    cout<<ans<<endl;
    ans -= 3*i*(i+1)/2;
    cout<<ans<<endl;
    ans -= 5*j*(j+1)/2;
    cout<<endl;
    ans += 15*k*(k+1)/2;
    cout<<ans<<endl;
/*
    long int T;
    cin>>T;
    for(long int i=0;i<T;++i){
        long int n;
        long long int a, b;
        cin>> n;
        vector<pair<long long int, long long int>> v;
        for(long int j=0;j<n;++j){
            cin>> a>> b;
            v.push_back(pair<long long int, long long int>(a, b));
        }
        for(int k=0;k<n;++k){}}
*/
    return 0;}


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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int):
    sum_N = 0
    for i in range(len(str(N))):
        sum_N += int(str(N)[i])
    if N % sum_N == 0:
        print(YES)
    else:
        print(NO)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import core.bitop;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

import std.bigint;

long modPow(long x, long n, long mod) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        if (x < int.max) return modPow(x * x % mod, n / 2, mod);
        auto y = BigInt(x) ^^ 2;
        return modPow(y % mod, n / 2, mod);
    } else {
        if (x < int.max) return x * modPow(x, n - 1, mod) % mod; 
        auto y = BigInt(x) * modPow(x, n - 1, mod);
        return y % mod;
    }
}
bool isPrime(long n) {
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    long s = bsf(n);
    long t = (n - 1) / (1L << s);
    bool test() {
        long b = uniform(2, n);
        if (modPow(b, t, n) == 1) return true;
        foreach (r; 0 .. s) {
            if (modPow(b, (1L<<r) * t, n) == n - 1) return true;
        }
        return false;
    }
    foreach (_; 0 .. 100) {
        if (! test()) return false;
    }
    return true;
}

void main() {
    int N = readln.chomp.to!int;
    int ans = 0;
    foreach (i; 0 .. N) {
        int x = readln.chomp.to!int;
        if (isPrime(x)) ans++;
    }
    writeln(ans);
}

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

int main()
{
  int N; int K;
  cin >> N;
  cin >> K;
  vector<int> p(N);
  for(int i=0; i<N; i++){
    cin >> p.at(i);
  }
  //昇順並び替え
  sort(p.begin(),p.end());
  int ans=0;
  for(int i=0; i<K;i++){
    ans += p.at(i);
  }

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

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n,m;
	cin >> n;
	map<string,int> s;
	for (int i = 0; i < n; i++) {
		string tmp;
		cin >> tmp;
		s[tmp]++;
	}
	cin >> m;
	map<string,int> t;
	for (int i = 0; i < m; i++) {
		string tmp;
		cin >> tmp;
		t[tmp]++;
	}
	int ans = 0;
	for (auto&& i : s) {
		bool same = false;
		for (auto&& j : t) {
			if (i.first == j.first) {
				same = true;
				ans = max(ans,i.second - j.second);
			}
		}
		if (!same) {
			ans = max(ans,i.second);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()

#YYMM か MMYY か AMBIGUOUS か NA か
#YYMM 1902
#MMYY 0599
#AMBIGUOUS 1212
#NA 9999

if S[0:2] < '13' and S[0:2] != '00' :
    if S[2:4] < '13' and S[2:4] != '00' :
        print('AMBIGUOUS')
    else :
        print('MMYY')

else:
    if S[2:4] < '13' and S[2:4] != '00' :
        print('YYMM')
    else :
        print('NA')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
  ll N; cin >> N;
  ll ans = 0LL, prod = 10LL;
  if(N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  while(prod <= N) {
    ans += N/prod;
    prod *= 5;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f[(1<<13)+1][2],q,tt0,tt1,x,i;
int tinh(int tt,int k)
{
    if((tt&tt0)==tt0) return 1;
    if((tt&tt1)==tt1) return 0;
    if(f[tt][k]>-1) return f[tt][k];
    //cerr<<tt<<" "<<((tt>>5)&1)<<'\n';
   // if(!((tt>>5)&1)) cerr<<1<<'\n';
    if(k==0)
    {
        bool kt=0;
        int kq=0;
        for(int i=0;i<13;i++)
            if((tt>>i)&1)
            {
                if(i>0 && (!((tt>>(i-1))&1)) && ((tt0>>(i-1))&1))
                {
                    kq=max(kq,tinh(tt+(1<<(i-1)),1));
                    kt=1;
                }
                if(i<12 && (!((tt>>(i+1))&1)) && ((tt0>>(i+1))&1))
                {
                    kq=max(kq,tinh(tt+(1<<(i+1)),1));
                    kt=1;
                }
            }
        if(kt==0) return f[tt][k]=tinh(tt,1);
        return f[tt][k]=kq;
    }
    else
    {
        bool kt=0;
        int kq=1;
        for(int i=0;i<13;i++)
            if((tt>>i)&1)
            {
                if(i>0 && (!((tt>>(i-1))&1)) && ((tt1>>(i-1))&1))
                {
                    kq=min(kq,tinh(tt+(1<<(i-1)),0));
                    kt=1;
                }
                if(i<12 && (!((tt>>(i+1))&1)) && ((tt1>>(i+1))&1))
                {
                    kq=min(kq,tinh(tt+(1<<(i+1)),0));
                    kt=1;
                }
            }
        if(kt==0) return f[tt][k]=tinh(tt,0);
        return f[tt][k]=kq;
    }
}
bool check(int tt,int i)
{
    return (tt>>i)&1;
}
int main()
{
   // freopen("seven.inp","r",stdin);
   // freopen("seven.out","w",stdout);
    cin>>q;
    while(q--)
    {
        memset(f,-1,sizeof(f));
        tt0=0;
        for(i=1;i<=6;i++)
        {
            cin>>x; x--;
            tt0+=(1<<x);
        }
      //  cerr<<check(8191-(1<<5),6);
       // cerr<<check(8191-(1<<5)-tt0,6)<<'\n';
        tt1=(1<<13)-1-(1<<6)-tt0;
       // cerr<<((tt1>>6)&1);
        if(tinh(1<<6,0)==1) cout<<"yes"<<'\n'; else cout<<"no"<<'\n';
    }
}



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

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

	vector<long long> a(n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	vector<long long> A(a);
	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());
	for (int i = 0; i < n; i++) a[i] = lower_bound(A.begin(), A.end(), a[i]) - A.begin();

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		if ((a[i] + i) % 2 != 0) {
			ans++;
		}
	}
	cout << ans / 2 << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")`  

int ans = 0;
int n, m, q;
vector<vector<int>> qq;

void check(vector<int> a) {
    int cur = 0;
    for (auto k : qq) {
        if (a[k[1]] - a[k[0]] == k[2]) {
            cur += k[3];
        }
    }
    ans = max(ans, cur);
}

void count(vector<int> a, int lft, int lst) {
    if (lft == 0) {
        check(a);
        return;
    }
    for (int i = lst; i <= m; i++) {
        a.pb(i);
        count(a, lft - 1, i);        
        a.pop_back();
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> q;
    qq = vector<vector<int>> (q, vector<int>(4, 0));
    for (int i = 0; i < q; i++) {
        for (int j = 0; j < 4; j++) {
            cin >> qq[i][j];
        }
        qq[i][0]--, qq[i][1]--;
    }
    count({}, n, 1);
    cout << ans;
}
/*

*/  

Measured memory_bytes: 3668
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static boolean solve() {
		int h = in.nextInt();
		int w = in.nextInt();
		if (h + w == 0) return false;

		char[][] table = new char[h][w];

		for (int i=0; i<h; i++) {
			table[i] = in.next().toCharArray();
		}

		boolean[][] f = new boolean[h][w];

		int ch = 0, cw = 0;
		while (true) {
			if (f[ch][cw]) {
				out.println("LOOP");
				return true;
			}

			f[ch][cw] = true;

			switch (table[ch][cw]) {
				case '>':
					cw++;
					break;
				case 'v':
					ch++;
					break;
				case '<':
					cw--;
					break;
				case '^':
					ch--;
					break;
				case '.':
					out.println(cw+" "+ch);
					return true;
			}
		}
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		while(solve());
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

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

int main () {
    int R, G, B, N;
    int ans = 0;
    cin >> R >> G >> B >> N;
    for (int i = 0; i <= N; i++) {
        if (R * i <= N) {
            for (int j = 0; j <= N; j++) {
                if (R * i + G * j <=N) {
                    if ((N - R * i - G * j ) % B == 0) {
                        ans++;
                    }
                }
                else {
                    break;
                }
            }
        }
        else {
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll a, b;
	cin >> a >> b;
	if (a*b == 15)cout << '*' << endl;
	else if (a + b == 15)cout << '+' << endl;
	else cout << 'x' << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int maxN = static_cast<const int>(1e5 + 10);

int fa[maxN], dis[maxN], N, M;

int find(int x) {
    if(x == fa[x]) {
        return x;
    }
    int temp = fa[x];
    fa[x] = find(temp);
    dis[x] = dis[x] + dis[temp];
    return fa[x];
}

bool merge(int x, int y, int d) {
    int fx = find(x), fy = find(y);
    if(fx == fy) {
        return dis[y] - dis[x] == d;
    } else {
        fa[fx] = fy;
        dis[fx] = dis[y] - dis[x] - d;
        return true;
    }
}


int main() {
#ifdef ACM_XYZHAO_TEST
    freopen("../test.in", "r", stdin);
//	freopen("../test.out", "w", stdout);
#endif

    scanf("%d %d", &N, &M);
    for (int i = 1; i <= N; ++i) {
        fa[i] = i;
        dis[i] = 0;
    }
    int l, r, d;

    bool flag = true;
    for (int i = 0; i < M; ++i) {
        scanf("%d %d %d", &l, &r, &d);
        if(flag && !merge(l, r, d)) {
            flag = false;
        }
    }

    printf("%s\n", flag ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

ll qmi(ll a, ll k){
	ll res = 1;
	while(k){
		if(k & 1){
			res = res * a % mod;
		}
		a = a * a % mod;
		k >>= 1;
	}
	return res;
}
int main(){
	int n;
	cin >> n;
	ll all = qmi(10, n);
	ll none = qmi(8, n); 
//	ll only = (qmi(9, n) - qmi(8, n) + 2 * mod) % mod;
	cout << (qmi(10ll, n) - qmi(9ll, n) - qmi(9ll, n) + qmi(8ll, n) + 4 * mod) % mod << endl;
}

Measured memory_bytes: 3624
N = int(input())
P = list(map(int,input().split()))
count = 1
 
if N > 0:
  min = P[0]
  
for i in range(1, N): 
  if min < P[i]:
    continue
  elif min >= P[i]:
    min = P[i]
    count += 1
    continue      
print(count)

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> v(N);
  
  int cnt=0;
  for(int i=0;i<N;i++){
    cin >> v[i];
    if(v[i]>=K){
      cnt++;
    }
  }
  cout << cnt <<endl;
}
  

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

int main(void) {
   char str[30];
   char year[11] = "2019/04/30";

   scanf("%s", str);
   if(strcmp(str, year) <= 0) {
      printf("%s\n", "Heisei");
   } else {
      printf("%s\n", "TBD");
   }


   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n,m;
  cin>>n>>m;
  int a[n];
  int sum=0;
  for(int i=0;i<n;i++) {
    cin>>a[i];
    sum+=a[i];
  }
  int st;
  if(sum%(4*m)==0) st=sum/(4*m)-1;
  else st=sum/(4*m);
  int ans=0;
  for(int i=0;i<n;i++){
    if(a[i]>st) ans++;
  }
  if(ans>=m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
def find_cycle_start(A, start=1):
    N = len(A)
    next_nodes = [a - 1 for a in A]
    start -= 1
    visited = [0 for _ in range(N)]
    node = start
    visited[node] = 1
    for _ in range(N):
        node = next_nodes[node]
        if visited[node] == 1:
            break
        visited[node] = 1
    return node + 1  # start of cycle


def main():
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    cycle_start = find_cycle_start(A)
    offset = list()
    a = 1
    while True:
        a = A[a - 1]
        if a == cycle_start:
            break
        offset.append(a)
    cycle = [cycle_start]
    period = 0
    for _ in range(N):
        a = A[a - 1]
        period += 1
        if a == cycle_start:
            break
        cycle.append(a)
    # calculate answer
    if K <= len(offset):
        print(offset[K - 1])
    else:
        rest = K - len(offset)
        print(cycle[(rest - 1) % period])


if __name__ == '__main__':
    main()

Measured memory_bytes: 32188
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll int p,q,r;
		cin>>p>>q>>r;
		cout<<p+q+r-max(p,max(q,r));
	}
	return 0;
}

Measured memory_bytes: 256
L = []
ans = 0
x,y = map(int,input().split())
for _ in range(10):
    l = list(map(int, input().split()))
    L.append(l)

def warshall_floyd(n,w,d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

d = [[float("inf") for i in range(10)] for i in range(10)] 
for i in range(10):
    for j in range(10): 
        d[i][j] = L[i][j]
for i in range(10):
    d[i][i] = 0 #
w =  warshall_floyd(10,10,d)
for _ in range(x):
    s = list(map(int, filter(lambda x:x!="-1",input().split())))
    for x in s:
     
        ans += w[x][1]
print(ans)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
struct answer {
  double water, suger;
  double dens;
};
int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  double all{0}, suger{0}, dens_max{E / (100.0 + E)};
  answer max; max.dens = -1.0;
  for (int i{0}; i * A * 100 <= F; ++i) {
    for (int j{0}; i * A * 100 + j * B * 100 <= F; ++j) {
      for (int m{0}; i * A * 100 + j * B * 100 + m * C <= F; ++m) {
        for (int n{0}; i * A * 100 + j * B * 100 + m * C + n * D <= F; ++n) {
          double water = i * A * 100 + j * B * 100;
          double suger = m * C + n * D;
          double dens = suger / (water + suger);
          if (dens > dens_max) break;
          if (max.dens < dens) {
            max.water = water;
            max.suger = suger;
            max.dens = dens;
          }
        }
      }
    }
  }

  cout << max.water + max.suger << " " << max.suger << "\n";
  return 0;
}


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

int N, K;
string S;

int main(){
  cin >> N >> K;
  cin >> S;
  int ans = 0;
  for(int i = 0; i < N - 1; i++){
    if(S[i] == S[i + 1]){
      ans++;
    }
  }
  ans = min(N - 1, ans + 2 * K);
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main() {
  // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string S;
  cin >> S;

  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
# frozen_string_literal: true

require 'set'

gets
arr = gets.split(' ').map(&:to_i)
cand = Set[0]
arr.each do |ai|
  togo = Set.new
  cand.each do |c|
    togo.add(c + ai) unless cand.include?(c + ai)
  end
  cand |= togo
end
gets
res = gets.split(' ').map(&:to_i)
puts res.map { |mi| cand.include?(mi) ? 'yes' : 'no' }.join("\n")



Measured memory_bytes: 7216
import java.io.PrintWriter
import java.math.BigDecimal
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val k = sc.nextInt()
    val n = sc.nextInt()
    val arr =Array(n){sc.nextInt()}
    println(abc160c(n,k,arr))
}

fun abc160c(n: Int, k: Int, arr: Array<Int>): Int{
    var maxDiff = 0
    if(arr[0] != 0){
        maxDiff = (k-arr[n-1]) + arr[0]
    }else{
        maxDiff = k - arr[n-1]
    }
    for(i in 0 until n - 1){
        val tmp = arr[i+1] - arr[i]
        if(tmp > maxDiff) maxDiff = tmp
    }
    return k - maxDiff
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define llint long long
int main() {
    int h,w,k;
    cin>>h>>w>>k;
    char s[h][w];
    rep(i,h){
        rep(j,w){
            cin>>s[i][j];
        }
    }

    int ans=1000000;

    for (int i=0;i<(1<<(h-1));i++){
        bitset<9> ss(i);

        vector<vector<int>> vec={};
        int index=0;
        int ans1=0;
        vec.push_back({0});
        for (int j=0;j<h-1;j++){
            if (ss.test(j)){
                index++;
                ans1++;
                vec.push_back({j+1});
            }
            else{
                vec[index].push_back(j+1);
            }
        }

        int b=1;//分割が条件を満たしうるか
        int b1=1;//横に進んで行くときにkを超えていないか

        vector<int> vv(index+1,0);
        vector<int> vs(index+1,0);

        for (int j=0;j<w;j++){
            for (int l=0;l<index+1;l++){
                int s1=0;
                for (int aa=0;aa<vec[l].size();aa++){
                    if (s[vec[l][aa]][j]=='1'){
                        s1+=1;
                    }
                }
                if (s1>k){
                    b=0;
                }
                else{
                    vv[l]+=s1;
                    vs[l]=s1;
                    if (vv[l]>k){
                        b1=0;
                    }
                }
            }
            if (b1==0){
                for (int l=0;l<index+1;l++){
                    vv[l]=vs[l];
                }
                ans1+=1;
                b1=1;
            }
        }
        if (b){
            ans=min(ans,ans1);
        }



    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define endl '\n'
#define mo 998244353
 
using namespace std ;
 
#define MAXN 305 

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

lld dp[MAXN][MAXN][MAXN];

int main()
{
//////////////////////////////////////

    lli n;
    cin>>n;

    lli c1=0,c2=0,c3=0;

    loopl(i,0,n)
    {
        lli x;
        cin>>x;

        if(x == 1) c1++;
        if(x == 2) c2++;
        if(x == 3) c3++;
    }

    loopl(k,0,MAXN)
    {
        loopl(j,0,MAXN)
        {
            loopl(i,0,MAXN)
            {
                if(i+j+k == 0) continue;
                if(i+j+k > n) continue ;

                lld pi = 1.0*i/(i+j+k) ;
                lld pj = 1.0*j/(i+j+k) ;
                lld pk = 1.0*k/(i+j+k) ;
                lld sum = 1.0*n/(i+j+k) ;

                if(i>0) sum+=pi*dp[i-1][j][k];
                if(j>0) sum+=pj*dp[i+1][j-1][k];
                if(k>0) sum+=pk*dp[i][j+1][k-1];

                dp[i][j][k] = sum ; 
            }

        }
    }

    cout<<fixed<<setprecision(12)<<dp[c1][c2][c3]<<endl;

}

Measured memory_bytes: 436480
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
typedef long double ld;
const ll inf = (1LL << 60);
const int MOD = 1000000007;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int n, m, k;
int main() {
    string s,t; cin >> s >> k;
    set<string> st; n = s.size();
    int a = min(n, k);
    req(i, a) {
        rep(j, n - i + 1) {
            t = s.substr(j, i);
            st.insert(t);
        }
    }auto it = st.begin();
    rep(i, k - 1) it++;
    cout << *it << endl;
}

Measured memory_bytes: 1664
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 111;
const int M = 11;

int n;
int k;
int v[N];
int mem[N][N][N];

int go(int l , int r , int stp){
    if(stp < 0)
        return -1e9;
    if(l > r || stp == 0)
        return 0;
    if(~mem[l][r][stp])
        return mem[l][r][stp];
    int ret = 0;
    int c1 , c2 , c3 , c4;
    c1 = go(l + 1 , r , stp - 1) + v[l];
    c2 = go(l , r - 1 , stp - 1) + v[r];
    c3 = go(l + 1 , r , stp - 2);
    c4 = go(l , r - 1 , stp - 2);
    return mem[l][r][stp] = max(0 , max(max(c1 , c2) , max(c3 , c4)));
}

int main(){
    scanf("%d%d" , &n , &k);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &v[i]);
    }
    memset(mem , -1 , sizeof mem);
    printf("%d\n" , max(go(1 , n , k) , 0));
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int dx[4]={0,-1,0,1};
const int dy[4]={-1,0,1,0};
int h,w;
int bfs(const vector<string> &s,int x,int y){
    vector<vector<int>> d(h,vector<int>(w,-INF));
    queue<P> q;
    q.push(make_pair(x,y));
    d[x][y] = 0;
    int ma=0;
    while(!q.empty()){
        int xi = q.front().first;
        int yi = q.front().second;
        q.pop();
        rep(i,4){
            int nx = xi + dx[i];
            int ny = yi + dy[i];
            if(nx>=0 && nx<h && ny>=0 && ny<w && d[nx][ny]==-INF &&s[nx][ny]=='.'){
                q.push(make_pair(nx,ny));
                d[nx][ny] = d[xi][yi] + 1;
                ma = max(ma,d[nx][ny]);
                //cout << d[nx][ny] << endl;
            }
        }
    }
    return d[h-1][w-1];
}

int main(){
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int black = 0;
    rep(i,h) rep(j,w) if(s[i][j]=='#') ++black;
    int road = bfs(s,0,0);
    if(road==-INF){
        cout << -1 << endl;
        return 0;
    }
    //cout << road << endl;
    int ans = h*w - black - road - 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;

int main(void){
  map<ll,ll> x;
  ll n,p;
  cin>>n>>p;
  ll a=p;
  for(ll i=2;i*i<=p&&a!=1;){
    if(a%i==0){
      a/=i;
      x[i]++;
    }
    else{
      i++;
    }
  }
  ll ans=1;
  if(a!=1) x[a]++;
  for(auto z:x){
    ll b=z.second/n;
    for(ll i=0;i<b;i++){
      ans*=z.first;
    }
  }
  cout<<ans<<endl;
}

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

int main(void){
	int n;
	unordered_set<int> s;
	for(int i = 0; i < 3; ++i){
		cin >> n;
		s.insert(n);
	}
	if(s.size() == 2){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int c[3], c1c2, e, i;

	while (scanf(" %d %d %d ", c, c+1, c+2) != EOF) {
		e = 0;
		c1c2 = c[0] + c[1];
		for (i = 1; i < 11; i++) {
			if (i != c[0] && i != c[1] && i != c[2]) {
				e += i + c1c2 <= 20;
			}
		}
		puts(e > 3 ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<vector<int> >wr(n,vector<int> (3));
	for (int i = 0; i < n; i++) {
		cin >> wr[i][0] >> wr[i][1] >> wr[i][2];
	}
	for (int i = 0; i < n; i++) {
		int ans = 0;
		for (int j = 0; j < 3; j++) {
			int uni = 0;
			for (int k = 0; k < n; k++) {
				if (wr[k][j] == wr[i][j]) {
					uni++;
				}
			}
			if (uni == 1) {
				ans += wr[i][j];
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3172
#include<stdio.h>
int main(){
  int i,j;
  int c[3][3];
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&c[j][i]);
    }
  }
  int flag=0;
  int a[3];
  int b[3];
  a[0]=0;
  b[0]=c[0][0]-a[0];
  b[1]=c[0][1]-a[0];
  b[2]=c[0][2]-a[0];
  a[1]=c[1][0]-b[0];
  a[2]=c[2][0]-b[0];
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      if(c[j][i]!=a[j]+b[i]){
        flag=1;
        break;
      }
    }
  }
  if(flag==0){
    printf("Yes");
  }
  else {
    printf("No");
  }
}



Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 1000
using namespace std;
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  if (abs(a - b) % 2 == 1) {
    cout << "Borys" << endl;
  } else {
    cout << "Alice" << endl;
  }
  return 0;
}


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

main(){
	int N,A,B,C,X ;
	
	while( cin>>N>>A>>B>>C>>X , N ){
		int Y[N] ;
		for( int i=0 ; i<N ; i++ ) cin >> Y[i] ;
		
		int cnt=0 ;
		for( int i=0 ; i<=10001 ; i++ ){
			if( i == 10001 ){
				cout << -1 << endl ;
				break ;
			}
			if( Y[cnt] == X ){
				if( cnt+1 == N ){
					cout << i << endl ;
					break ;
				}
				else cnt++ ;
			}
			
			X = (A*X+B)%C ;
		}
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<long> a(n);
	for (int z = 0; z < n; z++) {
		cin >> a[z];
	}
	sort(a.begin(), a.end());
	cout << a[0] << ' ' << a[n - 1] << ' ' << accumulate(a.begin(), a.end(), 0L) << endl;
}


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

const int INF = 1001001001;

int main(){
  int n;
  cin >> n;
  vector<tuple<int,int,int>> csf(n-1);
  for(int i=0;i<n-1;i++){
    int val; cin >> val;
    get<0>(csf.at(i)) = val;
    cin >> val;
    get<1>(csf.at(i)) = val;
     cin >> val;
    get<2>(csf.at(i)) = val;
  }
  for(int i=0;i<n-1;i++){
    //iは出発駅
    int time = get<0>(csf.at(i)) + get<1>(csf.at(i));
    for(int j=i+1;j<n-1;j++){
      if(time>=get<1>(csf.at(j))){
        if(time%get<2>(csf.at(j)) != 0){
          time += get<2>(csf.at(j)) - (time%(get<2>(csf.at(j))));
        }
      }else{
        time = get<1>(csf.at(j));
      }
      time += get<0>(csf.at(j));
    }
    cout << time << endl;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
#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>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
        a[i] -= i+1;
    }
    sort(a.begin(), a.end());
    int c = 0;
    if (n%2 == 1) c = a[n/2];
    else c = (a[n/2]+a[n/2-1])/2;
    ll ans = 0;
    rep(i,n) {
        ans += abs(a[i]-c);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, t;
  cin >> n >> t;

  ll ans = 0;
  int bef;
  cin >> bef;
  rep(i, 0, n - 1) {
    int x;
    cin >> x;
    ans += min(t, x - bef);
    bef = x;
  }
  ans += t;
  cout << ans << endl;
}


Measured memory_bytes: 256
use proconio::input;
use std::cmp;

fn main() {
    input! {
        n: usize,
        t: usize,
        mut foods: [(usize, usize); n],
    }

    foods.sort_by(|a, b| b.cmp(a));
    let max_n = n + 1;
    let max_h = 6001;

    let mut dp = vec![vec![0; max_h]; max_n];

    for i in (0..n).rev() {
        for j in 0..max_h {
            if j < foods[i].0 {
                dp[i][j] = dp[i+1][j];
            } else {
                if j - foods[i].0 <= t - 1 {
                    dp[i][j] = cmp::max(dp[i + 1][j], dp[i + 1][j - foods[i].0] + foods[i].1);
                } else {
                    dp[i][j] = dp[i+1][j];
                }
            }
        }
    }

    let mut ans = 0;
    for j in 0..max_h {
        ans = cmp::max(ans, dp[0][j]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 142992
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
using namespace std;

int GCD(int a, int b){
	while(1){
		if(a<b){
			swap(a,b);
		} 
		a=a%b;
		if(a==0){
			return b;
		}
	}
}

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

	int a,b;
	cin >> a ;
	for(int i=1;i<n;i++){
		cin >> b;
		a = a*b/GCD(a,b); 
	}
	cout << a <<endl;

	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#define maxn 100005
#define N 26
int n,cnt[maxn][N+5],l=-1,r=-1;
char s[maxn];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=2;i<=n;i++)
	{
		if(s[i]==s[i-1])
		{
			printf("%d %d\n",i-1,i);
			return 0;
		}
		else if(i>2&&s[i]==s[i-2])
		{
			printf("%d %d\n",i-2,i);
			return 0;
		}
	}
	printf("-1 -1\n");
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
const ll maxSum = 50*50+1;
int main() {
    ll x, y;
    cin >> x >> y;
    bool w = true;
    int cou = 1;
    ll now = x;
    while(w) {
        if(now * 2 <= y) {
            cou++; 
            now *= 2;
        }
        else w = false;
    }
    cout << cou << endl;
 
    return 0;
}

Measured memory_bytes: 3636
n=int(input())
list=list(map(int, input().split()))
def pair(parameter):
        pairedList = []
        for iterater1 in range(len(parameter)):
                for iterater2 in range(iterater1+1,len(parameter)):
                        pairedList.append([parameter[iterater1],parameter[iterater2]])
        return pairedList

pairings = pair(list)
count=0
add=0
for i in pairings:
    x=i[0]*i[1]
    add+=x
print(add)


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


#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

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

int	main() {
	int X;
	cin >>X;
	while(!isPrime(X))
		X++;
	cout <<X <<endl;
	return 0;
}



Measured memory_bytes: 256