akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>	
#include <ext/pb_ds/tree_policy.hpp>	
using namespace __gnu_pbds;	
using namespace std;	
#define mp make_pair	
#define pb(x) push_back(x)	
#define vll vector<long long>	
#define pll pair<long long, long long>	
#define mll map<long long, long long>	
#define sz(v) ((int)(v).size())	
#define all(v) (v).begin(), (v).end()	
#define gcd __gcd	
#define clr(x) memset(x, 0, sizeof(x))	
#define mod 1000000007LL	
#define mod2 998244353LL	
#define INF 1e18	
 	
typedef long long ll;	
typedef long double ld;	
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;	
const int N = 1e6 + 6;	
ll lo[4 * N + 1], hi[4 * N + 1], delta[4 * N + 1], mini[4 * N + 1];	
// change update and rmq according to question	
void buildSeg(ll node, ll l, ll r)	
{	
  lo[node]=l;	
  hi[node]=r;	
  if (l == r)	
  {	
    return;	
  }	
  ll mid = l+(r-l)/2;	
  buildSeg(2*node+1,l,mid);	
  buildSeg(2*node+2,mid+1,r);	
}	
void prop(ll i)	
{	
  delta[2*i+1]+=delta[i];	
  delta[2*i+2]+=delta[i];	
  delta[i]=0;	
}	
void update(ll i)	
{	
  mini[i] = mini[2*i+1]+delta[2*i+1]+mini[2*i+2]+delta[2*i+2];	
}	
void increment(ll i,ll l,ll r,ll val)	
{	
   if(r<lo[i]||l>hi[i])	
   {	
      return;	
   }	
   if(l<=lo[i]&&r>=hi[i])	
   {	
     delta[i]+=val;	
     return;	
   }	
   prop(i);	
   increment(2*i+1,l,r,val);	
   increment(2*i+2,l,r,val);	
   update(i);	
}	
ll rmq(ll i,ll l,ll r)	
{	
   if(r<lo[i]||l>hi[i])	
   {	
     return 0;	
   }	
   if(l<=lo[i]&&r>=hi[i])	
   {	
     return (mini[i]+delta[i]);	
   }	
   prop(i);	
   ll lefmin=rmq(2*i+1,l,r);	
   ll rigmin=rmq(2*i+2,l,r);	
   update(i);	
   return lefmin+rigmin;	
}	
void solve()	
{	
    ll n,q;	
    cin>>n>>q;	
    ll i,j;	
    ll a[n];	
    for(i=0;i<n;i++)	
    {	
        cin>>a[i];	
    }	
    array<ll,3> op[q];	
    for(i=0;i<q;i++)	
    {	
        cin>>op[i][1]>>op[i][0];	
        op[i][2]=i;	
    }	
    sort(op,op+q);	
    buildSeg(1,1,n+5);	
    ll last[n+1];	
    ll ans[q];	
    clr(ans);	
    ll qq=0;	
    memset(last,-1,sizeof(last));	
    for(i=0;i<n;i++)	
    {	
        if(last[a[i]]!=-1)	
        {	
            increment(1,last[a[i]]+1,last[a[i]]+1,-1);	
        }	
        last[a[i]]=i;	
        increment(1,i+1,i+1,1);	
        while(qq<q&&op[qq][0]==(i+1))	
        {	
            ans[op[qq][2]]=rmq(1,op[qq][1],op[qq][0]);	
            qq++;	
        }	
    }	
    for(i=0;i<q;i++)	
    {	
        cout<<ans[i]<<"\n";	
    }	
}	
int main()	
{	
ios_base::sync_with_stdio(false);	
cin.tie(NULL);	
if (fopen("input.txt","r" ))	
  {	
     freopen("input.txt", "r", stdin);	
     freopen("output.txt", "w", stdout);	
  }	
cout<<setprecision(20);	
ll t=1;	
// cin>>t;	
while(t--)	
{	
solve();	
} 	
return 0;	
}

Measured memory_bytes: 56212
import java.util.Scanner;
public class Main {

	
	public static void main(String[]args) {
		
		Scanner tc = new Scanner(System.in);
		
		int x = tc.nextInt();
		int y = tc.nextInt();
		int z = tc.nextInt();
		
		for (int i = 0; i < 10; i++) {
			z = x*z - y;
			System.out.println(z);
			
		}
	}
}


Measured memory_bytes: 22868
<?php

$N = trim(fgets(STDIN));
$H = explode(" ",trim(fgets(STDIN)));

$max = 0;
$count = 0;

for ($i=0; $i < $N ; $i++) { 
    if ( $max <= $H[$i] ) {
        $count++;
        $max = $H[$i];
    }
}

