akhauriyash/Code-Regression huggingface dataset:
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------
struct unionfind{
    vector<int> rank,parent,size;
    int independent_tree;
    int N;
    
    unionfind(int n){
        N=n;
        for(int i=0;i<n;i++){
            rank.push_back(1);
            parent.push_back(i);
            size.push_back(1);
            independent_tree=N;
        }
    }
    int getroot(int x){
        if(parent[x]==x)
            return x;
        return parent[x]=getroot(parent[x]);
    }
    bool issame(int a,int b){
        return getroot(a)==getroot(b);
    }
    void unite(int a,int b){
        a=getroot(a);
        b=getroot(b);
        if(a==b)
            return;
        else if(rank[a]>rank[b]){
            parent[b]=a;
            size[a]+=size[b];
        }
        else if(rank[a]==rank[b]){
            parent[b]=a;
            rank[a]++;
            size[a]+=size[b];
        }
        else{
            parent[a]=b;
            size[b]+=size[a];
        }
    }
};
//---------------------------------------------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s[26][26];
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
        {
            cin>>s[i][j];
            if(s[i][j]=="snuke")
            {
                char c='A';
                c+=(j-0);
                cout<<c<<i+1<<endl;
            }
        }
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
s = input()
l = len(s)

idx = 0
ans = "NO"
dream = False
erase = False
while idx<l:
    if s[idx]=="d":
        if s[idx:(idx+5)] == "dream":
            idx += 5
            dream = True
            erase = False
        else:
            break
    elif s[idx] == "e":
        if s[idx+1] != "r":
            break
        else:
            if s[idx:(idx+5)] == "erase":
                idx += 5
                erase = True
                dream = False
            elif dream:
                idx += 2
                erase = False
                dream = False
            else:
                break
    elif s[idx]== "r":
        if erase:
            idx += 1
            erase = False
            dream = False
        else:
            break
    else:
        break

if idx == l:
    ans = "YES"

print(ans)

Measured memory_bytes: 9116
#include <iostream>

using namespace std;

int main () {
  long long n, m;
  cin >> n >> m;
  long long sum = 0;
  long long ch;
  for (long long i = 0; i < m; ++i) {
    cin >> ch;
    sum += ch;
  }
  if (sum > n) {
    cout << "-1\n";
  } else {
    cout << n - sum << '\n';
  }
  return 0;
}

Measured memory_bytes: 3584
open Hashtbl;;let t,b=create 26,Bytes.iter;;let rec f()=let l=read_line()in b(fun c->if c>'@'&&c<'['||c>'`'&&c<'{'then let x=(if c>'@'&&c<'['then Char.chr(Char.code c+32)else c)in if mem t x then add t x(find t x+1)else add t x 1)l;f()in try f()with _->b(fun c->Printf.printf"%c : %d
"c(if mem t c then find t c else 0))"abcdefghijklmnopqrstuvwxyz"

Measured memory_bytes: 2452
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int face[][] = new int[n][6];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < 6; j++) {
				face[i][j] = sc.nextInt();
			}
		}

		char com[] = new char[] {'E', 'N', 'E', 'N', 'E', 'N'};

		//2つめのサイコロをDiceクラスのインスタンスとして考える
		boolean frag = false;  //判定が終了したらtrueにする

		for(int i = 0; i < n-1; i++) {
			for(int j = i + 1; j < n; j++) {
				Dice4 d4 = new Dice4(face[j]);

				for(int k = 0; k < 6; k++) {  //rollのループ //なぜ7回の操作が必要なのか？
					for(int l = 0; l < 4; l++) {  //rotaのループ
						if(d4.a[0] == face[i][0] && d4.a[1] == face[i][1] && d4.a[2] == face[i][2]
								&& d4.a[3] == face[i][3] && d4.a[4] == face[i][4] && d4.a[5] == face[i][5]) {
							frag = true;
							break;
						}
						if(frag == true) break;
						d4.rota();
					}
					if(frag == true) break;
					d4.roll(com[k]);
				}
				if(frag == true) break;
			}
			if(frag == true) break;
		}
		if(frag) System.out.println("No");
		else System.out.println("Yes");
	}
}

class Dice4{
	int a[] = new int[6];
	int temp;
	Dice4(int face[]){
		for(int i = 0; i < 6; i++) {
			a[i] = face[i];
		}
	}

	void roll(char c) {
		switch(c) {
		case 'E':
			temp = a[5];
			a[5] = a[2];
			a[2] = a[0];
			a[0] = a[3];
			a[3] = temp;
			break;
		case 'N':
			temp = a[5];
			a[5] = a[4];
			a[4] = a[0];
			a[0] = a[1];
			a[1] = temp;
			break;
		case 'S':
			temp = a[5];
			a[5] = a[1];
			a[1] = a[0];
			a[0] = a[4];
			a[4] = temp;
			break;
		case 'W':
			temp = a[5];
			a[5] = a[3];
			a[3] = a[0];
			a[0] = a[2];
			a[2] = temp;
			break;
		}
	}
	void rota() {  //横方向の回転をさせるメソッド
		temp = a[1];
		a[1] = a[2];
		a[2] = a[4];
		a[4] = a[3];
		a[3] = temp;
	}
}


