akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int H,W,N;
int a[201][201];
int A[201][201];

inline int calc(int h,int w,int H,int W){
  return A[H][W]-A[H][w]-A[h][W]+A[h][w];
}

bool solve(int h,int w,int H,int W,int N,int M){
  if(calc(h,w,H,W)<M*N)return false;
  if(N==1)return true;
  for(int i=h+1;i<H;i++){
    if(calc(h,w,i,W)<M)continue;
    if(solve(i,w,H,W,N-1,M))return true;
    break;
  }
  for(int j=w+1;j<W;j++){
    if(calc(h,w,H,j)<M)continue;
    if(solve(h,j,H,W,N-1,M))return true;
    break;
  }
  for(int i=H-1;i>h;i--){
    if(calc(i,w,H,W)<M)continue;
    if(solve(h,w,i,W,N-1,M))return true;
    break;
  }
  for(int j=W-1;j>w;j--){
    if(calc(h,j,H,W)<M)continue;
    if(solve(h,w,H,j,N-1,M))return true;
    break;
  }
  return false;
}

bool check(int nv,int sv,int M){
  int ev=0,wv=0;
  while(calc(0,0,wv,nv)<M&&wv<H)wv++;
  while(calc(0,nv,ev,W)<M&&ev<H)ev++;
  if(sv<nv)ev=max(ev,wv);
  if(sv>nv)wv=max(ev,wv);
  if(calc(wv,0,H,sv)<M)return false;
  if(calc(ev,sv,H,W)<M)return false;
  return true;
}

bool check(int M){
  if(N==4)
    for(int nv=1;nv<W;nv++)
      for(int sv=1;sv<W;sv++)
        if(check(nv,sv,M))return true;
  return solve(0,0,H,W,N,M);
}

int compute(){
  int L=0,R=200000001,M;
  while(R-L>1){
    M=(L+R)/2;
    if(check(M))L=M;
    else R=M;
  }
  return L;
}

int main(){
  scanf("%d %d %d",&H,&W,&N);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      scanf("%d",&a[i][j]);
      A[i+1][j+1]=a[i][j]+A[i+1][j]+A[i][j+1]-A[i][j];
    }
  }
  int ans=compute();
  printf("%d\n",ans);
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        mp[tmp]++;
    }

    int even_cnt = 0, ans = mp.size();
    for(auto x : mp){
        if(x.second % 2);
        else even_cnt++;
    }

    if(even_cnt % 2) ans -= even_cnt % 2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  double n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=INF,z=0;
  string s="",t="";
  //

  // ここから
  IN3(a,b,c);
  Vd h(a);
  VIN(h)
  Vd ave(a);
  REP(i,a){
    ave[i] = b - h[i] * 0.006;
  }
  REP(i,a){
    if(abs(ave[i] - c) < y){
      x = i+1;
      y = abs(ave[i] - c);
    }
  }
  OUT(x);
}

Measured memory_bytes: 384
def resolve():
	count = 0
	N = int(input())
	L = sorted(list(map(int, input().split())))
	for i in range(N-2):
		for j in range(i+1, N-1):
			for k in range(j+1, N):
				if L[i] == L[j]:
					None
				elif L[j] == L[k]:
					None
				elif L[i] == L[k]:
					None
				elif (L[i] + L[j]) > L[k]:
					# print(i,j,k, file=sys.stderr)
					count += 1
	print(count)
resolve()

Measured memory_bytes: 9196
double d[3],e[3],s[99][3];main(T,n,i,j,k,l){for(scanf("%d",&T);T;T--){
for(scanf("%lf%lf%lf%d",d,d+1,d+2,&n),i=0;i<n;i++)scanf("%lf%lf%lf",s[i],s[i]+1,s[i]+2);
for(i=0;i<n;i++)for(j=0;j<n;j++)for(k=0;k<n;k++)if(i-j&&j-k&&k-i){
	*e=sqrt(pow(*s[j]-*s[i],2)+pow(s[j][1]-s[i][1],2)+pow(s[j][2]-s[i][2],2));
	e[1]=sqrt(pow(*s[k]-*s[j],2)+pow(s[k][1]-s[j][1],2)+pow(s[k][2]-s[j][2],2));
	e[2]=sqrt(pow(*s[i]-*s[k],2)+pow(s[i][1]-s[k][1],2)+pow(s[i][2]-s[k][2],2));
	for(l=0;l<3;l++)if(d[l]/d[(l+1)%3]-e[l]/e[(l+1)%3]>1e-3)break;
	if(l>2)printf("%d %d %d\n",k+1,i+1,j+1);
}
}exit(0);}

Measured memory_bytes: 644
using System;

class Program
{
	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		string[] input =new string[n];
		input = Console.ReadLine().Split(' ');