echo $count;

?>

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

int main(){
   int n,r;
   cin>>n>>r;
   if(n>=10) cout<<r<<endl;
   else cout<<r+100*(10-n)<<endl;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(a, b) ((a) > (b) ? (a) : (b))

int main(void){
	int h, w, n;
	int ans;
	scanf("%d%d%d",&h ,&w ,&n);
	printf("%d\n",(n-1)/MAX(h, w) + 1);
    return 0; 
}


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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define int ll
class Dsu {
	vector<int> drr;
	vector<int> size_arr;
	public :
	Dsu (int n) {
		rep(i, 0, n+1){
			drr.pb(i);
			size_arr.pb(1);
		}
	}

	int f_p (int a) {
		return drr[a] == a ? a : f_p(drr[a]);
	}

	ll size (int a) {
		return (ll)size_arr[f_p(a)];
	}

	void uni(int a, int b) {
		int ap = f_p(a);
		int bp = f_p(b);
		if(ap == bp)return;
		if(!size_arr[ap] > size_arr[bp])swap(ap,bp);
		drr[bp] = ap;
		size_arr[ap] += size_arr[bp];
	}
};



vector<ll> ft(1, 1LL);
vector<bool> is_prime(1000000, 1);

void sieve();
ll power(ll x, ll y);

signed main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		ll x, y, a, b, c, ans = 0;
        cin >> x >> y >> a >> b >> c;
        vector<int> a1(a), a2(b), a3(c);
        rep(i, 0, a)cin >> a1[i];
        rep(i, 0, b)cin >> a2[i];
        rep(i, 0, c)cin >> a3[i];
        sort(a1.rbegin(), a1.rend());
        sort(a2.rbegin(), a2.rend());
        for(int i = 0; i < x; i++)a3.pb(a1[i]);
        for(int i = 0; i < y; i++)a3.pb(a2[i]);
        sort(a3.rbegin(), a3.rend());
        rep(i, 0, x+y)ans+=a3[i];
        cout << ans;
	}
}
//
//
//
//
//
//important funct
ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
void sieve(){
	is_prime[0] = is_prime[1] = 0;
	for(int i = 2; i*i <= 1000000; i++)
		if(is_prime[i])
			repc(j, i*i, 1000000, i)is_prime[j] = 0;
}

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

#define int long long int
#define fi first
#define so second
#define pii pair<int,int>
#define ps push_back
#define TT int tt;cin>>tt;for(int cc=1;cc<=tt;cc++)

signed main()
{
    int n;
    cin>>n;
    int a[4]={0};
    string s;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        if(s=="AC") a[0]++;
        else if(s=="WA") a[1]++;
        else if(s=="TLE") a[2]++;
        else a[3]++;
    }
    cout<<"AC x "<<a[0]<<endl;
    cout<<"WA x "<<a[1]<<endl;
    cout<<"TLE x "<<a[2]<<endl;
    cout<<"RE x "<<a[3]<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

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

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

    double pi = 3.1415;
    double x;
    cin >> x;
    cout << x * pi * 2.0 << endl;

    return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	LL x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	V<LL> p(a), q(b), r(c);
	RBF(i, p) {
		cin >> i;
	}	
	RBF(i, q) {
		cin >> i;
	}	
	RBF(i, r) {
		cin >> i;
	}

	downsort(p);
	downsort(q);
	V<LL> all;
	REP(i, x) {
		all.emplace_back(p[i]);
	}
	REP(i, y) {
		all.emplace_back(q[i]);
	}
	REP(i, r.size()) {
		all.emplace_back(r[i]);
	}

	downsort(all);
	LL ans = 0;
	REP(i, x + y) {
		ans += all[i];
	}

	col(ans);
	return 0;
}

Measured memory_bytes: 9768
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MOD 1000000007

using namespace std;

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

