akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;



int main() {
	ll r, d, x;
	int i;

	cin >> r >> d >> x;

	rep(i, 10) {
		x = x * r - d;
		cout << x << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int Ab[64], Bb[64], Cb[64];
int main() {
    long long A, B;
    cin >> A >> B;

    long long a = A;
    long long b = B;
    for (int i=0; i<64; i++, a>>=1, b>>=1) {
        Ab[i] = a & 1;
        Bb[i] = b & 1;
    }
  

    if (A == B) {
        cout << A << endl;
        return 0;
    }
    long long T = 2;
    for (int i=0; i<62; i++, T<<=1) {
        long long mask = T - 1;
        long long size = B - A + 1;
        long long turn = size / T;
        long long rest = size % T;
        long long turnBitSum = (turn * T / 2) % 2;
        long long phase0 = (A + (T * turn)) & mask;
        
        long long phase1 = B & mask;
        if (rest > 0) {
            if (phase0 == phase1) turnBitSum += (phase0 < T/2 ? 0 : 1);
            else if (phase0 < phase1) {
                if (phase1 < T/2) turnBitSum += 0;
                else if (phase0 < T/2) turnBitSum += phase1 - T/2 + 1;
                else turnBitSum += phase1 - phase0 + 1;
            } else {
                if (phase0 < T/2) turnBitSum += T/2;
                else if (phase1 < T/2) turnBitSum += T - phase0;
                else turnBitSum += phase0 - phase1 + 1;
            }
        
        }
        Cb[i] = turnBitSum % 2;
    }
    long long C = 0;
    for (int i=63; i>=0; i--) {
        C = C * 2 + Cb[i];
    }
    cout << C << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char **argv)
{
	unsigned int n, i;
	
	while(1){
		scanf("%d", &n);
		if(n == 0){
			break;
		}
		
		for(i = 0; n != 1; i++){
			if(n%2 == 0){
				n /= 2;
			} else {
				n = 3*n+1;
			}
		}
		printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 0
use proconio::input;

fn main() {
    input!{
        n: usize,
        mut a: [usize; n],
    }

    a.sort();

    let mut ans = 0usize;
    if n < 3 { println!("0"); return; }
    for i in 0..n-2 {
        for j in i+1..n-1 {
            for k in j+1..n {
                let b = (a[i], a[j], a[k]);
                if b.0 == b.1 || b.1 == b.2 { continue; }
                if b.0 + b.1 > b.2 {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);



}


Measured memory_bytes: 2136
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{   
        
        string s;
        string t;
        cin>>s>>t;
        cout<<( (s[0]==t[0]?1:0) + (s[1]==t[1]?1:0) + (s[2]==t[2]?1:0))<<endl;
            
            
            
        
       return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	int n;
	cin>>n;
	int a[n+1];
	bool check[n+1];
	int sum=0;
	check[0]=false;
	rep(i,n){cin>>a[i+1];check[i+1]=false;}
	loop(i,1,n+1){
		if(a[a[i]]==i){
			if(check[i] || check[a[i]])continue;
			sum++;
			check[i]=check[a[i]]=true;
		}
	}
	cout<<sum<<endl;
	return 0;
}

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

//テストケースはあんまり見ないほうが良い。デバッグする能力が必要.
int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i,n){
        int j = i+n/2;
        if(s[i] == s[j] && j <n)++ans;
    } 
    if(ans==n/2 && n%2 == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef int64_t I;
typedef vector<I> vI;

template<typename T>
ostream& operator<<(ostream& os, vector<T> const& v) {
  os << "[";
  for (size_t i = 0; i < v.size(); i++) {
    os << (i == 0 ? "" : ",") << v[i];
  }
  return os << "]";
}

const I M = 0x100000;
I inv(I a, I b) {
  I x0 = 1, y0 = 0, x1 = 0, y1 = 1;
  while (b != 0) {
    I q = a / b, nb = a % b;
    a = b;
    b = nb;
    I nx1 = x0 - q * x1, ny1 = y0 - q * y1;
    x0 = x1;
    x1 = nx1;
    y0 = y1;
    y1 = ny1;
  }
  while (x0 < 0) {
    x0 += M;
  }
  return x0;
}

I comb(I n, I k) {
  I r1 = 1;
  I r2 = 1;
  for (I i = 0; i < k; i++) {
    r1 = (r1 * (n - i)) % M;
    r2 = (r2 * (i + 1)) % M;
  }
  return (r1 * inv(r2, M)) % M;
}

I comb1(I n, I k) {
  I r1 = 1;
  I r2 = 1;
  for (I i = 0; i < k; i++) {
    r1 = (r1 * (n - i));
    r2 = (r2 * (i + 1));
  }
  return (r1 / r2) % M;
}

I lzero(I x) {
  I r = 0;
  while (x > 0) {
    if ((x & 1) != 0) break;
    r++;
    x = (x >> 1);
  }
  return r;
}

int main() {
#if 0
  for (I n = 1; n < 20; n++) {
    cerr << n << " : ";
    I a = 0, b = 0;
    for (I i = 0; i <= n; i++) {
      cerr << (i == 0 ? "" : ",") << (comb1(n, i) & 1);
    }
    cerr << endl;
    for (I i = 0; i <= n; i++) {
      I c = (a > b ? 0 : 1);
      cerr << (i == 0 ? "" : ",") << c;
      a += lzero(n - i);
      b += lzero(i + 1);
    }
    cerr << endl;
  }
#endif
  I n; cin >> n;
  string s; cin >> s;
  vI v;
  for (size_t i = 0; i < n - 1; i++) {
    v.push_back(abs(s[i] - s[i + 1]));
  }
//  cout << v << endl;
  I div2 = 1;
  if (find(v.begin(), v.end(), 1) == v.end()) {
    for (size_t i = 0; i < n - 1; i++) v[i] /= 2;
    div2 = 2;
  } else {
    for (size_t i = 0; i < n - 1; i++) v[i] &= 1;
  }
//  cout << v << endl;
  I r = 0;
  I a = 0, b = 0;
  for (size_t i = 0; i < n - 1; i++) {
//#    cerr << "comb(i=" << i << ")=" << comb(n-2, i) << endl;
//#    cerr << "comb1(i=" << i << ")=" << comb1(n-2, i) << endl;
    I c = (a > b ? 0 : 1);
    r ^= (v[i] & c & 1);
    a += lzero(n - 2 - i);
    b += lzero(i + 1);
  }
  cout << r * div2 << endl;
}


Measured memory_bytes: 11896
#include<iostream>
#include<map>
#define line cout<<"here - "<<__LINE__<<"\n";
#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
using namespace std;
main()
{
    int a,b,c,t=0,i,j,k;
    cin>>a>>b>>c;
    string aa[a];
    for(i=0;i<a;i++)
        cin>>aa[i];
    for(i=0;i<a;i++)
    {
        for(j=0;j<b;j++)
        {
            if(aa[i][j]=='#')
                t++;
        }
    }
//    line
    int ans=0;
    if(t==c)
        ans=1;
    for(i=1;i<(1LL<<a);i++)
    {
//        line
        int s=0;
        map<pair<int,int>,int>mp;
            for(j=0;j<10;j++)
            {
                if(i&(1LL<<j))
                {
                    for(k=0;k<b;k++)
                    {
                       if(aa[j][k]=='#')
                       {
                           s++;
                           mp[{j,k}]=1;
                       }
                    }
                }
            }
//            line
        for(int m=1;m<(1LL<<b);m++)
        {
            int d=0;
            for(j=0;j<10;j++)
            {
                if(m&(1LL<<j))
                {
                    for(k=0;k<a;k++)
                    {
                        if(aa[k][j]=='#' && mp[{k,j}]==0)
                        {
                            d++;
                        }
                    }
                }
            }
            if(t-(s+d)==c)
            {
                ans++;
            }

        }


    }
    for(i=1;i<(1LL<<a);i++)
    {
        int s=0;
            for(j=0;j<10;j++)
            {
                if(i&(1LL<<j))
                {
                    for(k=0;k<b;k++)
                    {
                       if(aa[j][k]=='#')
                       {
                           s++;
                       }
                    }
                }
            }
            if(t-s==c)
                ans++;
    }
    for(int m=1;m<(1LL<<b);m++)
        {
            int d=0;
            for(j=0;j<10;j++)
            {
                if(m&(1LL<<j))
                {
                    for(k=0;k<a;k++)
                    {
                        if(aa[k][j]=='#')
                        {
                            d++;
                        }
                    }
                }
            }
            if(t-(d)==c)
            {
                ans++;
            }

        }
        cout<<ans<<endl;

}




Measured memory_bytes: 3572
fun main(args : Array<String>) {
    val (L, R) = readLine()!!.split(" ").map { it.toLong() }
    val MOD = 2019
    var i = L
    val candidates = mutableListOf<Int>()
    candidates.add(i.mod(2019).toInt())
    (0..2019 * 4).forEach {
        i++
        if (i <= R) {
            candidates.add(i.mod(2019).toInt())
        }
    }

    val size = candidates.size

    if (size <= 1) {
        println(0)
        return
    }

    var answer = Int.MAX_VALUE
    (0..(size - 2)).forEach { i ->
        ((i+1)..(size - 1)).forEach { j ->
            answer = Math.min(answer, (candidates[i] * candidates[j]).mod(2019))
        }
    }

    println(answer)
}

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

int main(void) {
  int N;
  cin >> N;
  vector<int> t(N), x(N), y(N);
  string ans = "Yes";
  int cx = 0, cy = 0, ct = 0;
  for (int i = 0; i < N; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  for (int i = 0; i < N; i++) {
    int distance = abs(x[i] - cx) + abs(y[i] - cy);
    int diff_t = t[i] - ct;
    cx = x[i];
    cy = y[i];
    ct = t[i];
    if (!(distance <= diff_t && distance % 2 == diff_t % 2)) {
      ans = "No";
      break;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
x, y, a, b, c = map(int, input().split())

p = list(map(lambda x: (int(x), 0), input().split()))
p += list(map(lambda x: (int(x), 1), input().split()))
p += list(map(lambda x: (int(x), 2), input().split()))
p = sorted(p, reverse=True)

from collections import deque
p = deque(p)
_n = x+y
ans = 0

D = [x, y ,x+y]
while _n > 0:
    _x, _y = p.popleft()
    if D[_y] == 0:
        pass
    else:
        D[_y] -= 1
        ans += _x
        _n -= 1

print(ans)

Measured memory_bytes: 119760
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 3e6 + 17;
ll a[N], b[N], cnt, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    for(ll i = 1; i <= n; i ++)
    {
        for(ll j = 1; j <= n; j ++)
        {
            if(i % 2 == 1 and j % 2 == 0)
            {
                cnt ++;
            }
        }
    }
    cout << cnt;
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,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 main(){
  ll N,M;
  cin>>N>>M;
  ll A[N],B[M],C[M];
  REP(i,N) cin>>A[i];
  REP(i,M) cin>>B[i]>>C[i];
  
  vector<pair<ll,ll>> L;
  REP(i,N) L.PB(MP(A[i],1LL));
  REP(i,M) L.PB(MP(C[i],B[i]));
  
  SORT(L);
  REVERSE(L);
  
  ll ans=0LL,cnt=0LL;
  REP(i,N){
    if(cnt+L[i].second<N){
      ans+=L[i].first*L[i].second;
      cnt+=L[i].second;
    }
    else{
      ans+=L[i].first*(N-cnt);
      break;
    }
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 8432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace P0008_SumOf4Integers
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> lines = new List<int>();
            string readLine;

            do
            {
                readLine = Console.ReadLine();
                if (readLine != null)
                {
                    lines.Add(int.Parse(readLine));
                }
            }
            while (readLine != null);
                       

            foreach (int sum in lines)
            {
                int result = 0;

                for (int a = 0; a <= 9; a++)
                {
                    for (int b = 0; b <= 9; b++)
                    {
                        for (int c = 0; c <= 9; c++)
                        {
                            for (int d = 0; d <= 9; d++)
                            {
                                
                                if(sum == a + b + c + d)
                                {
                                    result++;
                                }

                            }

                        }
                    
                    }
                }

                Console.WriteLine(result);
               

            }
            

        }
    }
}

Measured memory_bytes: 5668
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#include <random>
using namespace std;

/////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)


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

    ll sum = 0;

    repe(i, 1, n) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>

typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans;
    if (a >= k) {
        ans = k;
    } else if(a < k && k <= a + b) {
        ans = a;
    } else {
        ans = a + (-1) * (k - a - b);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  ll n,W;
  cin>>n>>W;
  ll w[n], v[n];
  rep(i,n) cin>>w[i]>>v[i];
  ll dp[n + 1][W + 1];
  rep(i, n + 1) {
    rep(j, W + 1) dp[i][j] = 0;
  }
  rep(i, n) {
    rep(j, W + 1) {
      if(j < w[i]) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i+1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      }
    }
  }
  cout << dp[n][W] << endl;

  return 0;
}


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

using namespace std;
struct I{I(){ios::sync_with_stdio(false);cin.tie(0);}}init;
typedef long long LL;
typedef vector<LL> V;
const LL MOD=1e9+7;
int main(){
    int n;cin>>n;
    V dp(n+1,0);
    dp[0]=1;
    for(int i=0;i<n;i++){
        string s;cin>>s;
        if(s=="-")continue;
        V nxt(n+1,0);
            for(int k=0;k<n;k++){
                if(s=="D"){
                    if(k==0)continue;
                    (nxt[k]+=dp[k]*k%MOD)%=MOD;          
                    (nxt[k-1]+=dp[k]*k*k%MOD)%=MOD;
                }
                else{
                    (nxt[k+1]+=dp[k])%=MOD;
                    if(k>0)(nxt[k]+=dp[k]*k%MOD)%=MOD;

                }
            }
        swap(dp,nxt);
    }
    cout<<dp[0]<<endl;
    

    return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >>n;
    ll l = 1;
    ll l2 = 1;

    REP(i,n) {
        ll x,x2;
        cin >> x >> x2;
        ll m =  (l-1) / x +1;
        ll m2 = (l2-1) / x2 +1;
        ll mm = max(m,m2);

        l = x * mm;
        l2 = x2 * mm;
    
    }
    cout << l+l2 << endl;

    return 0;
}

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

  int A,B,C;
  int ans = 0;
  cin >> A >> B >> C;
  for(int i = B;i < C+1;i++){
      if(i % A == 0){
             ans = 1;
             break;
      }
  }
  if(ans != 0)  cout << "OK" <<endl;
  else   cout << "NG" <<endl;
  
}

Measured memory_bytes: 3632
/*
ID: leezhen
TASK: practice
LANG: C++11                
*/
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <bitset>
#include <list>

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef long long ll;
const int inf = 1e9;
const int mod = 1e9+7;

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	int h[100024];
	for(int i=0; i<n; i++) scanf("%d", &h[i]);
	sort(h, h+n);
	int ans = inf;
	for(int i=0; i<n-k+1; i++) {
		ans = min(ans, h[k-1+i] - h[i]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
while 1:
    a,b=map(int,raw_input().split())
    if a==b==0:break
    n=input()
    c=[map(int,raw_input().split()) for _ in xrange(n)]
    dp=[[0]*(b+1) for _ in xrange(a+1)]
    for i in xrange(a):
        if [i+1,1] in c: break
        dp[i+1][1]=1
    for i in xrange(b):
        if [1,i+1] in c: break
        dp[1][i+1]=1
    for i in xrange(1,a):
        for j in xrange(1,b):
            if [i+1,j+1] in c: continue
            dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]
    print(dp[a][b])

Measured memory_bytes: 6448
/*
    なせば大抵なんとかなる！
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a>=c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	char a[2000],b[2000];
	scanf("%s %s",a,b);
	int len=strlen(a)+strlen(b);
	int x=0,y=0;
	forin(i,0,len)
	{
		if(i%2==0)
		{
			printf("%c",a[x]);
			x++;
		}
		else
		{
			printf("%c",b[y]);
			y++;
		}
	}
	newline;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  private static boolean isPossible(int n, int[] counter) {
    if (n % 2 == 0) {
      for (int i = 1; i < n; i += 2) {
        if (counter[i] != 2) {
          return false;
        }
      }
      for (int i = 0; i < n; i += 2) {
        if (counter[i] != 0) {
          return false;
        }
      }
      return true;
    } else {
      if (counter[0] != 1) {
        return false;
      }
      for (int i = 1; i < n; i += 2) {
        if (counter[i] != 0) {
          return false;
        }
      }
      for (int i = 2; i < n; i += 2) {
        if (counter[i] != 2) {
          return false;
        }
      }
      return true;
    }
  }

  private static long solve(int n, int[] counter) {
    if (!isPossible(n, counter)) {
      return 0;
    }
    long output = 1;
    for (int i = 0; i < n/2; i++) {
      output *= 2;
      output %= 1000000007;
    }
    return output;
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = Integer.parseInt(s.next());
    int[] counter = new int[n];
    for (int i = 0; i < n; i++) {
      counter[Integer.parseInt(s.next())]++;
    }
    System.out.println(solve(n, counter));
  }
}


Measured memory_bytes: 31832
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(x, a, b) for(int x=a; x<=b; x++)
typedef double db;
typedef long long ll;
const double pi = acos (-1.0);
int n, m;
double ans;
db
dist (db x1, db y1, db x2, db y2)
{
  return sqrt ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

struct data
{
  double x, y;
  int w;
  bool operator < (const data & rhs) const
  {
    return x < rhs.x || (x == rhs.x && y < rhs.y);
  }
  bool operator == (const data & rhs) const
  {
    return fabs (x - rhs.x) < 1e-8 && fabs (y - rhs.y) < 1e-8;
  }
}
p[1000];
struct asshole
{
  double fi;
  int se;
  bool operator < (const asshole & rhs) const
  {
    return fi > rhs.fi || (fi == rhs.fi && se > rhs.se);
  }
};
priority_queue < asshole > q;
vector < data > rng;
bool
check (int o, double R)
{
  double d;
  rng.clear ();
  rep (i, 1, n) if (i != o
		    && (d = dist (p[o].x, p[o].y, p[i].x, p[i].y)) <= 2 * R)
    {
      double ang = atan2 (p[i].y - p[o].y, p[i].x - p[o].x);
      double del = acos (d / 2 / R);
      double l = ang - del, r = ang + del;
      if (l < -pi)
	rng.pb ((data)
		{
		l + 2 * pi, pi, p[i].w}
      ), rng.pb ((data)
		 {
		 -pi, r, p[i].w}
      );
      else
    if (r > pi)
      rng.pb ((data)
	      {
	      l, pi, p[i].w}
      ), rng.pb ((data)
		 {
		 -pi, r - 2 * pi, p[i].w}
      );
      else
      rng.pb ((data)
	      {
	      l, r, p[i].w}
      );
    }
  sort (rng.begin (), rng.end ());
  while (!q.empty ())
    q.pop ();
  int sum = p[o].w;
/*	
	int sz=rng.size();
	printf("%d\n", sz);
	rep(i, 0, sz-1) printf("%lf %lf %d\n", rng[i].x, rng[i].y, rng[i].w);
*/
  rep (i, 0, (int) rng.size () - 1)
  {
    while (!q.empty ())
      {
	asshole tp = q.top ();
	if (tp.fi < rng[i].x)
	  sum -= tp.se, q.pop ();
	else
	  break;
      }
    q.push ((asshole)
	    {
	    rng[i].y, rng[i].w}
    );
    sum += rng[i].w;
    if (sum >= m)
      return 1;
  }
  return 0;
}

int
main ()
{
  srand (567825);
  scanf ("%d", &n);
  m = n;
  rep (i, 1, n) scanf ("%lf%lf", &p[i].x, &p[i].y), p[i].w = 1;
  sort (p + 1, p + n + 1);
  int cnt = 1;
  rep (i, 2, n) if (p[i] == p[cnt])
    p[cnt].w += p[i].w;
  else
    p[++cnt] = p[i];
  n = cnt;
  random_shuffle (p + 1, p + n + 1);
  ans = 1e4;
  rep (i, 1, n) if (p[i].w >= m)
    return puts ("0"), 0;
  rep (i, 1, n)
  {
    if (!check (i, ans))
      continue;
    double l = 0, r = ans;
    rep (t, 1, 50)
    {
      double mid = (l + r) / 2;
      if (check (i, mid))
	r = mid;
      else
	l = mid;
    }
    ans = l;
  }
  printf ("%.9lf\n", ans);
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace X_Cubic
{
    class Program
    {
        static void Main( string[ ] args ) {

            int x = int.Parse(Console.ReadLine( ));

            x = x * x * x;//x^3

            Console.WriteLine( x );



        }
    }
}



Measured memory_bytes: 15944
#include <iostream>
using namespace std;
int main()
{
    long long int answer = 0;
    long long int x;
    cin >> x;

    answer += 2 * (x / 11);
    x %= 11;
    answer += 2 * (x / 10);
    x %= 10;
    answer += 2 * (x / 9);
    x %= 9;
    answer += 2 * (x / 8);
    x %= 8;
    answer += 2 * (x / 7);
    x %= 7;

    if (x == 0) {
        cout << answer << endl;
    } else {
        cout << answer + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);
 
int main() {
	ll x;
	cin >> x;
	ll m = 100,cnt = 1;
	while(m+m/100<x){
		m += m/100;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

int main() {

	int n, m; cin >> n >> m;	
	vector<pair<int, int>> pa;
	vector<vector<int>> c(n);
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		a--;
		pa.push_back({ a,b });
		c[a].push_back(b);
	}
	for (int i = 0; i < c.size(); i++) {
		sort(c[i].begin(), c[i].end());		
	}
	for (int i = 0; i < m; i++) {
		int x = pa[i].second;
		int index = distance(c[pa[i].first].begin(), find(c[pa[i].first].begin(), c[pa[i].first].end(), x));
		cout << setw(6) << setfill('0') << pa[i].first + 1 << setw(6) << setfill('0') << index + 1 << endl;
	}	
	return 0;
}

Measured memory_bytes: 9384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cassert>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
#define pb push_back
#define mp make_pair
typedef long long ll;
/////////////////////////

int const N = 1e3 + 41;
int const MOD = 1e9 + 7;

int cnt[N], n;

void push(int v){
	for(int i=2;i*i<=v;++i){
		while(v % i == 0){
			++cnt[i];
			v /= i;
		}
	}
	++cnt[v];
}

void solve(){
	for(int i=1;i<=n;++i){
		push(i);
	}
	int ans = 1;
	for(int i=2;i<N;++i){
		ans = ans * 1LL * (cnt[i] + 1) % MOD;
	}
	printf("%d\n",ans);
}

void read(){
	scanf("%d",&n);
}

void prepare(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
}

int main(){
	prepare();
	read();
	solve();


	return 0;
}


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

int main(){
  int a = 0;
  int b = 0;
  int c = 0;
  int d = 0;
  int x = 0;
  int N;
  
  cin>>N;
  
  for(int i = 0; i < N; i++){
    string S;
    cin>>S;
    if(S == "P")
      a++;
    if(S == "W")
      b++;
    if(S == "G")
      c++;
    if(S == "Y")
      d++;
  }
  
  if(a > 0)
    x++;
  if(b > 0)
    x++;
  if(c > 0)
    x++;
  if(d > 0)
    x++;
  if(x == 3)
    cout<< "Three" <<endl;
  if(x == 4)
    cout<< "Four" <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int>g[1000];
signed main()
{
    int n, d;
    cin >> n >> d;
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < d; ++j)
        {
            int aa;
            cin >> aa;
            g[i].push_back(aa);
        }
    }
    vector<int>ans;
    for(int i = 0; i < n; ++i)
    {
        for(int j = i + 1; j < n; ++j)
        {
            int s = 0;
            for(int k = 0; k < d; ++k)
            {
                s += (g[i][k] - g[j][k]) * (g[i][k] - g[j][k]);
            }
            ans.push_back(s);
        }
    }
    int res = 0;
    for(int i = 0; i < ans.size(); ++i)
    {
        int xx = (int)sqrt(ans[i]);
        if (xx * xx == ans[i])
            ++res;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int a, b, c;

int main()
{
	scanf("%d%d%d", &a, &b, &c);
	
	if ((b + c) >= a)
	{
		int left = b + c - a;
		printf("%d\n", left);
	}
	else
	{
		printf("0\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

struct Graph {
    struct Vertex { int n; };
    struct Edge { int i, n; };
    Graph(int n, int m) : v(n, { -1 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n };
        v[i].n = m;
        m++;
    }
    int dfs(int i, int p, const vector<int> &x, vector<ll> &y) {
        int l = x[i];
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge &o = e[j];
            if (o.i == p) continue;
            int k = dfs(o.i, i, x, y);
            y[k]++;
            l ^= k;
        }
        return l;
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    Graph g(n, (n - 1) * 2);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b);
        g.add_edge(b, a);
    }

    int m;
    cin >> m;

    vector<int> x(n);
    vector<ll> y(1 << m);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;

        int t = 1 << i;
        x[u] ^= t;
        x[v] ^= t;
    }
    g.dfs(0, -1, x, y);

    for (int i = 0; i < m; i++) {
        int t = 1 << i;
        for (int l = 0; l < 1 << m; l += t * 2) {
            for (int k = 0; k < t; k++) {
                y[l + t + k] += y[l + k];
            }
        }
    }

    vector<char> z(1 << m);
    z[0] = -1;

    ll r = 0;
    for (int k = 1; k < 1 << m; k++) {
        z[k] = -z[k & (k - 1)];
        r += (ll)z[k] << y[k ^ ((1 << m) - 1)];
    }

    r = (1LL << (n - 1)) - r;
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 9472
unittest
{
	assert( [ "?tc????", "coder" ].parse.expand.solve == "atcoder" );
	assert( [ "??p??d??", "abc" ].parse.expand.solve == "UNRESTORABLE" );
}



import std.conv;
import std.range;
import std.regex;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.strip.to!( char[] );
	input.popFront;
	auto t = input.front.strip;
	return tuple( s, t );
}

auto solve( char[] s, string t )
{
	// 正規表現で使えるように置換
	s = s.replace( "?", "." );
	
	// S内のTにマッチする個所を置換（複数個所マッチする場合を考慮して後ろから検索する）
	for( long i = s.length - t.length; 0 <= i; i-- )
	{
		auto re = matchFirst( t, s[ i .. i + t.length ] );
		if( !re.empty )
		{
			// マッチした
			s[ i .. i + t.length ] = t;
			s = s.replace( ".", "a" );
			return s.to!( string );
		}
	}
	
	// マッチしなかった
	return "UNRESTORABLE";
}


Measured memory_bytes: 380
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
const int N = 1005;
const int M = 1000000007;

int nums[N];

bool check(long long num){
    int last_num=-1;
    while(num>0){
        int now = num%10;
        num/=10;

        if(last_num==-1){
            last_num = now;
        }else{
            if(now!=last_num-1){
                return false;
            }
            last_num = now;
        }

    }
    return true;
}

int main() {
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&nums[i]);
    }
    long long result = -1;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            long long tmp = nums[i]*nums[j];
            if(check(tmp)){
                if(tmp>result)
                    result = tmp;
            }
        }
    }
    printf("%lld\n", result);
}

Measured memory_bytes: 2744
H,W = [int(i) for i in input().split()]
A = [list(input()) for i in range(H)]
i = 0
while i < len(A):
    if A[i].count(".") == len(A[0]):
        del A[i]
    else:
        i += 1
i = 0
while i < len(A[0]):
    if [j[i] for j in A].count(".") == len(A):
        for j in range(len(A)):
            del A[j][i]
    else:
        i += 1
print("\n".join("".join(i) for i in A))

Measured memory_bytes: 9276
import bisect

N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

cnt = []   
for a in A:
    i = bisect.bisect_left(cnt, a)
    if i >= len(cnt):
        cnt.append(a)
    elif cnt[i] > a:
        cnt[i] = a

print(len(cnt))


Measured memory_bytes: 10348
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(ll, w, h, x, y);
    printf("%.3f %d\n", 1.0*w*h/2, 2*x == w && 2*y == h ? 1 : 0);
}


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

int main(void){
  int a,b,i,result=0,tmp,tmp2;
  scanf("%d",&a);
  scanf("%d",&b);
  
  for(i=0;i<=2000;i++){
    tmp=(int)(i*0.08);
    tmp2=(int)(i*0.1);
    if(tmp==a&&tmp2==b){
      printf("%d",i);
      return 0;
    }
  }
  printf("-1");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define fi first
#define se second
#define inf 1000000000
#define mod 1000000007
using namespace std;
template <typename T> void chmax(T &x,T y){x=x>y?x:y;return;}
template <typename T> void chmin(T &x,T y){x=x<y?x:y;return;}
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pi;

string s;

int main()
{
	cin>>s;
	int len=s.size()-1;
	cout<<s;
	if(s[len]=='s')
	{
		cout<<"es"<<endl; 
	}
	else
	{
		cout<<"s"<<endl;
	}
	return 0;
}

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

int main(){
    int n; cin >> n;
    set<int> s;
    for (int i=0; i<n; i++){
        int a; cin >> a;
        if(s.count(a)==0){
            s.insert(a);
        }
        else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 12992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n; sc(n)
    int a[n], now = 0, cnt = 0;
    for (int i = 0; i < n; i++) sc(a[i])
    while (cnt <= n){
        cnt += 1;
        now = a[now] - 1;
        if (now + 1 == 2) break;
    }
    if (now + 1 != 2) cnt = -1; 
    cout << cnt << endl;
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

::std::vector<::std::pair<::std::int64_t, ::std::int32_t>> primeFactors(::std::int64_t x) {
	::std::vector<::std::pair<::std::int64_t, ::std::int32_t>> res;
	for (::std::int64_t i = 2; i*i <= x; ++i) {
		if (x % i == 0) {
			res.emplace_back(i, 1);
			x /= i;
			while (x % i == 0) x /= i, res.back().second++;
		}
	}
	if (x != 1) res.emplace_back(x, 1);
	return res;
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int64 N;
	cin >> N;
	auto ret = primeFactors(N);
	int64 r1 = 0, r2 = 1;
	REP(i, ret.size()) {
		r1++;
		r2 = r2 * (ret[i].sc+1);
	}
	cout << r1 << " " << r2-1 << endl;
}



Measured memory_bytes: 3232
#include <stdio.h>

int main(void){

int r,c,n,ans=0,ansa=0,ansb=0;
int i,j;

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

int t[r][c];

for(i=0;i<r;i++){
  for(j=0;j<c;j++){
    scanf("%d",&n);
    printf("%d ",n);
    ans=ans+n;
    t[i][j] = n;
  if(j==c-1){
    printf("%d\n",ans);
    ans=0;
}}}
for(j=0;j<c;j++){
  for(i=0;i<r;i++){
    ansa = ansa + t[i][j];
  if(i==r-1){
    printf("%d ",ansa);
    ansb=ansb+ansa;
    ansa=0;}}}
printf("%d\n",ansb);
}


Measured memory_bytes: 2040
while 1:
    a, b, c = map(int, input().split())
    if a == b == c == -1:
        break
    if a == -1 or b == -1 or a + b < 30:print('F')
    elif a + b >= 80:print('A')
    elif a + b >= 65: print('B')
    elif a + b >= 50:print('C')
    elif a + b >= 30 and c >= 50:print('C')
    else:print('D')
    
    


Measured memory_bytes: 5592
answer = []
n, q = [int(i) for i in input().split(" ")]
for i in range(n):
    name, time = input().split(" ")
    time = int(time)
    answer.append([name, time])

time = 0
while len(answer) > 0:
    p = answer.pop(0)
    if p[1] <= q:
        time += p[1]
        print(p[0], time)
    else:
        p[1] -= q
        time += q
        answer.append(p)



Measured memory_bytes: 13020
#include <cstdio>
#include <vector>
#include <iostream>

const int STEP_NUM = 4;
const int STEP[STEP_NUM][STEP_NUM] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

const int MAX_SIZE = 1000;
char field[MAX_SIZE + 1][MAX_SIZE + 1];

const int MAXN = 10;
int locationsX[MAXN];
int locationsY[MAXN];
 
int H, W, N;

int get_shortest_distance(int current_HP)
{
	int sx = locationsX[current_HP-1];
	int sy = locationsY[current_HP-1];
	int ex = locationsX[current_HP];
	int ey = locationsY[current_HP];

	bool is_visit[MAX_SIZE + 1][MAX_SIZE + 1]={};
	is_visit[sx][sy]=true;

	std::vector<std::pair<int,int>> frontier;
	frontier.push_back(std::pair<int,int>{sx,sy});
	int nx,ny;
	for(int step=0;step<W*H;step++)
	{
		std::vector<std::pair<int,int>> next_frontier;
		for(auto p:frontier)
			for(int i=0;i<STEP_NUM;i++)
			{
				nx = p.first+STEP[i][0];
				ny = p.second+STEP[i][1];
				if(nx<0 || H<=nx) 		continue;
				if(ny<0 || W<=ny) 		continue;
				if(field[nx][ny]=='X') 	continue;
				if(is_visit[nx][ny]) 	continue;
				next_frontier.push_back(std::make_pair(nx,ny));
				is_visit[nx][ny] = true;
				if(nx==ex && ny==ey)	return step+1;
			}
		frontier = next_frontier;
	}
	return -1;
}

int solve()
{
	int total_step = 0;
	for(int i=1;i<N+1;i++)
		total_step += get_shortest_distance(i);
	return total_step;
}

int main()
{
	scanf("%d %d %d", &H, &W, &N);
	for(int i=0; i<H; i++)
		scanf("%s", field[i]);
	for(int i=0; i<H; i++)
		for(int j=0; j<W; j++)
		{
			int HP=-1;
			if(field[i][j]=='S')	HP=0;
			if(field[i][j]=='1')	HP=1;
			if(field[i][j]=='2')	HP=2;
			if(field[i][j]=='3')	HP=3;
			if(field[i][j]=='4')	HP=4;
			if(field[i][j]=='5')	HP=5;
			if(field[i][j]=='6')	HP=6;
			if(field[i][j]=='7')	HP=7;
			if(field[i][j]=='8')	HP=8;
			if(field[i][j]=='9')	HP=9;
			if(HP!=-1)
			{
				locationsX[HP]=i;
				locationsY[HP]=j;
			}
		}
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,x,y;
  cin >>a>>b>>c>>x>>y;
  int ans = 0;
  if(a+b>2*c){
    int t = min(x,y);
    ans += t*2*c;
    x -= t;
    y -= t;
  }
  ans += x*min(a,2*c);
  x = 0;
  ans += y*min(b,2*c);
  y = 0;
  cout << ans << endl;
}

Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>

#define int64 long long int
#define RIGHT 1
#define UP 2
#define LEFT 3
#define DOWN 4
#define CLEARED 5

using namespace std;

int main()
{
	int H, W, x, y;
	int map[101][101];
	string buf;
	while(1){
		cin >> H >> W;
		if(H == 0) break;

		memset(map, 0, sizeof(int)*101*101);

		for(int i=0; i<H; i++){
			cin >> buf;
			for(int j=0; j<W; j++){
				if(buf[j] == '>') map[i][j] = RIGHT;
				else if(buf[j] == '^') map[i][j] = UP;
				else if(buf[j] == '<') map[i][j] = LEFT;
				else if(buf[j] == 'v') map[i][j] = DOWN;
			}
		}

		x = 0, y = 0;

		while(1){
			if(map[y][x] == CLEARED){
				cout << "LOOP" << endl;
				break;
			} else if(map[y][x] == RIGHT){
				map[y][x] = CLEARED;
				x++;
			} else if(map[y][x] == UP){
				map[y][x] = CLEARED;
				y--;
			} else if(map[y][x] == LEFT){
				map[y][x] = CLEARED;
				x--;
			} else if(map[y][x] == DOWN){
				map[y][x] = CLEARED;
				y++;
			} else {
				cout << x << ' ' << y << endl;
				break;
			}
		}
	}
	return 0;
}
			

Measured memory_bytes: 1256
#include <stdio.h>

int main() {
  int w, h, x, y, r;
  scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);
  if (x - r >= 0 && y - r >= 0 && x + r <= w && y + r <= h) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 2644
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())

N = int(input())
S = input()

R = [0]*(N)
L = [0]*(N)
for i in range(N-1):
    R[i+1] = R[i] + (S[i] == "W")
    L[-(i+1)-1] = L[-(i+1)] + (S[-(i+1)] == "E")

ans = 10**6

for i in range(N):
    ans = min(ans, R[i] + L[i])

print(ans)

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

 int main()
 {
   map<int,bool> memo;

   int N;
   cin>>N;

   int cnt=0;
   for(int i=0;i<N;i++){
     int p[3];
     cin>>p[0]>>p[1]>>p[2];

     sort(p,p+3);

     int k=((p[0]-1)*1000+(p[1]-1))*1000+(p[2]-1);

     if(memo.find(k)!=memo.end()){
       cnt++;
     }else{
       memo[k]=true;
     }
   }
   cout<<cnt<<endl;
   return 0;
 }

Measured memory_bytes: 3192
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include <cmath>
#include <random>
#include <functional>
#include <climits>
using namespace std;
using lint=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  cout<<((n==2||m==2)? "No" : "Yes")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;cin >> N;
    vector<int> a_idx(N);
    FOR(i,1,N+1){
        int a;
        cin >> a;
        a_idx[a]=i;
    }
    set<int> se = {0,N+1};
    ll res = 0;
    for(int i=1;i<=N;i++){
        auto itr = se.lower_bound(a_idx[i]);
        ll r=*itr;
        ll l=*(--itr);
        res += i*(r-a_idx[i])*(a_idx[i]-l);
        se.insert(a_idx[i]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 10368