Measured memory_bytes: 29548
n=int(input())
l=[int(i) for i in input().split()]
c=[0 for i in range(n)]
for i in l:
    c[i-1]+=1
res=0
for i in range(n):
    res+=c[i]*(c[i]-1)//2
for i in range(n):
    j=l[i]-1
    print(res-c[j]*(c[j]-1)//2+(c[j]-1)*(c[j]-2)//2)


Measured memory_bytes: 86092
#include <bits/stdc++.h>
#define _boost ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define fi first
#define se second
#define clz __builtin_clz
#define clzll __builtin_clzll
#define bp __builtin_popcount
#define _unique(x) sort((x).begin(),(x).end()),(x).erase(unique((x).begin(), (x).end()),(x.end()))
#define all(x) (x).begin(),(x).end()
#define _rand(i,j) uniform_int_distribution<int>(i, j)(rng___)
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;
template < typename _T, typename _T2> string to_string(pair<_T,_T2> x) {return "<"+to_string(x.fi)+", "+to_string(x.se)+">";}
template < typename _T> string to_string(vector<_T> vec) {string s="[ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]=']';s[s.size()-2]=' '; return s;}
template < typename _T> string to_string(set<_T> vec) {string s="{ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T, typename _T2> string to_string(map<_T,_T2> vec) {string s="{ "; for(auto el:vec)s+="mp["+to_string(el.fi)+"]= "+to_string(el.se)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T > inline void _DBG(const char *s, _T x){cerr << s << " = " << to_string(x) << "\n";}
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a){while(*s != ',') cerr << *s++;cerr << " = " << to_string(x) << "\n";_DBG(s + 1, a...);}
#ifdef LOCAL
#define _print(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define _print(...) ;//cout<<2;//(__VA_ARGS__)
#endif
mt19937 rng___(chrono::steady_clock::now().time_since_epoch().count());


const LL MOD = 998244353;//1e9+7;
const LL LLINF = 1e18+7;
const int N=2e5+8;


int main()
{
    _boost;
    int n;
    cin>>n;
    vector<vector<int>> days(n,vector<int>(3));
    vector<vector<LL>> dp(n,vector<LL>(3,0));
    for(int i=0;i<n;i++)for(int j=0;j<3;j++)cin>>days[i][j];
    for(int i=0;i<3;i++)dp[0][i]=days[0][i];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(k!=j)
                {
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+days[i][j]);
                }
            }
        }
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}




Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    ll n; cin >> n;
    if(n == 1)
        cout << 0;
    if(n == 0)
        cout << 1;
}
   

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
const int N=3000+5,mod=1e9+7;
typedef long long ll;
ll n,arr[N],dp[N][N][3];

ll solve(int i=1,int j=n,bool f=0)
{
    if(i>j)
        return 0;
    ll &ret=dp[i][j][f];
    if(~ret)
        return ret;
    if(f==0){
        ret=arr[i]+solve(i+1,j,1);
        ret=max(ret,arr[j]+solve(i,j-1,1));
    }
    else{
        ret=-arr[i]+solve(i+1,j,0);
        ret=min(ret,-arr[j]+solve(i,j-1,0));
    }
    return ret;
}
int main()
{
    Elhabashy
    input();
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>arr[i];
    cout<<solve()<<endl;

}



Measured memory_bytes: 215516
#include<bitset>   //1
#include<iostream> //2
#include<cmath> //3
using namespace std;  //1
#include<bits/stdc++.h> //2
#define int long long //大悪魔すくにきあ //3
int GoHome(int n){   //1
} // 2
int Kaerinasai(int n){return n*(n+1)/2;} //3
signed main(){    //1
    int sucu; // 2
    int tkmt; //3
    cin>>sucu;tkmt=0;   //1
    tkmt = sucu; // 2
    #define Would   //3
    tkmt=0; //1
    #define you // 2
    #define rep(a) for(int i=0;i<a;i++) //3
    while(Kaerinasai(tkmt)<sucu){Would you ++tkmt;}  //1
    #undef rep(a) // 2
    Would you cerr << "塚本はつかも　岩になる"; //3
    #define Oreno_Kotaeha(kore) cout<<(kore)<<endl   //1
    Oreno_Kotaeha(tkmt); // 2
    const int tempura = 810; //3
    you return 0;   //1
Would you } // 2

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);

        long length = scanner.nextLong();
        long blue = scanner.nextLong();
        long red = scanner.nextLong();

        long sum = blue + red;
        long div = length / sum;
        long rem = length % sum;

        long blueCount = (div * blue);

        if (rem > 0) {
            blueCount += Math.min(rem, blue);
        }
        System.out.println(blueCount);
    }
}

