akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = x2 - x1;
  int dy = y2 - y1;

  int x3 = x2 - dy;
  int y3 = y2 + dx;

  int x4 = x1 -dy;
  int y4 = y1 + dx;
  cout << x3 << " " << flush;
  cout << y3 << " " << flush;
  cout << x4 << " " << flush; 
  cout << y4 << " " << flush;
   return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var T = D.Sum();
		T *= T;
		var d = D.Select(v => v * v).Sum();
		Console.WriteLine((T - d) / 2);
	}
	int N;
	long[] D;
	public Sol(){
		N = ri();
		D = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;
 
ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int main()
{
    int a,b,c,d,e,f;
    int i1,i2,i3,i4,tot,sug;
    cin>>a>>b>>c>>d>>e>>f;
    a*=100;
    b*=100;
    tot=a;
    sug=0;
    for(i1=0;i1<=100;i1++)for(i2=0;i2<=100;i2++)for(i3=0;i3<=100;i3++)for(i4=0;i4<=100;i4++){
        int totwat=i1*a+i2*b;
        int totsug=i3*c+i4*d;
        if(totwat+totsug<=f){
            if(totsug*100<=totwat*e){
                if(sug*(totsug+totwat)<=tot*totsug){
                    sug=totsug;
                    tot=totwat+totsug;
                }
            }
        }
    }
    cout<<tot<<" "<<sug<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define em3 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define EPS 1e-7
long long mod = 1e9 +7;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double pi = acos(-1);
typedef complex <double> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
string s1, s2;
ll len, memo[3005][3005] ;
ll solve(int i, int j)
{
    if(i >= s1.size() || j >= s2.size())
        return 0;
    if(s1[i] == s2[j])
        memo[i][j] = solve(i + 1, j + 1) + 1;
    else
    {
        ll ans = 0;
        if(memo[i][j] != -1)
            return memo[i][j];
        else
        {
            ans = max(ans, solve(i , j + 1));
            ans = max(ans, solve(i + 1 , j));
            memo[i][j] = ans;
            return ans;
        }
    }
}
void build(int i, int j)
{
    if(i >= s1.size() || j >= s2.size())
        return;
    if(s1[i] == s2[j])
    {
        cout << s1[i];
        build(i + 1, j + 1);
    }
    else
    {
        if(memo[i][j] == solve(i , j + 1))
            build(i , j + 1);
        else
            build(i + 1 , j);
    }


}
int main()
{
    em3
    memset(memo, -1, sizeof memo);
    cin >> s1 >> s2;
    ll y = solve(0, 0);
    build( 0 , 0 );
    return 0;
}



Measured memory_bytes: 71168
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string t;
    string s;
    cin>>s;
    cin>>t;
    rep(i,s.length()-t.length()+1){
        sum=0;
        for(ll j=0;j<t.length();j++){
            if(s[i+j]!=t[j]) sum++;
        }
        mini=min(mini,sum);
        
    }
    cout<<mini<<endl;
    
    return 0;
}


Measured memory_bytes: 3656
while True:
    x=int(input())
    if x==0:
        break
    a=[]
    for i in range(x):
        a.append(int(input()))
    A=max(a)
    B=min(a)
    C=sum(a)
    D=len(a)
    E=C-A-B
    F=D-2
    print(E//F)


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

int main() { 
    ll N, M, X;
    cin >> N >> M >> X;
    vector<ll> C(N);
    vector<vector<ll>> A(N, vector<ll>(M, 0));
    for (int i = 0; i<N; ++i){
      cin >> C[i];
      for (int j = 0; j < M; j++) cin >> A[i][j];
    }

    bool no = true;
    ll cost_min = 9223372036854775807;

    for (int bit = 0; bit < (1 << N); ++bit) {
      vector<ll> total(M, 0);
      ll cost = 0;
      for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
          for (int j = 0; j < M; j++){
            total[j] += A[i][j];
          }
          cost += C[i];
        }
      }
      bool check = true;
      for (int j = 0; j < M; ++j) {
        if (total[j] < X) check = false;
      }
      if (check) {
        cost_min = min(cost_min, cost);
        no = false;
      }
    }

    if(no) cout << -1 << endl;
    else cout << cost_min << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <map>
#include <string>

using namespace std;
using ll = long long;

void solve() {
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x-a) < abs(x-b)){
        cout << "A" << endl;
    }else{
        cout << "B" <<endl;
    }

}

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

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

