akhauriyash/Code-Regression huggingface dataset:
//ABC136
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main(){
    string S;
    cin>>S;
    string T=S;
    reverse(T.begin(),T.end());
    vector<int> ans(S.length(),0);
    vector<int> RLR,RLL;
    for (int i = 0; i < S.length()-1; ++i) {
        if(S[i]=='R'&&S[i+1]=='L') {
            RLR.push_back(i);
        }
    }

    for (int i = 0; i < T.length()-1; ++i) {
        if(T[i]=='L'&&T[i+1]=='R') {
            RLL.push_back(i);
        }
    }

    for (int i = 0; i < S.length(); ++i) {
        int hajime;
        if(S[i]=='R'){
            int loopbegin;
            auto iter=lower_bound(RLR.begin(),RLR.end(),i);
            loopbegin=*iter;//-i;
            hajime=loopbegin-i;
            if(hajime%2==1){
                ans[*iter+1]++;
            }else{
                ans[*iter]++;
            }
        }
    }

    for (int i = 0; i < T.length(); ++i) {
        int hajime;
        if(T[i]=='L'){
            int loopbegin;
            auto iter=lower_bound(RLL.begin(),RLL.end(),i);
            loopbegin=*iter;//-i;
            hajime=loopbegin-i;
            if(hajime%2==1){
                ans[T.length()-1-(*iter+1)]++;
            }else{
                ans[T.length()-1-*iter]++;
            }
        }
    }

    for (int i = 0; i < S.length()-1; ++i) {
        cout<<ans[i]<<" ";
    }
    cout<<ans[S.length()-1]<<endl;

    return 0;
}

Measured memory_bytes: 1548
import sys
from itertools import accumulate

def input():
    return sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 9)
INF = 1 << 60

N, M, Q = map(int, input().split())
G = [[0] * N for _ in range(N)]
for _ in range(M):
    l, r = map(int, input().split())
    G[l - 1][r - 1] += 1

csum = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(N):
    for j in range(N):
        csum[i + 1][j + 1] = csum[i + 1][j] + csum[i][j + 1] - csum[i][j] + G[i][j]

ans = []
for _ in range(Q):
    p, q = map(int, input().split())
    ans.append(csum[q][q] - csum[q][p - 1] - csum[p - 1][q] + csum[p - 1][p - 1])

print(*ans, sep='\n')


Measured memory_bytes: 21184
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		String b = sc.next();
		if(b.equals("A")) {
			System.out.println("T");
		}else if(b.equals("T")) {
			System.out.println("A");
		}else if(b.equals("C")){
			System.out.println("G");
		}else {
			System.out.println("C");
		}
	}
}

Measured memory_bytes: 26928
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}

void solve(){
  int n;
  cin>>n;
  vector<ll> v1(n),v2(n);
  rep(i,0,n) cin>>v1[i]>>v2[i];
  sort(all(v1));
  sort(all(v2));
  if(n%2) cout<<v2[n/2]-v1[n/2]+1LL<<endl;
  else{
    double x = (v1[n/2]+v1[(n-1)/2]), zy= (v2[n/2]+v2[(n-1)/2]);
    double z=(zy-x)+1;
    cout<<(ll)z<<endl;
  }
}
int main(){
    optimizeIO();
    // tc
    {
      solve();
    }
}


Measured memory_bytes: 6312
// #include <bits/stdc++.h>
#include <utility>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
// #include <deque>
// #include <queue>
// #include <array>
// #include <ctime>
// #include <list>
// #include <map>
#include <set>
// #include <cassert>
// #include <complex>
// #include <sstream>
// #include <forward_list>
// #include <unordered_set>
// #include <unordered_map>

using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define scani(n) scanf("%d",&n);
#define EPS 1e-9
#define FOR(i,n) for(int i=0; i<n; i++)
#define X first
#define Y second
#define arrinput for(int i=0; i<n; i++) cin>>arr[i];
#define sumarr for(int i=0; i<n; i++) sum+=arr[i];
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,n) for(int i=n-1; i>=0; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

typedef long long ll;  
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MOD = 1e9+7;
const int n_ = 1e5+1000;
const long double PI = acos(-1.0);

ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

bool vowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') return true;
    else return false;
}

// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
class UnionFind {                                              // OOP style
private:
    vi p, rank, setSize;                       // remember: vi is vector<int>
    int numSets;
public:
    UnionFind(int N) {
        setSize.assign(N, 1); numSets = N; rank.assign(N, 0);
        p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
    int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
    bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
    void unionSet(int i, int j) { 
        if (!isSameSet(i, j)) { numSets--; 
        int x = findSet(i), y = findSet(j);
        // rank is used to keep the tree short
        if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
        else                   { p[x] = y; setSize[y] += setSize[x];
                                 if (rank[x] == rank[y]) rank[y]++; } } }
    int numDisjointSets() { return numSets; }
    int sizeOfSet(int i) { return setSize[findSet(i)]; }
};

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

    int n;
    cin>>n;
    int arr[n];
    arrinput;
    int ans = arr[0];
    for1(i,n-1) {
        if(arr[i] > arr[i-1]) ans += (arr[i] - arr[i-1]);
    }
    cout<<ans;

    return 0;
}

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

int main() {
	long long int N, K, ans = 0;
	cin >> N >> K;
	ans = pow(N / K, 3);
	if (K % 2 == 0) ans += pow((N + K / 2) / K, 3);
	cout << ans;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<int> a(n);
  int ma = 0, mi = INF;
  for(int i=0;i<n;++i) {
    cin >> a[i];
    ma = max(ma, a[i]);
    mi = min(mi, a[i]);
  }
  if(ma - mi > 1) {
    cout << "No" << endl;
  } else if(ma == mi) {
    if(ma == n-1 || ma <= n/2) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    int m = 0;
    for(int i=0;i<n;++i) {
      if(a[i] == mi) m++;
    }
    if(n - m > 1 && m - 1 + (n - m) / 2 >= mi && mi >= m) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  vin pp(10);//i-1が何個あるか
  
 int h,w;
  cin>>h>>w;
  vector<vin> c(10,vin(10));
  rep(i,0,10){
   rep(j,0,10) cin>>c[i][j]; 
  }
  vector<vin> a(h,vin(w));
  rep(i,0,h){
    rep(j,0,w) {
      cin>>a[i][j]; 
      if(a[i][j]!=-1){
        pp[a[i][j]]++;
      }
    }
  }
  int dp[11][11];//i回変換して1に行く最小値　jから
  rep(i,0,11){
   rep(j,0,11) dp[i][j]=inf; 
  }
  rep(i,0,10){
   dp[1][i]=c[i][1]; 
  }
  dp[0][1]=0;
  rep(i,2,10){
    rep(j,0,10){
      
      rep(k,0,10){
        
        chmin(dp[i][j],dp[i-1][k]+c[j][k]);
      }
    }
  }
  vin mn(10);
  rep(i,0,10) mn[i]=inf;
  rep(i,0,10){
    rep(j,0,10) chmin(mn[i],dp[j][i]);
  }
  int ans=0;
  rep(i,0,10){
    ans+=(pp[i]*mn[i]);
  }
  cout<<ans<<endl;
}

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

total_price = 0

if A + B <= 2 * C:
    total_price += min(X, Y) * (A + B)
else:
    total_price += min(X, Y) * 2 * C

if X - Y > 0:
    total_price += (X - Y) * min(A, 2 * C)
else:
    total_price += (Y - X) * min(B, 2 * C)

print(total_price)

Measured memory_bytes: 3060
def main():
    k, n = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    answer = a[-1] - a[0]
    for i in range(n - 1):
        answer = min(answer, max(a[i + 1] - a[i], k + a[i] - a[i + 1]))
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 26420
#include <bits/stdc++.h>
using namespace std;
#define f(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define len(s) s.size()
#define all(v) v.begin(), v.end()
#define tr(it, v) for (auto &it : v)
#define bit(x) __builtin_popcount(x)
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
// =================
void impgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1e9;
const int N = 3e5 + 1;

vi g[N];
int A[N];

void solve()
{
    int n, m, ans = 0, cnt = 0, k;
    cin>>n;
    int h[n+1];
    f(i,1,n+1) cin>>h[i];
    vi dp(n+1,mod);
    dp[1]=A[1];
    f(i,1,n-1) {
        for(int j:{i+1,i+2}) {
            dp[j]=min(dp[i]+abs(h[j]-h[i]),dp[j]);
        }
    }
    dp[n]=min(dp[n],dp[n-1]+abs(h[n]-h[n-1]));
    cout<<dp[n];
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    // cin >> t;
    while (t--)
        solve();

    return 0;
}

void impgraph(int n, int m)
{
    int i, u, v;
    while (m--)
    {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par)
{
    for (int v : g[u])
    {
        if (A[v])
        {
        }
        dfs(v, 0);
    }
}


Measured memory_bytes: 11084
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 998244353;
const lint INF = mod*mod;
const int MAX = 100010;

int del(int x, int i){
    int u=(x>>i)<<i, v=(x>>(i+1))<<(i+1);
    return x^u^(v>>1);
}

int add(int x, int i, int p){
    int u=(x>>i)<<i;
    return x^u^(u<<1)^(p<<i);
}

vector<int> dfs(int n, int a, int b){
    if(n==1) return {a, b};
    int pos;
    rep(i, n)if(((a>>i)&1)!=((b>>i)&1)) pos=i;
    int s=del(a, pos), t=del(b, pos);
    int u=s^1;
    vector<int> S=dfs(n-1, s, u), T=dfs(n-1, u, t);
    vector<int> ret;
    for(int x: S) ret.push_back(add(x, pos, (a>>pos)&1));
    for(int x: T) ret.push_back(add(x, pos, (b>>pos)&1));
    return ret;
}

int main(){
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    if(__builtin_popcount(a)%2==__builtin_popcount(b)%2){
        printf("NO\n");
        return 0;
    }
    auto v=dfs(n, a, b);
    printf("YES\n");
    for(int x: v) printf("%d ", x);
}

Measured memory_bytes: 1628
while 1:
    n=int(input())
    if n==0: break
    a=list(map(int,input().split()))
    i,s=0,32
    while s>0:
        s-=(s-1)%5
        print(s)
        s-=a[i%n]
        i+=1
        print(max(0,s))

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

using namespace std;
#define ll long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

signed main()
{
	string s;
	int k;
	cin >> s >> k;
	rep(i, k) {
		if (s[i] != '1') {
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << 1 << endl;
}


Measured memory_bytes: 256
use std::io::{self, BufRead, BufWriter, Write};
use std::str;

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let _ = lines.next();
    let s = lines.next().unwrap().unwrap();

    let mut cur_b: u8 = 0;
    let mut ans: i32 = 0;
    for &b in s.as_bytes() {
        if cur_b != b {
            ans += 1;
        }
        cur_b = b;
    }

    writeln!(&mut writer, "{}", ans).unwrap();
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"10
aabbbbaaca",
            br"5
",
        ),
        (
            br"5
aaaaa",
            br"1
",
        ),
        (
            br"20
xxzaffeeeeddfkkkkllq",
            br"10
",
        ),
    ];

    #[test]
    fn test_c() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
//グリッドグラフの範囲チェック
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
//ビットカウント
int popcount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  int h,w,a,b;
  cin >> h >> w >> a >> b;

  REP(i,b){
    REP(j,w){
      if(j<a){
        cout << 1;
      }else{
        cout << 0;
      }
    }
    cout << endl;
  }

  REP(i,h-b){
    REP(j,w){
      if(j<a){
        cout << 0;
      }else{
        cout << 1;
      }
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
n = int(input())
a = list(map(int, input().split()))

s_total = a[0]
r_total = sum(a)-a[0]
ans = abs(s_total - r_total)
#reverse_a = list(reversed(a))
for i in range(1, n-1):
    s_total += a[i]
    r_total -= a[i]
    diff = abs(s_total - r_total)
    if ans > diff:
        ans = diff

print(ans)


Measured memory_bytes: 76752
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	int a,b;
	cin>>a>>b>>s;
	s=" "+s;
	for(int i=1;i<=a+b+1;i++)
		if(s[i]<48&&i!=a+1||s[i]>58&&i!=a+1||i==a+1&&s[i]!='-')
			cout<<"No"<<endl,exit(0);
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main()
{
  int n, m;
  cin >> n >> m;
  int h[n];
  vector<vector<int> > towers(n,vector<int>(0));
  for(int i=0; i<n; ++i){
    cin>>h[i];
  }
  for(int i=0; i<m; ++i){
    int a, b;
    cin >> a >> b;
    towers.at(a-1).push_back(b-1);
    towers.at(b-1).push_back(a-1);
  }

  int ret = 0;
  for(int i=0; i<n; ++i){
    if(towers.at(i).size() == 0){
      // cout << "nice tower 0" << endl;
      ret += 1;
    }else{
      bool check = true;
      for(int j=0; j<towers.at(i).size(); ++j){
        if(h[i]<=h[towers.at(i).at(j)]) check = false;
      }
      if(check){
        // cout << "nice tower :" << i << endl;
        ret += 1;
      }
    }
  }

  cout << ret << endl;

  return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            String S = in.next();
            int x = 0;
            int ans = 0;

            for (int i = 0; i < n; i++) {
                if (S.charAt(i) == 'I') {
                    x++;
                } else {
                    x--;
                }
                ans = Math.max(ans, x);
            }

            // 出力
            out.println(ans);

        }

    }
}



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

int main(){
  string a,b;
  cin >> a>>b;
  int l_a=a.size(),l_b=b.size();
  if(l_a < l_b){
    cout <<"LESS"<<endl;
    return 0;
  }
  if(l_a > l_b){
    cout <<"GREATER"<<endl;
        return 0;
  }
  for(int i=0;i<l_a;i++){
    if(a.at(i) < b.at(i)){
      cout <<"LESS"<<endl;
          return 0;
    }
    if(a.at(i) > b.at(i)){
      cout <<"GREATER"<<endl;
          return 0;
    }
  }
  cout << "EQUAL" <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;

int main(){
  int n; cin>>n;
  string s,t,S; cin>>s>>t;
  rep(i,n){
    S.pb(s[i]);
    S.pb(t[i]);
  }
  cout<<S<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
const int MAXN = 100005;
typedef long long ll;
struct Poi{
    int id,x;
    bool operator < (const Poi &b)const
    {
        return x>b.x;
    }
}a[2][MAXN];
int n,vis[MAXN];
ll ans;
inline bool cmp(int x1,int x2,int Sta)
{
    if(Sta==0){
        return x2<=x1;
    }else
        return x2>=x1;
}
inline void move(int Sta)
{
    memset(vis,0,sizeof(vis));
    int p[2]={0},pos=0,k[2];
    k[0]=1,k[1]=-1;
    ll now=0;
    while(p[Sta]<n){
        while(p[Sta]<n && vis[a[Sta][p[Sta]+1].id])++p[Sta];
        if(p[Sta]==n)break;
        ++p[Sta];
//        cout<<k[Sta]*a[Sta][p[Sta]].x<<" "<<pos<<" "<<Sta<<endl;
        if(!cmp(k[Sta]*a[Sta][p[Sta]].x,pos,Sta))break;
        now+=abs(pos-k[Sta]*a[Sta][p[Sta]].x);
        //      cout<<"Now dis "<<a[Sta][p[Sta]].id<<" "<<abs(pos-k[Sta]*a[Sta][p[Sta]].x)<<endl;
        pos=k[Sta]*a[Sta][p[Sta]].x;
        vis[a[Sta][p[Sta]].id]=1;
        Sta^=1;
//        cout<<p[Sta]<<endl;
    }
//    cout<<"-------"<<endl;
    ans=max(ans,now+abs(pos));
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d%d",&a[0][i].x,&a[1][i].x); 
        a[1][i].x=-a[1][i].x;
        a[0][i].id=a[1][i].id=i;
    }
    sort(a[0]+1,a[0]+n+1);
    sort(a[1]+1,a[1]+n+1);
    move(0);move(1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
int h, w;
int dp[1000][1000];
const int INF = 10000000;
string s[1000];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main()
{
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
    }
    queue<P> que;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            dp[i][j] = INF;
            if (s[i][j] == '#')
            {
                dp[i][j] = 0;
                que.push(P(i, j));
            }
        }
    }
    int mx = 0;
    while (!que.empty())
    {
        P p = que.front();
        que.pop();
        for (int i = 0; i < 4; i++)
        {
            if (dx[i] + p.second < 0 || dx[i] + p.second >= w)
                continue;
            if (dy[i] + p.first < 0 || dy[i] + p.first >= h)
                continue;
            if (dp[p.first + dy[i]][p.second + dx[i]] != INF)
                continue;
            dp[p.first + dy[i]][p.second + dx[i]] = dp[p.first][p.second] + 1;
            mx = max(mx, dp[p.first + dy[i]][p.second + dx[i]]);
            que.push(P(p.first + dy[i], p.second + dx[i]));
        }
    }
    cout << mx << endl;
}

Measured memory_bytes: 13456
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	LL n;
	cin>>n;
	double x = n*1.0/3.0;
	printf("%0.12lf\n", x*x*x);
}

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


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
void print() {}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail){ cout << head << " \n"[sizeof...(tail) == 0]; print(forward<Tail>(tail)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll h[100010];
    rep(i,0,N) cin >> h[i];
    ll ans = 0;
    rep(i,0,N){
        if(h[i] >= K) ans++;
    }
    print(ans);
    
}

Measured memory_bytes: 1024
x, k, d = gets.split.map(&:to_i)
n = [x.abs / d, k].min
if x > 0
  x -= n * d
else
  x += n * d
end
k -= n
if k.even?
  puts x.abs
else
  puts [(x - d).abs, (x + d).abs].min
end


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


def solve(r: int):
    print(3 * r * r)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import collections

n = int(input())
a = list(input().split())

#print(a)
c = collections.Counter(a)

#print(c)

c_value_list = list(c.values())

#print(c_value_list)

sum = 0
for i in range (len(c_value_list)):
  sum += int((c_value_list[i]*(c_value_list[i]-1))/2)

#print(sum)

for i in range(len(a)):
  if c[a[i]] == 1:
    print(sum)
  else:
    diff = int((c[a[i]] * (c[a[i]]-1)) / 2)
    diff_a = int(((c[a[i]]-1) * (c[a[i]]-2)) / 2)
    print(sum - diff + diff_a)

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

int main(int argc, char *argv[])
{
	int i, j;
	int *tmp = (int *)malloc(1000000000);

	for (i = 0;;i++) {
		scanf("%d", &tmp[i]);
		if (tmp[i] == 0)
			break;
	}
	for (j = 0; j < i; j++)
		printf("Case %d: %ld\n", j+1, tmp[j]);

	free(tmp);

	return 0;
}

Measured memory_bytes: 628
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

int n;
const int mod=1000000007;
int a[100010];

int kaijo(LL x){
    if(x==0)return 1;
    else return (x*kaijo(x-1))%mod;
}
int main(){
    int cut=0;
    LL ans=1;
    
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];	
    for(int i=0;i<n-1;i++){
        if(a[i]<=2*(i-cut)){
	   ans=(ans*(i+1-cut))%mod;
	   cut++;
        }
    }
    cout<<(ans*kaijo(n-cut))%mod<<endl;
    return 0;
}