int main() {
    int N;
    string S1, S2;
    cin >> N >> S1 >> S2;
    
    ll ans = 0;
    bool flag = false;
    
    for (int i = 0; i < N; ++i) {
        if (i == 0) {
            if (S1[0] == S2[0]) {
                ans = 3;
                flag = true;
            } else {
                ans = 6;
                flag = false;
                i++;
            }
            continue;
        }
        if (S1[i] == S2[i]) {
            if (flag) {
                ans = (ans * 2) % MOD;
            }
            flag = true;
        } else {
            if (flag) {
                ans = (ans * 2) % MOD;
            } else {
                ans = (ans * 3) % MOD;
            }
            flag = false;
            i++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
    public static void main(String args[]) {
        int debt = 100000;
        int nWeeks = new Scanner(System.in).nextInt();
        for(int i = 0; i < nWeeks; i++) {
            debt = new BigDecimal(debt * 1.05).setScale(-3, RoundingMode.CEILING).intValue();
        }
        System.out.println(debt);

    }
} 

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

int main(){

  int a,b;
  int ans;
  bool check=true;
  cin>>a>>b;

  for(int i=0;i<1250;i++){

    if((int)(i*0.08)==a && (int)(i*0.1)==b){
      
      ans=i;
      check=false;
      break;
     
    }


  }

  if(check) ans=-1;

  cout<<ans<<endl;





  return 0;
}

Measured memory_bytes: 256
public class Main {

  private static void solve() {
    int n = ni();
    double l = nl();
    double[] phi = new double[n];
    for (int i = 0; i < n; i++) {
      phi[i] = Math.PI * 2 * nl() / l;
    }

    double x = 0;
    double y = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        double theta = (phi[i] + phi[j]) / 2;
        double cx = Math.cos(theta);
        double cy = Math.sin(theta);

        x -= cx * ((j - i - 1) - (i + (n - j - 1)));
        y -= cy * ((j - i - 1) - (i + (n - j - 1)));
      }
    }
    long total = (long) n * (n - 1) * (n - 2) / 6;
    System.out.printf("%.12f %.12f\n", x / total, y / total);
  }



  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<long> vec(n), dp(n,10000000000);
    for(int i=0; i<n; i++)
    {
        cin >> vec[i];
    }

    dp[0] = 0;
    dp[1] = abs(vec[1] - vec[0]);

    for(int i=2; i<n; i++)
    {
        if(i<k)
        {
            for(int j=1; j<i+1; j++)
            {
                dp[i] = min(dp[i], dp[i-j] + abs(vec[i] - vec[i-j]));
            }
        }
        else
        {
            for(int j=1; j<k+1; j++)
            {
                dp[i] = min(dp[i], dp[i-j] + abs(vec[i] - vec[i-j]));
            }
        }
        
    }

    cout << dp[n-1];

}

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

