akhauriyash/Code-Regression huggingface dataset:
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{
    int a, b, c;
    cin >> a >> b >> c;

    int k;
    cin >> k;

    while(a >= b && k > 0)
    {
        b *= 2;
        k--;
    }

    while(b >= c && k > 0)
    {
        c *= 2; 
        k--;
    }

    if(a < b && b < c)
    {
        cout << "Yes\n";
        return;
    }

    cout << "No\n";

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int T = 1;
    //cin >> T;
    
    while (T--)
    {
        solve();
    }
    
    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double d;
typedef vector<ll> v;
typedef pair<ll,ll> p;
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	string s,t;
	cin>>s>>t;
	ll count=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i])count++;
	}
	cout<<count<<endl;
}

Measured memory_bytes: 3920
#include<stdio.h>

int main(){



int N;
int p,q,r,c;

while(1){
	int n[1024][6]={};
scanf("%d",&N);if(N==0)break;

for(int i=0;i<N;i++)
{scanf("%d %d %d %d",&n[i][0],&n[i][1],&n[i][2],&n[i][3]);
n[i][4]=4*n[i][1]+9*n[i][2]+4*n[i][3];
}

scanf("%d %d %d %d",&p,&q,&r,&c);

bool f=true;
for(int i=0;i<N;i++)
{if(n[i][1]<=p&&n[i][2]<=q&&n[i][3]<=r&&n[i][4]<=c){printf("%d\n",n[i][0]);f=false;}
}

if(f==true)printf("NA\n");


}
return 0;
}

Measured memory_bytes: 1072
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if(s == "MON") cout << 6 << endl;
  if(s == "TUE") cout << 5 << endl;
  if(s == "WED") cout << 4 << endl;
  if(s == "THU") cout << 3 << endl;
  if(s == "FRI") cout << 2 << endl;
  if(s == "SAT") cout << 1 << endl;
  if(s == "SUN") cout << 7 << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
S = input()
reverse_S = S[::-1]
T = ""
dreamlist = ["erase","eraser","dream","dreamer"]
newlist = [dreamlist[i][::-1] for i in range(len(dreamlist))]

flg = 1
while flg >= 1:
    flg = 0
    for i in range(len(newlist)):
        if reverse_S.startswith(T + newlist[i]):
            T += newlist[i]
            flg += 1
            break
        else:
            continue
if reverse_S == T:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;

	vector<string> A(H+2);
	for(int i=1;i<=H;i++){
		cin >> A.at(i);
		A.at(i) = '#' + A.at(i) + '#';
	}
	string str = "";
	for(int i=0;i<W+2;i++){
		str += "#";
	}
	A.at(0) = str;
	A.at(H+1) = str;

	for(int i=0;i<H+2;i++){
		cout << A.at(i) << endl;
	}
}

Measured memory_bytes: 256
S = gets.chomp
a = Array.new(26){Array.new(0)}

for i in 0...S.size do
    a[S[i].ord-97].push(i)
end

T = gets.chomp
b = 0
c = -1
s = 0
for i in 0...T.size do
    s = T[i].ord-97
    if a[s].empty?
        puts "-1"
        exit
    elsif a[s].last > c
        if a[s][0] > c
            c = a[s][0]
        else
            l = 0
            r = a[s].size-1
            o = (l+r)/2
            while r-l > 1
                if a[s][o] > c
                    r = o
                else
                    l = o
                end
                o = (l+r)/2
            end
            c = a[s][r]
        end
    else
        b += 1
        c = a[s][0]
    end
end
answer = (b*S.size)+c+1
puts answer

Measured memory_bytes: 3324
// finish date: 2019/2/24

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;

vvvd memo;
int N;

double dfs(int x, int y, int z) {
    if (x < 0 || y < 0 || z < 0) return 0;
    if (memo[x][y][z] != -1) return memo[x][y][z];
    return memo[x][y][z] = (dfs(x - 1, y, z) * x +
                            dfs(x + 1, y - 1, z) * y +
                            dfs(x, y + 1, z - 1) * z) /
                           (x + y + z) +
                           (double) N / (x + y + z);
}

int main() {
    cin >> N;
    vi cnt(3, 0);
    rep(i, N) {
        int a;
        cin >> a;
        cnt[a - 1]++;
    }
    memo = vvvd(N + 1, vvd(N + 1, vd(N + 1, -1)));
    memo[0][0][0] = 0;
    printf("%.10lf\n", dfs(cnt[0], cnt[1], cnt[2]));

    return 0;
}

Measured memory_bytes: 216960
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		while (true) {
        // 入力されるH,Wを定義

        int H = scanner.nextInt();
        int W = scanner.nextInt();

        // H,Wともに0の時終了
        if (H == 0 && W == 0) {
        	break;
        }

        for (int i = 0; i < H; i++) {
        	for (int j = 0; j < W; j++) {
        		if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
        		System.out.print("#");
        		} else {
        			System.out.print(".");
        		}
        	}
        	System.out.println("");
        }
        System.out.println("");
		}
	}

}


