akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int64_t dp[310][310][310];
string s;int64_t K;
int main(){
cin>>s>>K;
  int64_t N=s.size();
  for(int i=0;i<N;i++)
    for(int j=0;j<=K;j++)
    dp[i][i][j]=1;
  for(int i=0;i<N-1;i++)
    if(s.at(i)==s.at(i+1))
      dp[i][i+1][0]=2;
  else
    dp[i][i+1][0]=1;
  for(int j=2;j<=N-1;j++)
    for(int i=0;i<N-j;i++){
    if(s.at(i)==s.at(i+j))
      dp[i][i+j][0]=2+dp[i+1][i+j-1][0];
      else
        dp[i][i+j][0]=max(dp[i+1][i+j][0],dp[i][i+j-1][0]);
    }for(int i=0;i<N-1;i++)
      for(int j=1;j<=K;j++)
      dp[i][i+1][j]=2;
  for(int k=1;k<=K;k++)
      for(int j=2;j<=N-1;j++)
        for(int i=0;i<N-j;i++){
        if(s.at(i)==s.at(i+j))
          dp[i][i+j][k]=2+dp[i+1][i+j-1][k];
          else
dp[i][i+j][k]=max(max(2+dp[i+1][i+j-1][k-1],dp[i][i+j-1][k]),dp[i+1][i+j][k]);
          
        }cout<<dp[0][N-1][K]<<endl;
  return 0;
}

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

using namespace std;
#define pb push_back
#define ll long long
#define fast std::ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
 
 //string ans="";
/*ll solve(ll n )
 {
     if(n<12)
        return n;
     if(mp[n]==0)
            mp[n]=max(solve(n/2)+solve(n/3)+solve(n/4),n);
     return mp[n];
        
 }
*/
int main(){
   fast;
   ll n;
   cin>>n;
   double  d;
   cin>>d;
   double x,y;
   ll ans=0;
   while(n--)
   {
       cin>>x>>y;
       x*=x;y*=y;
       x+=y;
       double di=sqrt(x);
       if(di<=d)
       ans++;
   }
   cout<<ans;
   
}

Measured memory_bytes: 3824
N,A,B = map(int,input().split())
H = [int(input()) for i in range(N)]

def is_ok(k):
    hp = []
    for h in H:
        if h - B*k > 0:
            hp.append(h - B*k)
    if len(hp)==0: return True
    x = 0
    for h in hp:
        x += 0--h//(A-B)
        if x > k: return False
    return True

ok = 10**14
ng = 0
while ok-ng > 1:
    m = (ok+ng)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

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

int main()
{
    char s[10];
    scanf("%s",s);
    if(s[0]=='S'){
        printf("Cloudy");
    }
    else if(s[0]=='C'){
        printf("Rainy");
    }
    else{
        printf("Sunny");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    vi v1((n+1)/2),v2(n/2);
    rp(i,n/2){
        cin >> v1.at(i) >> v2.at(i);
    }
    if(n&1) cin >> v1.at((n-1)/2);
    priority_queue<P> que1,que2;
    sort(all(v1)); sort(all(v2));
    int ctr=1;
    rp(i,(n+1)/2-1){
        if(v1.at(i)==v1.at(i+1)) ctr++;
        else{
            que1.push(mp(ctr,v1.at(i)));
            ctr=1;
        }
    }
    que1.push(mp(ctr,v1.back()));
    ctr=1;
    rp(i,n/2-1){
        if(v2.at(i)==v2.at(i+1)) ctr++;
        else{
            que2.push(mp(ctr,v2.at(i)));
            ctr=1;
        }
    }
    que2.push(mp(ctr,v2.back()));
    int t[2][2];
    t[0][0]=que1.top().first; t[0][1]=que1.top().second;
    t[1][0]=que2.top().first; t[1][1]=que2.top().second;
    que1.pop(); que2.pop();
    if(t[0][1]!=t[1][1]){
        print(n-t[0][0]-t[1][0]);
    }
    else if(que1.empty()){
        if(que2.empty()){
            print(n/2);
        }
        else{
            print(n/2-que2.top().first);
        }
    }
    else if(que2.empty()){
        print((n+1)/2-que1.top().first);
    }
    else{
        print(n-max(t[0][0]+que2.top().first,t[1][0]+que1.top().first));
    }
    return 0;
}

Measured memory_bytes: 1784
IDENTIFICATION DIVISION.
PROGRAM-ID. 141B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 S     PIC X(101).
01 CNT   PIC 9(3).
01 SW    PIC 9(1).
01 I     PIC 9(3).
01 OUT   PIC X(3).
01 X     PIC X(1).
   88 R  VALUES IS 'R' 'U' 'D'.
   88 L  VALUES IS 'L' 'U' 'D'.
*>
PROCEDURE DIVISION.
  ACCEPT S.
  UNSTRING S DELIMITED BY ' '
      INTO S COUNT CNT.
*>
  MOVE 0     TO SW.
  MOVE 'Yes' TO OUT.
  PERFORM VARYING I FROM 1 BY 1 
    UNTIL (I > CNT) OR (OUT = 'No')
*>
    MOVE S(I:1) TO X
    IF NOT ((SW = 0 AND R) OR (SW = 1 AND L))
      MOVE 'No' TO OUT
    END-IF
*>
    COMPUTE SW = 1 - SW
  END-PERFORM.
*>
  DISPLAY OUT.
  STOP RUN.


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#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;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n,ans=0;cin>>n;
    for(int i=0;i<4;i++){
        if(n%10==2)ans++;
        n/=10;
    }
    cout<<ans<<endl;
}


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