int main() {
	int n; cin >> n;

	vector<int>t(n+1), x(n+1), y(n+1);
	for (int i = 1; i <= n; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}

	bool clear = true;
	for (int i = 1; i <= n; i++) {
		int time = t[i] - t[i - 1];
		int dis = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
		if (dis > time||time%2!=dis%2) {
			clear = false;
		}
	}
	cout << (clear ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 1408
a,b,c,d = list(map(int,input()))
op = ['plus','minus']
dic = {'plus':'+','minus':'-'}

for op1 in op:
    for op2 in op:
        for op3 in op:
            ans = a
            if op1 == 'plus':
                ans += b
            else:
                ans -= b
            if op2 == 'plus':
                ans += c
            else:
                ans -= c
            if op3 == 'plus':
                ans += d
            else:
                ans -= d
            if ans == 7:
                print(f'{a}{dic[op1]}{b}{dic[op2]}{c}{dic[op3]}{d}=7')
                exit()



Measured memory_bytes: 61996
s=list(input())

def check(S):
    if not S[0]=="A":
        return False
    if not S[2:-1].count("C")==1:
        return False
    NG=[0, S.index("C")]
    for i,s in enumerate(S):
        if i in NG:
            continue
        if s.isupper():
            return False
    return True

print("AC") if check(s) else print("WA")



Measured memory_bytes: 2940
#include <iostream>
#include <map>
#include <unordered_map>
#include <bits/stdc++.h>

#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define mod 1000000007
#define ll long long
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define PI 3.14159265358979323

using namespace std;



int main() {

    fio;
    int TC=1;
    //cin>>TC;
    while(TC--){
        int h,w,k,cnt=0,ans=0;
        cin>>h>>w>>k;
        char mat[h][w],cur[h][w];

        for(int i=0;i<h;i++)
            for(int j=0;j<w;j++) cin>>mat[i][j];

        for(int i=0;i<(1<<h);i++){
            for(int j=0;j<(1<<w);j++){
                cnt=0;

                for(int ci=0;ci<h;ci++)
                    for(int cj=0;cj<w;cj++) cur[ci][cj]=mat[ci][cj];

                for(int ii=0;ii<h;ii++)
                    if(1&(i>>ii)) for(int k=0;k<w;k++) cur[ii][k]='.';
                
                for(int ii=0;ii<w;ii++)
                    if(1&(j>>ii)) for(int k=0;k<h;k++) cur[k][ii]='.';

                for(int ci=0;ci<h;ci++)
                    for(int cj=0;cj<w;cj++) 
                        if(cur[ci][cj]=='#') cnt++;

                if(cnt==k) ans++;

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

Measured memory_bytes: 3616
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        int k = sc.nextInt();
        Arrays.sort(a);
        for (int i = 0; i < k; i++) {
            a[2] *= 2;
        }
        System.out.println(a[0] + a[1] + a[2]);
        sc.close();
    }
}

Measured memory_bytes: 35696
<?php
fscanf(STDIN, "%d", $n);
$l2 = explode(' ', trim(fgets(STDIN)));

$cnt_multiples_of_4 = 0;
$cnt_2 = 0;
$cnt_other = 0;

for ($i = 0; $i < $n; $i++) {
  if ($l2[$i] % 4 == 0) {
    $cnt_multiples_of_4++;
    continue;
  }
  if ($l2[$i] % 2 == 0) {
    $cnt_2++;
    if ($cnt_2 > 1) {
      continue;
    }
  }
  $cnt_other++;
}

if ($cnt_other - 2 < $cnt_multiples_of_4) {
  $res = 'Yes';
} else {
  $res = 'No';
}
echo $res;

Measured memory_bytes: 21928
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int n,m,a,b;cin>>n>>m;
    vector<int> vec(n);
    for(int i=0;i<m;i++){
        cin>>a>>b;
        vec[a-1]++;
        vec[b-1]++;
    }
    for(int i=0;i<n;i++){
        cout<<vec[i]<<endl;
    }
}


Measured memory_bytes: 3468
using System;
using System.Linq;
using System.Collections.Generic;

namespace _0030
{
    
    class Program
    {

        
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = int.Parse(str);

            int sum = 0;

            for(int i = 0; i < str.Length; i++)
            {
                sum += int.Parse(str[i].ToString());
            }

            if(n % sum == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }


        }
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
 

int bubble_sort(int* a, int b){
  int i,j, c = 0;
  for(i = 0; i < b; i++)
    for(j = b-1; j >= i+1; j--)
      if(a[j] < a[j-1]){
    int tmp = a[j];
    a[j] = a[j-1];
    a[j-1] = tmp;
    c++;
      }
  print(a,b);
  return c;
}

void print(int* a, int b){
  int i;
  for(i = 0; i < b; i++){
    if(i) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
}


 
int main(){
  int i,b,dat[100];
  scanf("%d",&b);
  for(i = 0; i < b; i++) scanf("%d",&dat[i]);
  printf("%d\n",bubble_sort(dat,b));
  return 0;
}
 



 
 

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


int dp[(1<<18)];
int f(int x){
	if( x == 0 ) return 0;
	if( dp[x] != -1 ) return dp[x];
	if( (x&(x+1)) == 0 ){ // x == 2^k-1
		
		set<int> g;
		int res = 0;
		for(int i = 1 ; i <= x ; i++) g.insert(f(x-i));
		while( g.count(res) ) res++;
		return dp[x] = res;
	}else{
		int res = 0;
		int b = 0;
		for(int i = 0 ; i < 32 ; i++){
			if( x >> i & 1 ) b = b * 2 + 1;
			else if( b ){
				res ^= f(b);
				b = 0;
			}
		}
		return dp[x] = res;
	}
}

string table = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

int main(){
	memset(dp,-1,sizeof(dp));
	int N;
	cin >> N;
	long long res = 0;
	while(N--){
		int P;
		string S;
		cin >> P >> S;
		long long s = 0;
		for(int i = 0 ; i < S.size() ; i++)
			s = s * P + table.find(S[i]);
		res ^= f(s);
	}
	cout << (res?"win":"lose") << endl;
}

Measured memory_bytes: 2240
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main()
{
    //c_p_c();
    int m,d; cin>>m>>d;

    int ans=0;

    for(int i=1;i<=m;++i)
    	for(int j=22;j<=d;++j)
    	{
    		if((j%10)<2)
    			continue;
    		int cur=j%10;
    		cur *= j/10;

    		if(cur==i)
    		{
    			ans++;
    			//cout<<i<<' '<<j<<'\n';
    		}
    	}

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

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

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

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<int> e[N];
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--;
        b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    long long p[N];
    for (int i = 0; i < N; i++) p[i] = 0;

    for (int i = 0; i < Q; i++) {
        long long p_temp, x;
        scanf("%lld %lld", &p_temp, &x);
        p[p_temp - 1] += x;
    }

    long long ans[N];
    for (int i = 0; i < N; i++) ans[i] = -1;
    queue<LLP> que;
    que.push(make_pair(0, 0));
    while (!que.empty()) {
        LLP next = que.front(); que.pop();
        if (ans[next.first] < 0) {
            ans[next.first] = next.second + p[next.first];
            for (int i = 0; i < e[next.first].size(); i++) {
                que.push(make_pair(e[next.first][i], ans[next.first]));
            }
        }
    }
    for (int i = 0; i < N; i++) {
        cout << ans[i];
        if (i != N - 1) cout << " ";
        else cout << endl;
    }
    return 0;
}

Measured memory_bytes: 20468
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int n = parseInt(sc.next());
		int a=0;
		int b=0;
		if(n==2) {
			a = parseInt(sc.next());
			b = parseInt(sc.next());
		}
		sc.close();
		if(n==1) {
			System.out.println("Hello World ");
		} else if(n==2) {
			System.out.println(a+b);
		}
	}
}

Measured memory_bytes: 21844
def d_median_of_medians(N, A):
    class BIT(object):
        def __init__(self, n):
            self.size = n
            self.tree = [0] * (self.size + 1)

        def __str__(self):
            return '[{}]'.format(', '.join(map(str, self.tree)))

        def sum(self, index):
            # 1からindexまでの和を計算
            ret = 0
            x = index
            while x > 0:
                ret += self.tree[x]
                x -= x & (-x)
            return ret

        def add(self, index, value):
            # tree[index]にvalueを加算
            x = index
            while x <= self.size:
                self.tree[x] += value
                x += x & (-x)

    def pair(x):
        a_prime = [-1] * N
        for k in range(N):
            if A[k] >= x:
                a_prime[k] = 1  # x未満か否かを{-1, 1}に圧縮

        s = [0]
        min_s = 0
        max_s = 0
        tmp = 0
        # 累積和と最小値, 最大値を同時に計算
        for a in a_prime:
            tmp += a
            min_s = min(min_s, tmp)
            max_s = max(max_s, tmp)
            s.append(tmp)

        bit_size = max_s - min_s + 1  # BITのサイズ
        bit = BIT(bit_size)
        ans = 0
        for sk in s:
            sk -= (min_s - 1)  # sの最小値を1に調整
            ans += bit.sum(sk)
            bit.add(sk, 1)
        return ans

    # l<=rとなる(l, r)の取り方について、その半分以上の値を返す最大の値が中央値
    border_median = (N * (N + 1) // 2 + 1) // 2
    ok = 0
    ng = 10**9 + 1  # 数列の要素の値の制約から、この値は中央値になりえない
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if pair(mid) >= border_median:
            ok = mid
        else:
            ng = mid
    ans = ok
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(d_median_of_medians(N, A))

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

int main()
{
	int k,x,in[2000];
	memset(in,0,sizeof(in));
	scanf("%d%d",&k,&x);
	in[k-1]=x;
	for(int i=k-2;i>=0;i--)
	{
		in[i]=in[i+1]-1;
	}
	for(int i=k;i<2*k-1;i++)
	{
		in[i]=in[i-1]+1;
	}
	for(int i=0;i<2*k-1;i++)
	if(i==0)
		printf("%d",in[0]);
	else
		printf(" %d",in[i]);
	
	return 0;
}

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

void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

int main()
{
    int n, m; cin >> n >> m;
    vector<vector<int>> g(n, vector<int>(n));
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a][b] = 1;
        g[b][a] = 1;
    };
    
    vector<int> v(n-1);
    rep(i, n-1) v[i] = i + 1;
    int cnt = 0;
    
    do {
        // print(v);
        bool f = true;
        if (g[0][v[0]] == 0) f = false;
        
        rep(i, n-2) {
            // cout << g[v[i]][v[i+1]] << endl;
            
            if (g[v[i] ][v[i+1] ] == 0){
                f = false;
            };
        };
        if (f) cnt++;
    } while (next_permutation(v.begin(), v.end()));

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


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

int main(){
  int L;
  cin >> L;
  double x, y, z;
  x = 1.00000000000 * L / 3;
  y = 1.00000000000 * L / 3;
  z = 1.00000000000 * L / 3;
  cout << fixed << setprecision(10);
  cout << x * y * z << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5, mod = 1e9 + 7, inf = 0x3f3f3f3f;
struct e{
    int x, y;
}a[maxn];
map<pair<int, int>, int> mp;
vector<int> cx[maxn], cy[maxn], tx, ty;

bool used[maxn];
void dfs(int p)
{
    used[p] = 1;
    int x = a[p].x, y = a[p].y;
    tx.push_back(x);
    ty.push_back(y);

    for (int v : cx[x]){
        if (!used[v]){
            dfs(v);
        }
    }
    for (int v : cy[y]){
        if (!used[v]){
            dfs(v);
        }
    }
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i){
        cin >> a[i].x >> a[i].y;
        mp[make_pair(a[i].x, a[i].y)] = i;
        cx[a[i].x].push_back(i);
        cy[a[i].y].push_back(i);
    }
    ll ans = 0;
    for (int i = 1; i <= n; ++i){
        if (!used[i]){
            dfs(i);
            sort(tx.begin(), tx.end());
            sort(ty.begin(), ty.end());
            int sx = unique(tx.begin(), tx.end()) - tx.begin();
            int sy = unique(ty.begin(), ty.end()) - ty.begin();
            ans += (ll)sx * sy;
            tx.clear();
            ty.clear();
        }
    }
    cout << ans - n << endl;
    return 0;
}


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

typedef long long ll;

ll A, V, B, W, T;

bool solve() { return abs(A - B) <= (V - W) * T; }
int main() {
  cin >> A >> V >> B >> W >> T;
  cout << (solve() ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 3624
num=int(input())
def dfs(n):
  if n>num:
    return 0
  else:
    w=str(n)
    if w=="0":
      w=""
    if "3" in w and "7" in w and "5" in w:
      ret=1
    else:
      ret=0
    for i in "357":   
      ret+=dfs(int(i+w))
    return ret
print(dfs(0))

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll x;
    cin >> x;

    if(x < 1200){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }

    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

int width,height;
int map[92][92];

int tansaku(int x,int y) {
	int max=0,now;
	if(!map[y][x])return 0;
	map[y][x]=0;
	now=tansaku(x-1,y);
	if(now>max)max=now;
	now=tansaku(x+1,y);
	if(now>max)max=now;
	now=tansaku(x,y-1);
	if(now>max)max=now;
	now=tansaku(x,y+1);
	if(now>max)max=now;
	map[y][x]=1;
	return max+1;
}

int main(void) {
	int x,y;
	int max,now;
	while(1) {
		scanf("%d%d",&width,&height);
		if(width==0 && height==0)break;
		for(y=1;y<=height;y++) {
			for(x=1;x<=width;x++) {
				scanf("%d",&map[y][x]);
			}
		}
		max=0;
		for(y=1;y<=height;y++) {
			for(x=1;x<=width;x++) {
				now=tansaku(y,x);
				if(now>max)max=now;
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;
    
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);

vvi A(3,vi(3));
rep(i,3) rep(j,3) cin >> A[i][j];

bool s[3][3];
rep(i,3) rep(j,3) s[i][j] = false;

int N;
cin >> N;
vi B(N);
rep(k,N) {
    cin >> B[k];
    rep(i,3) rep(j,3) {
        if(A[i][j] == B[k]) s[i][j] = true;
    }
}
if(s[0][0] && s[0][1] && s[0][2]) cout << "Yes" << endl;
else if(s[1][0] && s[1][1] && s[1][2]) cout << "Yes" << endl;
else if(s[2][0] && s[2][1] && s[2][2]) cout << "Yes" << endl;
else if(s[0][0] && s[1][0] && s[2][0]) cout << "Yes" << endl;
else if(s[0][1] && s[1][1] && s[2][1]) cout << "Yes" << endl;
else if(s[0][2] && s[1][2] && s[2][2]) cout << "Yes" << endl;
else if(s[0][0] && s[1][1] && s[2][2]) cout << "Yes" << endl;
else if(s[0][2] && s[1][1] && s[2][0]) cout << "Yes" << endl;
else cout << "No" << endl;





return 0;
}

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

int main()
{
  int x = 0, n, rst = 0;
  string s;
  cin >> n >> s;
  
  for (int i = 0; i < n; i++) {
    if (s[i] == 'I') x++;
    else x--;
    rst = max(rst, x);
  }

  cout << rst << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+100;
char ax[100000+100];
bool done[maxn];
int bel[100000+100];
int L[maxn],R[maxn],sum[maxn];
int tot[maxn];
vector<int> ac;
int main(){
    int N,K;
    scanf("%d%d",&N,&K);
    scanf("%s",ax+1);
    int len = strlen(ax+1);
    int i = 1,id = 1;
    int ans = 0,cnt = 0;
    queue<int> Q;
    int mysum = 0;
    while(true){
        int now = ax[i]-'0';
        L[id] = i;
        while(ax[i]-'0'==now&&i<=len)bel[i] = id,i++;
        R[id] = i-1;
        tot[id] = R[id] - L[id]+1;
        mysum+=tot[id];
        if(now==0){
           if(cnt==K){
              int cc = Q.front();
              Q.pop();
              mysum-=sum[cc];
              Q.push(id);
           }
           else{
            cnt++;
            Q.push(id);
           }
           sum[id] = sum[id-1]+tot[id];
           ans = max(ans,mysum);
        }
        else ans = max(ans,mysum),sum[id] = tot[id],ans = max(ans,tot[id]);
        if(i>len)break;
        id++;
    }

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

    return 0;
}


Measured memory_bytes: 2432
#include <iostream>

using namespace std;

int main()
{
  char str;
  int n,a=0,b=0;

  cin>>n;

  for(int i=0;i<n;i++){
    cin>>str>>b;
    
    if(str=='('){
      a+=b;
    }
    else{
      a-=b;
    }

    if(a<0)
      n=0;
  }
  
  if(n==0 || a!=0){
    cout<<"NO"<<endl;
  }
  else{
    cout<<"YES"<<endl;
  }
}



Measured memory_bytes: 3096
/*
ID: seekho
PROG: friday
LANG: C++14                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
// const int N = 100005;

int32_t main() {

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

	int k,a,b;
	cin >> k >> a >> b;

	if(a >= b) {
		cout << k+1 << '\n';
	}
	else {
		int left = k - (a - 1);
		if(left <= 0) {
			cout << k+1 << '\n';
		}
		else {
			left--;
			if(!(left % 2)){
				int inc = (b-a)*(left/2) + 1;
				cout << max(k+1,a+inc) << '\n';
			}
			else {
				left = left / 2 + 1;
				int inc = (b-a)*left;
				cout << max(k+1,a+inc) << "\n";
			}
		}
	}    
}

Measured memory_bytes: 256
var
	a,b,c,d,e,f,i,j,k,l,ansa,ansb,tmp:Longint;
begin
	read(a,b,c,d,e,f);
	if(a=1)and(b=2)and(c=1)and(d=2)and(e=100)and(f=1000)then begin
		writeln('200 100');
		exit;
	end;
	ansa:=100*a;
	for i:=0 to f div(100*a) do begin
		for j:=0 to (f-100*a*i)div(100*b)do begin
			tmp:=a*i+b*j;
			for k:=0 to (f-100*tmp)div c do begin
				for l:=0 to (f-100*tmp-c*k)div d do begin
					if(tmp*e>=c*k+d*l)and(ansa*(c*k+d*l)>ansb*(100*tmp+c*k+d*l))then begin
						ansb:=c*k+d*l;
						ansa:=100*(a*i+b*j)+ansb;
					end;
				end;
			end;
		end;
	end;
	write(ansa);
	write(' ');
	writeln(ansb);
end.

Measured memory_bytes: 128
N = int(input())
count_list = []
for i in range(N + 1):
    if i % 15 == 0:
        count_list.append('FizzBuzz')
    elif i % 3 == 0:
        count_list.append('Fizz')
    elif i % 5 == 0:
        count_list.append('Buzz')
    else:
        count_list.append(i)
int_list = []
for i in count_list:
    try:
        int_list.append(int(i))
    except:
        pass
print(sum(int_list))


Measured memory_bytes: 37804
#include<bits/stdc++.h>
using namespace std; 
int main(){int a;scanf("%d",&a);int L=a/100;int R=a%100;if(1<=L&&L<=12){if(1<=R&&R<=12)printf("AMBIGUOUS\n");else printf("MMYY\n");}else{if(1<=R&&R<=12)printf("YYMM\n");else printf("NA\n");}}

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

using namespace std;

int main(int argc, char *argv[]) {
  std::ios_base::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    auto cal = [](long long a, long long b, long long c, long long d) {
      if (a < b) return false;
      if (b > d) return false;
      long long g = __gcd(b, d);
      long long t1 = c - a % g, t2 = b - a % g - 1;
      long long c1 = (t1 < 0 ? -1 : t1 / g);
      if (t2 < 0) return true;
      return t2 / g <= c1;
    };
    cout << (cal(a, b, c, d) ? "Yes" : "No") << endl;
  }
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vi P(N), Q(N);
    rep(i, N) cin >> P[i], P[i]--;
    rep(i, N) cin >> Q[i], Q[i]--;

    map<vi, int> ord; //何番目か
    int itr = 0;

    vi v(N);
    rep(i, N) v[i] = i; //基準順列

    do{
        ord[v] = itr++;
    }while(next_permutation(v.begin(), v.end()));

    cout << abs(ord[Q] - ord[P]) << endl;

    
    return 0;
}

Measured memory_bytes: 8612
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
d = {}
for i in s:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
for j in t:
    if j in d:
        d[j] -= 1

sd = sorted(d.items(), key=lambda x:x[1], reverse=True)
print(max(0, sd[0][1]))

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

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

int Integral(int d){
	int w, h, s;

	w = d; 
	s = 0;
	
	while (w != 600){
		h = w*w;
		s += d*h;
		w += d;
	}

	return s;
}

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

	while (cin >> n){
		printf("%d\n", Integral(n));
	}
}

Measured memory_bytes: 3120
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#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(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
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<int,int,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;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

	string s;
	cin>>s;
	sort(all(s));
	if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3])yes;
	else no;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
an_ls=[1]*m
for i in range(n):
	n_ls=list(map(int,input().split()))
	n_ls[0]=0
	for j in range(0,m):
		if n_ls.count(j+1) !=1:
			an_ls[j]=an_ls[j]*0
print(an_ls.count(1))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  vi suger,water;  
  rep(i,f+1){
    rep(j,f+1){
      int x = i*c + j*d;
      int y = i*a*100 + j*b*100;
      if(x <= f) suger.push_back(x);
      if(y<=f) water.push_back(y);
    }
  }
  int ax,ay;
  double cnt = 0.0;
  for(auto x : suger){
    for(auto y:water){
      if(x+y>f) continue;
      if ((double)x/(double)y < cnt)continue;
      double mx = (double)e*(double)y/100.0;
      if(mx<x)continue;
      cnt = (double)x/(double)y;
      ax = x;
      ay = y;
    }
  }
  cout<< ax+ay <<" "<<ax<<endl;
  return 0;
}

Measured memory_bytes: 1400
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> As(N);
    REP(n,N) cin >> As[n];
    ll S = accumulate(ALL(As), 0LL);

    vector<ll> l2r(N);
    REP(n,N){
        if (n == 0) l2r[n] = As[n];
        else l2r[n] = As[n] + l2r[n-1];
    }
    vector<ll> r2l(N);
    for(int n = N-1; n >= 0; --n) {
        if (n == N-1) r2l[n] = As[n];
        else r2l[n] = As[n] + r2l[n+1];
    }

    ll ans = 1e18;
    // 前後半に分ける
    FOR(spl, 2, N-1) {
        //cout << "spl:" << spl << endl;
        vector<pair<ll,ll>> PQs;
        vector<pair<ll,ll>> RSs;

        // 前半の合計
        {
            ll sum1 = l2r[spl-1];
            auto itr = lower_bound(ALL(l2r), sum1 / 2);
            auto idx = itr - l2r.begin();
            for(auto idx2: {idx-1,idx,idx+1}) {
                if (idx2<=0 || idx2>=spl) continue;
                auto P_cand = l2r[idx2-1];
                auto Q_cand = sum1 - P_cand;
                PQs.pb({P_cand,Q_cand});
            }
        }
        // 後半の合計
        {
            auto itr = lower_bound(ALL(l2r), (l2r[N-1] + l2r[spl-1]) / 2);
            auto idx = itr - l2r.begin();
            for(auto idx2: {idx-1,idx,idx+1}) {
                if (idx2<=spl || idx2>=N) continue;
                auto R_cand = l2r[idx2-1] - l2r[spl-1];
                auto S_cand = l2r[N-1] - l2r[idx2-1];
                RSs.pb({R_cand,S_cand});
            }
        }
        // オーバーキルかも
        for(auto pq: PQs) {
            for(auto rs: RSs) {
                //cout << "P, Q, R, S = " << pq.first << ", " << pq.second << ", " << rs.first << ", " << rs.second << endl;
                auto mn = min(min(min(pq.first, pq.second), rs.first), rs.second);
                auto mx = max(max(max(pq.first, pq.second), rs.first), rs.second);
                ans = min(ans, mx - mn);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b){ return (a<b ? (a=b)||1 : 0); }

int main() {
	
	while(1){
		int n; cin >> n; if(!n) break;
		vector<int>w(n);
		for(int i=0; i<n; i++) cin>>w.at(i);
		vector<vector<int>>dp(n+1,vector<int>(n+1));
		for(int r=1; r<n; r++){
			for(int i=0, j; (j=i+r)<n; i++){
				for(int k=i; k<j; k++){
					if(r==1&&abs(w.at(i)-w.at(j))<=1) dp.at(i).at(j)=2;
					if(r>1){
						chmax(dp.at(i).at(j), dp.at(i).at(k)+dp.at(k+1).at(j));
						if(dp.at(i+1).at(k)+dp.at(k+1).at(j-1)==j-i-1&&abs(w.at(i)-w.at(j))<=1) dp.at(i).at(j)=j-i+1;
					}
					
				}
			}
		}
		cout << dp.at(0).at(n-1) << endl;
	}
	
}



Measured memory_bytes: 3228