akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
//#include <iostream>
//#include <vector>
//#include <string>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
	dx8[8] = { 0,1,1,1,0,-1,-1,-1 },
	dy8[8] = { 1,1,0,-1,-1,-1,0,1 },
	dx4[4] = { 0,1,0,-1 },
	dy4[4] = { 1,0,-1,0 };

template<class T>inline bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int main() {
	setc;

	lint n; cin >> n;
	if (n % 2)co(n * 2);
	else co(n);
	gc();
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	double N, M;
	cin >> N >> M;
	vector<double> A(N);
	double sum = 0;
	int check = 0;
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		sum = sum + A.at(i);
	}
	for (int i = 0; i < N; i++) {
		if (A.at(i) < (sum / (4 * M))) {
			check++;
		}
	}
	if (M > (N-check)) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a, n, m, i, Q[100], N[100], R[100], l, key, temp, O = 1;
    scanf("%d %d", &n, &m);
    while ( O ) {
        key = 0;
        for ( i = 0; i < m; i++ ) {
            Q[i] = 0;
            N[i] = i + 1;
            /*printf("N[%d]:%d\n", i, N[i]);*/
        }
        for ( i = 0; i < n; i++ ) {
            for ( l  = 0; l < m; l++ ) {
                scanf("%d", &a);
                Q[l] += a;
            }
        }
        /*printf("%d %d %d %d %d %d\n",Q[0], Q[1], Q[2], Q[3], Q[4], Q[5] );*/
        key = 1;
        /*for ( i = 0; i < m; i++ ) printf("%d ", N[i]); printf("\n");*/
        while ( key ) {
            key  = 0;
            for ( i = m - 1; i > 0; i-- ) {
                if ( Q[i] > Q[i - 1]) {
                    /*printf("before N[%d]:%d N[%d]:%d\n",i,  N[i], i-1, N[i-1]);*/
                    temp = Q[i];
                    Q[i] = Q[i - 1];
                    Q[i - 1] = temp;
                    temp = N[i];
                    N[i] = N[i - 1];
                    N[i - 1] = temp;
                    key++;
                    /*printf("after N[i]:%d N[i-1]:%d\n", N[i], N[i-1]);
                    printf("%d %d %d %d %d %d\n",Q[0], Q[1], Q[2], Q[3], Q[4], Q[5] );
                    for ( i = 0; i < m; i++ ) printf("%d ", N[i]); printf("\n\n");*/
                }
            }
        }
        /*printf("%d %d %d %d %d %da\n",Q[0], Q[1], Q[2], Q[3], Q[4], Q[5] );*/
        printf("%d", N[0]);
        for ( i = 1; i < m; i++ ) printf(" %d", N[i]); printf("\n");
        scanf("%d %d", &n, &m);
        if ( n == 0 && m == 0 ) O = 0;
    }
    return 0;
}

Measured memory_bytes: 1760
#include <bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define int long long
#define mod 1000000007

int solve1(int x, int y, vector<vector<int>> &dp, vector<vector<char>> &a, int n, int m) {
	if (x >= n || y >= m)return 0;
	if (dp[x][y] != -1)return dp[x][y];
	if (x == n - 1 && y == m - 1)return dp[x][y] = 1;

	if (x < n - 1)dp[x + 1][y] = solve1(x + 1, y, dp, a, n, m) % mod;
	if (y < m - 1)dp[x][y + 1] = solve1(x, y + 1, dp, a, n, m) % mod;
	dp[x][y] = (solve1(x + 1, y, dp, a, n, m) + solve1(x, y + 1, dp, a, n, m));
	dp[x][y] = dp[x][y] % mod;
	return dp[x][y];
}

int solve() {
	int n, m;
	cin >> n >> m;
	vector<vector<char>> a(n, vector<char>(m));
	int i, j;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++)cin >> a[i][j];
	}
	vector<vector<int>> dp(n, vector<int>(m));
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if (a[i][j] == '.')dp[i][j] = -1;
			else dp[i][j] = 0;
		}
	}

	solve1(0, 0, dp, a, n, m);
	int len = dp[0][0];
	return len;
}




int32_t main() {
	std::ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	cout << solve();
	return 0;
}

Measured memory_bytes: 12396
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.ArrayLong(3);

            Array.Sort(a);
                                             
            Console.WriteLine(Math.Abs(a[1] - a[2]) + Math.Abs(a[0] - a[1]));
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const double pi = 3.14159265358979323846;