Measured memory_bytes: 2176
count, start = 0, 0
count,start = gets.chomp.split(' ').map(&:to_i)
nums = gets.chomp.split(' ').map(&:to_i)
times = 0
sum = 0
nums.each do |num|
  times = times + 1 if sum <= start
  sum = sum + num
end
  times = times + 1 if sum <= start
puts times

Measured memory_bytes: 1788
import math

a, b, x = map(int,input().split())

# おおい
if x >= (1/2)*a*a*b :
    a3 = a*a*a
    tan = 2*((a*a*b - x)/a3)
    atan1 = math.degrees(math.atan(tan))
    print(atan1)

# すくない
else :
    bo = a*b*b
    tan = 2*x/bo
    atan1 = math.degrees(math.atan(tan))
    print(90-atan1)



Measured memory_bytes: 3060
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> a(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
    }
    sort(a.begin(), a.end());

    long x[8]={400,800,1200,1600,2000,2400,2800,3200};
    long count[9]={0};

    long j;
    for(i=0; i<n; i++) {
        for(j=0; j<8; j++) {
            if(a[i]<x[j]) break;
        }
        count[j]++;
    }

    long sum=0;
    for(i=0; i<8; i++) {
        if(count[i]>0) sum++;
    }
    printf("%ld %ld\n", sum>0? sum: 1, sum+count[8]);

    return 0;
}


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