		BubbleSort(input);	
		SelectSort(input);
	}


	static void BubbleSort(string[] input)
	{
		string[] array = new string[input.Length];
		Array.Copy(input, array, input.Length);

		for (int i=0; i<array.Length; i++)
		{
			for (int j=array.Length-1; j>i; j--)
			{
				int a = int.Parse(array[j-1].Substring(1, 1));
				int b = int.Parse(array[j].Substring(1, 1));
				if (a > b)
				{
					Swap(ref array[j-1], ref array[j]);
				}
			}
		}

		Write(array, input);
	}

	static void SelectSort(string[] input)
	{
		string[] array = new string[input.Length];
		Array.Copy(input, array, input.Length);

		for (int i=0; i<array.Length; i++)
		{
			int min = i;
			for (int j=i+1; j<array.Length; j++)
			{
				int a = int.Parse(array[min].Substring(1, 1));
				int b = int.Parse(array[j].Substring(1, 1));
				if (a > b)
				{
					min = j;
				}
			}

			if (min != i)
			{
				Swap(ref array[i], ref array[min]);
			}
		}

		Write(array, input);
	}

	static void Swap(ref string a, ref string b)
	{
		string buf = a;
		a = b;
		b = buf;
	}

	static void Write(string[] array, string[] input)
	{
		bool is_stable = true;
		for (int i=0; i<array.Length; i++)
		{
			if(i > 0)
			{
				int a = int.Parse(array[i].Substring(1, 1));
				int b = int.Parse(array[i-1].Substring(1, 1));
				if(a == b)
				{
					for(int j=0; j<array.Length; j++)
					{
						if(array[i].Equals(input[j]))
						{
							is_stable = false;
							break;
						}
						else if(array[i-1].Equals(input[j]))
						{						
							break;
						}
					}
				}
			}
			Console.Write((i > 0 ? " " : "") + array[i]);
		}
		Console.WriteLine();
		Console.WriteLine(is_stable ? "Stable" : "Not stable");
	}
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    bool ok = true;
    string s;
    cin >> s;
    for(int i = 0; i < s.length(); ++i) {
        if((i + 1) % 2 == 1) {
            if(s[i] == 'L') ok = false;
        }
        else {
            if(s[i] == 'R') ok = false;
        }
    }
    cout << ((ok == true) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){ 
  double n,k;cin>>n>>k;
  
  vector<double>p(n);
  
  rep(i,n)
  {
    cin>>p.at(i);
  }
  double m=0;
  for(int i=0;i<k;i++)
  {
    m+=p.at(i);
  }
  double ans=m;
  for(int i=k;i<n;i++)
  {
    m=m+p.at(i)-p.at(i-k);
    ans=max(ans,m);
  }
  cout << fixed << setprecision(12) << (ans+k)/2 ;

}


Measured memory_bytes: 1792
package main

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