#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

void rw()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}

int main()
{
    speed;
    //rw();

    ll q,p;
    cin>>q>>p;
  	cout<<q*p;
    return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int a[100];
multiset<int> s;
int main()
{
	int i,j,k,n,m,x,y,l,sum,ans=0;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<=k;i++)
	{
		for(j=i;j<=n;j++)
		{
			if(i+n-j>k)
			{
				continue;
			}
			s.clear();
			sum=0;
			for(l=0;l<i;l++)
			{
				s.insert(a[l]);
				sum+=a[l];
			}
			for(l=j;l<n;l++)
			{
				s.insert(a[l]);
				sum+=a[l];
			}
			x=k-i-(n-j);
			ans=max(ans,sum);
			while(x>0&&!s.empty()&&*s.begin()<0)
			{
				sum-=(*s.begin());
				s.erase(s.begin());
				x--;
			}
			ans=max(ans,sum);
		}
	}
	printf("%d",ans);
	return 0;
}

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

using namespace std;

#define ll long long

void solve() {
	string s;
	cin >> s;
	if (s.back() == 's') {
		s += "es";
	} else {
		s += "s";
	}
	cout << s << "\n";
}

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

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



Measured memory_bytes: 3664
import copy
n = int(input())
L = list(map(int, input().split()))
flag = 1
if L == sorted(L):
  print('YES')
  exit()
for i in range(n-1):
  for j in range(i+1, n):
    R = copy.copy(L)
    a = L[i]
    b = L[j]
    R[i] = b
    R[j] = a
    if R == sorted(R):
      flag *= 0
if flag == 0:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3444
import java.util.Scanner;
class Main {
	int a,b;
	String op;
	public void si() {
		Scanner sc = new Scanner(System.in);
		boolean sw = true;
		while(sw == true) {
			a = sc.nextInt();
			op = sc.next();
			b = sc.nextInt();
			if(op.equals( "+" )){
				System.out.println(a + b);
			} else if(op.equals ( "-" )) {
				System.out.println(a - b);
			} else if(op.equals ( "*" )) {
				System.out.println(a * b);
			} else if(op.equals ( "/" ) ) {
				if(b > 0) {
					System.out.println(a / b);
				}
			} else if(op.equals( "?" )) {
				sw = false;
			}
		}
	}
	public static void main(String[] args){
		new Main().si();
	}
}

Measured memory_bytes: 18008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF=1e18,MOD=1e9+7;
int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
}


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

int main()
{
    int64_t S;
    cin >> S;

    int64_t X1 = 0, Y1 = 0, X2 = 1e9, Y2 = 1;
    int64_t X3 = (X2 - (S % X2)) % X2;
    int64_t Y3 = (S + X3) / X2;
    cout << X1 << " " << Y1 << " ";
    cout << X2 << " " << Y2 << " ";
    cout << X3 << " " << Y3 << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	class Roman {
		String figure;
		public Roman(String s) {
			figure = new String(s);
		}

		private int getNumber(char c) {
			switch (c) {
			case 'I': return 1;
			case 'V': return 5;
			case 'X': return 10;
			case 'L': return 50;
			case 'C': return 100;
			case 'D': return 500;
			case 'M': return 1000;
			default: return 0;
			}
		}

		public long toArabic() {
			int prev = Integer.MAX_VALUE;
			long count = 0;
			for (int i = 0 ; i < figure.length() ; i++) {
				int current = getNumber(figure.charAt(i));
				if (prev >= current) {
					count += current;
				} else {
					count = count - prev*2 + current;
				}
				prev = current;
			}
			return count;
		}
	}


	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Main m = new Main();

		String line;
		while ((line = br.readLine()) != null) {
			Roman roman = m.new Roman(line);
			System.out.println(roman.toArabic());
		}

	}

}

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

int main(void){
    int a;scanf("%d",&a);
    if(a==1){cout<<1<<endl; return 0;}
    vector <ll> v={2,1};
    for(int i=2;i<a;i++){
        v.push_back(v.at(i-2)+v.at(i-1));
    }
    printf("%ld",v.at(a-1)+v.at(a-2));
}


Measured memory_bytes: 764
#include<iostream>

using namespace std;