int main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());

    vector<string> v = {"dream", "dreamer", "erase", "eraser"};
    for (int i = 0; i < 4; ++i) reverse(v.at(i).begin(), v.at(i).end());

    bool ans1 = true;
    for (int i = 0; i < S.size();) {
        bool ans2 = false;
        for (int j = 0; j < 4; ++j) {
            string v_word = v.at(j);
            if (S.substr(i, v_word.size()) == v_word) {
                ans2 = true;
                i += v_word.size();
            }
        }
        if (!ans2) {
            ans1 = false;
            break;
        }
    }
    if (ans1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 512
N = int(input())
c = list(input())

a = 0
for i in range(N):
    if c[i] == 'R':
        a += 1
b = 0

ans = max(a,b)

for i in range(N):
    if c[i] == 'R':
        a -= 1
    else:
        b += 1
    ans = min(ans, max(a,b))
print(ans)

Measured memory_bytes: 10672
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long 
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair <int,  int>
#define pll pair <long long , long long>  
#define FAST ios::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 1e3 + 10 , S = 1e4 , N = 3e4 + 30 , sig = 2e4 , INF = 1e9 , mod = 1e9 + 7;

bool mark[maxn];
ll a[maxn];
vector <int> vec;

int main() {
    ll x , n;
    cin >> x >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        mark[a[i]] = 1;
    }
    for (int i = 0; i <= 110; ++i) {
        if(!mark[i]) {
            vec.PB(i);
        }
    }
    ll ans1 = 0 , ans2 = 0;
    for (int i = 0; i < vec.size(); ++i) {
        if(vec[i] >= x) {
            // is = 1;
            ans2 = vec[i];
            ans1 = (i ? vec[i - 1] : -1000);
            break;
        }
    }
    if(x - ans1 <= ans2 - x) {
        cout << ans1 << endl;
    }
    else {
        cout << ans2 << endl;
    }
}

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