Measured memory_bytes: 23764
#include<cstdio>
int main(){
	int a,b,y;
	char op;

	while(1){
		scanf("%d %c %d",&a,&op,&b);

		if(op == '?') break;

		if(op == '+'){
			y = a+b;
		}else

		if(op == '-'){
			y = a-b;
		}else

		if(op == '*'){
			y = a*b;
		}else

		if(op == '/'){
			y = a/b;
		}

		printf("%d\n",y);

	}

	return 0;

}

Measured memory_bytes: 1028
def main():
	a = input()
	b = input()
	if len(a) + 1 != len(b):
		print('No')
		return

	i = 0
	for s in a:
		if s != b[i]:
			print('No')
			return
		i+=1
	print('Yes')


if __name__ == "__main__":
	main()

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;
ll comb(ll a, ll b);
int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int n;
    cin >> n;
    map<int, int> a;
    int ans = 0;
    rep(i, n)
    {
        int b;
        cin >> b;
        a[b]++;
    }

    for (auto it = a.begin(); it != a.end();)
    {

        if (it->first < it->second)
        {
            ans += it->second - it->first;
            ++it;
        }
        else if (it->first != it->second)
        {
            ans += it->second;
            it = a.erase(it);
        }
        else
        {
            ++it;
        }
    }

    c(ans);
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    typedef pair<int, int> pint;
    vector<pint> X(N);
    vint Y(N);
    rep(i, N)
    {
        int x;
        cin >> x;
        X[i] = {x, i};
        Y[i] = x;
    }
    sort(all(X));
    int med2 = X[N / 2].first, med1 = X[N / 2 - 1].first;
    int idx1 = X[N / 2].second, idx2 = X[N / 2 - 1].second;
    rep(i, N)
    {
        if (Y[i] == med1)
        {
            cout << med2 << "\n";
        }
        else if (Y[i] < med1)
        {
            cout << med2 << "\n";
        }
        else if (Y[i] > med1)
        {
            cout << med1 << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

int main()
{
    int a,b;
     cin>>a>>b;
     int vis[4]={0};
      vis[a]=vis[b]=1;
      int j=1;
       while(vis[j])
        j++;
         cout<<j;
         return 0;
}

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

int main() {
    int k,a,b;
    cin >> k >> a >> b;
    if(a-b>=k){
        cout << "OK" << endl;
        return 0;
    }else{
        for(int i = a; i <= b;i++){
            if(i%k == 0){
                cout << "OK" << endl;
                return 0;
            }
        }
        cout << "NG" << endl;
    }
}

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

int compare_int_big(const void *a,const void *b){
    return *(int *)b - *(int *)a;
}

int compare_int_small(const void *a,const void *b){
    return *(int *)a - *(int *)b;
}

int main(void){
    int N,K;
    int H[200010];
    long ans;

    scanf("%d",&N);
    scanf("%d",&K);

    for(int i=0;i<N;i++){
        scanf("%d",&H[i]);
    }

    qsort(H,N,sizeof(int),compare_int_big);

    ans=0;
    for(int i=0;i<N;i++){
        if(i<K){
            continue;
        }
        ans += H[i];
    }

    printf("%ld",ans);

    return 0;
}

Measured memory_bytes: 1788
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n,m;
  cin >> n >> m;
  
  int ans = 0;
  REP(i,n){
    ans += i;
  }
  
  REP(i,m){
    ans += i;
  }
  
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 3584
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n;
  rd(n);
  auto a = readln.split.to!(long[]);

  sort(a);
  int[long] freq;
  foreach (x; a) {
    if (x in freq) {
      freq[x]++;
    } else {
      freq[x] = 1;
    }
  }
  int ans = 0;
  foreach_reverse (x; a) {
    if (x in freq) {
      if ((--freq[x]) == 0) {
        freq.remove(x);
      }
      long p2 = 1;
      long[] cand;
      while (p2 <= (1L << 31)) {
        if (p2 - x >= 1) {
          cand ~= (p2 - x);
        }
        p2 *= 2;
      }
      foreach_reverse (y; cand) {
        if (y in freq) {
          ans++;
          if ((--freq[y]) == 0) {
            freq.remove(y);
          }
          break;
        }
      }
    }
  }
  writeln(ans);
}

void rd(T...)(ref T x) {
  import std.stdio, std.string, std.conv;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 35100
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o A.exe A.cpp 
Execute: ./A
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

void check_var(int x, int y) {
	if(x == 0) {
		cout << y << endl; 
	}
}

int main() { 	
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	
	check_var(a, 1); 
	check_var(b, 2); 
	check_var(c, 3); 
	check_var(d, 4); 
	check_var(e, 5); 
	
	return 0; 
} 


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

int main()
{
	string s;
	int ans = 0, mx = - 1;
	
	cin >> s;
	
	int l = s.size();
	
	for(int i = 0; i < l; i++){
		if(s[i] == 'A' || s[i] == 'C' || s[i] == 'T' || s[i] == 'G') ans++;
		else {mx = max(mx, ans); ans = 0;}
	}
	mx = max(mx, ans);
	
	cout << mx << "\n";
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


import java.util.Comparator;
import java.util.Arrays;
import java.util.ArrayList;



public class Main {

	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char s1 = S.charAt(0);
		char s2 = S.charAt(1);
		char s3 = S.charAt(2);
		char s4 = S.charAt(3);
		if (s1 == s2) {
			if(s3 == s4 && s1 != s3) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
		else {
			if((s1 == s3 && s2 == s4) ||(s1 == s4 && s2 == s3) ) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
		
	}
}


Measured memory_bytes: 21332
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] l = new int[n];
        int d = 0;
        for(int i = 0 ; i < n ; i++ ){
            l[i] = sc.nextInt();
        }
        boolean in = false;
        int s = 0;
        while(in == false){
            d += l[s];
            if(x < d || s == n - 1){
                in = true;
            }else{
                s++;
            }
        }
        int a = 0;
        for(int i = 0 ; i < n ; i++ ){
            a += l[i];
        }
        if(x >= a){
            s++;
        }
        s++;
        System.out.println(s);
    }
}

Measured memory_bytes: 36112
#include<bits/stdc++.h>
#define D(...) fprintf(stderr,__VA_ARGS__)
#define int long long
#define LL long long
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef pair<int,int>PII;typedef vector<int>VI;typedef vector<PII>VII;
template<typename T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;}
template<typename T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);}
int h1,m1,h2,m2,k;
signed main(){
	rd(h1),rd(m1),rd(h2),rd(m2),rd(k);
	int len=(h2-h1)*60+m2-m1;
	pt(max(0LL,len-k),'\n');
	return 0;
}

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