int main(){
    int n, i = 0;
    scanf("%d",&n);
    scanf("%*c");
    char *s = malloc(1 * sizeof(char));
    while (scanf("%c", &s[i]) != EOF){
        ++i;
        s = realloc(s, (i+1) * sizeof(char));
        //printf("%s\n", s);
    }
    s[i-1] = '\0';
    int num;
    for (int a = 0; a < i-1; ++a){
        num = (int)s[a];
        num = ((num - 65 + n)%26)+65;
        printf("%c", (char)num);
    }
    printf("\n");


    return 0;
}


Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func abs(x int) int {
	if x < 0 {
		return -x
	} else {
		return x
	}
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	A, V := nextInt(), nextInt()
	B, W := nextInt(), nextInt()
	T := nextInt()

	if abs(A-B) <= (V-W)*T {
		fmt.Fprintln(out, "YES")
	} else {
		fmt.Fprintln(out, "NO")
	}
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

ll a[200010], m[1000005];
int main()
{
    ll t,n,i,j,k,l,r,mn=0, mx=1;
    cin>>n;
    ll cnt=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i]; m[a[i]]++;
    }

    ll f =0;
    for(int i=0; i<n; i++)
    {
        f=0;
        if(m[a[i]]>1) continue;
        for(ll j=1; j*j<=a[i]; j++)
        {

            if(a[i]%j==0)
            {
                if(m[j]>0 && j!=a[i]) f=1;

                ll p=a[i]/j;
                if(m[p]>0 && p!=a[i]) f=1;
            }
        }
        //cout<<a[i]<<" "<<f<<endl;
        if(f==0) cnt++;
    }
  cout<<cnt;
}


Measured memory_bytes: 12888
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int a, b; 
  cin >> a >> b;

  if(a <= 0 && 0 <= b) cout << "Zero" << endl;
  else if(0 < a) cout << "Positive" << endl;
  else{
    if((b-a+1)%2 == 0) cout << "Positive" << endl;
    else cout << "Negative" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
  int A, B;
  scanf("%d %d", &A, &B);

  if (A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0) {
    puts("Possible");
  } else {
    puts("Impossible");
  }
}

Measured memory_bytes: 128
n,x,y = map(int,input().split())
ans = []
for i in range(n-1):
    ans.append(0)
for m in range(1,n):
    for a in range(1,n-m+1):
        d = abs(m - x)+ abs(m + a - y) +1
        if a <= d:
            ans[a-1] = ans[a-1] + 1
        else:
            ans[d-1] = ans[d-1] + 1
for l in ans:
    print(l)

Measured memory_bytes: 74412
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    a, b, c, k = f.read_int_list()

    if k % 2 == 0:
        return a - b
    else:
        return b - a


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 6400
N,M = (int(num) for num in input().split())
ab = []
for i in range(M):
    ab.append([int(num)-1 for num in input().split()])
    
ab.sort(key= lambda l:l[1])

tmppos = 0
cnt = 0
for dem in ab:
    a = dem[0]
    b = dem[1]
    if a >= tmppos:
        tmppos = b
        cnt += 1
        
print(cnt)

Measured memory_bytes: 64568
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
const int N = 1e9;
using namespace std;
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define read(x) scanf("%d",&x)
#define put(x) printf("%d\n",x)
#define memset(x,y) memset(x,y,sizeof(x))
#define ll long long