#define int long long

int dp[201][200001];
int a[201], c[201];
int mx, inf = 1e18;

main()
{
	ios::sync_with_stdio(0);
	int n, w;
	cin >> n >> w;
	
	for(int i = 1; i <= n; i++)
		cin >> a[i] >> c[i], mx += c[i];
	
	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= mx; j++)
			dp[i][j] = inf;
	
	for(int i = 0; i <= n; i++)
		dp[i][0] = 0;
	
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= mx; j++)
		{
			if(j >= c[i]) dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - c[i]] + a[i]);
			else dp[i][j] = dp[i - 1][j];
		}
	}
	
	for(int j = mx; j >= 0; j--)
	{
		if(dp[n][j] == inf || dp[n][j] > w);
		else return cout << j << " ", 0;
	}
}


Measured memory_bytes: 157184
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _009_A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            var aArray = new long[n];
            var bArray = new long[n];
            for(int i = 0; i < n; i++)
            {
                int[] ab = ReadInts();
                aArray[i] = ab[0];
                bArray[i] = ab[1];
            }
            Array.Reverse(aArray);
            Array.Reverse(bArray);
            long cnt = 0;
            for(int i = 0; i < n; i++)
            {
                long aNow = aArray[i] + cnt;
                if (aNow % bArray[i] == 0) continue;

                long dest = (aNow / bArray[i] + 1) * bArray[i];
                cnt += dest - aNow;
            }
            Console.WriteLine(cnt);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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