#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define Sort(vec) sort(all(vec))
#define Rev(vec) reverse(all(vec))

using Graph = vector<vector<int>>;

namespace Input
{
                
    void input(){return;}
    template<typename First,typename... Rest> void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}
    
    void inputVec(){return;}
    template<typename First,typename... Rest> void inputVec(vector<First> &first,Rest&... rest){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i];
        }
        inputVec(rest...);
    }
    
    template<typename First,typename Second> void inputTwoVec(vector<First> &first,vector<Second>& second){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i] >> second[i];
        }
    }

    void inputGraph(Graph &g,int path_num,bool isdirected){
        for(int i = 0;i < path_num;i++){
            int a,b;
            cin >> a >> b;
            a--;b--;
            if(isdirected){
                g[a].push_back(b);
            }
            else{
                g[a].push_back(b);
                g[b].push_back(a);
            }
        }
    }
}

void calculate(){
    int K,A,B;
    Input::input(K,A,B);
    for(int i = A;i <= B; ++i){
        if(i % K == 0){
            cout << "OK\n";
            return;
        }
    }
    cout << "NG\n";
}

int main(int,char**){
    calculate();    
}





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

typedef long long LL;

long gcd(LL a, LL b)
{
    LL temp;
    while (b > 0)
    {
        temp = b;
        b = a % b;
        a = temp;
    }
    return a;
}


