akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main(void)
{	
	int i=0, j=0;
	int cnt=0;
	int s_len=0, p_len=0;
	char s[100], p[100];
	scanf("%s", s);
	scanf("%s", p);

	while(s[i] != '\0'){
		s_len++;
		i++;
	}
	i=0;
	while(p[i] != '\0'){
		p_len++;
		i++;
	}
	for(i=0; i<s_len+1; i++){
		for(j=0; j<p_len+1; j++){
			if(s[(i+j)%s_len] != p[j])
				break;
			else
				cnt++;
			if(cnt == p_len){
				printf("Yes\n");
				return 0;
			}
		}
		cnt = 0;
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
#include<cassert>
#include<utility>
#include<algorithm>
#include<complex>
using namespace std;
string s,t;
char smin='z',tmax='a';
int main(){
  cin>>s>>t;
  if(s.size()<t.size()){
    for(int i=0;i<s.size();i++){
      if(s[i]!=t[i])break;
      if(i==s.size()-1){cout<<"Yes"<<endl;return 0;}
    }
  }
  for(int i=0;i<s.size();i++){
    if(smin>=s[i])smin=s[i];
  }
  for(int i=0;i<t.size();i++){
    if(tmax<=t[i])tmax=t[i];
  }
  if(smin<tmax)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>

int main()
{
	int ans=0;
	char c=getchar();
	while(c!='\n'){
		if(c=='+')ans++;
		if(c=='-')ans--;
		c=getchar();
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

signed main(){
    cout << fixed << setprecision(10);
    intl h,n;
    cin >> h >> n;
    intl a[n],b[n];
    rep(i,n)cin >> a[i] >> b[i];
    intl dp[n + 1][h + 1];
    rep(j,h + 1)dp[0][j] = INF;
    rep(i,n){
        rep(j,h + 1){
            if(j > a[i])dp[i + 1][j] = min(dp[i][j],dp[i + 1][j - a[i]] + b[i]);
            else dp[i + 1][j] = min(dp[i][j],b[i]);
        }
    }
    cout << dp[n][h] << endl;
    return 0;
}


Measured memory_bytes: 81784
import math
n, m = map(int, input().split())
mod = 10 ** 9 + 7
if abs(n - m) > 1:
    print(0)
elif abs(n - m) == 1:
    print(math.factorial(n) * math.factorial(m) % mod)
elif n == m:
    print(2 * math.factorial(n) * math.factorial(m) % mod)

Measured memory_bytes: 5176
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.io.PrintWriter;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        final String s;

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            s = reader.readLine();
        }

        PrintWriter out = new PrintWriter(System.out);

        final String[] sl = s.split(" ");
        long N = Long.parseLong(sl[0]);
        long M = Long.parseLong(sl[1]);

        long N2 = 2L * N;
        long tmps = N2 < M ? N : M / 2;
        long tmpm = M - tmps * 2;

        out.println(tmps + tmpm / 4);

        out.flush();
    }
}


Measured memory_bytes: 20820
using System;

namespace APG4b
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int cnt = 0;
            int num =int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            for (int i = 1; i < num;i++)
            {
                if(int.Parse(input[i]) == int.Parse(input[i-1]))
                {
                    cnt++;
                    i++;
                }
            }
            Console.WriteLine(cnt);

        }
    }
}


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

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

    cin >> a >> b >> c >> d;

    a += b;
    c += d;

    if(a > c) cout << "Left" << endl;
    else if(c > a) cout << "Right" << endl;
    else cout << "Balanced" << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.conv, std.string, std.algorithm, std.math;

void main() {
  auto n = readln.chomp.to!int;

  for (int i = 0; i < n; i++) {
    auto tri = readln.chomp.split.map!(to!int).array.sort;

    if (pow(tri[0], 2) + pow(tri[1], 2) == pow(tri[2], 2)) {
      writeln("YES");
    } else {
      writeln("NO");
    }
  }
}