int main()
{
	int m, d;
	while (cin >> m >> d, m || d){
		int day = 0;
		for (int i = 1; i < m; i++){
			if (i == 2){
				day += 29;
			}
			else if (i == 4 || i == 6 || i == 9 || i == 11){
				day += 30;
			}
			else{
				day += 31;
			}
		}
		day += d;
		if (day % 7 == 1){
			cout << "Thursday" << endl;
		}
		else if (day % 7 == 2){
			cout << "Friday" << endl;
		}
		else if (day % 7 == 3){
			cout << "Saturday" << endl;
		}
		else if (day % 7 == 4){
			cout << "Sunday" << endl;
		}
		else if (day % 7 == 5){
			cout << "Monday" << endl;
		}
		else if (day % 7 == 6){
			cout << "Tuesday" << endl;
		}
		else{
			cout << "Wednesday" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  sort(all(A), greater<ll>());
  ll mx = -longinf;
  int mxi = -1;
  rep(i, n) {
    if(i) {
      if(min(A[0]-A[i], A[i]) > mx) {
        mx = min(A[0]-A[i], A[i]);
        mxi = i;
      }
    }
  }
  cout << A[0] << ' ' << A[mxi] << endk;
  return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define SZ(x) ((int)(x).size())
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define UNIQUE(x) x.erase(unique(x.begin(), x.end()), x.end())

const static llong MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static double eps = 1e-6;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

llong dp[160001];

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<llong> V;
    V.push_back(1);
    for (llong i = 6; i <= n; i *= 6) {
        V.push_back(i);
    }
    for (llong i = 9; i <= n; i *= 9) {
        V.push_back(i);
    }

    dp[0] = 0;
    rep(i, n + *max_element(all(V))) dp[i + 1] = i + 1;
    for (int i = 0; i <= n; ++i) {
        rep(j, V.size()) {
            // cout << i + V[j] << endl;
            dp[i + V[j]] = min(dp[i + V[j]], dp[i] + 1);
        }
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

class UnionFind {
public:
    int n;
    std::vector<int> par;
    vll vsum;
    UnionFind(int n) : n(n), par(n, -1), vsum(n) {}

    // 集合の代表を返す
    int find(int x) {
        if (par[x] < 0) return x;
        return par[x] = find(par[x]);
    }
    // x と y が同じ集合に属するかを判別
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    // x が属する集合の大きさを返す
    int size(int x) {
        return -par[find(x)];
    }
    // x と y を結合 (merge した場合に true を返す)
    bool unite(int x, int y) {
        int px = find(x), py = find(y);
        if (px == py) return false;
        if (par[px] > par[py]) swap(px, py);
        vsum[px] += vsum[py];
        par[px] += par[py];
        par[py] = px;
        return true;
    }
};

using PI = P<ll, P<int, int> >;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    UnionFind uni(n);
    vll x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        uni.vsum[i] = x[i];
    }
    
    vll y(m);
    V<int> a(m), b(m);
    V< V< P<int, int> > > edges(n);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i] >> y[i];
        a[i]--, b[i]--;
        edges[a[i]].emplace_back(b[i], i);
        edges[b[i]].emplace_back(a[i], i);
    }
    V<int> ord(m); iota(ALL(ord), 0);
    sort(ALL(ord), [&](int i, int j) {
        return y[i] < y[j];
    });

    // 候補となる辺を記録
    V<int> cand_idx;
    for (int i: ord) {
        uni.unite(a[i], b[i]);
        if (uni.vsum[uni.find(a[i])] >= y[i]) cand_idx.emplace_back(i);
    }

    int ans = 0;
    V<bool> used(m, false);
    auto dfs = [&](auto && self, int i, ll maxwe) -> void {
        for (P<int, int> e: edges[i]) {
            if (!used[e.second] && y[e.second] <= maxwe) {
                ans++;
                used[e.second] = true;
                self(self, e.first, maxwe);
            }
        }
    };

    reverse(ALL(cand_idx));
    for (int i: cand_idx) {
        if (!used[i]) dfs(dfs, a[i], y[i]);
    }
    cout << m - ans << '\n';
    return 0;
}


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