int main() {
    int N;
    cin >> N;
    LL A_0, A_1;
    cin >> A_0;
    for (int i = 1; i < N; i++)
    {
        cin >> A_1;
        A_0 = gcd(A_1, A_0);
    }

    cout << A_0;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

void solve(){
	ll n;
	cin>>n;
	vector<ll> w(n,0);
	vector<ll> r(n+1,0);
	for(ll i=0;i<n;i++){
		cin>>w[i];
		r[i+1]=r[i]+w[i];
	}

	ll min=100000;
	for(ll i=0;i<n;i++){
		if(abs((r[n]-r[i])-(r[i]))<min){
			min=abs((r[n]-r[i])-(r[i]));
		}
	}

	cout<<min<<endl;
}


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


Measured memory_bytes: 256
object Main extends App {
  val n = io.StdIn.readInt
  val as = for (_ <- 1 to n) yield io.StdIn.readInt
  
  val sorted = as.sorted.reverse.take(2)
  val max_first = sorted(0)
  val max_second = sorted(1)

  for (a <- as) {
    if (a == max_first) println(max_second)
    else println(max_first)
  }
}

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

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

    vector<int> count(M, 0);

    for (int i = 0; i < N; i++)
    {
        int K;
        cin >> K;

        for (int j = 0; j < K; j++)
        {
            int A;
            cin >> A;
            count[A - 1]++;
        }
    }

    int ans = 0;

    for (int i = 0; i < M; i++)
    {
        if (count[i] == N)
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
nets = [0]*n

for _ in range(m):
    a,b = map(int, input().split())
    nets[a - 1] = max(nets[a-1], h[b-1])
    nets[b - 1] = max(nets[b-1], h[a-1])

ans = 0

#print(nets)

for i in range(n):
    if (h[i] >nets[i]):
        ans += 1

print(ans)

Measured memory_bytes: 20000
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

ll get(string arr[], ll n)
{
    ll m = arr[0].length();
    ll cnt = 0;
    rep(n)
        repi(j,m)
            if(arr[i][j] == '#')
                cnt++;
    return cnt;            
}

int main()
{
  FAST/**/
   
   ll powa[64];
   powa[0] = 1;
   for(ll i=1;i<64;i++)
        powa[i] = powa[i-1]*2;
   
   ll n,m,k;
   cin>>n>>m>>k;
   
   string arr[n];
   rep(n)
        cin>>arr[i];
   
   ll lim1 = (1ll<<(n));
   ll lim2 = (1ll<<(m));
   
   ll ans = 0;
   
   repi(rowMask,lim1){
       repi(colMask,lim2){
           
           string arr1[n];
           rep(n)
                arr1[i] = arr[i];
           rep(n)
                repi(j,m)
                {
                    if(rowMask & powa[i])
                        arr1[i][j] = '-';
                    if(colMask & powa[j])
                        arr1[i][j] = '-';
                }
           ll cnt = get(arr1,n);
           if(cnt == k)
                ans++;
           
       }
   }
   cout<<ans;
   
   
   return 0;        
}  
  
          
   

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

using namespace std;

int main()
{
  int x, a, b;

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

  if (b - a <= 0)
  {
    printf("delicious");
  }
  else if (b - a <= x)
  {
    printf("safe");
  }
  else
  {
    printf("dangerous");
  }
}

Measured memory_bytes: 256
S = input()
ans = "Yes"
cnt = 0
if len(S)%2 == 1:
  ans = "No"
for i in S:
  if cnt%2==0:
    if i != "h":
      ans = "No"
  else:
    if i != "i":
      ans = "No"
  cnt += 1
print(ans)

Measured memory_bytes: 38384
let id x = x

let n = Scanf.scanf "%d\n" id
let (s, t) = Scanf.scanf "%s %s\n" @@ fun s t -> (s, t)

let split = Str.split (Str.regexp "")

let solve = 
  List.combine (split s) (split t)
    |> List.map (fun (x, y) -> x ^ y)
    |> String.concat ""
    |> print_endline

Measured memory_bytes: 384
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 0x3f3f3f3f
#define bug puts("--------------")
const int N = 1e5 + 10;
const ll mod = 1e9 + 7 ;
using namespace std;
// C = A * b, A >= 0, b > 0
vector<int> mul(vector<int> &A, int b)
{
    vector<int> C;
    int t = 0;
    for (int i = 0; i < A.size() || t; i ++ )
    {
        if (i < A.size()) t += A[i] * b;
        C.push_back(t % 10);
        t /= 10;
    }

    return C;
}
int main(){
    int n,m;
    cin >>n >>m;
    cout << max(m,m+(10-n)*100)<<endl;
}

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


int main() {
    int n;
    cin>>n;
    long long a[n],answer=0,mx=0;
    for(int i=0;i<n;i++) {
        cin>>a[i];
        if(a[i] < mx) {
            answer += mx - a[i];
        }
        else {
            mx = a[i];
        }
    }
    cout<<answer;
    return 0;
}


Measured memory_bytes: 5164
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int sm=a*12+(a+1)/2;
	int sm2=b*10;
	int sm3=(a+1)*12+(a+1)/2;
	int sm4=(b+1)*10;
	if(sm>sm2&&sm<sm4)
	{
		cout<<sm;
		return 0;
	}
	if(sm2>sm&&sm2<sm3)
	{
		cout<<sm2;
		return 0;
	}
	if(sm2==sm)
	{
		cout<<sm;
		return 0;
	}
	cout<<"-1";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int memo[50] = {0};

int fib(int i){
    if(i == 0 || i == 1){
        return 1;
    } else if(i > 1){
        if(memo[i] == 0){
            memo[i] = fib(i-1) + fib(i-2);
        }
        return memo[i];
    } else {
        return 0;
    }
}

int main(){
    int n, a;
    scanf("%d", &n);
    
    a = fib(n-1) + fib(n-2);
    
    printf("%d\n", a);
    
    return 0;
}



Measured memory_bytes: 2120
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c$}@2ZI7Zb5Xay1Ddw^{7GecmbIHXl_eBUX*cPeBL!m|CKK)G#x`?;gH&+u)XMQvD?@a3pFrjp(MWOakq}8cQPduWlmGd(9h>8{+;|C^M6@__S@{rb*=1QlP4uhhmX%QCU7|KECb+rqAhDvC@mMQ&>2~}8ir5rG(<>8de$=bREjG<Bnj5i$zDoR<m8tm@FA1K|5>U4LPyi{C2_?f8hZbj27BOozGXAWgN+dF^@w~!OK5>Ny*0c1`D1_C_+N<a`e6S!dDjgGgQ%_cG5+XPAi%sQ;N7~Kgp7~EiVL!D8R#|W&qSU~*Yb>=bOcdQ!k^*j6cyb^Fxh>J>Gl;WZm7sa?I-^uD01lEQYN5Q?^AEn=tP!oFbt<9k45A-^rpW$Yeu}I=`0ufxCW(Z`b^1~4)<SAIg)_0nIX48|6&TJdsx#ptaP}LewAMjG@!J8@%m=|q0mP&hLQB$Orhq<XYRR2izPZTv2eWd6UB{E>~ki>lgzp(FnFn3Z^cz5ieCRYUX-mqD32Rz>!&L38=oAqwd)_$b=1vOPSZOE~<u=U{`Bj4e=&~aN5m83^y3kx3;nvKbS_Lq4jrdb|m;eLA*GkI<k{uaUR$0#a_uoKq$9C4eG8SvOx;r|=z=g|2Rh|VGU2=PMk|1H_x$uAUJ<_p1=p*Rt|@8jQwd9e6+Se%(xki;kZ<2!!=vtwqq")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 18000
N = int(input())
s = list(input())
e_count =s.count("E")
w_count =s.count("W")
temp = s[1:].count("E")
ans = 10**6
if temp <= ans:
    ans = temp
for i in range(N-1):
    if s[i] == "E" and s[i+1] == "E":
        temp -= 1
    elif s[i] == "W" and s[i+1] == "E":
        pass
    elif s[i] == "E" and s[i+1] == "W":
        pass
    else:
        temp += 1

    if temp <= ans:
        ans = temp
print(ans)

Measured memory_bytes: 8012
N, M = map(int, input().split())
H = list(map(int, input().split()))
OBS = []
for i in range(0, N):
        OBS.append(1)
for i in range(0, M):
        A = 0
        B = 0
        A, B = map(int, input().split())
        if H[A - 1] > H[B - 1]:
                OBS[ B - 1 ] = 0
        elif H[A - 1 ] < H[B - 1]:
                OBS[ A - 1 ] = 0
        else:
                OBS[A - 1] = 0
                OBS[B - 1] = 0
cnt = 0
for i in OBS:
        if i == 1:
                cnt += 1
# print(OBS)
print(cnt)

Measured memory_bytes: 20040
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        a: usize,
        b: usize
    };

    let mut res = 0;
    let mut cur = 1;
    while cur < b {
        res += 1;
        cur += a - 1;
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2216
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll MOD = 1e9+7;
const ll S = 1e5+9;

string s;
vector<int> coe = {1, 10, 9, 12, 3, 4};
ll dp[S][13]; // i桁目まで見たとき

int main() {
    cin >> s;
    reverse(s.begin(), s.end());
    ll sum = 0;
    dp[0][0] = 1;
    for(int i = 0, sz = s.size(); i < sz; i++) {
        if(s[i] == '?') {
            for(int val = 0; val <= 9; val++) {
                int diff = (coe[i%6] * val)%13;
                // cout << diff << endl;
                for(int k = 0; k < 13; k++) {
                    dp[i+1][ (k + diff)%13 ] += dp[i][k];
                    dp[i+1][ (k + diff)%13 ] %= MOD;
                }
            }
        }
        else {
            int val = s[i] - '0';
            sum += coe[i%6] * val;
            sum %= MOD;
            for(int k = 0; k < 13; k++) {
                dp[i+1][k] = dp[i][k];
            }
            // dp[i+1][(coe[i%6] * val)%13]++;
            // dp[i+1][(coe[i%6] * val)%13] %= MOD;
        }
    }

    for(int k = 0; k < 13; k++) {
        dp[s.size()+1][ (k+sum) % 13 ] = dp[s.size()][k];
    }

    // for(int i = 0, sz = s.size(); i <= sz; i++) {
    //     for(int k = 0; k < 13; k++) {
    //         cout << dp[i][k] << " ";
    //     }
    //     cout << endl;
    // }

    cout << dp[s.size()+1][5] << endl;
}

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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;

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

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

  sort(RALL(A));
  int apoint = 0;
  int bpoint = 0;
  for(int i = 0; i < N; i += 2) apoint += A[i];
  for(int i = 1; i < N; i += 2) bpoint += A[i];

  cout << apoint - bpoint << endl;

  return 0;
}



Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main(){
	int n;
	cin >> n;
	map<string, int> count;
	for(int i=0; i<n; i++){
		string a;
		cin >> a;
		count[a]++;
	}
	int maxtimes = 0;
	for(auto &p: count){
		maxtimes = max(maxtimes, p.second);
	}
	vector<string> ans;
	ans.reserve(n);
	for(auto &p: count){
		if(p.second == maxtimes){
			ans.push_back(p.first);
		}
	}
	sort(ans.begin(), ans.end());
	for(auto &s: ans){
		cout << s << endl;
	}
	return 0;
}

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