Measured memory_bytes: 1064
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto abc = readints;
    abc.sort();
    if (abc[0] + abc[1] == abc[2])
        writeln("Yes");
    else
        writeln("No");
}


Measured memory_bytes: 256
fun main() {
    val (a, b, c, d) = readLine()!!.map { it.toString().toInt() }

    val mask = 1.shl(3)
    for (i in 0 until mask) {
        var tmp = a
        var op1 = ""
        if (i.shr(0).and(1) == 1) {
            tmp += b
            op1 = "+"
        } else {
            tmp -= b
            op1 = "-"
        }

        var op2 = ""
        if (i.shr(1).and(1) == 1) {
            tmp += c
            op2 = "+"
        } else {
            tmp -= c
            op2 = "-"
        }

        var op3 = ""
        if (i.shr(2).and(1) == 1) {
            tmp += d
            op3 = "+"
        } else {
            tmp -= d
            op3 = "-"
        }

        if (tmp == 7) {
            print("$a$op1$b$op2$c$op3$d=7")
            return
        }
    }
}


Measured memory_bytes: 34432
#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 rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N;
    cin >> N;
    ll a[N], sum1 = 0, sum2 = 0;
    rep(i, N){
        cin >> a[i];
        sum1 += a[i];
    }
    ll ans = INF;
    rep(i, N-1){
        sum2 += a[i];
        ans = min(ans, abs(sum1-2*sum2));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
    string a;
    int b,c;
    cin>>a;
    if(a=="SUN"){
        cout<<7;
    }
    else if(a=="MON"){
        cout<<6;
    }
    else if(a=="TUE"){
        cout<<5;
    }
    else if(a=="WED"){
        cout<<4;
    }
    else if(a=="THU"){
        cout<<3;
    }
    else if(a=="FRI"){
        cout<<2;
    }
    else if(a=="SAT"){
        cout<<1;
    }
}
//SUN, MON, TUE, WED, THU, FRI, or SAT.