func main() {
	scan_init()
	n := scanInt()
	ruikei:= 0
	for i:=1; i<=n; i++ {
		ruikei += i*sum(n/i)
		// fmt.Println(i*sum(n/i))
	}
	fmt.Println(ruikei)
}
func sum(n int) int {
	return (n*(n+1))/2
}
func primeFactorizate (number int ) map[int]int{
	var N int
	N = number
	var memo map[int]int
	memo = map[int]int{}
	// fmt.Println(N)
	for i:=2; i * i <= N; i++ {
		if N % i == 0{
			target := i
			check := true
			for check {
				check = false
				for j, value := range memo {
					if target%j == 0 {
						target = target / j
						memo [j] = value + 1
						check = true
						break
					}
				}
			}
			if target != 1 {
				// fmt.Println(target)
				memo[target] = 1
			}
			N = N/i
		}
	}
	target := N
	check := true
	for check {
		check = false
		// fmt.Println(memo,target)
		for j, value := range memo {
			// fmt.Println(j,value,target)
			if target%j == 0 {
				target = target / j
				memo [j] = value + 1
				check = true
				break
			}
		}
	}
	if target != 1 {
		// fmt.Println("check",target)
		memo[target] = 1
	}
	return memo
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1792
import sys
a,b=map(int,input().split())
i=0
while True:
    kouho=10*b+i
    if kouho//10 > b:
        print("-1")
        sys.exit()

    if int(kouho*0.08) == a:
        print(kouho)
        sys.exit()
    i+=1
    


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define EACH( it, c ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

vector<int> eratosthenes( int n )
{
	vector<bool> nums( n + 1, true );
	nums[0] = nums[1] = false;
	vector<int> res;

	for ( int i = 0; i < nums.size(); i++ )
	{
		if ( !nums[i] )
		{
			continue;
		}

		res.push_back( i );
		for ( int j = 1; i * j < nums.size(); j++ )
		{
			nums[ i * j ] = false;
		}
	}

	return res;
}

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

	VI primes = eratosthenes( 1000000 );

	while ( true )
	{
		int a, d, n;
		cin >> a >> d >> n;

		if ( !( a | d | n ) )
		{
			break;
		}

		int res, count = 0;

		for ( int s = a; count < n; s += d )
		{
			if ( binary_search( ALL( primes ), s ) )
			{
				res = s;
				count++;
			}
		}

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1752
n = int(input())
a = [int(input()) for i in range(n)]

c = 0

for i in range(n-1):
  if a[i]%2 == 1 and a[i+1]>=1:
    c += 1
    a[i] -= 1
    a[i+1] -= 1
for i in range(n):
  c += a[i]//2
  a[i] -= (a[i]//2)*2
print (c)

Measured memory_bytes: 13028
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

#define int long long

signed main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> v(n);
    rep(i, n) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());
    int money = 0;
    int sum = 0;
    int i = 0;
    while (true) {
        if (sum + v[i].second <= m) {
            money += v[i].first * v[i].second;
            sum += v[i].second;
        }
        else {
            money += (m - sum) * v[i].first;
            sum = m;
        }
        if (sum == m)
            break;
        i++;
    }
    cout << money << endl;
    return 0;
}

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

#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())));


int main()
{
    #define file "A"
    //freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
    int n, a, b; 
    cin >> n >> a >> b; 
    if ((abs(a - b) - 1) % 2) { 
    	cout << "Alice"; 
    }
    else cout << "Borys"; 
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int N,L[200],j,k,ans=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++)scanf("%d",&L[i]);
    for(int i=0;i<N-2;i++){
        for(j=i+1;j<N-1;j++){
            for(k=j+1;k<N;k++){
                if(L[i]+L[j]>L[k]&&L[j]+L[k]>L[i]&&L[k]+L[i]>L[j]){
                    if(L[i]!=L[j]&&L[j]!=L[k]&&L[k]!=L[i]){
                        ans++;
                    }
                }
            }
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1700
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (auto &i : a) cin >> i;
    sort(all(a));
    ll ans = 0;
    const int N = 2e3 + 11;
    vector <int> pref(N);
    for (auto &i : a) ++pref[i];
    for (int i = 1; i < N; i++) {
        pref[i] += pref[i - 1];
    }
    for (int i = 0; i < n; i++) {
        for (int j = a[i]; j < N; j++) {
            --pref[j];
        }
        for (int j = 0; j < i; j++) {
            ans += pref[a[i] + a[j] - 1] - pref[a[i] - 1];
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3600
W, H, x, y = map(int, input().split())
ans1 = W * H / 2
cen_x, cen_y = W/2, H/2
if cen_x == x and cen_y == y:
  ans2 = 1
else:
  ans2 = 0
print(str(ans1) + " " + str(ans2))

Measured memory_bytes: 9096
#include<bits/stdc++.h>
#include<iostream>
using namespace std; 
int main(){
	string c;
	cin>>c;
	for(int i=0;i<c.size();i++){
		if(c[i]=='7'){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
} 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vl red(a),gre(b),tr(c);
    rep(i,a) cin >> red[i];
    rep(i,b) cin >> gre[i];
    rep(i,c) cin >> tr[i];
    sort(red.begin(),red.end(),greater<ll>());
    sort(gre.begin(),gre.end(),greater<ll>());
    sort(tr.begin(),tr.end(),greater<ll>());

    vl xe(x),ye(y);
    rep(i,x) xe[i] = red[i];
    rep(i,y) ye[i] = gre[i];

    reverse(xe.begin(),xe.end());
    reverse(ye.begin(),ye.end());

    int ix=0,iy=0;
    rep(i,c){
        if(min(xe[ix],ye[iy]) < tr[i]){
            if(ix<x && xe[ix] < ye[iy]){
                xe[ix] = tr[i];
                ix++; 
            }else if(iy < y && ye[iy] < tr[i]){
                ye[iy] = tr[i];
                iy++;
            }
        }
        if(iy>=y) iy = y-1;
        if(ix>=x) ix = x-1;
    }
    ll ans = 0;
    rep(i,x) ans += xe[i];
    //cout << ans << endl;
    rep(i,y) ans += ye[i];
    cout << ans << endl;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define hell 1000000007
using namespace std;
void solve()
{
  ll n,m,i,j,k,c=0,y=0,ans=0,a,b;
  string s;
  cin>>n>>k;
vector < ll > v(n);
rep(i,0,n)
{
    cin>>v[i];
}
rep(i,k,n)
{
    if(v[i]>v[i-k]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--)
    solve();
}


Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int f(){
	
}

int32_t main(){
    fast_io;
    int x,y;
    cin>>x>>y;
    int a = 2*x;
    int b = 4*x;
    if(y%2==0 and a<=y and b>=y){
        show("Yes");
    }
    else {
        show("No");
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main()
{
	int n, x, y, w, h, m, s, t, c;
	cin >> n;
	while(n--){
		c = 0;
		cin >> x >> y >> w >> h;
		cin >> m;
		while(m--){
			cin >> s >> t;
			if((x <= s && s <= x+w) && (y <= t && t <= y+h)){
				c++;
			}
		}
		
		cout << c << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

n = I()
a = [I() for i in range(n)]
b = sorted(a)
for i in range(n):
    if(a[i] == b[-1]):print(b[-2])
    else:print(b[-1])

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

int main()
{
	int n;
	char w[100][15] = { "\0" };

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		scanf("%s", w[i]);
	}

	// 同じ単語が存在
	for (int i = 0; i < n-1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (strcmp(w[i], w[j]) == 0)
			{
				printf("No\n");
				return 0;
			}
		}
	}

	// 直前の語尾と異なる
	for (int i = 0; i < n - 1; i++)
	{
		for (int j = 0; j < 15; j++)
		{
			if (w[i][j] == '\0')
			{
				if (w[i][j - 1] != w[i + 1][0])
				{
					printf("No\n");
					return 0;
				}
break;
			}
		}
	}

	printf("Yes\n");

	return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	int N;
	LL H;
	cin>>N>>H;
	vector<LL> A(N),B(N);
	int i;
	LL maxA=0;
	for (i=0;i<N;i++){
		cin>>A[i]>>B[i];
		if (maxA<A[i]){
			maxA=A[i];
		}
	}
	sort(B.begin(),B.end(),greater<LL>());
	int aw=0;
	for (i=0;i<N;i++){
		if (B[i]>maxA){
			aw++;
			H-=B[i];
			if (H<=0){
				cout<<aw<<endl;
				return 0;
			}
		}
	}
	if (H%maxA==0){
		aw+=H/maxA;
	}else{
		aw+=H/maxA+1;
	}
	cout<<aw<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <ctime>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const int maxn = 100005;

int n;
pair<int,int> a[maxn];

bool check_1(){
  if(a[1].first!=0||a[2].second!=0||a[2].first!=a[1].second||a[1].second==0)return false;
  for(int i=3;i<=n;i++)
    if(a[i].first==0||a[i].second==0||a[i].first+a[i].second<a[1].first+a[1].second)return false;
  set<pair<int,int>>st;
  for(int i=1;i<=n;i++)st.insert(a[i]);
  for(int i=3;i<=n;i++){
    int cnt=0;
    for(int j=-1;j<=1;j++)
      if(st.find(make_pair(a[i].first-1,a[i].second+j))!=st.end()){
        cnt++;
        break;
      }
    for(int j=-1;j<=1;j++)
      if(st.find(make_pair(a[i].first+j,a[i].second-1))!=st.end()){
        cnt++;
        break;
      }
      if(cnt<2)return false;
  }
  return true;
}

bool cmp(pair<int,int> a,pair<int,int> b){
  int ta = a.first + a.second;
  int tb = b.first + b.second;
  return ta == tb ? a.first < b.first: ta < tb;
}

int cal(){
  int ret=0;
  sort(a+1,a+n+1,cmp);
  map<pair<int,int>,int>mp;
  for(int i=1;i<=n;i++){
    int pos = i;
    vector<pair<int,int>>v;
    v.push_back(a[i]);
    for(int j = i;j<=n;j++){
      if(a[j].first + a[j].second!=a[i].first + a[i].second)break;
      pos = j;
      if(mp.find(a[j])==mp.end())mp[a[j]]=1;
      else mp[a[j]]+=1;
      if(j>i&&a[j]!=a[j-1])v.push_back(a[j]);
    }
    int l = 0;
    for(int j=0;j<v.size();j++){
      int nl = mp[v[j]];
      int nr = nl;
      if(v[j].second==0)nr=0;
      ret+=min(l,nl);
      nl-=l;
      if(nl<0)nl=0;
      if(mp.find(make_pair(v[j].first-1,v[j].second-1))!=mp.end()){
        ret+=min(nl,nr);
        nr -= min(nl,nr);
      }
      l = nr;
      if(l<0)l=0;
      if(j+1<v.size()&&v[j].first+1<v[j+1].first)l=0;
      //cout<<j<<" : "<<ret<<endl;
      //cout<<v[j].first<<","<<v[j].second<<endl;
    }
    i =pos;
  }
  //cout<<ret<<endl;
  return ret;
}

int main() {
   // freopen("in.cpp","r",stdin);
    cin>>n;
    for(int i=1; i<=n; i++) {
        int x,y;
        cin>>x>>y;
        a[i].first = x;
        a[i].second = y;
    }
    if(!check_1()){
      cout<<-1<<endl;
      return 0;
    }
    cout<<2*n-2-cal()<<endl;
    return 0;
}


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


int main(){
    int n,m;
    cin>>n>>m;
    ll ans=0;
    vector<ll>a(n),b(n),c(n),x(n);
    rep(i,n)cin>>a[i]>>b[i]>>c[i];
    
    for(int bit=0;bit<(1<<3);bit++){
        rep(i,n){
            if(bit&1)x[i]=a[i];
            else x[i]=-1*a[i];
            if(bit&(1<<1))x[i]+=b[i];
            else x[i]-=b[i];
            if(bit&(1<<2))x[i]+=c[i];
            else x[i]-=c[i];
        }
        sort(x.begin(),x.end());
        ll sum=0;
        rep(i,m)sum+=x[n-1-i];
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, M = map(int, rl().split())
    graph = []
    for _ in range(M):
        a, b, c = map(int, rl().split())
        a -= 1
        b -= 1
        c *= -1
        graph.append([a, b, c])
    
    def bellman_ford(s):
        dist_ls = [10 ** 15] * N
        dist_ls[s] = 0
        for i in range(N):
            for u, v, w in graph:
                if dist_ls[u] + w < dist_ls[v]:
                    dist_ls[v] = dist_ls[u] + w
                    if i == N - 1 and v == N - 1:
                        return -1
        return dist_ls
    
    dist = bellman_ford(0)
    if dist == -1:
        print('inf')
    else:
        print(-dist[-1])


if __name__ == '__main__':
    solve()


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

int main() {
    int i,j,t;
    string S;
    cin >> S;

    for(i=0; i<(1<<3); i++) {
        t = S.at(0)-'0';
        for(j=0; j<3; j++)
            if(1<<j & i)
                t += S.at(j+1)-'0';
            else
                t -= S.at(j+1)-'0';
        if(t == 7)
            break;
    }

    cout << S.at(0);
    for(j=0; j<3; j++)
        if(1<<j & i)
            cout << "+" << S.at(j+1);
        else
            cout << "-" << S.at(j+1);
    cout << "=7" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
    char O[256], E[256];
    int i;
    fgets(O, sizeof(O), stdin);
    fgets(E, sizeof(E), stdin);
    for ( i = 0; O[i] != '\n'; i++ ){
        printf("%c", O[i]);
        if ( E[i] != '\n' ){
            printf("%c", E[i]);
        }
    }
    printf("\n");
    return 0;
}

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

typedef long long ll;
typedef pair <ll, ll> pii;

const ll N = 1e5 + 5, mod = 1e15;

ll dist[N];
vector <pii> adj[N];
ll n, m;

void dij() {
	for (int i = 0; i < n; i++)	dist[i] = mod;
	set <pii> s;
	dist[0] = 0;
	s.insert({0, 0});
	while(!s.empty()) {
		int v = (*s.begin()).second;
		s.erase(s.begin());
		for (auto e : adj[v]) {
			int w = e.second, u = e.first;
			if(dist[u] > dist[v] + w) {
				s.erase({dist[u], u});
				dist[u] = dist[v] + w;
				s.insert({dist[u], u});
			}
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	vector <pair <pii , int> > edge;
	for (int i = 0; i < n - 1; i++) {
		adj[i + 1].push_back({i, 0});
	}
	for (int i = 0; i < m; i++) {
		int v, u, w;
		cin >> v >> u >> w;
		v--, u--;
		adj[v].push_back({u, w});
		adj[u].push_back({v, w});
	}
	dij();
	if(dist[n - 1] == mod)	cout << -1 << "\n";
	else
		cout << dist[n - 1] << "\n";
}

Measured memory_bytes: 12928
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int h,w,n; cin >>h>>w>>n;
    vector<int> a(n); vector<int> b(n);
    rep(i,n) {cin >> a[i] >> b[i]; a[i]--; b[i]--;}

    vector<P> nn;
    for (int k = 0; k < n; k++) {
        for (int di = 0; di >= -2; di--) {
            for (int dj = 0; dj >= -2; dj--) {
                int ni = a[k] + di;
                int nj = b[k] + dj;
                if (ni >= 0 && ni + 2 < h && nj >= 0 && nj + 2 < w) {
                    nn.push_back(P(ni, nj));
                } 
            }
        }
    }

    sort(nn.begin(), nn.end());
    vector<ll> ans(10, 0); 

    for (int i = 0; i < nn.size();) {
        int j = i;
        while (nn[i] == nn[j] && j < nn.size()) {
            j++;
        }
        ans[j - i]++;
        i = j;
    }

    ll hll = (ll)h, wll = (ll)w;
    ans[0] = hll*wll - 2*hll - 2*wll + 4;
    for (int i = 0; i < 9; i++) {
        ans[0]-= ans[i+1];
    }

    for (int i = 0; i < 10; i++) {
        cout << ans[i] << endl;
    }
    
    return 0;
}




Measured memory_bytes: 11372
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,a,b[1001],c[1001],j,flg=0,tt,ht,ba,tn=1,h;
	scanf("%d",&a);
	while(a!=0){
		ba=0;
		tn=1;
		h=1;
		for(i=0;i<=1001;i++){
			c[i]=1000000;
			b[i]=1000000;
		}
		ht=a;
		tt=a;
		for(i=1;i<=a;i++){
			scanf("%d",&b[i]);
		}
		for(i=1;i<=a*2;i++){
			flg=0;
			for(j=1;j<=a;j++){
				if(i==b[j]){
					flg=1;
				}
			}
			if(flg!=1){
				c[h]=i;
				h++;
			}
		}
		sort(b+1,b+a+1);
		sort(c+1,c+a+1);
		while(tt!=0 && ht!=0){
			flg=0;
			if(tn%2!=0){
				if(ba==0){
					sort(b,b+a);
					ba=b[0];
					b[0]=1000000;
					tt--;
				}
				else{
					for(i=1;i<=a;i++){
						if(ba<b[i] && b[i]<=a*2){
							ba=b[i];
							b[i]=100000;
							tt--;
							flg=1;
							i=a;
						}
					}
					if(flg==0){
						ba=0;
					}
				}
			}
			else{
				if(ba==0){
					sort(c,c+a);
					ba=c[0];
					c[0]=1000000;
					ht--;
				}
				else{
					for(i=1;i<=a;i++){
						if(ba<c[i] && c[i]<=a*2){
							ba=c[i];
							c[i]=100000;
							ht--;
							flg=1;
							i=a;
						}
					}
					if(flg==0){
						ba=0;
					}
				}
			}
			tn++;
		}
		printf("%d\n",ht);
		printf("%d\n",tt);
		scanf("%d",&a);
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll n, k;
    cin >> n >> k;

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

    sort(rall(a));
    sort(all(f));

    ll lo = -1, hi = 1e12;
    while(hi - lo > 1) {
        ll mid = hi - (hi - lo) / 2;
        ll kk = 0;
        rep(i, n)  if(mid < a[i] * f[i]) {
            int x = - mid / f[i] + a[i];
            kk += max(x, 0);
            // cout << mid << " " << i << " " << x << endl;
        }

        // cout <<  mid << " " << kk << endl;
        if (kk > k) lo = mid;
        else hi = mid;
    }

    cout << hi << endl;

    return 0;
}

Measured memory_bytes: 3456
#include <stdio.h>
#include <math.h>

int main()
{
	double a,b;
	double total,keta;
	int iketa;

	while(scanf("%lf %lf",&a,&b) != EOF){
		total = a + b;
		keta = log10(total);
		keta = keta + 1;
		printf("%d\n",(int)keta);
	}

	return 0;
}

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

int main()
{
    int n,k,x,y;
    cin>> n >> k >> x >> y;

    if(n <= k)
    {
        cout<< n*x;
    }
    else
    {
        int temp = n-k;

        cout<< k*x + temp*y;

    }

    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 100005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int a[3];
   rep(i,0,3)cin>>a[i];
   sort(a,a+3);
   cout<<a[0]+a[1]<<endl;
}



Measured memory_bytes: 256
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

sys.setrecursionlimit(10**8)

#メモ化再帰
def rec(x):
    global dp
    if dp[x]!=-1:
        return dp[x]
    num = 0
    for a in adj[x]:
        num = max(num, rec(a)+1)
    dp[x] = num
    return num

#入力受け取り
N, M = mi()
x = li2(M)

#隣接リスト作成
adj = [[] for i in range(N)]
for i in range(M):
    x[i][0] -= 1
    x[i][1] -= 1
    adj[x[i][0]].append(x[i][1])

#メモ化再帰を実行
dp = [-1]*N
for i in range(N):
    rec(i)

print(max(dp))


Measured memory_bytes: 75672
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
  int N;
  while (cin >> N) {
    vector<int> p(N);
    for (int i = 0; i < N; i++) cin >> p[i], --p[i];
    vector<ll> a(N), b(N);
    for (int i = 0; i < N; i++) a[i] = 30000ll * (i + 1);
    for (int i = 0; i < N; i++) b[i] = 30000ll * (N - i);
    for (int i = 0; i < N; i++) a[p[i]] += i;
    for (ll x : a) cout << x << " ";
    cout << endl;
    for (ll x : b) cout << x << " ";
    cout << endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;

  N -= 1;// Nを移動回数に

  ll tar = abs(B-A);

  ll O = (N-N/2) * C - (N/2) * D;
  
  tar -= O; // 原点を移動

  ll kai = tar / (C+D);

  if(tar >= (N/2) * (C+D)){
    tar -= (N/2) * (C+D);
  }else{
    tar = tar % (C+D);//原点より小さかったら
  }

  // tarが [0, N(D-C)]に入っていればOK

  if(0<=tar && tar <= N*(D-C)){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())
cnt = 0
for i in range(A, B + 1):
  x = str(i)
  j, k = 0, len(x) - 1
  while j < k:
    if x[j] != x[k]:
      break
    j += 1
    k -= 1
  if k <= j:
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
k = int(input())
s = input()
n = len(s)
MOD = 10 ** 9 + 7

ans = 0
comb = 1
for i in range(k+1):
    if i > 0: comb = comb * (n+i-1) * pow(i, MOD-2, MOD) % MOD
    ans = (ans + comb * pow(25, i, MOD) * pow(26, k-i, MOD)) % MOD
print(ans)


Measured memory_bytes: 70356
# C
N = int(input())

A1_list = list(map(int, input().split()))
A2_list = list(map(int, input().split()))

s = 0
for i in range(N):
    t = s
    s += A1_list[i]
    A1_list[i] += t

s = 0   
for i in range(N-1, -1, -1):
    t = s
    s += A2_list[i]
    A2_list[i] += t
    
print(max([A1_list[i] + A2_list[i] for i in range(N)]))

Measured memory_bytes: 3064
A, B, C, X, Y = map(int,input().split())

ans = 10 ** 9
max_xy = max(X, Y)
for i in range(max_xy + 1):
    tmp = 2 * C * i
    tmp += A * max(X-i, 0) + B * max(Y-i, 0)
    if tmp < ans:
        ans = tmp
print(ans)



Measured memory_bytes: 2940
#include <stdio.h>

int main(void) {
	int a, b, s, d;
	while (~scanf ("%d %d", &a, &b)){
		s = a + b;
		for (d=1; s/10 != 0; d++) s = s/10;
		printf ("%d\n", d);
	}
	return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>

using namespace std;
#define MAX 1000000000

int main(){

    int N;
    cin >> N;

    int cnt = 0;
    set<char> sample;
    sample.insert('3');
    sample.insert('5');
    sample.insert('7');

    for (int i = 357; i <= N; i = i + 2){
        int contiFlg = false;
        string temp = to_string((long long int)i);
        for (int len = temp.size(); len > 3; len--){
            temp = temp.substr(temp.size() - len,temp.size());
            if ((temp[0] != '3') && (temp[0] != '5') && temp[0] != '7'){
                i += (int)pow(10.0, (int)temp.size() - 1);
                contiFlg = true;
                break;
            }
        }
        if (contiFlg) continue;
        temp = to_string((long long int)i);
        set<char> tempS;
        for (unsigned int i = 0; i < temp.size(); i++){
            tempS.insert(temp[i]);
        }
        if(tempS != sample) continue;

        /*if(false == tempS.find('3'))

        if ((temp.end() != find(temp.begin(), temp.end(), '0')) 
            || (temp.end() != find(temp.begin(), temp.end(), '1'))
            || (temp.end() != find(temp.begin(), temp.end(), '2'))
            || (temp.end() != find(temp.begin(), temp.end(), '4'))
            || (temp.end() != find(temp.begin(), temp.end(), '6'))
            || (temp.end() != find(temp.begin(), temp.end(), '8'))
            || (temp.end() != find(temp.begin(), temp.end(), '9'))){
                continue;
        }
        if ((temp.end() == find(temp.begin(), temp.end(), '3')) 
            || (temp.end() == find(temp.begin(), temp.end(), '5'))
            || (temp.end() == find(temp.begin(), temp.end(), '7'))){
                continue;
        }*/
        cnt++;
    }
    std::cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>

using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int A,B,T;
    cin>>A>>B>>T;
    cout<<(T/A)*B<<endl;
    return 0;
}

Measured memory_bytes: 256
s = list(input())
t = list(input())
mx = 0
for i in range(len(s)-len(t)+1):
  count = 0
  for j in range(len(t)):
    if s[j+i] == t[j]:
      count += 1
  if mx < count:
    mx = count
print(len(t)-mx)
  

Measured memory_bytes: 8964
// 解き直し.
// https://img.atcoder.jp/abc061/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL INF = 1LL << 50;
const int NMAX = 1000;
const int MMAX = 2000;
int a[MMAX], b[MMAX];
LL c[MMAX], dist[NMAX];
bool negative[NMAX];

int main(){

    // 1. 入力情報.
    int N, M;
    scanf("%d %d", &N, &M);
    rep(i, M){
        scanf("%d %d %lld", &a[i], &b[i], &c[i]);
        c[i] *= -1;
    }
    
    // 2. Bellman Ford法.
    rep(i, N) dist[i] = INF;
    
    // 3. コストの小さい経路を確認.
    dist[0] = 0;
    rep(_, N){
        rep(i, M){
            if(dist[a[i] - 1] == INF) continue;
            dist[b[i] - 1] = min(dist[b[i] - 1], dist[a[i] - 1] + c[i]);
        }
    }
    
    // 4. 閉路チェック.
    LL ans = dist[N - 1];
    rep(_, N){
        rep(i, M){
            if(dist[a[i] - 1] == INF) continue;
            LL d = dist[a[i] - 1] + c[i];
            if(dist[b[i] - 1] > d){
                dist[b[i] - 1] = d;
                negative[b[i] - 1] = true;
            }
            
            if(negative[a[i] - 1]) negative[b[i] - 1] = true;
        }
    }
    
    // 5. 出力.
    if(negative[N - 1]) printf("%s\n", "inf");
    else                printf("%lld\n", -ans);
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,t;
    cin>>n>>t;
    int ar[n+1];
    int dif,ct=0;
    int max_dif=-1;
    for(int i=0; i<n; i++)
    {
        cin>>ar[i];
    }
    int mn;
    mn=ar[0];
    for(int i=1; i<n; i++)
    {
        if(ar[i]<mn)
        {
            mn=ar[i];
        }
        dif=ar[i]-mn;
        if(dif>max_dif)
        {
            max_dif=dif;
            ct=1;
        }
        else if(dif==max_dif)
        {
            ct++;
        }
    }
    cout<<ct<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
void swap(int& x, int& y){
    int tmp = x;
    x=y;
    y=tmp;
}
 
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);
    if(a>b) swap(a,b);
     
    cout << a << " " << b << " "  << c << endl;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){

string s,t;
cin >> s >> t;
int coun = 0;
for(int i = 0 ; i <  3 ; i++){
    if( s[i] == t[i])
        coun++;
}
cout << coun << endl;
return 0;
}

Measured memory_bytes: 256
N = gets.to_i
prev = 0
now = 0
dist = []
sum = 0
gets.split.map do |x|
  prev = now
  now = x.to_i
  distance = now - prev
  dist << distance
  sum += distance.abs
end
# p now
dist << -now
# p dist
sum += now.abs
# binding.pry
N.times do |i|
  puts sum - (((dist[i+1]).abs + (dist[i]).abs) - (dist[i+1] + dist[i]).abs)
end

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

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

  bool flg=false;
  if (abs(a-c)<=d) flg=true;
  if (abs(a-b)<=d && abs(b-c)<=d) flg=true;

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

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, err := strconv.Atoi(input())
	if err != nil {
		log.Fatalln(err)
	}

	//if n < 1000 {
	//	fmt.Println(n)
	//	return
	//}
	//
	//if n%1000 == 0 {
	//	fmt.Println(0)
	//	return
	//}

	tmp := 1000
	for i := 1; tmp < n; i++ {
		tmp += 1000
	}

	fmt.Println(tmp - n)
}


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

int main(){
    string s;
    cin >> s;
    string s2 = s.substr(0,3);
    cout << s2 << endl;
    return 0;
}

Measured memory_bytes: 3600
#include "iostream"

using namespace std;

int main(){
	int N;
	cin >> N;
	long long A[N];
	for(int i = 0; i < N; i++){
        cin >> A[i];
    }

	long long ans = 0;
    int cnt = 0;
    long long min_A = abs(A[0]);
	for(int i = 0; i < N; i++){
        ans += abs(A[i]);
    }

    for(int i = 0; i < N; i++){
        min_A = min(min_A, abs(A[i]));

        if(A[i] < 0){
            cnt++;
        }
    }
    if(cnt % 2 == 1){
        ans -= 2 * min_A;
    }


	cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1024
#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)
#define ALL(a) (a).begin(),(a).end()

int main(){
    string str;cin>>str;
    if(str.length()<4){
        cout<<"No"<<endl;
    }else if(str.substr(0,4)=="YAKI"){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
def main():
  def p(a,b):
    if a < b:
      return (a,b)
    else:
      return (b,a)
  input = sys.stdin.readline
  N = int(input())
  E = [[] for i in range(N)]
  C = {}
  D = [0] * N
  parent = [0]*N
  for i in range(N-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    E[a].append(b)
    E[b].append(a)
    C[p(a,b)] = c

  M, K = map(int, input().split())
  K -= 1
  parent[K] = K
  Q = deque()
  Q.append(K)

  while Q:
    u = Q.popleft()
    d = D[u]
    for v in E[u]:
      if parent[u] == v:
        continue
      parent[v] = u
      D[v] = d + C[p(u,v)]
      Q.append(v)

  for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(D[x]+D[y])

main()
  
 

Measured memory_bytes: 44288
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
    static void Main(string[] args)
    {
		int N = int.Parse(Console.ReadLine());
		var A = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		Array.Sort(A);
		var P = new Program();
		int gcd = P.GetGcdOfSortedArray(A);
		Console.WriteLine(gcd);
	}
    public int GetGcdOfSortedArray(int[] array)
	{
		if (array.Length == 0) { return 1; }
		else if (array.Length == 1) { return array[0]; }
		else
		{
			int n = 0;
			int g = -1;
			while (n<=array.Length-2)
			{

				int a = array[n + 1];
				int b = array[n];
				int r = a % b;
				while (r > 0)
				{
					a = b;
					b = r;
					r = a % b;
				}
				g = b;
				array[n + 1] = g;
				n++;
			}

			return g;
            
		}
	}
}





Measured memory_bytes: 19680