#define rep(i, N) for(int i = 0; i < (int)N; i++)
#define ll long long
const ll INF = 2LL<<60;

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

    int a = 0;

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

    rep(i, S.size())
    {
        rep(j, S.size())
        {
            if(i == j)
            {
                continue;
            }

            if(S.at(i) == S.at(j))
            {
                a++;
            }
        }
    }
    
    if(a == 4)  cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n, d = map(int, input().split())

A = []

for i in range(n):
  A_i = list(map(int, input().split()))
  A.append(A_i)
  
ans = 0

for j in A:
  if (j[0] ** 2 + j[1] ** 2) <= d **2 :
    ans += 1

print(ans)


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

int main()
{
 char s[101];
 int len=0;
  
 scanf("%s",s);
 len=strlen(s);
  
 for(int i=0;i<len;i++)
 {
   printf("x");
  }; 
  
  return 0;
  };




Measured memory_bytes: 128
#include <iostream>
#define A_SIZE 300
using namespace std;

int main() 
{
    int h_size, array[A_SIZE], value;
    scanf("%d", &h_size);
    for (int id = 1; id <= h_size; ++id) 
    {
        scanf("%d", &value);
        array[id] = value;
    }
    for (int id = 1; id <= h_size; ++id) 
    {
        printf("node %d: key = %d, ", id, array[id]);
        if (id/2 >= 1) printf("parent key = %d, ", array[id/2]);
        if (id*2 <= h_size) printf("left key = %d, ", array[id*2]);
        if (id*2+1 <= h_size) printf("right key = %d, ", array[id*2+1]);
        printf("\n");
    }
}


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