Measured memory_bytes: 256
/*input
11
0.9
1
1
1.25
2.30000
5
70
0.000000001
9999.999999999
0.999999999
1.000000001
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=1e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    ll res=0LL;
    while(b){
        if(b&1) res=(res+a)%MOD;
        a=(a+a)%MOD;
        b>>=1;
    }
    return res%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int mp[50][20][10];
int32_t main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
  cin>>n;
    ll ans=0;
    REP(i,n){
        string s;
        cin>>s;
        int cnt=0;
        REP(j,sz(s)){
            if(s[j]=='.'){
                cnt=sz(s)-j-1;
                s.erase(s.begin()+j);
                break;
            }
        }
        ll x=stoll(s);
        int two=0,five=0;
        while(x%2==0){
            x/=2;
            ++two;
        }
        while(x%5==0){
            x/=5;
            ++five;
        }
        
        REP(i,47){
            REP(j,20){
                //if(!sz(mp[i][j])) continue;
                int cur=min(i+two,j+five);
                //if(mp[i][j][max(min(cur-cnt,9),0)]) cout<<i<<' '<<j<<'\n';
                int k=min(cur-cnt,9);
                if(k<0) continue;
                ans+=mp[i][j][k];

            }
        }
       //cout<<ans<<'\n';
        //cout<<sz(mp)<<'\n';
        for(int j=cnt;j<10;j++) mp[two][five][j]++;
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 3664
#include<iostream>
#define ll long long

using namespace std;

int main() {
	ll n, m;
	cin >> n >> m;
	ll a = 1, b = 1, mod=1000000007;
	for (ll i = 1; i <= n; i++) {
		a *= i;
		a %= mod;
		}
	for (ll i = 1; i <= m; i++) {
		b *= i;
		b %= mod;
		}
	
	if (n == m) {
		cout << (a*b * 2) % mod << endl;
	}
	else if (n + 1 == m || m + 1 == n) {
		cout << a*b %mod << endl;
	}
	else {
		cout << 0 << endl;
	}


	return 0;
}

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



int main(){
    int N,L;
    cin >> N >> L;
    vector<string> S(N);
    for(int i = 0;i<N;i++){
        cin >> S.at(i);
    }
    sort(S.begin(),S.end());
    string ans;
    for(int j = 0;j<N;j++){
        ans = ans + S.at(j);
    }
    cout << ans << endl;
}

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

int main(){
  int A,B;
  cin>>A>>B;
  if(A==1 && B==2){
    cout<<3<<endl;
  }
   if(A==2 && B==1){
    cout<<3<<endl;
  }
   if(A==1 && B==3){
    cout<<2<<endl;
  }
   if(A==3 && B==1){
    cout<<2<<endl;
  }
   if(A==3 && B==2){
    cout<<1<<endl;
  }
   if(A==2 && B==3){
    cout<<1<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mm=1000000007;
struct data{
	int c,v;
}b[400001];
ll ans,fac[400001];
int i,j,k,n,t1,t2,a[400001],c[400001],mv,w,m,d[400001],bn;
ll pw(ll b,ll p){
	ll res=1;
	for (;p;p>>=1,b=b*b%mm)
	 if (p&1) res=res*b%mm;
	return res;
}
int main(){
	scanf("%d%d%d",&n,&t1,&t2);memset(c,0,sizeof(c));memset(d,0,sizeof(d));bn=n;
	for (fac[0]=i=1;i<=n;i++) fac[i]=fac[i-1]*(ll)i%mm;
	for (i=1,mv=mm,m=0;i<=n;i++){
		scanf("%d%d",&b[i].c,&b[i].v);mv=min(mv,b[i].v);m=max(m,b[i].c);
		if (!c[b[i].c]) c[b[i].c]=1,a[b[i].c]=b[i].v;else c[b[i].c]++,a[b[i].c]=min(a[b[i].c],b[i].v);
	}
	for (w=1;!c[w]||a[w]!=mv;w++);
	for (i=1,k=mm;i<=m;i++){
		if (!c[i]||w==i) continue;
		k=min(k,a[i]);
		if (a[i]+mv>t2) n-=c[i],c[i]=0;//,printf("* %d\n",i);
	}
	for (i=1;i<=bn;i++){
		if (!c[b[i].c]) continue;
		if (b[i].v+a[b[i].c]>t1&&b[i].v+(b[i].c==w?k:mv)>t2){
			n--;c[b[i].c]--;//printf("** %d %d\n",b[i].c,b[i].v);
		}
	}
	for (ans=fac[n],i=1;i<=m;i++)
	 if (c[i]) ans=ans*pw(fac[c[i]],mm-2)%mm;//,printf("*** %d\n",c[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10496
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x: u64 = read();
    let y: u64 = read();

    let x_byte: String = format!("{:b}", x);
    let y_byte: String = format!("{:b}", y);

    let diff = y_byte.len() - x_byte.len();
    let mut ans = diff;
    if x <= (y >> diff) {
        ans += 1;
    }

    // println!("{:b}", x);
    // println!("{:b}", y);
    // println!("{:b}", y >> diff);

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i,k,n) for(int i=(k);i<=(n);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 pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()  //greater<int>()
#define LL long long
using namespace std;

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

	cnt=1;
	FOR(i,1,N){
		//cnt=cnt%((1e9)+7);
		cnt=cnt*i;
		cnt=cnt%(1000000000+7);
	}

	cout<<cnt<<endl;
   	return 0;
}

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

int main(){
  int N; cin >> N;
  map<string, int> mp;
  rep(i, N) {
    string S; cin >> S;
    mp[S]++;
  }
  vector<string> L = {"AC", "WA", "TLE", "RE"};
  rep(i, 4)  cout << L[i] << " x " << mp[L[i]] << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
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; }

lli dist[60];
lli oya[60];

vector<pair<lli,lli>> G[60];

map<pair<lli,lli>,lli> edgeToBit;

vector<pair<lli,lli>> v;


void func(lli from,lli now,lli start,lli target,lli bit){
  if(now==target){
      edgeToBit[{start,target}] = bit;
      edgeToBit[{target,start}] = bit;
  }

  for(auto e:G[now]){
    if(e.first == from)continue;
    lli nextBit = bit;
    nextBit |= (1LL<<e.second);
    func(now,e.first,start,target,nextBit);
  }
}

lli powpow(lli num,lli jisu){
  if(jisu<=0)return 1;
  lli n = num;
  while(jisu>1){
    jisu--;
    n *= num;
  }
  return n;
}

lli bitCount(lli num){
  lli rtn = 0;
  while(num>0){
      if(num%2)rtn++;
      num /= 2;
  }
  return rtn;
}

int main(){

    lli n;
    cin>>n;

    REP(i,0,n-1){
      lli x,y;
      cin>>x>>y;
      x--,y--;
      G[x].push_back({y,i});
      G[y].push_back({x,i});
    }

    lli m;
    cin>>m;

    REP(i,0,m){
      lli x,y;
      cin>>x>>y;
      x--,y--;
      v.push_back({x,y});
      func(-1,x,x,y,0);
    }

    lli ans = 0 ;

    for(lli i=0;i<(1LL<<m);i++){
      lli bit = 0;
      lli bCnt = 0;
      for(lli k=0;k<m;k++){
        if(!(i&(1LL<<k)))continue;
        bit |= edgeToBit[v[k]];
        bCnt++;
      }
      lli cnt = bitCount(bit);
      lli leftEdge = n-1-cnt;

      if(bCnt%2)ans -= powpow(2,leftEdge);
      else ans += powpow(2,leftEdge);
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> a(N), b(M), sa(N + 1, 0), sb(M + 1, 0);
    rep(i, N) cin >> a[i];
    rep(j, M) cin >> b[j];
    rep(i, N) sa[i + 1] += sa[i] + a[i];
    rep(i, M) sb[i + 1] += sb[i] + b[i];
    ll ans = 0;
    rep(i, N + 1){
        ll jdm = 0;
        if(K - sa[i] < 0) continue;
        ll res = K - sa[i];
        jdm += i;
        jdm += upper_index(sb, res) - 1;
        chmax(ans, jdm);
    }
    pt(ans);
}

Measured memory_bytes: 9572
import collections
import bisect

def main():
    s = input()
    t = input()

    ns, nt = len(s), len(t)
    cs, ct = set(list(s)), set(list(t))
    for c in ct:
        if c not in cs: return -1

    # def unittest(s, t):
    #     i = 0
    #     for c in t:
    #         while s[i % ns] != c:
    #             i += 1
    #         i += 1
    #     return i

    d = collections.defaultdict(list)
    for i in range(ns):
        if s[i] in ct: d[s[i]].append(i)
    # print(s, t)
    i = 0
    for c in t:
        # binary search
        j = i % ns
        k = bisect.bisect_left(d[c], j)
        if k == len(d[c]):
            i = (i // ns + 1)*ns + d[c][0]
        else:
            if j <= d[c][k]:
                i = (i // ns)*ns + d[c][k]
            else:
                i = (i // ns + 1)*ns + d[c][k]
        # print(i)
        i += 1
    return i
    # return i, unittest(s, t)


if __name__ == '__main__':
    print(main())

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

using i64 = int64_t;

constexpr i64 MOD = 1e9 + 7;

vector<vector<i64>> set_comb(i64 n, i64 m){
    vector<vector<i64>> res(n+1, vector<i64>(m+1));
    res[0][0] = 1;
    for(int i=1;i<=n;++i){
        res[i][0] = 1;
        for(int j=1;j<=m;++j){
            res[i][j] = res[i-1][j-1] + res[i-1][j];
            res[i][j] %= MOD;
        }
    }
    return res;
}

int main(){
    i64 n, k;
    cin >> n >> k;
    auto comb = set_comb(n, n);
    for(int i=1;i<=k;++i){
        i64 ans = comb[k-1][i-1];
        if(i == 1){
            ans *= n-k+1;
            ans %= MOD;
        }else{
            i64 tmp = 0;
            for(int j=i-1;j<=n-k;++j){
                tmp += (comb[j-1][i-2] * (n-k-j+1)) % MOD;
                tmp %= MOD;
            }
            ans *= tmp;
            ans %= MOD;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 31616
first_line = input().split()
second_line = input().split()
third_line = input().split()
 
first_line = [int(i) for i in first_line]
second_line = [int(i) for i in second_line]
third_line = [int(i) for i in third_line]

N = input()
N = int(N)



B  = [] 
for i in range(N):
    inp  =input()
    inp = int(inp)
    B.append(inp)


# arr = [[0]*3]*3
# print(arr)
# for i in range(3):
#     arr[0][i]= first_line[i]
#     print(arr)
# print(arr)
# for i in range(3):
#     arr[1][i]= second_line[i]
# for i in range(3):
#     arr[2][i]= third_line[i]

arr = []
arr.append(first_line)
arr.append(second_line)
arr.append(third_line)
carr = [[False for i in range(3)] for j in range(3)]

for b in B:
    for i in range(3):
        for j  in range(3):
            if b == arr[i][j]:
                carr[i][j] = True

def yoko(carr):
    for i in range(3):
        flag = 0
        for j in range(3):
            if carr[i][j] != True:
                flag = 1
        if flag == 0 :
            return True    
    return False


def tate(carr):
    for i in range(3):
        flag = 0
        for j in range(3):
            if carr[j][i] != True:
                flag = 1
                break
        if flag == 0:

            return  True
    
    return False

def naname (carr):
    flag2 = 0
    flag1 = 0
    for i in range(3):
        if carr[i][i] != True:
            flag1 = 1

        if carr[i][3-i-1] != True:
            flag2 = 1;
    if flag1==0 or flag2 ==0:
        return True
    else:
        return False

def checker(carr):
    # print(tate(carr))
    # print(yoko(carr))
    # print(naname(carr))
    
    if not tate(carr)  and not yoko(carr) and not naname(carr):
        return 'No'
    else:
        return 'Yes' 
print(checker(carr))

Measured memory_bytes: 3188
fn main() {
    proconio::input! {
        n: usize,
        k: usize,
        ps: [usize; n],
        cs: [i128; n],
    }
    let loop_score_loop_indices = {
        let mut loop_score_loop_indices = vec![(0i128, 0usize); n];
        for start in 0..n {
            let mut visit = vec![false; n];
            let mut current = start;
            while !visit[current] {
                visit[current] = true;
                let next = ps[current] - 1;
                loop_score_loop_indices[start].0 += cs[next];
                loop_score_loop_indices[start].1 += 1;
                current = next;
            }
        }
        loop_score_loop_indices
    };
    let mut score_maxs = vec![(0i128, std::i128::MIN); n];
    for start in 0..n {
        let (loop_score, loop_indices_len) = loop_score_loop_indices[start];
        if loop_score <= 0 {
            let mut current = start;
            for _ in 0..std::cmp::min(k, loop_indices_len) {
                let next = ps[current] - 1;
                score_maxs[start].0 += cs[next];
                if score_maxs[start].1 < score_maxs[start].0 {
                    score_maxs[start].1 = score_maxs[start].0;
                }
                current = next;
            }
        } else {
            let mut current = start;
            if k < loop_indices_len {
                for _ in 0..k {
                    let next = ps[current] - 1;
                    score_maxs[start].0 += cs[next];
                    if score_maxs[start].1 < score_maxs[start].0 {
                        score_maxs[start].1 = score_maxs[start].0;
                    }
                    current = next;
                }
            } else {
                score_maxs[start].0 += loop_score * (k / loop_indices_len - 1) as i128;
                for _ in 0..(k % loop_indices_len) + loop_indices_len {
                    let next = ps[current] - 1;
                    score_maxs[start].0 += cs[next];
                    if score_maxs[start].1 < score_maxs[start].0 {
                        score_maxs[start].1 = score_maxs[start].0;
                    }
                    current = next;
                }
            }
        }
    }
    let ans = score_maxs.iter().map(|(_score, max)| max).max().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 2524
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {

static ArrayList<Integer[]> list=new ArrayList<>();
static ArrayList<Integer[]> set=new ArrayList<>();


	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  // String nyuA=sc.nextLine();
 //  String nyuB=sc.nextLine();
 
 //   String[] s=sc.nextLine().split(" ");
     String[] e=sc.nextLine().split(" ");

int X=Integer.parseInt(e[0]);

int Y=Integer.parseInt(e[1]);
int Z=Integer.parseInt(e[2]);
int res=0;
X-=Z;
while(true){
if(X>=Y){
res++;
X-=Y;
}else{
break;
}

if(X<Z){
res--;
}else if(X>=Z){
X-=Z;
}

}//while


System.out.println(res);


	}

}

Measured memory_bytes: 23252
#include<iostream>
using namespace std;
int main()
{
  long long int n, i, x, y;
  cin>>n;
  x = n-1;
  y = n+1;
  long long int arr[x], num[y]={0};
  for(i=0; i<x; i++)
  {
      cin>>arr[i];
      num[arr[i]]++;
  }
  for(i=1; i<=n; i++)
  cout<<num[i]<<endl;
  
  return 0;
}

Measured memory_bytes: 6760
#include<iostream>

using namespace std;

int main() {

	int a, b;

	cin >> a >> b;

	if (a > b) 
		cout << "a > b" << endl;

	else if (a < b) 
		cout << "a < b" << endl;
	
	else 
		cout << "a == b" << endl;
	
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ll long long
#define lf long double
#define INF 10000000000000000
#define MAX 300001
#define M 998244353
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int cnt = 1;
  for (int i=0;true;i++) {
    int rem = cnt+i*a - i;
    if (rem>=b) {
      cout << i;
      return 0;
    }
  }
  return 0;
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    System.out.println((a>=1 && a<=9) && (b>=1 && b<=9)?a*b:-1);
  }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;
int ctoi(char c){
	if(c >= '0' && c <= '9')return (c - '0');
}
int main(void){
  string s;
  cin >> s;
  int a = ctoi(s[0]), b = ctoi(s[1]), c = ctoi(s[2]), d = ctoi(s[3]);


  rep(i, 2){
    rep(j, 2){
      rep(k, 2){
        int tmp = a;
        if(i == 0) tmp += b;
        else tmp -= b;
        if(j == 0) tmp += c;
        else tmp -= c;
        if(k == 0) tmp += d;
        else tmp -= d;
        if(tmp == 7){
          cout << a << (i?'-':'+') << b << (j?'-':'+') << c << (k?'-':'+') << d << "=7";
          return 0;
        }
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
#pragma region Include
#include <bits/stdc++.h>
// #include <algorithm>
// #include <bitset>
// #include <climits>
// #include <cmath>
// #include <iostream>
// #include <iterator>
// #include <map>
// #include <queue>
// #include <sstream>
// #include <stack>
// #include <string>
// #include <unordered_map>
// #include <unordered_set>
// #include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(4) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

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;
}

#pragma endregion

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<bool> ac(N, 0);
  vector<int> wa(N, 0);
  rep(i, M) {
    int p;
    string S;
    cin >> p >> S;
    p--;
    if (S == "AC") {
      if (ac[p] == 0) {
        ac[p] = 1;
      }
    } else if (S == "WA") {
      if (ac[p] == 0) {
        wa[p]++;
      }
    }
  }
  int correct = 0;
  int wrong = 0;
  rep(i, N) {
    correct += ac[i];
    if (ac[i] == 1) {
      wrong += wa[i];
    }
  }
  cout << correct << " " << wrong << endl;
  return 0;
}

Measured memory_bytes: 768
// #include "bits/stdc++.h"

#include <iostream>
#include <vector>
#include <cstdlib>

// // vector
// #define MAX_ELE(vec) *max_element(vec.begin(), vec.end())
// #define SORT(vec) sort(vec.begin(), vec.end());


// // ---------------------------------------

// // string
// #define TO_UP(str) transform(str.cbegin(), str.cend(), str.begin(), ::toupper)

// // ---------------------------------------



using namespace std;

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;
}

    int N;
    long long h[100000][3];
    long long dp[100000][3];

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

    int N;
    cin >> N;
    
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> h[i][j];
        }
        
    }
    
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if(j != k){
                    chmax(dp[i+1][k], dp[i][j] + h[i][k]);
                }
            }
            
        }
        
        
    }

    long long ans = 0;
    for (int i = 0; i < 3; i++)
    {
        chmax(ans, dp[N][i]);
    }
    
    cout << ans << "\n";

}


Measured memory_bytes: 4992
using System;
using System.Text;

namespace ITP_4_C{
    public class Program{
        public static void Main(string[] args){
            StringBuilder result = new StringBuilder();
            bool exitFlag = true;

            while(exitFlag){
                String[] temp = Console.ReadLine().Split(' ');
                int a = int.Parse(temp[0]);
                int b = int.Parse(temp[2]);
                switch(temp[1]){
                    case "+":
                        a = a + b;
                        result.AppendLine(a.ToString());
                        break;
                    case "-":
                        a = a - b;
                        result.AppendLine(a.ToString());
                        break;
                    case "*":
                        a = a * b;
                        result.AppendLine(a.ToString());
                        break;
                    case "/":
                        a = a / b;
                        result.AppendLine(a.ToString());
                        break;
                    case "?":
                        exitFlag = false;
                        break;
                }
            }
            Console.Write(result.ToString());
        }
    }
}

Measured memory_bytes: 9100
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int X,Y;
  cin >> X >> Y;
  cout << X+Y/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main () {
  char str[21];
  scanf("%s", str);
  int l = strlen(str);
  char str_r[21];
  REP(i, l) str_r[i] = str[l-i-1];
  str_r[l] = '\0';
  printf("%s\n", str_r);
  return 0;
}

Measured memory_bytes: 2484
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#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>
#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 pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
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};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,m,x;cin>>n>>m>>x;
    vector<int>a(m);
    map<int,int>mm;
    for(int i=0;i<m;i++){
         cin>>a[i];
        mm[a[i]]++;
    }
    int sum1=0,sum2=0;
    for(int i=x;i>0;i--){
        if(mm[i-1])
            sum1++;
    }
    for(int i=x;i<n-1;i++){
        if(mm[i+1])
            sum2++;
    }
    cout<<min(sum1,sum2)<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
e = v[::2]
o = v[1::2]
ce = sorted([(v, k) for k, v in Counter(e).items()], reverse=True)
co = sorted([(v, k) for k, v in Counter(o).items()], reverse=True)
if ce[0][1] == co[0][1]:
    if len(ce) == 1 and len(co) == 1:
        print(len(o))
    elif len(ce) == 1:
        print(len(o) + len(e) - ce[0][0] - co[1][0])
    elif len(co) == 1:
        print(len(o) + len(e) - ce[1][0] - co[0][0])
    else:
        print(len(e) + len(o) - max(ce[1][0] + co[0][0], ce[0][0] + co[1][0]))
else:
    print(len(e) + len(o) - ce[0][0] - co[0][0])


Measured memory_bytes: 63468
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i=0; i<n; i++) a[i] = sc.nextLong();

        long MOD = (long)1e9 + 7;

        long res = 0;
        long[] sum = new long[n+1];

        for (int i=1; i<=n; i++) {
            sum[i] = sum[i-1] + a[i-1];
        }

        for (int i=0; i<n; i++) {
            long tmpSum = sum[n-i-1];
            tmpSum = tmpSum % MOD;
            tmpSum *= a[n-i-1];
            res += tmpSum;
            res %= MOD;
        }

        System.out.print(res % MOD);

    }

}



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

int main(){
   int N, X, m[101];
   cin >> N >> X;
   int S = 0, M = 1001001001;

   for(int i = 0; i < N; i++){
      cin >> m[i];
      S += m[i];
      if(M > m[i]){
         M = m[i];
      }
   }
   // 全種類の個数 + (初期残高 - 全種類コスト) / 最小コスト
   int ans = N + (X - S) / M;
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve(N int64, s []string, t []int64, X string) {
	var ans int64
	var sleeping bool
	for i := int64(0); i < N; i++ {
		if sleeping {
			ans += t[i]
		}
		if s[i] == X {
			sleeping = true
		}
	}
	fmt.Println(ans)
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int64
	scanner.Scan()
	N, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	s := make([]string, N)
	t := make([]int64, N)
	for i := int64(0); i < N; i++ {
		scanner.Scan()
		s[i] = scanner.Text()
		scanner.Scan()
		t[i], _ = strconv.ParseInt(scanner.Text(), 10, 64)
	}
	var X string
	scanner.Scan()
	X = scanner.Text()
	solve(N, s, t, X)
}


Measured memory_bytes: 640
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main() {
    string n;
    cin>>n;
    int t=stoi(n);
    int a=t/1000;
    t-=a*1000;
    int b=t/100;
    t-=b*100;
    int c=t/10;
    t-=c*10;
    int d=t;
    if(a+b+c+d==7)cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
    else if(a+b+c-d==7)cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
    else if(a+b-c+d==7)cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
    else if(a+b-c-d==7)cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
    else if(a-b+c+d==7)cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
    else if(a-b+c-d==7)cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
    else if(a-b-c+d==7)cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
    else if(a-b-c-d==7)cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


// [N©Ç¤©Æ¤}N : }NÉ·éÓ¡Í ÜèÈ¢ªK&RÉ»¤ÈÁÄ¢éÌÅB
#define leap(y) ((y)%4 == 0 && ((y)%100 != 0 || (y)%400 == 0))

// êNÌÌútÌÝvf[^
static int md[2][12] =
{
	0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334,
	0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 
};



// ¼ï1N11ú©çÌÝvú : 7ÅÁ½ ÜèªjúÉÈé (0:sun)
int TotalDays(int y, int m, int d)
{
	int ty = y-1;
	int t = ty*365 + ty/4 - ty/100 + ty/400;
	
	t += md[leap(y)][m-1];
	return t + d;
}

int main()
{
	int y1, y2, m1, m2, d1, d2;
	while(cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2 && y1 != -1)
	{
		int d = abs(TotalDays(y1, m1, d1) - TotalDays(y2, m2, d2));
		
		cout << d << endl;
		
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int n; cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i += 2){
        int count = 0;
        for(int j = 1; j <= n; j++){
            if(i % j == 0) count++;
        }
        if(count == 8) ans++; 
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, d[300][300], d2[300][300], ans;

int main() {
	cin >> n;
	rep(i,n) rep(j,n) {
		cin >> d[i][j];
		d2[i][j] = d[i][j];
	}
	
	rep(i,n) {
		rep(j,n) {
			rep(k,n) {
				if (i==k || j==k) continue;
				// 与えられた表が正しい最短距離の表じゃなかった場合終了
				if (d[i][j]>d[i][k]+d[k][j]) {
					cout << -1 << ln;
					return 0;
				} else if (d[i][j]==d[i][k]+d[k][j]) d2[i][j] = 0;
			}
		}
	}
	rep(i,n) rep(j,n) ans += d2[i][j];
	ans /= 2;
	cout << ans << ln;
}

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

int main(){
  string s[4];
  cin >> s[0] >> s[1] >> s[2];
  cout << (char) (s[0][0] - 0x20);
  cout << (char) (s[1][0] - 0x20);
  cout << (char) (s[2][0] - 0x20) << endl;
  return 0;
}

Measured memory_bytes: 256