namespace ABC081D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var s1 = Console.ReadLine();
            var s2 = Console.ReadLine();

            List<int> state = new List<int>();
            for(int i = 0; i < N; i++)
            {
                if (s1[i] == s2[i])
                {
                    state.Add(1);
                    continue;
                }
                else
                {
                    state.Add(2);
                    i++;
                    continue;
                }
            }

            long div = 1000000007;
            long ans = 0;
            if (state[0] == 1) ans = 3;
            else ans = 6;
            for(int i = 1; i < state.Count; i++)
            {
                if (state[i - 1] == 1)
                {
                    ans = ans * 2;
                }
                else
                {
                    if (state[i] == 2) ans = ans * 3;
                }
                ans %= div;
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

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

  set<string> s;
  string before = "";
  rep(i, N) {
    string w; in(w);
    if (s.find(w) != s.end() || (before != "" && before[before.size()-1] != w[0])) {
      out("No");
      return 0;
    }
    s.insert(w);
    before = w;
  }
  out("Yes");

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void main(void){
  char a[100];
  scanf("%s",a);
  int count = 0;
  for(int i=0; i<100; i++){
    if(a[i]!=0){
      count++;
    }else{
      break;
    }
  }
  char b[count+1];
  for(int i=0; i<count; i++){
    b[i] = 'x';
    printf("%c",b[i]);
  }
}
    
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  while (true) {
    ll n, w, d; cin >> n >> w >> d;
    if (!n && !w && !d) break;
    V<P<ll, ll>> cake;
    cake.push_back({w, d});
    REP(i, n) {
      ll p, s; cin >> p >> s;
      P<ll, ll> c = cake.at(p-1);
      cake.erase(cake.begin()+p-1);
      ll r = s % (c.first + c.second);
      if (r > c.first) {
        cake.push_back({c.first, min(r-c.first, c.first+c.second-r)});
        cake.push_back({c.first, max(r-c.first, c.first+c.second-r)});
      } else {
        cake.push_back({min(r, c.first-r), c.second});
        cake.push_back({max(r, c.first-r), c.second});
      }
    }
    sort(cake.begin(), cake.end(), [&](P<ll, ll> x, P<ll, ll> y) {
      return x.first * x.second < y.first * y.second;
    });
    REP(i, cake.size()) {
      cout << cake.at(i).first * cake.at(i).second;
      if (i != n) cout << ' ';
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
# -*- coding: utf-8 -*-
N = int(input())
if N == 0:
  print('0')
  exit()

N_ = N
S = ''
b = 1

for i in range(100):
  N__ = abs(N_)
  if N__ % (b*2) == 0:
    S = '0' + S
  else:
    N_ = N_ - b
    S = '1' + S
  if N_ == 0:
    break
  b = b * (-2)

print(S)

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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        long[] nmk = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = nmk[0];
        var m = nmk[1];
        var k = nmk[2];
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long[] b = Console.ReadLine().Split().Select(long.Parse).ToArray();


        long[] sum_a = new long[a.Length + 1];
        sum_a[0] = 0;
        for (int i = 1; i < a.Length + 1; i++)
        {
            sum_a[i] = sum_a[i - 1] + a[i-1];
        }

        long[] sum_b = new long[b.Length + 1];
        sum_b[0] = 0;
        for (int i = 1; i < b.Length + 1; i++)
        {
            sum_b[i] = sum_b[i - 1] + b[i-1];
        }

        long ans = 0;
        long j = m;
        for (int i = 0; i < a.Length + 1; i++)
        {
            if (sum_a[i] > k) break;
            while (sum_b[j] > k - sum_a[i])
            {
                j -= 1;
            }
            ans = Math.Max(ans, i + j);
        }

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 73120
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

int bitsum(int a) {//aの10進数での各桁の和を返す
	int ans = 0;
	string s = to_string(a);
	const int N = s.size();
	for (char x : s) ans += x - '0';
	return ans;
}

int main() {
	makei(N);
	yn(N % bitsum(N)==0);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n,m;
  while(scanf("%d%d",&n,&m), n+m){
    int time[100][100] = {{0}};
    int cost[100][100] = {{0}};
    REP(i,n){
      int a,b,c,d;
      scanf("%d%d%d%d",&a,&b,&c,&d);
      a--; b--;
      cost[a][b] = cost[b][a] = c;
      time[a][b] = time[b][a] = d;
    }
    int k;
    scanf("%d",&k);
    while(k --> 0){
      int p,q,type;
      int (*load)[100];
      scanf("%d%d%d",&p,&q,&type);
      if(type == 0) load = cost;
      else load = time;

      p--; q--;
      int memo[100];
      memset(memo, -1, sizeof(memo));
      priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > qq;
      qq.push(mp(0, p));
      while(qq.size()){
	int c = qq.top().f;
	int pos = qq.top().s;
	qq.pop();
	if(pos == q){
	  printf("%d\n",c);
	  break;
	}
	if(memo[pos] != -1)
	  continue;
	memo[pos] = c;
	REP(i,m){
	  if(memo[i] == -1 && load[pos][i] != 0)
	    qq.push(mp(c+load[pos][i], i));
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1056
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
   int a,b;
   cin>>a>>b;
   string aa,bb;
   for(int i=0;i<b;++i)
   {
       bb+=(a+'0');
   }
    for(int i=0;i<a;++i)
    {
        aa+=(b+'0');
    }
    cout<<min(aa,bb)<<"\n";


}

Measured memory_bytes: 3560