const int MAXN = 200000 + 10;
int n, a[MAXN], b[MAXN];

int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	memcpy(b,a,sizeof(a));
	sort(b + 1, b + n + 1);
	reverse(b + 1, b + n + 1); //降序 
	
	for(int i = 1; i <= n; i++)
	{
		if(a[i] == b[1]) cout << b[2] << endl;
		else cout << b[1] << endl;
	}
	
	return 0;
}


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

#define int int_fast64_t

void xmax(int& a, int b) {
  if (b < a)
    a = b;
}

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

  int n; cin >> n;
  int best=numeric_limits<int>::max();

  vector<int> sumd(max(int(10), n+1));
  for (int i=0; i<10; ++i)
    sumd[i] = i;
  for (int i=10; i<=n; ++i)
    sumd[i] = sumd[i/10] + i%10;
  
  for (int a=1; a<n; ++a) {
    xmax(best, sumd[a] + sumd[n-a]);
  }

  cout << best << '\n';
}

/*
 * Local variables:
 * compile-command:"g++ -D_GLIBCXX_DEBUG -g3 -ggdb3 -O0 -Wall -Wextra -std=c++14 a.cc -o a && for f in *.in; do echo \"--- $f -------------\"; ./a <$f; done"
 * end:
 */



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

const int MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n)cin>>a[i];
  ll ans=0;
  rep(i,60){
    bool t[n];
    ll num_0=0;
    ll num_1=0;
    rep(k,n){
      t[k]=(a[k]>>i)&1;
      if(t[k]==0)num_0++;
      else num_1++;
    }
    //cout << num_0 << " " << num_1 << endl;
    ans += ((num_0 * num_1)%MOD)*((1LL<<i)%MOD);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i=0;i<N;i++) {
    cin >> vec[i];
  }
  for (int i=K;i<vec.size();i++) {
    if (vec[i-K]<vec[i]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  string s;
  cin >> s;
  if((s[0]-'0')+(s[1]-'0')+(s[2]-'0')+(s[3]-'0')==7){
    cout << s[0] << '+' << s[1] << '+' << s[2] << '+' << s[3] << "=7" << endl;
  }
  else if((s[0]-'0')+(s[1]-'0')+(s[2]-'0')-(s[3]-'0')==7){
    cout << s[0] << '+' << s[1] << '+' << s[2] << '-' << s[3] << "=7" << endl;
  }
  else if((s[0]-'0')+(s[1]-'0')-(s[2]-'0')+(s[3]-'0')==7){
    cout << s[0] << '+' << s[1] << '-' << s[2] << '+' << s[3] << "=7" << endl;
  }
  else if((s[0]-'0')+(s[1]-'0')-(s[2]-'0')-(s[3]-'0')==7){
    cout << s[0] << '+' << s[1] << '-' << s[2] << '-' << s[3] << "=7" << endl;
  }
  else if((s[0]-'0')-(s[1]-'0')+(s[2]-'0')+(s[3]-'0')==7){
    cout << s[0] << '-' << s[1] << '+' << s[2] << '+' << s[3] << "=7" << endl;
  }
  else if((s[0]-'0')-(s[1]-'0')+(s[2]-'0')-(s[3]-'0')==7){
    cout << s[0] << '-' << s[1] << '+' << s[2] << '-' << s[3] << "=7" << endl;
  }
  else if((s[0]-'0')-(s[1]-'0')-(s[2]-'0')+(s[3]-'0')==7){
    cout << s[0] << '-' << s[1] << '-' << s[2] << '+' << s[3] << "=7" << endl;
  }
  else if((s[0]-'0')-(s[1]-'0')-(s[2]-'0')-(s[3]-'0')==7){
    cout << s[0] << '-' << s[1] << '-' << s[2] << '-' << s[3] << "=7" << endl;
  }
}

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

int main(){
    int n, m; cin >> n >> m;
    vector<int64_t> a(n);
    rep(i,n) cin >> a[i];
    vector<pair<int64_t,int>> cb;
    rep(i,m){
        int b, c;
        cin >> b >> c;
        cb.push_back(make_pair(c,b));
    }
    sort(cb.begin(),cb.end());
    reverse(cb.begin(),cb.end());

    int i = 0;
    int j = 0;
    while(i < n && j < m){
        int bj = cb[j].second;
        int64_t cj = cb[j].first;
        rep(k,bj){
            a.push_back(cj);
            i++;
            if(i >= n) break;
        }
        j++;
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int64_t ans = 0;
    rep(k,n) ans += a[k];
    cout << ans << endl;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define ll long long int 
#define endl '\n'
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
const ll INF=2e18;

typedef vector<ll>   vi;


int main()
{
ll n,sum=0,i;
cin>>n;
for(i=1;i<=n;i++){
	if(i%3==0 || i%5==0 || i%15==0)
	{
		;
	}
	else
	sum+=i;
}
cout<<sum;
return 0;
}


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

int main() {
  int N; cin >> N;
  vector<tuple<string, int, int>> a;
  rep(i, N) {
    string s;
    int p;
    cin >> s >> p;
    a.push_back(make_tuple(s, 100-p, i+1));
  }
  sort(a.begin(), a.end());
  
  for(auto x : a) {
    cout << get<2>(x) << endl;
  }
}

Measured memory_bytes: 256
#

import sys
input=sys.stdin.readline
MOD=10**9+7

fac=[1]*(5*10**5+1)
for i in range(1,5*10**5+1):
    fac[i]=(fac[i-1]*i)%MOD
    
def inv(x):
    return pow(x,MOD-2,MOD)

def nPr(n,r):
    return (fac[n]*inv(fac[n-r]))%MOD
def nCr(n,r):
    return (fac[n]*inv(fac[n-r])*inv(fac[r]))%MOD

def main():
    N,M=map(int,input().split())
    hojo=0
    for i in range(1,N+1):
        hojo+=(-1)**(i)*nCr(N,i)*nPr(M,i)*nPr(M-i,N-i)**2
        hojo%=MOD
    print((nPr(M,N)**2+hojo)%MOD)
    
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 73576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rep1(i,n) for(int i=1; (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
  int main(){
  int n; cin >> n;
  string s; cin >> s;
  int ans=0;
  rep(i,n){
    if(s[i]==s[i+1]) {}
    else ans++;
  }
  cout << endl << ans;
 
  return 0;
  }

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	long long n;
    cin>>n;
    long long tot=0;
    long long m=n-1;
    for (long long i=1;i*i<=m;i++){
        if (!(m%i)){
            if (i!=1){
                tot++;
            }
            if (m/i!=i){
                tot++;
            }
        }
    }
    vector <long long> a;
    for (long long i=1;i*i<=n; i ++){
        if (!(n%i)){
            a.push_back(i);
            if (n/i!=i){
                a.push_back(n/i);
            }
        }
    }
    for (vector<long long>::iterator i=a.begin();i<a.end();i++)
    {
        if (*i==1){
            continue;
		} 
        long long tmp = n, c = 0;
        while (!(tmp%(*i))){
            tmp/=*i;
			c=1;
		} 
        if (!c){
            continue;
		} 
        if (tmp%(*i) == 1){
            tot ++;
		} 
    }
    cout<<tot<<endl;
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(),(s).end())
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;

using namespace std;
long long x[1000010],y[1000010],z[1000010];
signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    double ans=0.0,a;

    rep(i,n){
        cin>>a;
        ans += 1.0/a;
    }
    ans=1.0/ans;
    cout<<setprecision(15)<<ans<<'\n';
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000002
mt19937 myrand(time(0));

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    priority_queue<pair<int,pair<int,int>>> pq;
    pq.push({a[n-1],{a[n-1],a[n-1]}});
    for(int i=n-2;i>=0;i--){
        pair<int,pair<int,int>> p=pq.top();
        pq.pop();
        ans+=p.ff;
        debug()<<imie(p);
        pq.push({a[i],{a[i],p.ss.ff}});
        pq.push({a[i],{a[i],p.ss.ss}});
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7220