int main(){
  int x,n;
  cin >> x >> n;
  vector<int> str(n);
  for(int i=0;i<n;i++){
    int p;
    cin >> p;
    str.at(i)=p;
  }
  for(int i=0;i<n+1;i++){
    int a,b;
    a=x+i;
    b=x-i;
    int acount=0,bcount=0;
    for(int j=0;j<n;j++){
      if(a==str.at(j))
        acount++;
      if(b==str.at(j))
        bcount++;
    }
    if(bcount==0){
      cout << b << endl;
      break;
    }
    else if(acount==0){
      cout << a << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

bool istriangle(int a, int b, int c) {
	int A = max({ a,b,c });
	int B = min({ a,b,c });
	int C = a + b + c - A - B;
	if (A == B || B == C || C == A) return false;
	if (B + C > A) return true;
	else return false;
}

int main() {
	int N;
	cin >> N;
	vector<int> L(N);
	Rep(i, N) cin >> L[i];
	int ans = 0;
	for (int i = 0; i < N - 2; i++) {
		for (int j = i + 1; j < N - 1; j++) {
			for (int k = j + 1; k < N; k++) {
				if(istriangle(L[i], L[j], L[k])) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
// Example program
#include <bits/stdc++.h>

using namespace std;

int main()
{
  int n;
  cin >> n;
  
  int peeps[n];
  for (int i = 0; i < n; i++) {
    cin >> peeps[i];
  }
  long sum = 0;
  
  int last = peeps[0];
  for (int i = 1; i < n; i++) {
      if (peeps[i] < last) {
          sum += abs(peeps[i] - last);
          peeps[i] = last;
      }
      last = peeps[i];
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 4416
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    string S;
    cin >> S;
    vector<int> vec(S.size()), index(S.size());
    int num, numR=0, numL;

    for (int i = 0; i < S.size(); i++)
    {
        num = i;
        if (S[i] == 'L')
        {
            index.at(i) = numR;
        }
        else
        {
            numR = i;
        }
    }

    for (int i = S.size()-1; i > -1; i--)
    {
        num = i;
        if (S[i] == 'R')
        {
            index.at(i) = numL;
        }
        else{
            numL = i;
        }
    }

    for (int i = 0; i < index.size(); i++)
    {
        if ((index.at(i) - i) % 2 == 0)
        {
            vec[index.at(i)]++;
        }
        else
        {
            if (S.at(i) == 'L')
            {
                vec[index.at(i) + 1]++;
            }
            else
            {
                vec[index.at(i) - 1]++;
            }
        }
    }

    for(int i=0;i<index.size();i++){
        if (i)
            cout << " ";
        cout << vec[i];
    }
    cout << endl;
}

Measured memory_bytes: 1408
def main():
    N, K = map(int, input().split())
    D = list(input().split())

    i = 0
    while True:
        S = str(N)
        f = True
        for s in S:
            if s in D:
                f = False
                break
        if f:
            break
        N += 1
    print(N)
    
if __name__ == "__main__":
    main()

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

int main() {
    ll N,K;cin >> N >> K;
    ll A[N] = {};
    for (int i = 0;i < N;i++){
        cin >> A[i];
        A[i]--;
    }
    ll B[N] = {};ll C[N] = {};ll D[N] = {};
    ll cur = 0;ll time = 0;ll cyc = 0;ll cycnum = 0;
    while(time < K){
        B[cur]++;
        if (B[cur] == 2) {
            cyc++;
            C[cycnum] = cur;
            D[cycnum] = time;
            cycnum++;
        }
        if (B[cur] == 3) break;
        time++;
        cur = A[cur];
        if (time == K){
            cout << cur + 1<< endl;
            return 0;
        }
    }
    ll X = K % cyc;
    for (int i = 0;i < cyc;i++){
        D[i] %= cyc;
        if (X == D[i]){
            cout << C[i] + 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 9876
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  int k,n; cin>>k>>n;
  vector<int> a(n);
  for(int &i:a)
    cin>>i;
  vector<int> dis(n);
  
  dis[0]=a[0]+k-a[n-1];
  for(int i=1;i<n;i++)
    dis[i]=a[i]-a[i-1];
  
  sort(dis.rbegin(),dis.rend());
  
  cout<<k-dis[0]<<endl;
}

Measured memory_bytes: 6428
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int maxW = sc.nextInt();
		int weight[] = new int[num];
		int value[] = new int[num];
		for(int i = 0; i < num; i ++) {
			weight[i] = sc.nextInt();
			value[i] = sc.nextInt();
		}

		int maxValue = 0;
		for(int i = 0; i < num; i ++) {
			maxValue += value[i];
		}

		long dpWeight[][] = new long[num + 1][maxValue + 1];
		long dpMin[][] = new long[num + 1][maxValue + 1];

		for(int j = 0; j <= maxValue; j ++) {
			dpWeight[0][j] = Long.MAX_VALUE;
			dpMin[0][j] = Long.MAX_VALUE;
		}
		for(int i = 0; i <= num; i ++) {
			dpWeight[i][0] = 0;
			dpMin[i][0] = 0;
		}

		for(int j = 1; j <= maxValue; j ++) {
			long min2 = Long.MAX_VALUE;
			for(int i = 1; i <= num; i ++) {
				min2 = Math.min(min2, dpWeight[i - 1][j]);
				dpMin[i][j] = min2;
				if(j - value[i - 1] < 0) {
					dpWeight[i][j] = min2;
				}else {
					long min = dpMin[i][j - value[i - 1]];
					if(min == Long.MAX_VALUE) {
						dpWeight[i][j] = min2;
					}else {
						dpWeight[i][j] = Math.min(min + weight[i - 1], min2);
					}
				}
			}
		}

		long max = 0;
		for(int i = 0; i <= num; i ++) {
			for(int j = maxValue; j >= 0; j --) {
				if(dpWeight[i][j] <= maxW) {
					max = j;
					break;
				}
			}
		}
		
		System.out.println(max);
	}
}

Measured memory_bytes: 242900
#include<iostream>
#include<cstdio>
#include<cmath>
#define ll long long
using namespace std;
ll x,y;
int main()
{
	scanf("%lld%lld",&x,&y);
	for(ll i=0;i<100;i++)
	{
		ll temp = pow(2,i-1)*x;
		if(temp > y)
		{
			printf("%lld\n",i-1);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
long long extGCD(long long a,long long mod,long long &x,long long &y){
    if(mod==0){
        x=1;
        y=0;
        return a;
    }
    long long d=extGCD(mod,a%mod,y,x);
    y-=(a/mod)*x;
    return d;
}
long long invmod(long long a,long long mod){
    long long x,y;
    extGCD(a,mod,x,y);
    x%=mod;
    if(x<0)x+=mod;
    return x;
}
ll fac[2000010],finv[2000010],inv[2000010];
void combinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    REP(i,2,2000010){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=invmod(i,mod);
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(){
    combinit();
    ll x,y;cin>>x>>y;
    if((x+y)%3==0&&x<=(x+y)*2/3&&y<=(x+y)*2/3){
        ll ans=comb((x+y)/3,x-(x+y)/3)%inf;
        if(ans<0)ans+=inf;
        cout<<ans<<endl;
    }
    else cout<<0<<endl;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
 
const ll MOD=1e9+7;
const ll INF=1e18;
 
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};


int par[110];//親
int rank2[110];//木の深さ

void init(int n){
  for(int i = 0;i < n;i++){
    par[i] = i;
    rank2[i] = 0;
  }
}

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

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return;
  
  if(rank2[x] < rank2[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank2[x] == rank2[y])rank2[x]++;
  }
}

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




int h,w,c;
int p[12][12];
int ban[7];

int main(){
    while(true){
        cin >> h >> w >> c;
        if(h + w + c == 0)break;
        for(int i = 1;i <= h;i++){
            for(int j = 1;j <= w;j++){
                cin >> p[i][j];
            }
        }
        for(int j = 0;j <= w+1;j++){
            p[0][j] = -1;
            p[h+1][j] = -1;
        }
        for(int i = 0;i <= h+1;i++){
            p[i][0] = -1;
            p[i][w+1] = -1;
        }
        int ans = 0;
        for(int n = 11111;n <= 66666;n++){
            int maxban = -1;
            int div = 1;
            for(int i = 1;i <= 5;i++){
                ban[i] = (n / div) % 10;
                maxban = max(maxban,ban[i]);
                div *= 10;
            }
            if(maxban >= 7)continue;
            init(80);

            int tmpans = 0;
            queue<P> que;
            que.push(P(1,1));
            tmpans++;
            while(!que.empty()){
                P q = que.front(); que.pop();
                for(int k = 0;k < 4;k++){
                    int ni = q.fs + dy[k],nj = q.sc + dx[k];
                    if(p[ni][nj] == p[1][1] && same(1,w*(ni-1)+nj) == false){
                        tmpans++;
                        unite(1,w*(ni-1)+nj);
                        que.push(P(ni,nj));
                    }
                }
            }

            for(int l = 1;l <= 5;l++){
                for(int i = 1;i <= h;i++){
                    for(int j = 1;j <= w;j++){
                        if(same(1,w*(i-1)+j)){
                            que.push(P(i,j));
                        }
                    }
                }
                while(!que.empty()){
                  P q = que.front(); que.pop();
                  for(int k = 0;k < 4;k++){
                    int ni = q.fs + dy[k],nj = q.sc + dx[k];
                    if(p[ni][nj] == ban[l] && same(1,w*(ni-1)+nj) == false){
                      tmpans++;
                      unite(1,w*(ni-1)+nj);
                      que.push(P(ni,nj));
                    }
                  }
                }
            }
            if(ban[5] == c){
              ans = max(ans,tmpans);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3048
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Pair = Tuple!(long, "x", int, "i");

void main() {
    int k;
    scan(k);
    auto a = readln.split.to!(long[]);

    long low = 2, high = 2;

    foreach_reverse (i ; 0 .. k) {
        low = ((low + a[i] - 1) / a[i]) * a[i];
        high = (high / a[i]) * a[i] + a[i] - 1;
        debug {
            writefln("low: %d, high: %d", low, high);
        }
    }

    if (low > high) {
        writeln(-1);
        return;
    }

    writeln(low, " ", high);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 4516
def main():
  M=10**9+7
  r1,c1,r2,c2=map(int,input().split())
  n=r2+c2+2
  val=1
  fac=[val]
  append=fac.append
  for i in range(1,n+1):
    val=val*i%M
    append(val)
  pr1=pow(fac[r1],M-2,M)
  pc1=pow(fac[c1],M-2,M)
  pr2=pow(fac[r2+1],M-2,M)
  pc2=pow(fac[c2+1],M-2,M)
  a=fac[r2+c2+2]*pr2*pc2
  a-=fac[r2+c1+1]*pr2*pc1
  a-=fac[r1+c2+1]*pr1*pc2
  a+=fac[r1+c1]*pr1*pc1
  print(a%M)
main()

Measured memory_bytes: 82220
last = {}
until gets.chomp == ''
    last[$_.chomp.split(',')[0]] = (last[$_.chomp.split(',')[0]].nil?)?1:(last[$_.chomp.split(',')[0]]+1)
end

this = {}
while gets
    this[$_.chomp.split(',')[0]] = (this[$_.chomp.split(',')[0]].nil?)?1:(this[$_.chomp.split(',')[0]]+1)
end

last.merge(this){|key, old, new| old + new}.select{|key,val| last.key?(key) && this.key?(key)}.to_a.sort{|x,y|x[0].to_i<=>y[0].to_i}.each { |x| puts x*' ' }

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

using namespace std;

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

    int n;
    cin >> n;
    
    vector<int> h(n);
    for(int i=0; i<n; ++i)
    {
        cin >> h[i];
    }
    
    vector<int> dp(n,0);
    dp[1] = abs(h[1]-h[0]);
    
    for(int i=2; i<n; ++i)
    {
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }

    cout <<  dp[n-1];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
//////////

void solve(){
  ini(N);
  V<string> S(N);
  V<ll> T(N);
  rep(i , N) in(S[i] , T[i]);
  ins(X);
  int idx = 0;
  while(S[idx] != X) idx++;
  ll ans = 0;
  idx++;
  while(idx != N)  {
    ans += T[idx];
    idx++;
  }
  out(ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int mod = 100000;
const int N = 100010;
int sum[N];

main(){
  int n,m;
  while(cin>>n>>m && n){
    sum[1] = 0;
    for(int i=2;i<n+1;i++){
      int tmp;
      cin>>tmp;
      sum[i] = sum[i-1] + tmp;
    }
    int ans = 0;
    int pos = 1;
    for(int i=0;i<m;i++){
      int a;
      cin>>a;
      a += pos;
      int l = min(a,pos),r = max(a,pos);
      ans = (ans+sum[r]-sum[l]);
      ans %= mod;
      pos = a;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){
	int A,B;
	int C = 1;
	int D = 2;
	int E = 3;
	scanf ("%d %d",&A,&B);
	if (A==1 && B== 2){
		printf ("%d\n",E);
	}
	else if (A==2 && B==3){
		printf ("%d\n",C);
	}
	else if (A==1 && B==3){
		printf ("%d\n",D);
	}
	else if (A==2 && B==1){
		printf ("%d\n",E);
	}
	else if (A==3 && B==1){
		printf ("%d\n",D);
	}
	else if (A==3 && B==2){
		printf ("%d\n",C);
	}
	return 0;
}

Measured memory_bytes: 2096
#pragma comment(linker, "/stack:200000000")
       #pragma GCC optimize ("Ofast")
        #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
         
         
        #include <iostream>
        #include <iomanip>
        #include <sstream>
        #include <cstring>
        #include <vector>
        #include <deque>
        #include <queue>
        #include <set>
        #include <map>
        #include <valarray>
        #include <iterator>
        #include <functional>
        #include <limits>
        #include <algorithm>
        #include <numeric>
        #include <cmath>
        #include <cassert>
        #include <unordered_map>
        #include <stack>
        using namespace std;
        #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
         #define trace(x) cerr << #x << ": " << x << " " << endl;
     
        typedef int64_t ll;
     
        #define endl '\n'
        #define int ll
        ll mod=1e9+7;
        ll mod1=1e9+5;
        ll power(ll a,ll b)
        {
            if(b==0) return 1;
            else if(b%2==0)
                return power((((a%mod)*(a%mod))%mod),b/2)%mod;
            else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
        }
        
          
        
        
        int32_t main()
        {
            IOS
           
             
            
            int n,k;
            cin>>n>>k;
            int count=0;
            for(int i=0;i<n;++i)
            {
                int a;
                cin>>a;
                if(a>=k)
                    count++;
            }
            cout<<count;
        }

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    int n;  cin >> n;
    int u[n],d[n];
    rep(i,n){
        cin >> u[i];
    }
    rep(i, n){
        cin >> d[i];
    }

    int ans(0);
    rep(i,n){
        int sum(0);
        bool isUp(true);
        rep(j,n){
            if(isUp){
                if(i==j){
                    isUp = false;
                    sum += u[j]+d[j];
                }else{
                    sum += u[j];
                }
            }else{
                sum += d[j];
            }
        }
        ans = max(ans,sum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
using System;
using System.Linq;
using System.Numerics;

namespace d
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = BigInteger.Parse(Console.ReadLine());
            var sum = (1 + n) * n / 2;
            Console.WriteLine(sum - n);
        }
    }
}


Measured memory_bytes: 13524
#include<stdio.h>
#define MAX_NUM 50
void swap(int *a, int *b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}
void insertion_sort(int num, int array[]){
  int i=0, j=0;
  for(i=1; i<num; i++){
    j=i;
    while(j>0 && array[j-1]>array[j]){
      swap(&array[j-1], &array[j]);
      j--;
    }
  }
}

int main(){
      int i=0, num, array[MAX_NUM];
      double sum = 0, result;

      scanf("%d", &num);

      for(i=0; i<num; i++){
        if(i==num-1)scanf("%d", &array[i]);
        else{
          scanf("%d ", &array[i]);
        }
      }

      insertion_sort(num, array);

      for(i=0;i<num;i++){
          sum  = result+(double)array[i];

          if(i!=0)result = sum/2;
          else{result = sum;}

      }
      printf("%f", result);

      return 0;

  }


Measured memory_bytes: 128
#include <stdio.h>
void insertionSort(int [],int);
void printArray(int [],int );
int main(){
  int i,j,A[100],n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  printArray(A,n);
  insertionSort(A,n);

  return 0;
}


  void insertionSort(int A[],int N){
    int i,j,v;
    for(i=1;i<N;i++){
      v=A[i];
      j=i-1;
      while(j>=0 && A[j]>v){
        A[j+1]=A[j];
        A[j]=v;
        j--;
      }
      printArray(A,N);
  }
}

void printArray(int A[],int N){
  int i;
  for(i=0;i<N;i++){
    if(i)printf(" ");
    printf("%d",A[i]);
  }
printf("\n");
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long int

void solve(ll caseNo)
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int l, r;
    l = 0;
    r = n-1;
    int ans = 0;
    while(l < r)
    {
        if(s[l] == 'R')
        {
            l++;
            continue;
        }
        else
        {
            while(l<r && s[r]=='W') r--;
            if(l==r)    break;
            ans++;
            l++;
            r--;
            continue;
        }
    }
    cout << ans << endl;
    return;
}

int main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll cases;
    cases = 1;
    for(ll i=1;i<=cases;i++)
    {
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N,K;
  cin>>N>>K;
  cout<<N-K+1<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int num,flag=0;
    double tall,weight;
    while(scanf("%d,%lf,%lf",&num,&weight,&tall)!=EOF){
        if(weight/(tall*tall)>=25){cout<<num<<endl;flag=1;}
    }
    if(flag==0)cout<<"該当なし"<<endl;
    return 0;
}

Measured memory_bytes: 1232
S = input()
T = input()
s_dict = {}
for s in S:
    if s in s_dict:
        s_dict[s] += 1
    else:
        s_dict[s] = 1
t_dict = {}
for t in T:
    if t in t_dict:
        t_dict[t] += 1
    else:
        t_dict[t] = 1

ss = list(s_dict.values())
ss.sort()
#ss = list(s_dict.values()).sort()
tt = list(t_dict.values())
tt.sort()
# print(ss)
# print(tt)
if ss == tt:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3632
//Author : Sidiq Tri Pratikto
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
//order_of_key(x) = number of elements stricly smaller than x
//find_by_order(x) = return x-th largest element
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);
LL dp[2001][2001];
int N;
vector<pair<int, int> > v;

LL rek(int idx, int l) {
	if (idx == N) return 0;
	if (dp[idx][l] == -1) {
		int kiri = l + 1, kanan = N - (idx - l);
		dp[idx][l] = max(rek(idx + 1, l + 1) + (LL)v[idx].fi * abs(v[idx].se - kiri), 
			rek(idx + 1, l) + (LL)v[idx].fi * abs(v[idx].se - kanan));
	}
	return dp[idx][l];
}

bool cmp(pair<int, int> a, pair<int, int> b) {
	return a.fi > b.fi;
}

int main() {
	memset(dp, -1, sizeof dp);
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		int x;
		scanf("%d", &x);
		v.pb(mp(x, i));
	}
	sort (all(v), cmp);
	LL ans = rek(0, 0);
	printf("%lld\n", ans);
}

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

using namespace std;

typedef long long LL;

const int N = 1010;

int n, m;
int x[N], y[N];

int main()
{
    cin >> n >> m;
    cin >> x[0] >> y[0];

    for(int i = 1; i <= n; i++) cin >> x[i];
    for(int i = 1; i <= m; i++) cin >> y[i];

    int miny = 0x3f3f3f3f, maxx = -0x3f3f3f3f;
    for(int i = 0; i <= n; i++)
        if(x[i] > maxx)
            maxx = x[i];

    for(int i = 0; i <= m; i++)
        if(y[i] < miny)
            miny = y[i];

    if(miny > maxx) puts("No War");
    else puts("War");

    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
def f(c):
  if a%c!=0:
    if B>=(c-a%c)+a:
      l=(c-a%c)+a
    else:
      l=B+c
  else:
    l=a
  return(1+(B-l)//c)
  
  

a,B,c,d=map(int,input().split())
print(B-a+1-(f(c)+f(d)-f(c*d//gcd(c,d))))

Measured memory_bytes: 5048
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;

bool a[4][100100];
int main(){
  int N;
  string s;
  cin >> N;
  cin >> s;
  //true yagi
  //false ookami
  a[0][0] = false;
  a[0][1] = false;
  a[1][0] = false;
  a[1][1] = true;
  a[2][0] = true;
  a[2][1] = false;
  a[3][0] = true;
  a[3][1] = true;
  s += s;

  for(int k=0;k<4;k++){
    for(int i=1;i<=N;i++){
      if(a[k][i]){//i banme ga yagi
        if(s[i] == 'o'){
          a[k][i+1] = a[k][i-1];
        }
        else{
          a[k][i+1] = !a[k][i-1];
        }
      }
      else{
        if(s[i] == 'o'){
          a[k][i+1] = !a[k][i-1];
        }
        else{
          a[k][i+1] = a[k][i-1];
        }
      }
    }
    if(a[k][0] == a[k][N] && a[k][1] == a[k][N+1]){
      for(int i=0;i<N;i++){
        if(a[k][i]){
          cout << 'S';
        }
        else{
          cout << 'W';
        }
      }
      cout << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
}


Measured memory_bytes: 936
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

int main(void) {
    string n;
    
    cin >> n;
    
    int i = 0;
    int counter = 0;
    int current_max = 0;
    
    while (n[i]) {
        counter = 0;
        while(n[i] == 'A' || n[i] == 'C' || n[i] == 'G' || n[i] == 'T') {
            counter++;
            i++;
        }
        if (counter > current_max) {
            current_max = counter;
        }
        i++;
    }
    cout << current_max << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

char str[1200];
	int c, i;
	i = 0;
	char t;
	int number[26] = { 0 };

	while (	scanf("%c", &str[i])!=EOF) {
		c = 0;
	

		if ('a' <= str[i] && str[i] <= 'z') {
			c = str[i] - 'a';
			number[c] += 1;
		}
		else if ('A' <= str[i] && str[i] <= 'Z') {
			c = str[i] - 'A';
			number[c] += 1;
		}
		i++;
	}

	for (i = 0, t = 'a'; i<26; i++, t++) {
		printf("%c : %d\n", t, number[i]);
	}


return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    // 解説みた
    // いじらないの決めて, 残りはうまい順で両端に動かす
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    int b[n];
    rep(i, n) {
        b[a[i] - 1] = i;
    }
    int mmax = 1, cnt = 1;
    rep3(i, 1, n) {
        if (b[i] > b[i - 1]) { cnt++; chmax(mmax, cnt); }
        else cnt = 1;
    }
    chmax(mmax, cnt);
    cout << n - mmax << endl;
}


Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    private int N = (int) (1e5 + 1);
    //private int[] stones = new int[N];
    private static List<Integer> stones = new ArrayList<>();
    private static int n;
    private static Scanner input = new Scanner(System.in);

    public static void main(String[] args) {
        n = input.nextInt();
        for (int i = 0; i < n; i++) {
            stones.add(input.nextInt());
        }
        int[] alreadyComputed = new int[n];
        for (int i = 0; i < n; i++) {
            alreadyComputed[i] = -1;
        }
        System.out.println(solution(stones, n - 1, alreadyComputed));
    }

    public static int solution(List<Integer> stones, int n, int[] alreadyComputed) {
        if (n == 0) {
            return 0;
        }
        if (alreadyComputed[n] != -1) {
            return alreadyComputed[n];
        }
        int poss1 = solution(stones, n - 1, alreadyComputed) + Math.abs(stones.get(n) - stones.get(n - 1));
        int poss2;
        if (n-2 < 0) {
            poss2 = (int)(1e9 + 7);
        } else {
            poss2 = solution(stones, n - 2, alreadyComputed) + Math.abs(stones.get(n) - stones.get(n - 2));
        }
        alreadyComputed[n] = Math.min(poss1, poss2);
        return alreadyComputed[n];
    }
}


Measured memory_bytes: 72208
l = [int(input()) for _ in range(5)]
mod = 10
sm = 0
for i in l:
    if i % 10 != 0:
        mod = min(mod, i % 10)
    sm += -10*(-i//10)
if mod == 10:
    mod = 0
else:
    sm -= 10
print(mod+sm)

Measured memory_bytes: 2940
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

a = 0
b = 0

for i, x in enumerate(itertools.permutations(range(1, N+1))):
    if x == P:
        a = i
    if x == Q:
        b = i

print(abs(a-b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

Int f(Int l[], bool used[], Int n, Int sum, Int x[3], Int k) {
    if (k == 3) return sum;
    Int res = 1e9;
    bool use[10] = {};
    for (Int bit = 0; bit < (1<<n); bit++) {
        for (Int i = 0; i < n; i++) use[i] = used[i];
        Int cnt = 0;
        Int mi = 0;
        for(Int i = 0; i < n; i++) {
            if (!use[i] && (bit & (1<<i))) {
                cnt++;
                mi += l[i];
                use[i] = true;
            }
        }
        if (cnt == 0) continue;
        Int mp = (cnt - 1) * 10 + abs(mi - x[k]);
        res = min(res, f(l, use, n, sum + mp, x, k + 1));
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    Int n, a, b, c;
    Int l[10] = {};
    bool used[10] = {};
    cin >> n >> a >> b >> c;
    for (Int i = 0; i < n; i++) {
        cin >> l[i];
        used[i] = false;
    }
    Int x[3] = {a, b, c};
   /*  x[0] = a;
    x[1] = b;
    x[2] = c; */
    dump(f(l, used, n, 0, x, 0));
    return 0;
}

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

/*
周囲にあるカードの枚数+1回返される
n,m>2のとき周囲の枚数は 3,5,8のどれか
n==1||m==1なら 0,1,2
裏になるのは周囲に0,2,8枚の時だけ
*/
int main(){
  int64_t n,m;
  cin >> n >> m;
  cout << ((n!=1&&m!=1)?(n-2)*(m-2):(n!=1)?(n-2):(m!=1)?(m-2):1) << endl;
  return 0;
}

Measured memory_bytes: 3616
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define debug(x)			{ cerr << #x << " = " << x << endl; }
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define vi					vector<int>
#define vii					vector<vi>
#define mid(s,e)			(s+(e-s)/2)

using namespace std;

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a*n,b);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;

//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int x,y;
    cin >> x >> y;
    bool flag = false;
    REP1(i,0,x){
        if(2*i+4*(x-i)==y) flag = true;
    }

    if(flag) cout << "Yes";
    else cout << "No";
    
    
    
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+5;
int a[N];
LL f[N][3];
int main(){
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	for(int i=0;i<=n;i++)f[i][0]=f[i][1]=f[i][2]=-1e18;
	f[1][0]=a[1],f[2][1]=a[2],f[3][2]=a[3],
	f[3][0]=a[3]+a[1];
	for(int i=4;i<=n;i++){
		f[i][0]=f[i-2][0]+a[i];
		f[i][1]=max(f[i-2][1],f[i-3][0])+a[i];
		f[i][2]=max(f[i-2][2],max(f[i-3][1],f[i-4][0]))+a[i];
	}
	LL ans;
	if(n&1)ans=max(f[n][2],max(f[n-1][1],f[n-2][0]));
	else ans=max(f[n][1],f[n-1][0]);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 9288
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;

const double EPS = 1e-5;
const int MAX_J = 5001;

int X,Y,Z;
double dp[51][MAX_J];
int V[4];
int event[51], event_A[51];

int main(){
    while(1){
        scanf("%d%d%d",&X,&Y,&Z);
        if(!X)break;

        for(int i = 0; i < X; i++){
            scanf("%d",&V[i]);
        }
        fill(event, event+Y+1, 0);
        for(int i=0;i<Z;i++){
            int N,E,A;
            scanf("%d%d%d",&N,&E,&A);
            event[N] = E;
            event_A[N] = A;
        }
        for(int i=0;i<Y+1;i++){
            for(int j=0;j<MAX_J;j++){
                dp[i][j] = 0;
            }
        }
        dp[0][0] = 1;
        for(int i = 0; i < Y; i++){
            for(int j = 0; j < 5000; j++){
                for(int k = 0; k < X; k++){
                    if(abs(dp[i][j])==0) continue;
                    int nx = min(Y, i + V[k]), mn = j;
                    if(event[nx] == 2) mn += event_A[nx];
                    else if(event[nx] == 3) mn = max(0, j-event_A[nx]);
                    else if(event[nx] == 1) nx = min(Y, nx + event_A[nx]);
                    dp[nx][mn] += dp[i][j] / X;
                }
            }
        }
        double ans = 0;
        for(int i = 0; i < 5000; i++) ans += i * dp[Y][i];
        printf("%d\n", (int)(ans+EPS));
    }
    return 0;
}

Measured memory_bytes: 3180
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string.h>
#include <stdlib.h>
#include <limits>
#include <iomanip>
using namespace std;

int main(){

    string str;
    cin >> str;

    for( int i = 0 ; i < str.size() ; i++ ){
        cout << "x";
    }
    cout << endl;

}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int n,k;
	cin >> n >> k;
	vector<double> p(n+10,0);
	rep(i,n){
		cin >> p[i+1];
		p[i+1] = (p[i+1]+1)/2.0;
	}
	for(int i = 1; i <= n; i++) p[i] += p[i-1];

	double ans = 0;
	for(int i = 0; i <= n-k; i++){
		ans = max(ans,p[i+k]-p[i]);
	}
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int main(){
    int k;
    string s;
    cin>>k>>s;
    int n= s.length();
    if(n<=k){
        cout<<s<<endl;
    }
    else{
        rep(i,k){
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  vector<int> res;
  vector<bool> used(N, false);
  function<void(int)> dfs = [&](int u) {
    res.emplace_back(u);
    used[u] = true;
    for (int v : G[u]) {
      if (used[v]) continue;
      dfs(v);
      break;
    }
  };
  dfs(0);
  reverse(res.begin(), res.end());
  res.pop_back();
  dfs(0);
  cout << res.size() << '\n';
  for (const auto& e : res) {
    cout << e + 1 << (&e == &res.back() ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 11956
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int>e[1000005];
int cnt[1000005];
vector<int>vct;
int frst;
void dfs(int v,int pr)
{
	cnt[v]=1;
	vct.push_back(v);
	if(v==n-1)
		frst=vct[(vct.size()+1)/2];
	for(int i=0;i<e[v].size();i++)
	{
		if(e[v][i]==pr)continue;
		dfs(e[v][i],v);
		cnt[v]+=cnt[e[v][i]];
	}
	vct.pop_back();
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	e[i].clear();
	for(int i=0;i<n-1;i++)
	{
		int u,v;
		cin>>u>>v;
		u--;v--;
		e[v].push_back(u);
		e[u].push_back(v);
	}
	frst=-1;
	dfs(0,0);
	bool win=cnt[frst]*2<n;
	string ans=win?"Fennec":"Snuke";
	cout<<ans;
	cout<<endl;
	return 0;
}


Measured memory_bytes: 34296
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
	int i, j;

	int num;//問題数//
	int time[101][100];//問題を解くのにかかる時間//
	int bottles;//ドリンクの本数//
	int problem;//問題番号//
	int sum;//合計時間//

	//行列の初期化//
	for (i = 0; i <= 100; i++) {
		for (j = 0; j <= 99; j++) {
			time[i][j] = 0;
		}
	}

	//入力//
	scanf("%d", &num);
	for (i = 0; i <= num-1; i++) {
		scanf("%d", &time[0][i]);
		for (j = 0; j <= 100; j++) {
			time[j][i] = time[0][i];
		}
	}

	scanf("%d", &bottles);
	for (i = 1; i <= bottles; i++) {
		scanf("%d", &problem);
		scanf("%d", &time[i][problem-1]);
	}

	   	  
	//合計の計算出力//
	for (i = 1; i <= bottles; i++) {
		sum = 0;
		for (j = 0; j <= num - 1; j++) {
			sum = sum + time[i][j];
		}
		printf("%d\n", sum);
	}

	

	return 0;

}

Measured memory_bytes: 256