int main(){
	int m1,m2,d1,d2;
	cin>>m1>>d1>>m2>>d2;
	if(d2==1) cout<<1<<endl;
	else cout<<0<<endl; 

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;


int main(void) {
  int n, N;
  int L[200];
  long long sum = 0;

  scanf("%d", &n);
  N = 2 * n;
  for (int i = 0; i < N; i++) 
    scanf("%d", &L[i]);

  sort(L, L + N);

  for (int i = 0; i < N; i++) 
    if (!(i % 2)) sum += L[i];

  printf("%lld\n", sum);

  return 0;
}


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

using namespace std;

int n;
int x=0,y=0;
int t=0,a,b,c;

int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		scanf("%d %d %d",&c,&a,&b);
		if (abs(x-a)+abs(y-b)>c-t)
		{
			cout<<"No"<<endl;
			return 0;
		}
		if ((abs(x-a)+abs(y-b))%2==0&&(c-t)%2==1)
		{
			cout<<"No"<<endl;
			return 0;
		}
		if (((abs(x-a))+abs(y-b))%2==1&&(c-t)%2==0)
		{
			cout<<"No"<<endl;
			return 0;
		}
		x=a;
		y=b;
		t=c;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <cstdlib>  
#include <cmath>
#include <bitset>

using namespace std;


int main(void) {
    int A,B,C;
    cin >> A >>B >>C;
    if (C-A+B>0) cout << C - A+ B;
    else cout <<0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

void solve(void){
    string S; cin >> S;
    int l = S.length();
    int mini = l;
    rep(l-1, i){
        if (S[i] != S[i+1]) {
            mini = min(mini, max(i+1, l-i-1));
        }
    }
    cout << mini << '\n';
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <algorithm>

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

using namespace std;

int n;
int p[40];
int q[40];
int l[41];
int r[41];
int k;
vector<int> v;

int dfs(int a, int b){
	if(a == b){
		return 0;
	}
	int s = p[k++];
	// printf("%d [%d, %d)\n", s, a, b);
	for(int i = a; i < b; ++i){
		if(q[i] == s){
			l[s] = dfs(a, i);
			r[s] = dfs(i + 1, b);
			return s;
		}
	}
}

void reconstruct(int x){
	if(x == 0){
		return;
	}
	reconstruct(l[x]);
	reconstruct(r[x]);
	v.push_back(x);
}

int main(){
	scanf("%d", &n);
	rep(i, n){
		scanf("%d", &p[i]);
	}
	rep(i, n){
		scanf("%d", &q[i]);
	}

	int r = dfs(0, n);
	reconstruct(r);

	rep(i, v.size()){
		if(i != 0){
			putchar(' ');
		}
		printf("%d", v[i]);
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int h,w;
	cin >> h >> w;
	
	int f[510][510];
	rep(i,0,h)
		rep(j,0,w)
			cin >> f[i][j] ;

	int cnt = 0;
	vector<pair<pair<int,int> , pair<int,int> > > p;
	rep(i,0,h){
		if( i % 2 ){
			rrep(j,w-1,1){
				if( f[i][j] % 2 ){
					f[i][j]--;
					f[i][j-1]++;
					cnt++;
					pair<int,int> a( i+1 , j+1 ) , b( i+1 , j );
					p.push_back( pair< pair<int,int> , pair<int,int> > (a,b));
				}
			}
			if( i != h - 1 ){
				if(f[i][0]%2){
					f[i][0]--;
					f[i+1][0]++;
					cnt++;
					pair<int,int> a( i+1 , 1 ) , b( i+2 , 1 );
					p.push_back( pair< pair<int,int> , pair<int,int> > (a,b));
				}
			}
		}
		else{
			rep(j,0,w-1){
				if( f[i][j] % 2 ){
					f[i][j]--;
					f[i][j+1]++;
					cnt++;
					pair<int,int> a( i+1 , j+1 ) , b( i+1 , j+2 );
					p.push_back( pair< pair<int,int> , pair<int,int> > (a,b));
				}
			}
			if( i != h - 1 ){
				if(f[i][w-1]%2){
					f[i][w-1]--;
					f[i+1][w-1]++;
					cnt++;
					pair<int,int> a( i+1 , w ) , b( i+2 , w );
					p.push_back( pair< pair<int,int> , pair<int,int> > (a,b));
				}
			}
		}
	}

	cout << cnt << endl;
	rep(i,0,p.size()){
		cout << p[i].first.first << " " << p[i].first.second << " " << p[i].second.first << " " << p[i].second.second << endl;
	}
	ret 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define out(n) cout << n << '\n'
#define rep(i, n) for (ll i = 0; i < (n); i++)
const int inf = 1000000000;
const ll linf = (ll)inf * (ll)inf;
void solve()
{
    int n;
    in(n);
    ll h[100001];
    rep(i, 100001) h[i] = 0;
    ll ans = 0;
    rep(i, n)
    {
        int a;
        in(a);
        ans += a;
        h[a]++;
    }
    int q;
    in(q);
    rep(i, q)
    {
        int b, c;
        in2(b, c);
        ans += (c - b) * h[b];
        h[c] += h[b];
        h[b] = 0;
        out(ans);
    }
}

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

Measured memory_bytes: 4356
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>

#define INF 1000000000
#define REP(i,n) for(int i=0; i<n; i++)
#define REP_R(i,n,m) for(int i=m; i<n; i++)
#define MAX 100

using namespace std;

int a,b,c,x,y;
int ans = 0;
int tt1, tt2, tt3;

int main() {
  scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);

  tt1 = a * x + b * y;
  int s;
  if (x > y) {
    tt2 = 2 * c * y;
    s = (x - y) * a;
    tt2 += s;
  } else {
    tt2 = 2 * c * x;
    s = (y - x) * b;
    tt2 += s;
  }

  tt3 = (x > y) ? 2 * c * x : 2 * c * y;

  if (tt1 < tt2 && tt1 < tt3) {
    cout << tt1 << endl;
  } else if (tt2 < tt1 && tt2 < tt3) {
    cout << tt2 << endl;
  } else {
    cout << tt3 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int A, B, C, X, sum;
    int ans = 0;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;

    // 500
    // 100 * 5
    // 100 * 4 + 50 * 2
    // 100 * 3 + 50 * 4
    // 100 * 2 + 50 * 6
    // 100 * 1 + 50 * 8
    // 50 * 10
    //
    // 100
    // 50 * 2

    for (int i = 0; i <= A; i++)
    {
        for (int j = 0; j <= B; j++)
        {
            for (int k = 0; k <= C; k++)
            {
                sum = 500 * i + 100 * j + 50 * k;
                if (sum == X)
                {
                    ans++;
                }
                
            }
            
        }
    }

    cout << ans << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
		#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
		#define endl "\n"

		using namespace std;
	
	int main() {	
		int a, b; cin >> a >> b;
		cout << (a + b) % 24;
		return 0;
		}
	


Measured memory_bytes: 3608
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n,min_n=100000000000,sum=0;
  cin >> n;
  ll a[n];
  ll mo[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  mo[0]=sum;
  for(int i=1;i<n;i+=2){
    mo[0]-=a[i]*2;
  }
  cout << mo[0]<<" ";
  for(int i=1;i<n;i++){
    mo[i]=2*a[i-1]-mo[i-1];
    cout <<mo[i]<<" ";
  }
  cout << endl;
}


Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX + 1];

int solve()
{
	int ans = 0;
	bool V[MAX];

	for (int i = 0; i < n; i++) {
		B[i] = A[i];
		V[i] = false;
	}

	sort(B, B + n);

	for (int i = 0; i < n; i++) {
		T[B[i]] = i;
	}

	for (int i = 0; i < n; i++) {
		if (V[i]) {
			continue;
		}
		int cur = i;
		int S = 0;
		int m = VMAX;
		int an = 0;
		while (true) {
			V[cur] = true;
			an++;
			int v = A[cur];
			m = min(m, v);
			S += v;
			cur = T[v];
			if (V[cur]) {
				break;
			}
		}
		ans += min(S + (an - 2)*m, m + S + (an + 1)*s);
	}

	return ans;
}

int main()
{
	cin >> n;
	s = VMAX;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		s = min(s, A[i]);
	}
	int ans = solve();
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define Set(a,b) memset(a,b,sizeof(a))
template<class T>inline void init(T&x){
	x=0;char ch=getchar();bool t=0;
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') t=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
	if(t) x=-x;return;
}typedef long long ll;
const int N=2001;
const int mod=1e9+7;
template<class T>inline void Inc(T&x,int y){x+=y;if(x>=mod) x-=mod;}
int R[N][N],L[N][N],U[N][N],D[N][N];
int H,W;
char s[N][N];
int main()
{
	init(H),init(W);
	for(int i=1;i<=H;++i) scanf("%s",s[i]+1);
	for(int i=1;i<=H;++i) {
		for(int j=1;j<=W;++j) {
			if(s[i][j]!='#') L[i][j]=L[i][j-1]+1,U[i][j]=U[i-1][j]+1;
		}
	}
	int ans=0;
	for(int i=H;i;--i) {
		for(int j=W;j;--j) {
			if(s[i][j]!='#') R[i][j]=R[i][j+1]+1,D[i][j]=D[i+1][j]+1,ans=max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3);
			
		}
	}cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 66816
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int h,w;
	cin>>w>>h;
	vector<pair<int,int> > edg;
	for(int i=0;i<w;i++){
		int x;
		cin>>x;
		edg.pb( mp( x, 0 ) );
	}
	for(int i=0;i<h;i++){
		int x;
		cin>>x;
		edg.pb( mp( x, 1) );
	}
	int hcnt = 0, wcnt = 0;
	sort( edg.begin(), edg.end() );
	int cur = 0, ans = 0;
	int lmt = (w+1)*(h+1) - 1;
	for(int i=0; i<edg.size();i++){
		int cost = edg[i].first;
		int tpe = edg[i].second;
		int num;
		if( tpe == 0 ){
			num = h+1-hcnt;
			wcnt++;
			num = min( num, lmt - cur );
			cur += num;
			ans += cost * num;
		}
		else{
			num = w+1 - wcnt;
			hcnt++;
			num = min( num, lmt - cur );
			cur += num;
			ans += cost * num;
		}
		if(lmt == cur)break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6384
#include <iostream>
#include <limits.h>
#include <stdio.h>
using namespace std;
int main(){
        int n,tmp,min=INT_MAX,max=INT_MIN;
        scanf("%d",&n);
        for(int i = 0; i < n; i++) {
                scanf("%d",&tmp);
                if(max < tmp-min) max = tmp - min;
                if(min > tmp) min = tmp;
        }
        printf("%d\n",max);
        return 0;
}



Measured memory_bytes: 3232
# -*- coding: utf-8 -*-
import array
import bisect
import collections
import fractions
import heapq
import itertools
import math
import re
import string
 
class joshu:
 
  # stdio
  @staticmethod
  def getInt():
    return int(raw_input().strip())
  @staticmethod
  def getInts():
    return [int(i) for i in raw_input().strip().split()]
  @staticmethod
  def getFloat():
    return float(raw_input().strip())
  @staticmethod
  def getFloats():
    return [float(i) for i in raw_input().strip().split()]
  @staticmethod
  def getStr():
    return str(raw_input().strip())
  @staticmethod
  def getStrs():
    return [str(i) for i in raw_input().strip().split()]
 
def main():
  n, k = joshu.getInts()
  if (n + 1) / 2 >= k:
    print('YES')
  else:
    print('NO')
  pass
 
if __name__ == '__main__':
  main()

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int n;
int p[100005];
void solve() {
    cin >> n;
    rep(i, n) {
        int v; cin >> v; --v;
        p[v] = i + 1;
    }

    multiset<int> s;
    s.emplace(0);
    s.emplace(0);
    s.emplace(n + 1);
    s.emplace(n + 1);
    ll ans = 0;
    repd(i, n) {
        auto r1 = s.lower_bound(p[i]);
        auto r2 = r1; ++r2;
        auto l1 = r1; --l1;
        auto l2 = l1; --l2;
        ans += (((ll)*l1 - *l2) * ((ll)*r1 - p[i]) + ((ll)p[i] - *l1) * ((ll)*r2 - *r1)) * (ll)(i + 1);
        s.emplace(p[i]);
    }

    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


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

int main(){
  int a,b; cin >> a >> b;
  if(b > 4*a){
    cout << "No" << endl;
  }
  else if(b < 2*a){
    cout << "No" << endl;
  }
  else if(b%2 == 1){
    cout << "No" << endl;
  }
  else{
    rep(i,a+1){
      if(2*i + 4*(a-i) == b){
        cout << "Yes" << endl;
        break;
      }
    }
  }
  
  
}

Measured memory_bytes: 3632
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[100007],b[100007];
set<int>st[100007];
int degree[100007];
vector<int>v[100007],id[100007];
int ans[100007];
void dfs(int u,int fa,int pre){
    int cnt=0;
    for(int i=0;i<v[u].size();++i){
        int vv=v[u][i];
        if(vv==fa)
            continue;
        ++cnt;
        if(cnt==pre)
            ++cnt;
        ans[id[u][i]]=cnt;
        dfs(vv,u,cnt);
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    for(int i=1;i<n;++i){
        cin>>a[i]>>b[i];
        ++degree[a[i]];
        ++degree[b[i]];
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
        id[a[i]].push_back(i);
        id[b[i]].push_back(i);
    }
    int mx=0;
    for(int i=1;i<=n;++i)
        mx=max(mx,degree[i]);
    cout<<mx<<"\n";
    dfs(1,0,0);
    for(int i=1;i<n;++i)
        cout<<ans[i]<<"\n";
    return 0;
}


Measured memory_bytes: 19072
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
#define INF (1<<29)


struct Node{
	int p;
	string s;
	bool operator<(const Node &a)const{return s>a.s;}
};
int n,e,s,g;
string edge[40][40][6+1];
string dp[40][40*6+1];


bool f(int i,bool v[]){
	if(v[i])return false;
	v[i]=true;
	if(i==g)return true;
	for(int j=0;j<n;j++){
		for(int k=0;k<7;k++){
			if(edge[i][j][k]!="}"){
				if(f(j,v))return true;
				break;
			}
		}
	}
	return false;
}
bool can_goal(int i){
	bool visit[40]={false};
	f(i,visit);
}
string dijkstra(){
	priority_queue<Node> pq;
	Node a,b;
	a.p=s;
	pq.push(a);
	bool goal[40];
	for(int i=0;i<n;i++){
		goal[i] = can_goal(i);
	}
	string ans = "}";
	while(!pq.empty()){
		a=pq.top();pq.pop();
		//cout<<a.s<<endl;
		if((n-1)*6<a.s.length())break;
		if(a.p==g)ans=min(ans,a.s);
		if(dp[a.p][a.s.length()]<a.s)continue;
		for(int i=0;i<n;i++){
			if(!goal[i])continue;
			b.p=i;
			for(int j=1;j<7;j++){
				b.s=a.s+edge[a.p][i][j];
				if(b.s<dp[b.p][b.s.length()]){
					dp[b.p][b.s.length()]=b.s;
					pq.push(b);
				}
			}
		}
	}
	if(ans=="}")return "NO";
	return ans;
}
int main(){
	while(cin>>n>>e>>s>>g,n|e|s|g){
		for(int i=0;i<40;i++){
			for(int j=0;j<40;j++){
				for(int k=0;k<7;k++)
					edge[i][j][k]="}";
			}
			for(int j=0;j<40*6+1;j++)
				dp[i][j]="}";
		}
		for(int i=0;i<e;i++){
			string s;
			int x,y;
			cin>>x>>y>>s;
			if(s<edge[x][y][s.length()])edge[x][y][s.length()]=s;
		}
		cout<<dijkstra()<<endl;
	}
	return 0;
}

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

using pii = pair<int, int>;
using ll  = long long;
#define rep(i, j) for (int i = 0; i < (int)(j); i++)
#define repeat(i, j, k) for (int i = (j); i < (int)(k); i++)
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " : " << x << endl

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

template <class T>
bool set_max(T &a, const T &b) {
    return a < b ? a = b, true : false;
}
// vector
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &a : v) is >> a;
    return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &t : v) os << "\t" << t;
    return os << endl;
}
// pair
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &v) {
    return os << "<" << v.first << ", " << v.second << ">";
}

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

int main() {
    int N; cin >> N;    
    set<string> S;
    rep(i, N) {
        string s; cin >> s;
        S.insert(s);
    }
    cout << S.size() << endl;


    return 0;
}


Measured memory_bytes: 19220
/**
 *    author:  tourist
 *    created: 13.10.2018 15:20:28       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  int g = __gcd(n, m);
  for (int i = 0; i < g; i++) {
    int x = n / g * i;
    int y = m / g * i;
    if (s[x] != t[y]) {
      cout << -1 << '\n';
      return 0;
    }
  }
  cout << (long long) n / g * m << '\n';
  return 0;
}


Measured memory_bytes: 640
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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 pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, q;
    cin >> n >> m >> q;
    VV vec(n,V(n));
    rep(i,m){
        ll l, r;
        cin>>l>>r;
        l--;
        r--;
        vec[l][r]++;
    }
    rep(i,n)rep(j,n-1){
        vec[i][j + 1] += vec[i][j];
    }
    rep(j,n)rep(i,n-1){
        vec[i+1][j] += vec[i][j];
    }
    rep(i,q){
        ll l,r;
        cin>>l>>r;
        l--;r--;
        if(l==0){
            cout<<vec[r][r]<<endl;
        }else{
            cout << vec[r][r] + vec[l - 1][l - 1] - vec[l - 1][r] - vec[r][l - 1] << endl;
        }
        
    }
}


Measured memory_bytes: 2944
#include<stdio.h>
int main()
{
    int i,flag=0;
    char s[1000];
    scanf("%s",s);
    for(i=1;i<3;i++)
    {
        if(s[i]!=s[i-1])
        {
            flag=1;
            continue;
        }
    }
       if(flag==1)
       {
           printf("Yes");
       }
       else
        printf("No");


    return 0;
}


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

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

vll d(100,0);
ll n=0;

ll solve(ll k,ll p){
	if(p<0) return 0;
	if (pow(2,p)>k){
		return solve(k,p-1)+pow(2,p)*d[p];
	}else if (d[p]<n-d[p]&&k<pow(2,p+1)-1){
		return max(solve(k-pow(2,p),p-1)+pow(2,p)*(n-d[p]),solve(k,p-1)+pow(2,p)*d[p]);
	}else{
		return solve(k,p-1)+pow(2,p)*max(d[p],n-d[p]);
	}
}

signed main(){
	cin >>n;
	llin(k);
	ll a=0;
	ll p=0;
	ll j=0;
	ll q=0;
	FOR(i,0,n-1){
		cin >>a;
		p=2;
		j=0;
		while(a>0){
			if(a%p!=0){
				d[j]++;
				a-=a%p;
			}
			p=p*2;
			j++;
		}
		q=max(q,j);
	}
	p=0;
	while(pow(2,p)<=k){
		p++;
	}
	sal(solve(k,max(q,p)-1));
}


Measured memory_bytes: 256
datas = []

while True:
    n,s = (int(x) for x in input().split(","))
    if n == 0:
        break;
    datas.append((n,s))
datas = sorted(datas,key = lambda x:x[1],reverse=True)

while True:
    try:
        q = int(input())
        rank = 1
        score = datas[0][1]
    
        for n,s in datas:
            if score > s:
                score = s
                rank += 1
            if n == q:
                break
        print(rank)
    except:
        break


Measured memory_bytes: 5596
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
       

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            int N = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            List<char> ans = new List<char>();
            int l = 0;
            int r = 0;
            for(var i = 0; i < N; i++)
            {
                if (s[i] == '(')
                {
                    l++;
                    ans.Add('(');
                }
                else
                {
                    r++;
                    ans.Add(')');
                    if (r > l)
                    {
                        ans.Insert(0, '(');
                        l++;
                    }
                }
            }

            for(var i = 0; i < l - r; i++)
            {
                ans.Add(')');
            }

            foreach(var k in ans)
            {
                Console.Write(k);
            }
            Console.WriteLine();

            //Console.Out.Flush();
        }
        


    }

    

    

    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	string s1, s2;
	cin >> s1 >> s2;

	bool flag = true;

	ll rsl = 0;
	int idx = 0;
	if(s1[0] == s2[0]) {
		rsl = 3;
		flag = true;
	} else {
		rsl = 6;
		flag = false;
		idx++;
	}
	idx++;
	ll mod = 1e9 + 7;
	while(idx < N) {
		if(s1[idx] == s2[idx]) {
			if(flag) rsl = rsl * 2 % mod;
			flag = true;
		} else {
			if(flag) rsl = rsl * 2 % mod;
			else rsl = rsl * 3 % mod;
			idx++;
			flag = false;
		}
		idx++;
	}

	cout << rsl << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
const int N = 100 + 5;

int n,m;
int mp[N][N];
int dirx[] = {0, 1, 0, -1};
int diry[] = {1, 0, -1, 0};
int apple, pear, orange;

void dfs(int x, int y, int color)
{
    mp[x][y] = 0;
    for(int i = 0; i < 4; i++)
    {
        int nx = x + dirx[i], ny = y + diry[i];
        if(nx < 0 || nx >= n || ny < 0 || ny >= m) continue;
        if(mp[nx][ny] == color)
            dfs(nx, ny, color);
    }
}


int main()
{
    while(scanf("%d%d", &n, &m), n || m)
    {
        apple = pear = orange = 0;
        char ch;
        getchar();
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                scanf("%c", &ch);
                if(ch == '@') mp[i][j] = 1;
                else if(ch == '#') mp[i][j] = 2;
                else if(ch == '*') mp[i][j] = 3;
            }
            getchar();
        }


        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                if(mp[i][j] == 1)
                {
                    apple++;
                }
                else if(mp[i][j] == 2)
                {
                    pear++;
                }
                else if(mp[i][j] == 3)
                {
                    orange++;
                }
                else
                    continue;
                dfs(i, j, mp[i][j]);
            }
        }
        printf("%d\n", apple+pear+orange);
    }
    return 0;
}

Measured memory_bytes: 3616
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N,M,P = map(int,input().split())
edge = []
for i in range(M):
    A,B,C = map(int,input().split())
    edge.append([A-1,B-1,P-C])

def Bellman_Ford(edges, start, N):
    inf = float("inf")
    # dist[i]: 頂点iまでの最短距離
    dist = [inf for i in range(N)]
    dist[start] = 0

    for i in range(N+N):
        for a,b,c in edges:
            if a != inf and dist[b] > dist[a] + c:
                dist[b] = dist[a] + c
                # startからgoalまでに負閉路がある場合
                if i >= N:
                    dist[b] = -inf
        # 一回目のベルマンフォード法の結果
        if i == N-1:
            first_time = dist[-1]
    # (一回目,二回目)
    return first_time, dist[-1]

first,second = Bellman_Ford(edge, 0, N)
if first != second:
    answer = -1
else:
    answer = max(0,-second)

print(answer)

Measured memory_bytes: 45916
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long A, B, C;
    scan(A, B, C);
    writeln((A + B + C < 22) ? "win" : "bust");
}


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

Measured memory_bytes: 1004
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        int i = 0;
        int j = 0;
        int k = 0;
        int uu,u,t,l,ll;
        int max=0,temp;
        for(i=0;i<n;i++) a[i] = sc.nextInt();
        Arrays.sort(a);
        for(i=0;i<n;){
            uu = 0; u = 0; t = 0; l=0; ll=0;
            for(j=i,k=i;j<n;j++){
                temp = a[j]-a[k];
		if(temp == 2){
                    uu++;
                }else if(temp == 1){
                    u++;
                }else if(temp == 0){
                    t++;
                    i++;
                }else{
                    break;
                }
            }
            if(uu+u+t > max) max = uu+u+t;
        }

        System.out.println(max);
    }
}



Measured memory_bytes: 51096
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#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 <utility>
#include <vector>

using namespace std;

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> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 30;

int a[2][12];

bool check(int n){
	rep(i,n)
		if(a[0][i]!=a[1][i])
			return true;
	return false;
}

int main(void){
	int n;
	while(cin >> n,n){
		rep(i,n)
			cin >> a[1][i];
		int ans=-1;
		while(check(n)){
			rep(i,n)
				a[0][i]=a[1][i];
			vi tmp;
			rep(i,n)
				tmp.pb(a[0][i]);
			sort( tmp.begin(),tmp.end());
			rep(i,n)
				a[1][i]=upper_bound(tmp.begin(),tmp.end(),a[0][i])-lower_bound(tmp.begin(),tmp.end(),a[0][i]);
			ans++;
		}
		cout << ans << endl;
		rep(i,n)
			cout << (i?" ":"") << a[1][i];
		cout << endl;
	}
	return 0;
}

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

int main(){
  int n,m,count=0,x,y;
  cin >> n >> m;
  map<int,int> mp;
  r(i,n){
    cin >> x;
    r(j,x){
      cin >> y;
      mp[y]++;
    }
  }
  r(i,m){
    if(mp[i+1]==n)count++;
  }
  cout << count << endl;
}


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

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}

int main()
{
        cin>>N>>M;
        --M;--N;
        cout<<ceilS(M,N)<<"\n";
        
        
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, w = 0, t = 0, ans = 300000;
  string s;
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'W') {
      w++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == 'W') {
      t++;
      ans = min(ans, t - 1 + (n  - (i + 1) - (w - t)));
    } else {
      ans = min(ans, t + (n - (i + 1) - (w - t)));
    }                                            
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

void print(int a, int b){
    cout << a << ' ' << b << endl;
}

int main(){
    int N, M;
    cin >> N >> M;
    int a = (M+1)/2;
    rep2(i, 1, a){
        print(i, 2*a+1-i);
    }
    int b = M-a;
    rep2(i, 1, b){
        print(2*a+i, 2*a+2*b+2-i);
    }
}

Measured memory_bytes: 3636
N, M = map(int, input().split())
L1, R1 = map(int, input().split())
min = L1
max = R1

for i in range(1, M):
    newL, newM = map(int, input().split())
    if newL > min:
        min = newL
    if newM < max:
        max = newM
result = 0
if max - min + 1 > 0:
    result = max-min+1
print("{}".format(result))


Measured memory_bytes: 3060