Measured memory_bytes: 32608
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		String s = in.next();
		int oversea = 0;
		int total = 0;
		for(int i=0;i<n;i++){
			char ch = s.charAt(i);
			if(ch == 'c')
				System.out.println("No");
			else if(ch == 'a'){
				if(total<a+b){
					total++;
					System.out.println("Yes");
				}
				else
					System.out.println("No");
			}
			else if(ch == 'b'){
				oversea ++;
				if(total<a+b && oversea<=b){
					total++;
					System.out.println("Yes");
				}
				else
					System.out.println("No");
			}
		}

	}

}


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

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  vector<int>ware(100,0);
  for(int i=1;i<=100;i++)
    if(a%i==0&&b%i==0)
      ware.at(i-1)=1;
  int c=0,ans=0;
  for(int i=99;i>=0;i--){
    if(ware.at(i)==1)
      c++;
    if(c==k){
      ans=i+1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll INF = (1LL << 60)-1;

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

  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> cumul(n), cumulR(n);
  cumul[0] = a[0];
  rep(i, n-1) cumul[i+1] = cumul[i]+a[i+1];
  cumulR[n-1] = a[n-1];
  for(int i = n-1; i > 0; i--) cumulR[i-1] = cumulR[i]+a[i-1];

  ll ans = INF;
  rep(i, n-1) {
    ans = min(ans, abs(cumul[i]-cumulR[i+1]));
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4992
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi a(n+1);
	rep(i,n){
		int x;cin>>x;
		a[i+1]+=a[i]+x;
	}
	vi b(n+1);
	rep(i,n)cin>>b[i];
	rep(i,n){
		b[n-i-1]+=b[n-i];
	}
	int out=0;
	rep(i,n)out=max(out,a[i+1]+b[i]);
	cout<<out<<endl;
}








Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    ABC151A solver = new ABC151A();
    solver.solve(1, in, out);
    out.close();
  }

  static class ABC151A {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      char[] c = in.next().toCharArray();
      out.println((char) (c[0] + 1));
    }

  }
}



Measured memory_bytes: 23764
mod = 10**9 + 7

def main():
    h,w,k = map(int,input().split())
    k -= 1

    if w == 1:
        return 1

    dp = [0 for i in range(w)]
    dp[0] = 1

    for i in range(h):
        nx = [0 for _ in range(w)]

        for mask in range(1<<(w-1)):
            bar = [0 for _ in range(w-1)]
            for j in range(w-1):
                bar[j] = (mask>>j&1)

            valid = True
            for j in range(w-2):
                if bar[j] == 1 and bar[j+1] == 1:
                    valid = False

            if not valid:
                continue

            for j in range(w):
                if j>0 and bar[j-1]:
                    nx[j-1] += dp[j]
                    nx[j-1] %= mod
                elif j+1<w and bar[j]:
                    nx[j+1] += dp[j]
                    nx[j+1] %= mod
                else:
                    nx[j] += dp[j]
                    nx[j] %= mod

        dp = nx

    return dp[k]

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


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
typedef pair<string, string> P;
string change(string s, string t, string r)
{
	vector<bool> flag(s.size(), false);
	for(int i = 0; i < s.size(); i++)
	{
		if(s.substr(i, t.size()) == t)
			flag[i] = true;
	}
	string ret;
	int pos = 0;
	while(pos < s.size())
	{
		if(flag[pos])
		{
			ret += r;
			pos += t.size();
		}
		else
		{
			ret += s[pos];
			pos++;
		}
	}
	return ret;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin >> n, n)
	{
		string a[n + 1], b[n + 1];
		for(int i = 0; i < n; i++)
			cin >> a [i]>> b[i];
		string s, t;
		cin >> s >> t;
		map<string, int> mp;
		mp[s] = 0;
		queue<string> que;
		que.push(s);
		int ans = -1;
		while(!que.empty())
		{
			string tmp = que.front();
			que.pop();
			if(tmp.size() > t.size())
				continue;
			if(tmp == t)
			{
				ans = mp[tmp];
				break;
			}
			for(int i = 0; i < n; i++)
			{
				string x = change(tmp, a[i], b[i]);
				if(!mp.count(x))
				{
					mp[x] = mp[tmp] + 1;
					que.push(x);
				}
			}
		}
		/*
		for(auto itr = mp.begin(); itr != mp.end(); itr++)
		{
			cout << itr->first << " " << itr->second << endl;
		}
		*/
		cout << ans << endl;
	}
	return 0;
}