int main(){
  int n,u,m,c;
  int b[1000][1000] = {};
  int a[1000][1000] = {};

  cin >> n;//点の数を入力する

  for(int i = 1;i <=n ;i++){
    cin >> u >> m;//次数を入力する
    for(int j = 1;j <= m;j++){
      cin >> b[u][j];//b[点の番号][接続先]
    }
  }

  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= n;j++){
      if(b[i][j] != 0){
	c = b[i][j];
	a[i][c] = 1;
      }
      if(j != n){
	cout << a[i][j] << " ";
      }else{
	cout << a[i][j] << endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 10888
#include<stdio.h>
#include<string.h>
#define MAX 100000

int min(int a, int b){ return a < b ? a : b; }
int max(int a, int b){ return a < b ? b : a; }

int val(char ch){ return ch-'0';}

int sub(char *maxs,char *mins){
  int i;
  for ( i = 0; i < strlen(maxs); i++ ){
    if ( maxs[i] != mins[i] ) {
      if ( i == strlen(maxs)-1 )
        return val(maxs[i]) - val(mins[i]);
      if ( i == strlen(maxs)-2 )
        return (10*val(maxs[i])+val(maxs[i+1])) - (10*val(mins[i])+val(mins[i+1]));
      return 10;
    }
  }
  return 0;
}

int checkEqual(char *S){
  char mins[MAX], maxs[MAX], tmp[MAX];
  int k, s, ans = 8;
  for ( k = 1; k < strlen(S); k++ ){
    if ( strlen(S)%k != 0 ) continue;
    strncpy(mins, S, k);
    strncpy(maxs, S, k);
    for (s = 0; s < strlen(S); s += k ){
      strncpy(tmp, S + s, k);
      if ( strcmp(tmp, maxs) > 0 ) strncpy(maxs, tmp, k);
      if ( strcmp(tmp, mins) < 0 ) strncpy(mins, tmp, k);
    }
    ans = min(ans, sub(maxs, mins));
  }
  return ans;
}

int check12(char *S){
  int maxv = 0;
  int minv = 10;
  int p, v;
  for( p = 0; p < strlen(S); p++){
    v = val(S[p]);
    if ( S[p] == '1' && p+1 < strlen(S) ) {
        v = 10 + val(S[p+1]);                                                                                                   p++;                                                                                                                }
    maxv = max(v, maxv);                                                                                                    minv = min(v, minv);
  }
  return maxv - minv;
}

int main(){                                                                                                               char S[MAX];
  scanf("%s", S);                                                                                                         printf("%d\n", min(checkEqual(S), check12(S)));
  return 0;
}



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

int main(){
    long long A, B, C;
    cin >> A >> B >> C;

    long long tmp_A = A;
    long long tmp_B = B;
    long long tmp_C = C;

    int counter = 0;
    while(true){
        if(tmp_A%2 == 1 || tmp_B%2 == 1 || tmp_C%2 == 1){
            break;
        }
        int _tmp_A = tmp_B/2 + tmp_C/2;
        int _tmp_B = tmp_A/2 + tmp_C/2;
        int _tmp_C = tmp_B/2 + tmp_A/2;

        tmp_A = _tmp_A;
        tmp_B = _tmp_B;
        tmp_C = _tmp_C;
        if(tmp_A == A && tmp_B == B && tmp_C == C){
            counter = -1;
            break;
        }


        counter += 1;
    }
    cout << counter << endl;
    return 0;
}

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

namespace ConsoleApplication3
{
class Program
{
    static void Main(string[] args)
    {
          
        while (true)
        {
            string[] str = Console.ReadLine().Split(' ');
            int tate = int.Parse(str[0]);
            int yoko = int.Parse(str[1]);

            if ((tate == 0) && (yoko == 0))
            {
                break;
            }
            for (int i = 1; i <= tate; ++i)
            {
                for (int j = 1; j <= yoko; ++j)
                { 
                    if ((i == 1) || (i == tate) || (j == 1) || (j == yoko))
                    {
                        Console.Write("#");
                    }
                    else
                    {
                        Console.Write(".");
                    }
                }
                Console.WriteLine();
            }
            Console.WriteLine(); 
            } 
        }
    }
}

Measured memory_bytes: 5296
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 100000;
typedef pair<int,int> P;
int main()
{
  int n,i;
  P p[N_MAX];
  cin >> n;
  for(i=0;i<n;i++){
    cin >> p[i].first;
    p[i].second=i+1;
  }
  sort(p,p+n);
  for(i=0;i<n;i++)
    cout << p[i].second << " ";
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

string s,t;

int main(){
  cin>>s>>t;
  int n=s.size();
  rep(i,n){
    bool ok=true;
    rep(j,n){
      if(s[(i+j)%n]!=t[j])ok=false;
    }
    if(ok){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
import math
L1=[int(input())/10 for i in range(5)]
L2=[]
for i in L1:
  L2.append(math.ceil(i)*10)
L3=[]
for i in range(5):
  L3.append(sum(L2)-L2[i]+L1[i]*10)
print(int(min(L3)))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

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




const int INF = 1000000;
const int mod = 1e9 + 7;



int main(){
	vi v(10001,1);
	v[0] = v[1] = 0;
	for(int i=2; i<10001; i++){
		if(v[i] == 1){
			for(int j = i*2; j< 10001; j+=i) v[j] = 0;
		}
	}
	int n;
	while (/*cin >> n*/scanf("%d",&n) != EOF && n > 0) {
		if(n % 4 == 3 && v[n]) {
			for(int i = 0; i<(n-1)/2; i++) printf("%d\n", (n-1)/2 -1);
			continue;	
		}
		set<int> s;
		map<int, int> m;
		for(int i = 1; i < n; i++) s.insert(i * i % n);
		//for(auto it :s) cout<<it<<endl;
		for(set<int>::iterator it = s.begin(); it != s.end(); ++it){
			//for(set<int>::iterator it2 = s.begin(); it2 != s.end(); it2++){
			set<int>::iterator it2 =it;
			++it2;
			while(it2 != s.end()){
				int a = *it - *it2;
				if(a < 0) a += n;
				if(a > (n - 1) / 2) a = n - a;
				m[a] += 2;
				++it2;
			}
		}
		for(map<int, int>::iterator it = m.begin(); it != m.end(); ++it){
			//cout<</*it->fi<<" "<<*/it->se<<endl;
			printf("%d\n", it->se);
		}
	}
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    string s; cin >> s;

    bool ans = true;

    for (int i = 0; i < s.size(); ++i) {
        if (i % 2 == 0) {
            //偶数
            if (s[i] == 'L') {
                ans = false;
                break;
            }
        } else {
            //奇数
            if (s[i] == 'R') {
                ans = false;
                break;
            }
        }
    }

    if (ans) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))
h = [int(input()) for i in range(N)]

h.sort()
min_l = h[K-1] - h[0]
for i in range(N-K+1):
    min_l = min(h[i+K-1]-h[i], min_l)

print(min_l)

Measured memory_bytes: 7488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1e9+1;

/*
トポロジカルソートをし、頂点を順に見ていけばOK。
*/

void solve(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> v;
    vector<int> e[n+5];//e[i]:頂点i+1から辺が伸びている頂点の集合
    vector<int> e2[n+5];//e2[i]:頂点i+1へ伸びている頂点の集合
    int g[n+5];//頂点iへ入っていく辺の数
    rep(i,n){
        g[i]=0;
    }
    rep(i,m){
        int x,y;
        cin >> x >> y;
        v.emplace_back(make_pair(x-1,y-1));
        e[x-1].emplace_back(y-1);
        e2[y-1].emplace_back(x-1);
        g[y-1]++;
    }
    vector<int> sorted;
    //トポロジカルソート。各頂点の入次数を管理。
    //gが0の頂点を取り出し、キューに追加。見た頂点について、辺が入っていく方の頂点の次数を-1。
    queue<int> q;
    
    rep(i,n){
        if(g[i]==0) q.push(i);
    }
    while(q.size()!=0){
        int tmp = q.front();
        q.pop();
        sorted.emplace_back(tmp);
        for(auto j:e[tmp]){
            g[j]--;
            if(g[j]==0) q.push(j);
        }
    }

    //rep(i,n-4){
        //cout << g[0] << endl;
    //}
    
    int dp[n+5];
    rep(i,n){
        
        int tmp = sorted[i];//セグフォ
        
        if(e2[tmp].size()==0) dp[tmp]=0;
        else{
            int m = 0;
            for(auto j:e2[tmp]){
                m = max(m, dp[j]);
            }
            dp[tmp] = m+1;
        }
        
        
    }
    
    int ma = 0;
    rep(i,n){
        ma = max(ma, dp[i]);
    }
    cout << ma << endl;
    
}

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


Measured memory_bytes: 13684
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
#define N 200005
int fa[N],siz[N];
int find(int u){return fa[u]==u?u:fa[u]=find(fa[u]);}
signed main()
{
	int n=read(),m=read();
	for(int i=1;i<=n;i++) fa[i]=i,siz[i]=1;
	for(int i=1;i<=m;i++)
	{
		int u=find(read()),v=find(read());
		if(u==v) continue;
		fa[u]=v,siz[v]+=siz[u];
	}
	int ans=0;
	for(int i=1;i<=n;i++) ans=max(ans,siz[find(i)]);
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 11424
#include <iostream>

using namespace std;

int gcd(int a,int b){
  if(b == 0) 
    return a;
  else 
    return gcd(b, a % b);
}

int main() {
  
  long long int A,B,C,D,cntc,cntd,ans;
  
  cin >> A >> B >> C >> D;
  A--;
  long long int cnt = C*D/gcd(C, D);
 
  cntc = B/C - A/C;
  cntd = B/D - A/D;
  
  ans = cntc + cntd - (B/cnt - A/cnt);

  cout << B - A - ans << endl;    
}

Measured memory_bytes: 256
//Winter is Coming - Game Of Thrones.
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    string str;cin >> str;
    if(str[2]==str[3] && str[4] == str[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    double ans = Double.parseDouble(s[0]) / Double.parseDouble(s[1]);
    System.out.println(ans);
  }
}

Measured memory_bytes: 21204
#include<stdio.h>
#include<stdlib.h>

typedef struct node{
    int a;
    int b;
}node;

int cmp(const void* a, const void* b){
    return ((node*)a)->b - ((node*)b)->b;
}

int main(){
    int n;
    scanf("%d", &n);
    node a[n];
    for(int i=0; i<n; i++){
        scanf("%d%d", &(a[i].a), &(a[i].b));
    }
    qsort(a, n, sizeof(node), cmp);
    int sum = 0;
    int f=1;
    for(int i=0; i<n; i++){
        sum += a[i].a;
        if(sum > a[i].b){
            f = 0;
        }
    }
    if(f){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 3324
import sys
input = sys.stdin.readline
n = int(input())
p = list(map(int, input().split()))
nl = [i for i in range(1, n+1)]
pi = -1
pii = 999
pj = -1
pji = 999
for i in range(n):
    if pi == -1:
        if p[i] != nl[i]:
            pi = p[i]
            pii = i
    else:
        if p[i] != nl[i]:
            pj = p[i]
            pji = i
            break

if pii != 999 and pji != 999:
    p[pji] = pi
    p[pii] = pj

ans = True
for i in range(n):
    if nl[i] != p[i]:
        ans = False
        break

if ans:
    print('YES')
else:
    print('NO')

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

int main() {
	int h, w;
	cin >> h >> w;

	string c[h];
	for (int i = 0; i < h; i++) {
		cin >> c[i];
	}

	string ans = "";
	for (int i = 0; i < h; i++) {
		ans += c[i] + "\n" + c[i] + "\n";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const long long MX = 1e18;
int main() {
    long long n,ans = 1;
    cin >> n;
    long long data[n];
    for (int i = 0; i < n; i++){
        cin >> data[i];
        if(data[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    for (int i = 0; i < n; i++){
        if(ans * data[i] > MX||(MX+1) /ans < data[i]){
            cout << -1 << endl;
            return 0;
        }
        ans *=data[i];
    }

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


Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const int mod = 1e9+7;
ll qpow(ll a,ll b){ll res=1;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int ans[maxn];
int n,x,y,mi;
int dist[maxn];
void bfs()
{
    memset(dist,-1,sizeof(dist));
    dist[mi]=0;
    queue<int>q;
    q.push(mi);
    while(!q.empty())
    {
        int now = q.front();
        q.pop();
        if(now+1<=n&&dist[now+1]==-1){
            dist[now+1]=dist[now]+1;
            q.push(now+1);
        }
        if(now-1<=n&&dist[now-1]==-1){
            dist[now-1]=dist[now]+1;
            q.push(now-1);
        }
        if(x==now)
        {
            if(y>=mi&&dist[y]==-1){
                dist[y]=dist[now]+1;
                q.push(y);
            }
        }
        if(y==now)
        {
            if(y>=mi&&dist[x]==-1){
                dist[x]=dist[now]+1;
                q.push(x);
            }
        }
    }
}
int main()
{
    scanf("%d%d%d",&n,&x,&y);
    for(int i = 1;i < n;++i)
    {
        mi = i;
        bfs();
        for(int j = i+1;j <= n;++j)
        {
            ans[dist[j]]++;
        }
    }
    for(int i = 1;i < n;++i)printf("%d\n",ans[i]);
    return 0;
}


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

int main(){
  string s,t ; 
  cin >> s ; 
  cin >> t ;
  int ans = 0 ; 
  int N = s.size() ; 
  int M = t.size() ; 
 
  for(int i = 0 ; i <= N-M ; i++){
    int cnt = 0 ;
    //cout << i << endl ; 
    for(int j = 0 ; j < M ; j++){
      if(s.at(i+j) - t.at(j) == 0 ){
        cnt++ ; 
      }
    }
    ans = max(cnt , ans) ; 
  }

  cout << t.size() - ans << endl ; 
  
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
//#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    string s;
    cin >> s;
    int ans = 0;
    int l = 0;
    char c = 'R';
    int n = sz(s);
    for (int i = 0; i < n; i++){
        if (s[i] == c) l++;
        else {
            ans = max(ans, l);
            l = 0;
        }
    }
    ans = max(ans, l);
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int N,ans;

void dfs(int k,int mask){
    if(k>N) return;
    if(mask==7) ans++;
    dfs(k*10+3,mask|1);
    dfs(k*10+5,mask|2);
    dfs(k*10+7,mask|4);
}

signed main()
{
    cin>>N;
    dfs(0,0);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <unordered_set>
using namespace std;
#define INF 999999999
#define FOR(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define REP(i, n) FOR(i, 0, n)
#define lin long long

int main(void)
{
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;

    unordered_set<int> xs;
    xs.insert(0);
    unordered_set<int> ys;
    ys.insert(0);
    bool first = true;
    bool isX = true;
    int distance = 0;
    int len = s.length();

    REP(i, len + 1)
    {
        if (s[i] == 'T' || i == len)
        {
            unordered_set<int> neo;

            if (first)
            {
                neo.insert(distance);
                xs = neo;
            }
            else if (isX)
            {
                for (auto p : xs)
                {
                    neo.insert(p + distance);
                    neo.insert(p - distance);
                }
                xs.clear();
                xs = neo;
            }
            else
            {
                for (auto p : ys)
                {
                    neo.insert(p + distance);
                    neo.insert(p - distance);
                }
                ys.clear();
                ys = neo;
            }

            first = false;
            isX = !isX;
            distance = 0;
        }
        else
        {
            distance++;
        }
    }

    if (xs.count(x) > 0 && ys.count(y) > 0)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


Measured memory_bytes: 896
#!python3.4
# -*- coding: utf-8 -*-
# abc160/abc160_e
import sys
from collections import deque


s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    X, Y, A, B, C = i2nn()
    p = deque(sorted(map(int, i2s().split(' ')), reverse=True)[:X])
    q = deque(sorted(map(int, i2s().split(' ')), reverse=True)[:Y])
    r = deque(sorted(map(int, i2s().split(' '))))
    s = 0
    while p or q:
        if p and q:
            t = p if p[-1] < q[-1] else q
        else:
            t = p if p else q
        if r and t[-1] < r[-1]:
            t.pop()
            s += r.pop()
        else:
            r.clear()
            s += t.pop()
    print(s)
    return

main()


Measured memory_bytes: 22944
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long ll;
ll N, ans;
int main() {
  scanf("%ld", &N);
  if(N%2 == 1) ans = 0;
  else {
    for(int i = 1; i <= 25; ++i) {
      ans += N/2/(ll)pow(5LL, i);
    }
  }
  printf("%ld\n", ans);
}

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

int getMaxDistance(int k, int an, int am)
{
    int d1 = abs(an - am);
    int d2 = k - d1;

    return d1 < d2 ? d2 : d1;
}

int main()
{
    int k = 0, n = 0;
    cin >> k >> n;
    int a[n];
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    int minDistance = INT_MAX;
    for(int start = 0; start < n; start++)
    {
        int goal = (start + 1) % n;
        int d = getMaxDistance(k, a[goal], a[start]);
        if(d < minDistance)
        {
            minDistance = d;
        }
    }

    cout << minDistance;

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
int a[100];
int n;
int index;

while (1){
scanf("%d", &n);
if (n == -1) break;
index = 0;
do {
a[index++] = (n & 0x3);
n >>= 2;
} while (n != 0);

index--;
while (index >= 0){
printf("%d", a[index--]);
}

puts("");
}
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int x, n; cin >> x >> n;
	int p[105];
	for(int i=0;i<n;i++){
		cin >> p[i];
	}
	int ans_val = 101;
	int ans = 0;
	if(n==0){
		cout << x << endl;
		return 0;
	}
	for(int i=101;i>=0;i--){
		int abs_val = 101;
		bool flag = true;
		for(int j=0;j<n;j++){
			if(p[j]==i) flag = false;
			if(p[j]!=i && abs(x-i)<=abs_val){
				abs_val = abs(x-i);
			}
		}
		if(ans_val>=abs_val && flag){
			ans_val = abs_val;
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>
using namespace std;
 
int dp(int k, int w, int* a, int* b);
 
int main(void){
    // Your code here!
    int d;
    std::cin >> d;
    int n;
    std::cin >> n;
    if(n == 100){
        n++;
    }
    int result;
    result = pow(100,d) * n;
    std::cout << result << std::endl;
}
 
int dp(int k, int w, int* a, int* b){
    int result = 0;
    if(k == 1){
        if(a[1] > w){
            result = 0;
        } else {
            result = b[1];
        }
    } else {
        if(a[k] > w){
            result = dp(k-1, w, a, b);
        } else {
            result = max(dp(k-1, w, a, b),dp(k-1, w - a[k], a, b) + b[k]);
        }
    }
    return result;
}

Measured memory_bytes: 256
import * as fs from 'fs';

namespace AtCoder {
    export interface Paramable {
        readonly args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc001 {
    export class TaskA implements AtCoder.Task, AtCoder.Paramable {
        public constructor(public readonly args: string[][]) {
        }

        public main(this: TaskA): void {
            const [n, a, b]: number[] = this.args[0].map(Number);
            console.log(Math.min(n * a, b));
        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(r => r.split(' '));
    const task: AtCoder.Task = new TaskA(args);
    task.main();
}



Measured memory_bytes: 7500
# coding: utf-8


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    A = list(map(int, args[1].split()))

    dist = [-1]*n
    dist[0] = 0
    routes = [1]

    joint = -1

    i = A[0]
    for j in range(1, n+1):
        if 0 <= dist[i-1]:
            joint = dist[i-1]
            break

        routes.append(i)
        dist[i-1] = j
        i = A[i-1]

    loop = routes[joint:]
    return str(loop[(k-joint) % len(loop)] if joint < k else routes[k])


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 33100
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,ll>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

ll gcd(ll a, ll b) {return(b?gcd(b,a%b):a);}

int main() {
    int n; cin >> n;
    map<P,int> x, y;
    int zeros = 0;
    rep(i,n) {
        ll a, b; cin >> a >> b;
        if (a == 0 && b == 0) {zeros++; continue;}
        ll gc = gcd(abs(a),abs(b));
        a /= gc; b /= gc;
        if ((a < 0 && b > 0) || (a > 0 && b < 0) || b == 0) {
            y[P(abs(b),abs(a))]++;
        }
        else x[P(abs(a),abs(b))]++;
    }
    n -= zeros;
    mint ans = 1;  
    for (auto p : x) {
        if (p.second == 0) continue;
        if (y[p.first] != 0) {
            ans *= (mint(2).pow(p.second)-1)+(mint(2).pow(y[p.first])-1)+1;
            n -= p.second;
        }
    }
    for (auto p : y) {
        if (p.second == 0) continue;
        if (x[p.first] != 0) n -= p.second;
    }
    ans *= mint(2).pow(n);
    ans += zeros - 1;
    cout << ans << endl;
}

Measured memory_bytes: 28604
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;

const int INF = 1e9+1;
int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];

  int neg_cnt=0, mn=INF;
  ll ans = 0;
  rep(i, n){
    if (a[i] < 0) {
      a[i] = - a[i];
      neg_cnt++;
    }
    mn = min(mn, a[i]);
    ans += a[i];
  }
  sort(a.begin(), a.end());
  if (neg_cnt%2 == 1){
    ans -= 2 * mn;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>

int main(){
   int N, T;
   std::cin >> N >> T;
   int t_prev(-T), t;
   long long ans = 0;
   for(int i=0; i<N; ++i){
      std::cin >> t;
      ans += t_prev+T <= t ? T : t - t_prev;
      t_prev = t;
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    string s;
    cin>>s;
    int a,b,c,d;
    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';
    if(a+b+c+d==7){
        cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<'='<<7;
    }else if(a+b+c-d==7){
        cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<'='<<7;
    }else if(a+b-c+d==7){
        cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<'='<<7;
    }else if(a+b-c-d==7){
        cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<'='<<7;
    }else if(a-b+c+d==7){
        cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<'='<<7;
    }else if(a-b+c-d==7){
        cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<'='<<7;
    }else if(a-b-c+d==7){
        cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<'='<<7;
    }else if(a-b-c-d==7){
        cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<'='<<7;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Set;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Set<String> set = new HashSet<String>();
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			String cmd = sc.next();
			String str = sc.next();
			switch (cmd) {
			case "insert":
				set.add(str);
				break;
			case "find":
				if (set.contains(str)) System.out.println("yes");
				else System.out.println("no");
				break;
			}
		}
	}
}



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

int N, K, MOD = 1e9+7;
vector<vector<int>> G;

long dfs(int pre, int v) {
  long ret = 1;
  int k = (pre == -1) ? K : K - 1;
  for (auto next : G.at(v)) {
    if (next == pre) continue;
    ret *= --k;
    ret %= MOD;
    ret *= dfs(v, next);
    ret %= MOD;
  }
  return ret;
}

int main() {
  cin >> N >> K;
  G.resize(N);
  for (int a, b; cin >> a >> b;) {
    G.at(--a).push_back(--b);
    G.at(b).push_back(a);
  }
  cout << dfs(-1, 0) * K % MOD << "\n";
}


Measured memory_bytes: 13236
#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")


def solve(N: int, C: int, x: "List[int]", v: "List[int]"):

    # 時計回りターンなし
    nt_cost = x
    nt_benefit = list(accumulate(v))
    nt_callory = [b-c for c, b in zip(nt_cost, nt_benefit)]
    nt_callory_acc = list(accumulate(nt_callory, max)) + [0]
    # [0]はモンキーパッチ。後に負の参照をした場合に参照させる用
    # print(nt_callory)
    # print(nt_callory_acc)

    # 反時計回りターンなし
    rnt_cost = list((reversed([C-v for v in x])))
    rnt_benefit = list(accumulate(reversed(v)))
    rnt_callory = [b-c for c, b in zip(rnt_cost, rnt_benefit)]
    rnt_callory_acc = list(accumulate(rnt_callory, max)) + [0]
    # print(rnt_callory)
    # print(rnt_callory_acc)

    # 時計回り
    m = -INF
    for i in range(N):
        # i番目でターン
        callory = max(nt_callory[i]-nt_cost[i]+rnt_callory_acc[N-i-2],
                      nt_callory[i])
        # print(i, callory)
        m = max(m, callory)

    # 反時計回り
    for i in range(N):
        # i番目でターン
        callory = max(rnt_callory[i]-rnt_cost[i]+nt_callory_acc[N-i-2],
                      rnt_callory[i])
        # print(i, callory)
        m = max(m, callory)

    print(max(0, m))
    return


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
    C = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, C, x, v)


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  cin>>a;

  sort(a.begin(),a.end(),greater<>());
  rep(i,min(k,n))a[i]=0;

  cout<<accumulate(a.begin(),a.end(),0ll)<<endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch CitySavers | diff CitySavers.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address CitySavers.cpp && ./a.out

/*
 
 7/27/2019
 
 5:06-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N],B[MAX_N];
int N;

void solve() {
  LL res=0;
  LL pre=0;
  REP(i,N+1) {
    LL a=min(pre+B[i],A[i]);
    res+=a;
    pre=min(pre+B[i]-a,B[i]);
//    dump(i,a,pre);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N+1) cin>>A[i];
  REP(i,N) cin>>B[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 5120