Measured memory_bytes: 3800
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#define Inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
int main()
{
    int a,b,c;
    while(~scanf("%d %d %d",&a,&b,&c))
    {
        int sum=a+b+c;
        if(sum%17==0)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


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

int main()
{
    int a;
    string s;
    cin >> a;
    cin >> s;
    if(3200 <= a){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
lines = []
colums = []
  
while True:
  H,W = map(int,input().split())
  if H == 0 and W == 0:
    break
  lines.append(H)
  colums.append(W)
  
for H,W in zip(lines,colums):
  for i in range(H):
    for j in range(W):
      print("#",end="")
    print("\n",end="")
  print("\n",end="")


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


def solve(T: int, X: int):
    print(T/X)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<string>
using namespace std;
int main (){
   int n,x;
   bool mouth[4][13];
   char ch;
   for(int i=0;i<4;i++)
       for(int j=0;j<13;j++)
          mouth[i][j]=false;
   cin>>n;
   for(int i=0;i<n;i++){
       cin>>ch>>x;
       if(ch == 'S')
           mouth[0][x-1]=true;
       if(ch == 'H')
           mouth[1][x-1]=true;        
       if(ch == 'C')
           mouth[2][x-1]=true;
       if(ch == 'D')
           mouth[3][x-1]=true;
    }
   for(int i=0;i<4;i++){
       for(int j=0;j<13;j++){
          if(mouth[i][j]==false){
              if(i==0)
                  cout<<"S "<<j+1<<endl;
             
              if (i==1)
                  cout<<"H "<<j+1<<endl;
             
              if(i==2)
                  cout<<"C "<<j+1<<endl;
             
              if(i==3)
                  cout<<"D "<<j+1<<endl;
		  }
       }
   }
return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    ll res = 0;

    // 以下の解法は誤り。
    // rep(i, N-1) {
    //     if (A[i] > 0) {
    //         res += A[i];
    //     }
    //     else {
    //         ll now = A[i] + A[i + 1];
    //         if (now <= 0) {
    //             // ひっくり返す
    //             res -= A[i];
    //             A[i+1] *= -1;
    //         } else {
    //             // ひっくり返さない
    //             res += A[i];
    //         }
    //     }
    // }
    // res += A[N-1];

    // 解法②
    // 0があったら、それまでの数字は全てプラスにできる。
    // 0がなく末端がきたら、それまでの数字の中で一番絶対値が小さな数をマイナスにしておけば良い。

    // 改め、0があったら、全ての数字をプラスにできる。
    // 0がなければ、どれか絶対値が一番小さい１個をマイナスにする。
    // ll res = 0;
    // int mn = INT_MAX;
    // rep(i, N-1) {
    //     if (A[i+1] == 0) {
    //         mn = INT_MAX;
    //     }
    // }

    // ll res = 0;
    int mn = INT_MAX;
    int minus = 0;
    bool zero = false;

    rep(i, N) {
        res += abs(A[i]);
        mn = min(mn, abs(A[i]));
        if (A[i] == 0) zero = true;
        if (A[i] < 0) minus++;
    }

    if (zero) cout << res << endl;
    else if (minus % 2 == 0) cout << res << endl;
    else cout << res - 2 * mn << endl;
}

Measured memory_bytes: 3748
S = input()
T = input()
lenS = len(S)
lenT = len(T)
res = []
for i in range(lenS - lenT + 1):
    tgt = S[i:i + lenT]
    for a, b in zip(tgt, T):
        if not (a == b or a == '?'):
            break
    else:
        tmp = S[:i] + T + S[i + lenT:]
        res.append(tmp.replace('?', 'a'))
if res:
    print(min(res))
else:
    print('UNRESTORABLE')

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

void out()
{
	puts("NO");
	exit(0);
}
typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=1e5+5;
int a[N];

int main()
{
	//freopen("1.in","r",stdin);
	s64 s=0;
	int n;cin>>n;
	rep(i,1,n){scanf("%d",a+i);s+=a[i];}
	s64 one=(s64)n*(n+1)/2;
	if(s%one)out();
	s/=one;
	a[0]=a[n];
	s64 ans=0;
	rep(i,1,n)
	{
		s64 now=s-a[i]+a[i-1];
		if(now%n||now<0)out();
		ans+=now/n;
	}
	if(ans!=s)out();
	puts("YES");
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    ll n,i;
    cin>>n;
    vector<ll>v,arr;
    map<ll,ll>mp;
    for(i=1;i<30;i++)
    {

        v.pb(4*i);
        mp[7*i]++;
        arr.pb(7*i);
    }
    ll flag=0;
    for(i=0;i<30;i++)
    {
        if(mp.find(n-v[i])!=mp.end())
        {
            flag=1;
            break;
       }
    }

    for(i=0;i<30;i++)
    {
        if(v[i]==n || arr[i]==n)
        {
            flag=1;
            break;
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;

    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  vector<string> a(100);
  vector<int> b(100);
  int i=0;
  while(cin>>a[i]>>b[i])i++;

  rep(k,i){
    rep(j,i-1){
      if(a[j]>a[j+1]){
	swap(a[j],a[j+1]);
	swap(b[j],b[j+1]);
      }
      if(a[j]==a[j+1]&&b[j]>b[j+1])
	swap(b[j],b[j+1]);
    }
  }


  rep(j,i){
    if(j&&a[j]==a[j-1])cout<<" "<<b[j];
    else cout<<a[j]<<endl<<b[j];
    if(j-i+1&&a[j]!=a[j+1])cout<<endl;
  }
  cout<<endl;
}

Measured memory_bytes: 1224
#include<iostream>

using namespace std;
int main()
{
    int X,j=0,flag;
    cin>>X;
    
    for(int i=1;  ;++i)
    {j+=i;
     
     if(X<=j)
     {flag=i;
     break;
     }
        
    }
    
    cout<<flag;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int N, A, B;
  scanf("%d %d %d", &N, &A, &B);
  if((N*A) < B) {
    printf("%d\n", N*A);
  } else {
    printf("%d\n", B);
  }
  return 0;
}


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

int main(){
    int n;  cin >> n;
    vector<ll> b(n-1);
    for(int i=0; i<n-1; i++){
        cin >> b.at(i);
    }
    ll sum = b.at(0)+b.at(n-2);
    for(int i=0; i<n-2; i++){
        sum += min(b.at(i), b.at(i+1));
    }
    cout << sum << endl;


}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

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

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

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

#define PUTS(x) cout << (x) << endl;

int n,m;
int k[10] = {0};
int p[10] = {0};
int s[10][10] = {0};
int on_off[10] = {0};
LL ans = 0;

void f(int d){
    if(d == n){
        bool ok = true;
        REP(i, m){
            int c = 0;
            REP(j, k[i]){
                c += on_off[s[i][j] - 1];
            }
            if(c % 2 != p[i]){
                ok = false;
                break;
            }
        }
        if(ok)ans++;
    }else{
        on_off[d] = 0;
        f(d+1);
        on_off[d] = 1;
        f(d+1);
    }
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m;
    REP(i,m){
        cin>>k[i];
        REP(j,k[i]){
            cin>>s[i][j];
        }
    }
    REP(i,m)cin>>p[i];
    f(0);
    PUTS(ans);
}


Measured memory_bytes: 256
s=list(input())
t=list(input())
a=[]
for i in range(int(len(s))-int(len(t))+1):
  g=0
  for j in range(int(len(t))):
    if s[i+j]!=t[j]:
      g=g+1
  a.append(g)
print(min(a))

Measured memory_bytes: 9060
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long

signed main(){
  int N;cin>>N;
  std::vector<char> v(N);
  for(int i=0;i<N;i++){
    cin>>v[i];
    if(v[i]=='T')v[i]=1;
    else v[i]=0;
  }
  int now=v[0];
  for(int i=1;i<N;i++){
    if(now&&!v[i])now=0;
    else now=1;
  }
  if(now)cout<<"T"<<endl;
  else cout<<"F"<<endl;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
//#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
signed main(){
	int y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);
	if(y>2019){
		puts("TBD");
		return 0;
	}
	else if(y==2019){
		if(m>4){
			puts("TBD");
			return 0;
		}
	}
	puts("Heisei");
	return 0;
}

Measured memory_bytes: 256
import sys
inputs=[[int(i) if i.isnumeric() else i for i in l.split()] for l in sys.stdin.readlines()][1:]
s_i=sorted(inputs,key=lambda x: (x[0],-x[1]))
for r in s_i:
    for n,i in enumerate(inputs):
        if r==i:
            print(n+1)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> M(N);
    int sum = 0;
    for (int  i = 0; i < N; i++)
    {
        cin >> M[i];
        sum += M[i];
    }

    int S = 0, Ss = 0, Smin = sum;
    for (int  i = 0; i < N - 1; i++)
    {
        S += M[i];
        Ss = abs(sum - 2 * S);
        Smin = min(Ss , Smin);
        //cout << "Smin" << Smin  <<endl;;
        //cout << "Ss" << Ss  <<endl;
    }

    cout << Smin << endl;
    
}

Measured memory_bytes: 256
N,M = map(int, input().split())
imos = [0]*(N+2)
for _ in range(M):
    l,r = map(int,input().split())
    imos[l] += 1
    imos[r+1] -= 1
for i in range(1,N+2):
    # print(i)
    imos[i] += imos[i-1]
# print(imos)
ans = 0
for ii in imos:
    if ii==M:
        ans += 1
print(ans)


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

double dp[301][301][301];
int n, n1, n2, n3;

double calc(int i, int j, int k){
    if(dp[i][j][k] >= 0) return dp[i][j][k];
    dp[i][j][k] = n;
    if(i != 0) dp[i][j][k] += calc(i-1, j, k) * i;
    if(j != 0 && i+1 <= n) dp[i][j][k] += calc(i+1, j-1, k) * j;
    if(k != 0 && j+1 <= n) dp[i][j][k] += calc(i, j+1, k-1) * k;
    dp[i][j][k] /= double(i+j+k);
    return dp[i][j][k];
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    cin >> n;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        ++(a == 1 ? n1: a == 2 ? n2 : n3);
    }

    for(int i = 0; i <= n; ++i){
        for(int j = 0; j <= n; ++j){
            for(int k = 0; k <= n; ++k){
                dp[i][j][k] = -1;
            }
        }
    }

    dp[0][0][0] = 0;

    cout << calc(n1, n2, n3) << "\n";



    return 0;
}

Measured memory_bytes: 213376
s = input()
i = int(s[:2])
j = int(s[2:])
if 1 <= i and i <= 12:
    if 1 <= j and j <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:    
    if 1 <= j and j <= 12:
        print('YYMM')
    else:
        print('NA')
    

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

// 0-indexed, 半開
template <typename T> struct BIT {
  private:
    int n;
    vector<T> dat;

  public:
    BIT(vector<T> v) : n(v.size()) {
        dat.assign(n + 1, 0);
        for(int i = 0; i < n; i++)
            dat[i + 1] = v[i];
        for(int i = 1; i < n; i++)
            if(i + (i & -i) <= n) dat[i + (i & -i)] += dat[i];
    }
    BIT(int n) : n(n) { dat.assign(n + 1, 0); }
    void add(int k, T a) {
        for(k++; k <= n; k += k & -k)
            dat[k] += a;
    }
    // [0,a)
    T sum(int a) {
        T ret = 0;
        for(; a > 0; a -= a & -a)
            ret += dat[a];
        return ret;
    }
    // [a,b)
    T sum(int a, int b) { return sum(b) - sum(a); }
    int lowerBound(int w) {
        if(w <= 0) return 0;
        int x = 0;
        for(int k = 1 << int(log2(n)); k; k /= 2) {
            if(x + k <= n && dat[x + k] < w) {
                x += k;
                w -= dat[x];
            }
        }
        return x + 1;
    }
};

ll n;
vector<int> a;

bool f(int x) {
    vector<int> sum(n + 1, 0);
    rep(i, n) sum[i + 1] = (a[i] >= x ? 1 : -1);
    rep(i, n) sum[i + 1] += sum[i];
    int mn = 0, mx = 0;
    rep(i, n + 1) chmin(mn, sum[i]);
    rep(i, n + 1) {
        sum[i] -= mn;
        chmax(mx, sum[i]);
    }
    BIT<int> bit(mx + 1);
    ll cnt = 0;
    rep(i, n + 1) {
        cnt += bit.sum(sum[i] + 1);
        bit.add(sum[i], 1);
    }
    return cnt * 4 >= n * (n + 1);
}

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

    cin >> n;
    int mx = 0;
    rep(i, n) {
        int x;
        cin >> x;
        chmax(mx, x);
        a.push_back(x);
    }
    int ok = 0, ng = mx + 1;
    while(ok + 1 < ng)
        (f(ok + ng >> 1) ? ok : ng) = ok + ng >> 1;
    cout << ok << endl;
}

Measured memory_bytes: 1528
#include <cstdio>
#include <algorithm>
using namespace std;

const int Mod = 998244353;
const int Maxn = 1e6;

int QuickPow(int a, int k) {
	int ret = 1;
	while(k) {
		if(k & 1) ret = 1LL * ret * a % Mod;
		a = 1LL * a * a % Mod;
		k >>= 1;
	}
	return ret;
}
int fac[Maxn + 5], inv_fac[Maxn + 5];
void Init() {
	fac[0] = inv_fac[0] = 1;
	for(int i = 1; i <= Maxn; i++)
		fac[i] = 1LL * fac[i - 1] * i % Mod;
	inv_fac[Maxn] = QuickPow(fac[Maxn], Mod - 2);
	for(int i = Maxn - 1; i >= 1; i--)
		inv_fac[i] = 1LL * inv_fac[i + 1] * (i + 1) % Mod;
}
int C(int n, int m) {
	return 1LL * fac[n] * inv_fac[m] % Mod * inv_fac[n - m] % Mod;
}
inline void add(int &n, int m) {
	n += m;
	if(n >= Mod) n -= Mod;
}
inline void del(int &n, int m) {
	n -= m;
	if(n < 0) n += Mod;
}

int powN[Maxn + 5], powM[Maxn + 5];
int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	int N, M;
	scanf("%d %d", &N, &M);
	Init();
	if(N > M) swap(N, M);
	powN[0] = powM[0] = 1;
	for(int i = 1; i <= M; i++)
		powN[i] = 1LL * powN[i - 1] * (N + 1) % Mod;
	for(int i = 1; i <= N; i++)
		powM[i] = 1LL * powM[i - 1] * (M + 1) % Mod;
	int ans = 0;
	for(int i = 0; i <= N; i++) {
		int tmp = 1LL * C(N, i) * C(M, i) % Mod * fac[i] % Mod * powN[M - i] % Mod * powM[N - i] % Mod;
		if(i & 1) del(ans, tmp);
		else add(ans, tmp);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 15744
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define REP(type,i,n) for(type i=0;i<(n);++i)
#define MP(a,b) make_pair((a),(b))

typedef long long int lli;
typedef pair<int,int> P;

const int INF=100000000;
const long long int INF_=1000000000000000000;

lli Gcd(lli a,lli b){
	if(b==0) return a;
	return Gcd(b,a%b);
}

lli Lcm(lli a,lli b){
	return a/Gcd(a,b)*b;
}

int N;

class Bar{
	public:
	int p,q,r,b,parent;
	bool exists,is_leaf;
	Bar():parent(-1),exists(false),is_leaf(false){}
	void Init(int a,int b,int c,int d,bool e);
};

void Bar::Init(int a,int bb,int c,int d,bool e){
	p=a; q=bb; r=c; b=d; exists=e;
	//cout << r << ' ' << b << endl;
}

int Find(vector<Bar> &m,int n){
	//cout << n << endl;
	if(m[n].parent==-1) return n;
	return Find(m,m[n].parent);
}

void Pre(vector<Bar> &m,int n){
	//cout << n << ' ' << d << endl;
	if(m[n].r==-1&&m[n].b==-1){
		m[n].is_leaf=true;
		return;
	}
	if(m[n].r!=-1) Pre(m,m[n].r);
	if(m[n].b!=-1) Pre(m,m[n].b);
}

lli DFS(const vector<Bar> &m,int n){
	if(m[n].is_leaf){
		//if(n+1==2) cout << n+1 << ' ' << m[n].p << ' ' << m[n].q << ' ' << Lcm(m[n].p,m[n].q)/m[n].p+Lcm(m[n].p,m[n].q)/m[n].q << endl;
		//else cout << n+1 << ' ' << Lcm(m[n].p,m[n].q)/m[n].p+Lcm(m[n].p,m[n].q)/m[n].q << endl;
		return Lcm(m[n].p,m[n].q)/m[n].p+Lcm(m[n].p,m[n].q)/m[n].q;
	}
	lli a,b;
	if(m[n].r==-1) a=Lcm(m[n].p,m[n].q)/m[n].p;
	else a=DFS(m,m[n].r);
	if(m[n].b==-1) b=Lcm(m[n].p,m[n].q)/m[n].q;
	else b=DFS(m,m[n].b);
	//cout << n+1 << ' ' << a*Lcm(a*m[n].p,b*m[n].q)/m[n].p+b*Lcm(a*m[n].p,b*m[n].q)/m[n].q << endl;
	return a*Lcm(a*m[n].p,b*m[n].q)/(m[n].p*a)+b*Lcm(a*m[n].p,b*m[n].q)/(m[n].q*b);
}

int main(){
	while(cin >> N&&N){
		vector<Bar> mobile(100);
		REP(int,i,N){
			int p,q,r,b;
			cin >> p >> q >> r >> b;//p:q,左の棒の番号、右の棒の番号
			--r;
			--b;
			mobile[i].Init(p,q,r,b,true);
			if(r!=-1) mobile[r].parent=i;
			if(b!=-1) mobile[b].parent=i;
		}
		int parent=-1;
		REP(int,i,100){
			if(mobile[i].exists){
				parent=Find(mobile,i);
				break;
			}
		}
		Pre(mobile,parent);
		lli ans=DFS(mobile,parent);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200010;
int n, a[maxn];
int s1[maxn], s2[maxn];
ll ans;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		s1[i] = s1[i - 1] + a[i]; s2[i] = s2[i - 1] ^ a[i];
	}
	for (int i = 1, p = 1; i <= n; ++i) {
		while (p <= i && s1[i] - s1[p - 1] != (s2[i] ^ s2[p - 1])) ++p;
		ans += i - p + 1;
	}
	printf("%lld", ans);
}


Measured memory_bytes: 2560
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(long[]), x = rd[0], y = rd[1];
  auto c = 1;
  for (;;) {
    x *= 2;
    if (x > y) break;
    ++c;
  }
  writeln(c);
}


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

typedef pair<int,int> P;

int N, h[10][3];
vector<P> times;

void insert(int h, int m, int s, int rot, int idx){
  
  h = ( h + rot ) % 60;
  m = ( m + rot ) % 60;
  s = ( s + rot ) % 60;
  
  if( h % 5 != m / 12 ) return;
  
  h /= 5;
  
  times.push_back( P( h * 3600 + m * 60 + s, idx ) );
  
}

void solve(){
  
  times.clear();
  
  for(int i=0;i<N;i++){
    
    for(int i1=0;i1<3;i1++){
      
      for(int i2=0;i2<3;i2++){
	
	if( i1 == i2 ) continue;
	
	for(int i3=0;i3<3;i3++){
	  
	  if( i1 == i3 || i2 == i3 ) continue;
	  
	  for(int rot=0;rot<60;rot++){
	    
	    insert( h[i][i1], h[i][i2], h[i][i3], rot, i );
	    
	  }	  
	  
	}
	
      }
      
    }
    
  }
  
  sort( times.begin(), times.end() );
  
  int mintime[10];
  const int INF = 1e9;
  
  priority_queue<P,vector<P>,greater<P> > ans;
  
  for(int i=0;i<(int)times.size();i++){
    
    for(int j=0;j<N;j++) mintime[j] = INF;
    
    for(int j=i;j<(int)times.size();j++){
      
      int idx = times[j].second;
      
      mintime[idx] = min( mintime[idx], times[j].first );
      
    }
    
    int maxtime = 0;
    
    for(int j=0;j<N;j++) maxtime = max( maxtime, mintime[j] );
    
    int mint = times[i].first;
    
    ans.push( P( maxtime - mint, mint ) );
    
  }
  
  int start = ans.top().second;
  int goal = start + ans.top().first;
  
  int sh = start / 3600, sm = start % 3600 / 60, ss = start % 3600 % 60;
  int gh = goal / 3600, gm = goal % 3600 / 60, gs = goal % 3600 % 60;
  
  printf("%02lld:%02lld:%02lld %02lld:%02lld:%02lld\n", sh, sm, ss, gh, gm, gs);
  
}

signed main(){
  
  while(1){
  
    cin>>N;
    if( !N ) break;
    
    for(int i=0;i<N;i++) cin>>h[i][0]>>h[i][1]>>h[i][2];
  
    solve();

  }
  
  return 0;
}



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

int main() {
	int n,k,i,j;
	cin>>n;
	int h[n],dp[n];
	
	for(int i=0;i<n;i++){
	    cin>>h[i];
	    dp[i]=1e9+5;
	}
	        dp[0]=0;
       for(i=0;i<n;i++){
           for(j=i+1;j<=(i+2);j++){
                 if(j<n){
                    dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));}
           }
       }
/*	for(int i=0;i<n;i++)
	    cout<<dp[i]<<" ";*/
	cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=5e5+5;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll h1,m1;cin>>h1>>m1;
    ll h2,m2;cin>>h2>>m2;
    ll k;cin>>k;

    ll t1 = h1*60 + m1;
    ll t2 = h2*60 + m2;

    ll d = t2 - t1;
    cout<<max(0ll , d-k);
}


Measured memory_bytes: 3652
#include <stdio.h>
int main() {
  int a,b;
  scanf("%d%d",&a,&b);
  if (a+b==15) {
    printf("+\n");
  } else if (a*b==15) {
    printf("*\n");
  } else {
    printf("x\n");
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.ArrayList;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    sc.nextLine();
    String s = sc.nextLine();
    
    int index = 0;
    int count = 1;
    while(index < n-1){
      	index++;
    	if(s.charAt(index-1) != s.charAt(index))
          count++;
          
    }
    System.out.println(count);
    
  }
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n;cin>>n;
  vector<ll> a(n), dp;

  rep(i, n)cin>>a[i];

  rep(i, n){
    // 後ろから見ていった時に、a[i]よりも小さい最初のiterator
    auto it = lower_bound(dp.rbegin(), dp.rend(), a[i]);
    // a[i]よりも小さい値はなかったので末尾に追加する
    if(it == dp.rbegin()) dp.push_back(a[i]);
    else {
      it--;
      *it = a[i];
    }

//rep(i, dp.size()) cout<<dp[i]<<' ';cout<<endl;
  }

//rep(i, dp.size()) cout<<dp[i]<<' ';cout<<endl;

  cout<<dp.size()<<endl;

  return 0;
}

Measured memory_bytes: 2168
#include <cstdio>
using namespace std;
int sum;
int h,n,a;
int main(){
	scanf("%d%d",&h,&n);
	while(n--){
		scanf("%d",&a);
		sum+=a;
	}
	if (sum>=h){
		puts("Yes");
	}
	else{
		puts("No");
	}
	return 0;
}


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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

signed main()
{
  string str;
  cin >> str;
  rep(i, 4) printf("%c", str[i]);
  printf(" ");
  reps(i, 4, sz(str)) printf("%c", str[i]);
  printf("\n");

  return (0);
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad.State.Strict
import qualified Data.ByteString.Char8      as B
import qualified Data.ByteString.Unsafe     as B
import           Data.Char                  (isSpace)
import qualified Data.Vector.Unboxed        as V

main :: IO ()
main = do
  n <- readLn
  txys <- V.unfoldrN n parseInt3 <$> B.getContents
  putStrLn $ if solve n txys then "Yes" else "No"

solve :: Int -> V.Vector (Int, Int, Int) -> Bool
solve _ txys = travelable ((0, 0, 0), (V.head txys)) && V.all travelable (V.zip txys (V.tail txys))

travelable :: ((Int, Int, Int), (Int, Int, Int)) -> Bool
travelable ((t, x, y), (t', x', y')) = dx + dy <= dt && even (dt - dx - dy) where
  dx = x' - x
  dy = y' - y
  dt = t' - t

type Parser a = B.ByteString -> Maybe (a, B.ByteString)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
  (,,) <$> StateT (B.readInt . B.dropWhile isSpace)
  <*> StateT (B.readInt . B.unsafeTail)
  <*> StateT (B.readInt . B.unsafeTail)


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

int main(){
  int i;
  vector<char> p(1000);
  vector<int> x(1000),y(1000);
  for (i=0;i>=0;i++){
    cin >> x[i] >> p[i] >> y[i];
    if (p[i]== '?'){
      break;
    }}
     for (i=0;i>=0;i++){
      if(p[i]=='+'){
      cout << x[i] +  y[i] << endl;
    } else if(p[i]=='-'){
      cout << x[i] - y[i] << endl;
    } else if (p[i]=='/'){
      cout << x[i] / y[i] << endl;
    } else if (p[i]=='*')  {
      cout << x[i]*y[i] << endl;
    } else {break;}
  }
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
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; }
const long long INF = 1LL << 60;
using Graph=vector<vector<int>>;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  string l[22];
  int count=0;
  for(int i=0;i<20;i++){
    string s;
    cin>>s;
    if(s=="0"){
      break;
    }
    else{
      l[i]=s;
      count++;
    }
  }
  char is='x';
  rep(i,count){
    int a,b;
    a=stringcount(l[i],'A');
    b=stringcount(l[i],'B');
    if(a>b) is=a;
    if(a<b) is=b;
    if(a==b){
      string e=l[i];
      reverse(all(e));
      if(e[0]=='A') {
        a++;b--;
      }
      else{
        b++;a--;
      } 
    }
    if(a<11&&b<11){
      if(a>b){
        a++;b--;
      }
      else{
        b++;a--;
      }
    }
    cout<<a<<" "<<b<<endl;
  }
  return 0;

}


Measured memory_bytes: 3156
/****************************
*  Developer : joshi08
*  Date  :  27-06-2020
*  Year  :  2020
****************************/

#include <bits/stdc++.h>

#define lli long long int
#define mod 1000000007
#define fi first
#define se second
#define ii pair<lli, lli>
#define mp make_pair
#define endl '\n'
const double PI = 3.141592653589793238460;
lli gcd(lli a, lli b) { if (a == 0) return b; return gcd(b % a, a);}
lli max(lli a, lli b) {if (a > b) return a; else return b;}
lli min(lli a, lli b) {if (a < b) return a; else return b;}
lli power(lli a, lli n){ lli res = 1; while(n){ if(n%2==0){ a *= a; n /= 2; } else{ res *= a; n--; } } return res; }

using namespace std;

int main()
{
    ios::sync_with_stdio(false);

	string s,t;
	cin>>s>>t;
	lli n=0,i;
	for(i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
			n++;
	}
	cout<<n;
    return 0;
}



Measured memory_bytes: 3856
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18
int INF = 1 << 30;
ll dp[100010][110];


int main(void){
    ll N,W;
    cin >> N >> W;
    vector<ll> w(N);
    vector<ll> v(N);
    for(int i = 0; i < N; i++){
        cin >> w.at(i) >> v.at(i);
    }
    //int dp[W+1][N];//重さi,j種類の品物の時の価値
    
    
    
    
    for(int i = 1; i <= W; i++){
        for(int j = 1; j <= N; j++){
            dp[i][j] = dp[i][j-1];
            if(i-w.at(j-1) >= 0){
                //cout << dp[i-w.at(j)][j-1] + v.at(j) << "#" << dp[i][j] << endl;
                dp[i][j] = max(dp[i-w.at(j-1)][j-1] + v.at(j-1), dp[i][j]);
            }
        }
    }
    cout << dp[W][N] << endl;
}


Measured memory_bytes: 86144
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
cnt = 0
check = 0
ans = 1

a.sort(reverse=True)
for i in range(n - 1):
    if a[cnt] == a[cnt + 1]:
        check += 1
        ans *= a[cnt]
        cnt += 2
        if check == 2:
            print(ans)
            exit()
    else:
        cnt += 1

    if cnt == n - 1:
        break
print(0)


Measured memory_bytes: 14252
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}
const int maxn = 2e3 + 5;
int a[maxn];

int main(){
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
		#if __cplusplus >= 201103L
		auto start = steady_clock::now();
		#endif
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;

	rep(i, 1, n) {
		cin >> a[i];
	}
	sort(a + 1, a + 1 + n);
    rep(i, 1, n) {
        prln(a[i]);
    }
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			int t = a[i] + a[j];
            pr(a[i]);pr(a[j]);prln(t);
			auto it = lower_bound(a + j, a + n + 1, t);
			int pos = it - a - 1;
            pr(i);pr(j);prln(pos);

			ans += 1ll * (pos - j);
		}
	}
	cout << ans << endl;


	#ifdef LOCAL
		#if __cplusplus >= 201103L
		auto end = steady_clock::now();
		duration<double> time_span = duration_cast<duration<double>>(end - start);;
		printf("Total time: %.6fs\n", time_span.count());
		#endif
	#endif
	return 0;
}

Measured memory_bytes: 256