akhauriyash/Code-Regression huggingface dataset:
import math

N = int(input())

T,A = map(int, input().split())
for _ in range(N-1):
  t,a = map(int, input().split())
  if T % t == 0:
    i = T // t
  else:
    i = T // t + 1
  if A % a == 0:
    j = A // a
  else:
    j = A // a + 1
  k = max(i,j)
  T = k*t
  A = k*a
  
print(T+A)

Measured memory_bytes: 73160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

class dice {
public:
	int f, l, d;
	int v[7];

	dice(void) {
		f = 1;
		l = 4;
		d = 2;
	}
	void rot(char c)
	{
		int pf = f, pl = l, pd = d;

		if (c == 'W') set(7 - pl, pf, pd);
		else if (c == 'S') set(7 - pd, pl, pf);
		else if (c == 'E') set(pl, 7 - pf, pd);
		else set(pd, pl, 7 - pf);
	}
	int front(void)
	{
		return v[f];
	}
private:
	void set(int fv, int lv, int dv) {
		f = fv;
		l = lv;
		d = dv;
	}
};

int main()
{
	dice d;
	string S;
	int len;

	repc(i, 1, 6) cin >> d.v[i];
	cin >> S;
	len = S.length();

	rep(i, len) d.rot(S[i]);

	cout << d.front() << endl;

	return 0;
}



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

namespace competitive_programming
{
    class Program
    {
        static void Main(string[] args)
        {
            var main = new Program();
            main.solve();
        }

        void solve()
        {
            long N = long.Parse(Console.ReadLine());
            Console.WriteLine((N - 1 + 1) * (N - 1) / 2);
        }
    }
    struct Vector2
    {
        public Vector2(long x, long y)
        {
            this.x = x;
            this.y = y;
        }
        public long x;
        public long y;
    }

    struct Vector3
    {
        public int x;
        public int y;
        public int z;
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 998244353;
const ll INF = 0x3f3f3f3f;
const ll maxn = 2e5 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }
 
int main(){
	// in;
	// out;
	int a,b;
	cin>>a>>b;
	bool flag=false;
	for(int i=1;i<=2000;i++){
		int x=int(i*0.1);
		int y=int(i*0.08);
		if(x==b&&y==a){
			flag=true;
			cout<<i<<endl;
			break;
		}
	}
	if(!flag) cout<<"-1"<<endl;
}

Measured memory_bytes: 256
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <time.h>
#include <stdio.h>

using namespace std;
typedef long long ll;
typedef pair<double, double> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) a.begin(), a.end()

template<typename T>
void vdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		if (i == size - 1) {
			cout << da[i] << endl;
		}
		else {
			cout << da[i] << ' ';
		}
	}
}
template<typename T>
void vvdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		vdeb(da[i]);
	}
}

struct hoge{
	int a, b, c;
};

int n,a,b;
int dp[410][410];
hoge da[40];

void mint(int &x, int y){
	if(x > y) x = y;
}

int main(){
	cin >> n >> a >> b;
	rip(i,n,0) cin >> da[i].a >> da[i].b >> da[i].c;
	rip(i,410,0){
		rip(j,410,0){
			dp[i][j] = INT_MAX/2;
		}
	}
	dp[0][0] = 0;
	rip(i,n,0){
		for(int j = 400;j>-1;j--){
			for(int k = 400;k>-1;k--){
				mint(dp[j+da[i].a][k+da[i].b], dp[j][k] + da[i].c);
			}
		}
	}
	int ans = INT_MAX/2;
	int x = a,y = b;
	while(x<410 && y < 410){
		mint(ans, dp[x][y]);
		x += a;y += b;
	}
	if(ans == INT_MAX/2){
		cout << -1 << endl;
	}
	else
	{
		cout << ans << endl;
	}
	
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

signed main () {
  int n, m, k;
  cin >> n >> m >> k;
  bool ans = false;
  FOR(s, 0, n+1) {
    FOR(t, 0, m+1) {
      if(n * t + m * s - s * t * 2 == k) {
        ans = true;
        break;
      }
    }
    if(ans == true) {
      break;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    N, D = map(int, input().split())
    P = [list(map(int, input().split())) for _ in range(N)]

    count = 0

    def diff(a, b):
        sm = 0
        for i in range(D):
            sm += ((a[i] - b[i]) ** 2)

        return sm

    for p in range(len(P) - 1):
        s = 0
        for x in range(p+1, len(P)):
            s = diff(P[p], P[x])

            if str(s**0.5)[-1] == '0':
                count += 1

    print(count)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3700
from collections import deque

H, W = map(int, input().split())
s = [None] * H
count = 0

for i in range(H):
  s[i] = input()
  count += s[i].count('#')

adj = [[] for _ in range(W*H)]
  
dx = [-1,1,0,0]
dy = [0,0,-1,1]
  
for i in range(H):
  for j in range(W):
    if s[i][j] == '.':
      for k in range(4):
        y = i + dy[k]
        x = j + dx[k]
        if 0<=x<W and 0<=y<H:
          if s[y][x] == '.':
            adj[W*i+j].append(W*y+x)
  
queue = deque([0])
visit = [-1] * (W*H)
visit[0] = 1
  
while queue:
  now = queue.popleft()
  for u in adj[now]:
    if visit[u] < 0:
      queue.append(u)
      visit[u] = visit[now] + 1

if visit[W*H-1] == -1:
  print(-1)
else:
  print(W*H - visit[W*H-1] - count)

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

using namespace std;

int minimo(int a, int b){
  if(a < b)
    return a;
  return b;
}

int main() {
  int n, time, c, min = 1001, t, ans, flag = 0;
  cin >> n >> time;
  while(n--){
    cin >> c >> t;
    if((c == minimo(min, c)) and (t <= time)){
      min = c;
      ans = c;
      flag = 1; 
    }
  }
  if(flag){
    cout << ans << endl;
  }
  else{
    cout << "TLE" << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  map<int, ll> mp;
  rep(i, n){
    int a;
    cin >> a;
    mp[a]++;
  }
  rep(i, m){
    int b, c;
    cin >> b >> c;
    mp[c] += b;
  }

  ll ans = 0;
  rrepit(itr, mp){
    if(n - itr->second <= 0){
      ans += (ll)itr->first * n;
      break;
    }else{
      ans += (ll)itr->first * (itr->second);
      n -= itr->second;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 16128
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

// 配列Aにcinする
//int main() {
//  int N;
//  cin >> N;
//  vector<int> A(N);
//  for (int i = 0; i < N; i++) {
//    cin >> A.at(i);
//  }
//  return 0;
//}

// 標準入出力
int main() {
	int A, B, C, X;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> X;

  int counter = 0;
  for (int a = 0; a <= A; a++) {
    for (int b = 0; b <= B; b++) {
      for (int c = 0; c <= C; c++) {
        if (a * 500 + b * 100 + 50 * c == X) {
          counter++;
        }
      }
    }
  }
  cout << counter << endl;

  return 0;
}

// 文字列を1文字ずつループ
//int main() {
//  string str;
//  cin >> str;
//  int sum = 0;
//  for(int i = 0; i < (int)str.size(); ++i){
//    char ch = str[i];
//
//    if (ch == '1') {
//      sum++;
//    }
//  }
//  cout << sum << endl;
//  return 0;
//}



Measured memory_bytes: 256
import java.io.*;

class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());

    int[][] building_1 = new int[3][10];
    int[][] building_2 = new int[3][10];
    int[][] building_3 = new int[3][10];
    int[][] building_4 = new int[3][10];

    int count = 0;
    while(count < n){
    String str1 = br.readLine();
    String[] str2 = str1.split(" ");
    int b = Integer.parseInt(str2[0]);
    int f = Integer.parseInt(str2[1]);
    int r = Integer.parseInt(str2[2]);
    int v = Integer.parseInt(str2[3]);

    if (b == 1){
      building_1[f - 1][r - 1] += v;
    }
    if (b == 2){
      building_2[f - 1][r - 1] += v;
    }
    if (b == 3){
      building_3[f - 1][r - 1] += v;
    }
    if (b == 4){
      building_4[f - 1][r - 1] += v;
    }
    count++;
    }

    for(int i = 0; i < 3; i++){
      for (int j = 0; j < 10; j++){
        System.out.print(" " + building_1[i][j]);
      }
      System.out.println();
    }
    System.out.println("####################");
    for(int i = 0; i < 3; i++){
      for (int j = 0; j < 10; j++){
        System.out.print(" " + building_2[i][j]);
      }
        System.out.println();
    }
    System.out.println("####################");
    for(int i = 0; i < 3; i++){
      for (int j = 0; j < 10; j++){
        System.out.print(" " + building_3[i][j]);
      }
      System.out.println();
    }
    System.out.println("####################");
    for(int i = 0; i < 3; i++){
      for (int j = 0; j < 10; j++){
        System.out.print(" " + building_4[i][j]);
      }
      System.out.println();
    }
  }
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int a, b, ans=0;
    cin >> a >> b;

    for(int i=a; i<=b; i++){
        string s = to_string(i);
        string s1 = s;
        reverse(s1.begin(), s1.end());
        if(s==s1) ans+=1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ax = sum([(2*i - n + 1)*x[i] for i in range(n)])
ay = sum([(2*i - m + 1)*y[i] for i in range(m)])
print((ax*ay)%(10**9+7))


Measured memory_bytes: 18556
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  VL divisor;
  for(ll i=1; i * i <= n; i++) {
    if (n % i == 0) {
      divisor.push_back(i);
      if (i * i != n) {
        divisor.push_back(n / i);
      }
    }
  }
  ll ans = 0;
  FOR(d,divisor) {
    ll m = d - 1;
    ll k = n / d;
    if (m < 1) continue;
    if (k < 0 || m <= k) continue;
    ans += m;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
using System;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] n = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            for (int cnt = 0; cnt < n.Length; cnt++)
            {
                if (n[cnt] == 0)
                {
                    Console.WriteLine(cnt + 1);
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 27888
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N;
    scan(N);

    auto w = new int[](N + 1);
    auto b = new int[](N + 1);
    w[] = -1;
    b[] = -1;

    auto sw = new int[][](2*N + 1, N + 1);
    auto sb = new int[][](2*N + 1, N + 1);

    foreach (i ; 0 .. 2*N) {
        char c; int a;
        scan(c, a);

        if (c == 'W') {
            w[a] = i;
            sw[i + 1][a]++;
        }
        else {
            b[a] = i;
            sb[i + 1][a]++;
        }
    }

    foreach (j ; 0 .. N + 1) {
        foreach (i ; 1 .. 2*N + 1) {
            sw[i][j] += sw[i - 1][j];
            sb[i][j] += sb[i - 1][j];
        }
    }
    foreach (i ; 0 .. 2*N + 1) {
        foreach (j ; 1 .. N + 1) {
            sw[i][j] += sw[i][j - 1];
            sb[i][j] += sb[i][j - 1];
        }
    }

    // dp(i, j) = (白の1 ~ i、黒の1 ~ jをソート順にするための最小操作回数)
    auto dp = new int[][](N + 1, N + 1);
    fillAll(dp, inf);
    dp[0][0] = 0;

    foreach (i ; 0 .. N + 1) {
        foreach (j ; 0 .. N + 1) {
            if (i > 0) {
                auto p = w[i];
                p += (i - 1 + j) - sw[p][i - 1] - sb[p][j];
                assert(p >= w[i]);
                chmin(dp[i][j], dp[i - 1][j] + abs(p - (i + j - 1)));
            }
            if (j > 0) {
                auto p = b[j];
                p += (i + j - 1) - sw[p][i] - sb[p][j - 1];
                assert(p >= b[j]);
                chmin(dp[i][j], dp[i][j - 1] + abs(p - (i + j - 1)));
            }
        }
    }

    auto ans = dp[N][N];
    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 2e5+10;

int K, N;
ll A[MAX];

int solve() {
    ll ans = K;
    REP (i, N) {
        CHMIN(ans, K-(A[(i+1)%N] - A[i] + K) % K);
    }
    return ans;
}

int main() {
    cin >> K >> N;
    REP (i, N) cin >> A[i];
    cout << solve() << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
void yes(bool c) { if (c)print("Yes"); else print("No"); };

void solve() {
    vi last(26,-1),ans(26,-1);
    string s; cin >> s;
    int n = s.length();
    rep(i,n){
        int c = s[i]-97;
        if(last[c]==-1) {
            last[c] = i;
            ans[c] = i;
        }
        else{
            ans[c] = max(i-last[c]-1,ans[c]);
            last[c] = i;
        }
        // DEBUG_VEC(last);
        // DEBUG_VEC(ans);
    }
    rep(c,26){
        if(ans[c]!=-1) ans[c] = max(n-last[c]-1,ans[c]);
    }
    // DEBUG_VEC(ans);
    int res = 100;
    rep(i,26){
        if(ans[i]!=-1) res = min(res,ans[i]);
    }
    print(res);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

#include <atcoder/string>
using namespace atcoder;

int main(){
	string s;cin>>s;
	auto sa=suffix_array(s);
	auto la=lcp_array(s,sa);
	ll ans=0;
	rep(i,s.size()){
		if(!i)ans+=(s.size()-sa[i]);
		else ans+=(s.size()-sa[i]-la[i-1]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 15636
#include <stdio.h>
#include <ctype.h>

int main(void){
	
	char ch;
	while(1){
		scanf("%c",&ch);
		if(isupper(ch)!=0){
			ch=tolower(ch);
			printf("%c",ch);
		}else if(islower(ch)!=0){
			ch=toupper(ch);
			printf("%c",ch);
		}else{
			printf("%c",ch);
		}
		if(ch=='\n') break;
	}
	return 0;
}

Measured memory_bytes: 524
n = int(input())
a = list(map(int, input().split()))
print(*a)
for i in range(1, n):
	v = a[i]
	j = i - 1
	while j >= 0 and a[j] > v:
		a[j+1] = a[j]
		j -= 1
	a[j+1] = v
	print(*a)


Measured memory_bytes: 5984
import java.util.* ;
class Main {
  public static void main(String[] args) {
    
    Scanner scan = new Scanner(System.in);
   int a = scan.nextInt();
    int b = scan.nextInt();
    int x = scan.nextInt();
    
    if(x>=a && x<=a+b){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
    
  }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

int main(void) {
    int h, w, k;
    cin >> h >> w >> k;

    vector<string> c(h);
    rep(i, 0, h) cin >> c[i];

    int ans = 0;
    rep(row, 0, 1 << h) rep(col, 0, 1 << w) {
        int cnt = 0;
        rep(i, 0, h) rep(j, 0, w) {
            if (row & (1 << i)) continue;
            if (col & (1 << j)) continue;
            if (c[i][j] == '#') cnt++;
        }

        if (cnt == k) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3488
#include<stdio.h>

int main( )
{
    int N , Mu[200] , X , lcount=0 , rcount=0 , i , j , M  ;
    
    scanf("%d%d%d" , &N , &M, &X);

    for( i = 1 ; i <= M ; i++)
        scanf("%d" , &Mu[i] );
    
    for( i = X-1 ; i > 0 ; i--)
    {
        for( j = 1 ; j <= M ; j++)
        {
            if( i == Mu[j] )
            {
                 lcount++ ;
                 break ;
            }
        }
    }
    
    
    for( i = X+1 ; i < N ; i++)
    {
        for( j = 1 ; j <= M ; j++)
        {
            if( i == Mu[j] )
            {
                 rcount++ ;
                 break ;
            }
               
        }
    }
    
    if( lcount >= rcount)
        printf("%d\n" , rcount);
    else 
        printf("%d\n" , lcount);
    
    return 0; 
}


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

long long n, res[22][55][55], power26[27], mod = 1000000007; string S[55];

long long solve(int pos, int l, int r) {
	if (l > r) return 1;
	if (res[pos][l][r] >= 1) return res[pos][l][r] - 1;
	if (pos == 20) return 1;
	long long dp[28][55];
	for (int i = l - 1; i <= r; i++) {
		for (int j = 0; j < 28; j++) dp[j][i] = 0;
	}
	dp[0][l - 1] = 1;
	for (int i = 0; i < 27; i++) {
		for (int j = l - 1; j <= r; j++) {
			long long P = 1;
			for (int k = j; k <= r; k++) {
				if (pos == 19 && k - j >= 2) continue;

				if (k != j && S[k][pos] != (char)(95 + i + 1) && (i == 0 || S[k][pos] != '?')) P = 0;
				long long Q = ((dp[i][j] * P) % mod)*solve(pos + 1, j + 1, k);
				dp[i + 1][k] += Q; dp[i + 1][k] %= mod;
			}
		}
	}
	res[pos][l][r] = dp[27][r] + 1;
	return res[pos][l][r] - 1;
}

int main() {
	cin >> n;
	power26[0] = 1; for (int i = 1; i < 21; i++) { power26[i] = (power26[i - 1] * 26LL) % mod; }
	for (int i = 1; i <= n; i++) {
		cin >> S[i];
		while (S[i].size() <= 20) S[i] += (char)(96);
	}
	cout << solve(0, 1, n) << endl;
	return 0;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

    int N, K;
    cin >> N >> K;
    int A[N];
    rep(i,N){
        cin >> A[i];
        --A[i];
    }
    int seen[N]{};
    int cnt = 1, num = 0;
    seen[0] = cnt;
    int loop, zen;
    while(true){
        ++cnt;
        num = A[num];
        if(seen[num] == 0){
            seen[num] = cnt;
        }
        else{
            loop = cnt - seen[num];
            zen = seen[num]-1;
            break;
        }
    }
    if(zen >= K){
        rep(i,N){
            if(seen[i] == K+1){
                cout << i+1 << endl;
            }
        }
    }
    else{
        K -= zen;
        K %= loop;
        rep(i,N){
            if(seen[i] == K+zen+1){
                cout << i+1 << endl;
            }
        }
    }
}

Measured memory_bytes: 6784
N, M = map(int, input().split())
G = [[] for i in range(N)]

for i in range(M):
  a, b = map(int, input().split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)

def dfs(node, prev, visited):
    visited.append(node)
    if len(visited) == N:
        return 1
 
    res = 0
    for edge in G[node]:
        if edge == prev:
            continue
        if edge in visited:
            continue
        res += dfs(edge, prev, visited[:])
 
    return res


print(dfs(0,-1,[]))  

Measured memory_bytes: 3064
def longest():
    alps1 = raw_input()
    alps2 = raw_input()
    
    a, b = len(alps1), len(alps2)
    x1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = alps1[i]
        x2 = x1+[]
        for j in range(b):
            if e1 == alps2[j]:
                x1[j+1] = x2[j] + 1
            elif x1[j+1] < x1[j]:
                x1[j+1] = x1[j]
 
    return x1[-1]
    
n = input()
for i2 in range(n):
    print longest()

Measured memory_bytes: 6456
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int C = sc.nextInt();
        int[][] D = new int[C][C];
        //int[][] c = new int[N][N];
        int[] remain0 = new int[C];
        int[] remain1 = new int[C];
        int[] remain2 = new int[C];
        for(int row=0;row<C;row++){
            for(int col=0;col<C;col++){
                D[row][col] = sc.nextInt();
            }
        }
        // /*记得从小c去找D时要把小c的值-1*/
        for(int row=0;row<N;row++){
            for(int col=0;col<N;col++){
                int nxt = sc.nextInt()-1;
                //c[row][col] = nxt-1; // 0<=c<=C-1
                if((row+col)%3==0) remain0[nxt]++;
                else if((row+col)%3==1) remain1[nxt]++;
                else remain2[nxt]++;
            }
        }
        long[][] cost = new long[3][C];
        for(int i=0;i<C;i++){
            long sum0 = 0;
            for (int r0 = 0; r0 < C; r0++) {
                sum0 += remain0[r0] * (D[r0][i]);
            }
            cost[0][i] = sum0;
        }
        for(int j=0;j<C;j++){
            long sum0 = 0;
            for (int r0 = 0; r0 < C; r0++) {
                sum0 += remain1[r0] * (D[r0][j]);
            }
            cost[1][j] = sum0;
        }
        for(int k=0;k<C;k++){
            long sum0 = 0;
            for (int r0 = 0; r0 < C; r0++) {
                sum0 += remain2[r0] * (D[r0][k]);
            }
            cost[2][k] = sum0;
        }
        long ans = Long.MAX_VALUE;
        for(int i=0;i<C;i++) { // target color for remain0
            for (int j = 0; j < C; j++) { // target color for remain1
                if (j == i) continue;
                for (int k = 0; k < C; k++) { // target color for remain2
                    if (k == i || k == j) continue;
                    long sum0 = cost[0][i];
                    long sum1 = cost[1][j];
                    long sum2 = cost[2][k];
                    ans = Math.min(ans, sum0 + sum1 + sum2);
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 78672
#E
import math
n = int(input())
ans = 0
i = 1
if n % 2 == 0:
    tmp = 5 ** i * 2
    while tmp <= n:
        tmp = 5 ** i * 2
        ans += n //tmp
        i += 1
    print(ans)
else:
    print(0)

Measured memory_bytes: 9112
import sys

input = sys.stdin.readline


def main():
    kane = 700
    a, b, c = input().strip()
    if a == "o":
        kane += 100
    if b == "o":
        kane += 100
    if c == "o":
        kane += 100
    print(kane)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<stdio.h>

int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b){
	if(b<c)
		printf("Yes\n");
	else
		printf("No\n");
	}
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >>N;
    vector<int> line(N);
    for(int i = 0; i<N; i++){
        cin >>line.at(i);
    }
    sort(line.begin(),line.end());
    int longest = line.at(N-1);
    int sum = 0;
    for(int i = 0; i < N-1; i++){
        sum += line.at(i);
    }
    if(sum > longest)
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
        int a, b;

        scanf("%d %d", &a, &b);

        if (a < b) printf("a < b\n");
        else if (a > b) printf("a > b\n");
        else printf("a == b\n");

        return 0;
}

Measured memory_bytes: 580
N = int(input())
lst_slimes = list(map(int, input().split()))

ans = 0
for i in range(1, N):
    # 単純に「同じ色が隣接していたら、色を変える」を繰り返す
    if lst_slimes[i]==lst_slimes[i-1]:
        lst_slimes[i] = -1
        ans += 1

print(ans)

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

using namespace std;

int main() {

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (b >= c && d>=a) {
		cout << (min(b, d) - max(a, c)) << endl;
	}
	else {
		cout << 0 << endl;
	}

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll =  long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;


constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
	template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
	template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
	template<typename T> void chadd(T& a, T b) { a = a + b; }

	void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }


	// 標準入出力
	struct inp {
		std::size_t sz;
		inp(std::size_t _sz = 1) : sz(_sz) {}
		template <typename T> operator T () const { T a; std::cin >> a; return a; }
		template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
		template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
	};

	inp inp1; // input one

	struct Monster {
	public:
		int x;
		int h;
		int need;
	};
}

int main() {

	int n, d, a;
	cin >> n >> d >> a;
	vector<Monster> monster(n);
	vector<int> x(n);
	rep(i, n) {
		cin >> monster[i].x >> monster[i].h;
		x[i] = monster[i].x;
	}
	ll ans = 0;

	sort(allof(x));
	sort(allof(monster), [&](Monster lhs, Monster rhs) {
		return lhs.x < rhs.x;
		});

	// 何回必要かに置き換える
	rep(i, n) {
		if (monster[i].h % a) monster[i].need = monster[i].h / a + 1;
		else monster[i].need = monster[i].h / a;
	}

	// imos法
	// 左から貪欲
	vector<ll> sum(n + 1, 0);
	rep(i, n) {
		if (sum[i] < monster[i].need) {
			int cnt = monster[i].need - sum[i];
			if (cnt < 0) continue;
			ans += cnt;
			// どこまで影響がでるか
			int to = upper_bound(allof(x), x[i] + 2 * d) - x.begin() - 1;
			sum[to + 1] -= cnt;
			sum[i] += cnt;
		}

		// imosの累積和をとる操作
		sum[i + 1] += sum[i];
	}

	// 完全理解 図に加工

	Cout(ans);

	return 0;
}

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

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

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

template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return true;}return false;}

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

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

  // ここから
  IN(n);
  Vs str(n);
  VIN(str)
  REP(i,n){
    SORT(str[i]);
  }
  for(char ch = 'a'; ch <= 'z'; ++ch) {
    int num = INF;
    int tmp = 0;
    REP(i,n) {
      tmp = 0;
      REP(j,str[i].size()){
        if(str[i][j] == ch) tmp++;
      }
      num = min(num, tmp);
    }
    REP(i,num) {
      s += ch;
    }
  }
  OUT(s);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{


	static int a(int n){
		int min=n;
		for(int z=0; z<101; z++){
			for(int y=0; y<1001; y++){
				int x = n - (z*z*z) - (y*y);
				if(x < 0) continue;
				int sum = x+y+z;
				if(min >= sum) min = sum;
			}
		}
		return min;
	}




	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);


		while(true){
			int n = sc.nextInt();
			if(n == 0) break;

			System.out.println(a(n));

		}

	}

}

Measured memory_bytes: 26404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int N, T, A;
    cin >> N >> T >> A;
    vector<int> H(N);
    vector<double> temp(N);
    for(int i=0; i<N; i++){
        cin >> H[i];
    }
    for(int i=0; i<N; i++){
        temp[i] = T-H[i]*0.006;
    }

    double dif = abs(A - temp[0]), num=1;
    for(int i=0; i<N; i++){
        if(abs(A-temp[i]) < dif){
            dif = abs(A-temp[i]);
            num = i+1;
        }
    }
    cout << num;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    char c;
    cin >> c;
    if(c == 'A'){
        cout << 'T' << endl;
    }else if(c == 'T'){
        cout << 'A' << endl;
    }else if(c == 'C'){
        cout << 'G' << endl;
    }else if(c == 'G'){
        cout << 'C' << endl;
    }
    return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int n;
   cin >> n;
   int a,b,c;
   a = n/100;
   b = (n/10)%10;
   c = n%10;

   if(b < a || (b == a && c <= a)) {
     cout << a << a << a << endl;
   } else {
     cout << a + 1 << a + 1 << a + 1 << endl;
   }

}



Measured memory_bytes: 256
using System;
using System.Linq;
class Program
{

    static void Main(string[] args)
    {

        long[] inp = null;
        long[] brd = new long[9];
        bool[] bng = new bool[9];

        for (int i = 0; i < 3; i++)
        {
            inp = Console.ReadLine().Split(' ').Select(k => long.Parse(k)).ToArray();
            brd[i * 3 + 0] = inp[0];
            brd[i * 3 + 1] = inp[1];
            brd[i * 3 + 2] = inp[2];

            bng[i * 3 + 0] = false;
            bng[i * 3 + 1] = false;
            bng[i * 3 + 2] = false;
        }

        long n = long.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {

            long m = long.Parse(Console.ReadLine());
            for (int k = 0; k < 9; k++)
            {
                if (brd[k] == m) bng[k] = true;
            }
        }

        bool yes = false;

        for (int i = 0; i < 3; i++)
        {
            if ( bng[i*3] && bng[i*3 + 1] && bng[i*3 + 2])
            {
                yes = true;
            }

            if (bng[i] && bng[i + 3] && bng[i + 6])
            {
                yes = true;
            }
        }

        if (bng[0] && bng[4] && bng[8]) yes = true;
        if (bng[2] && bng[4] && bng[6]) yes = true;


        Console.WriteLine(yes ? "Yes" : "No");

    }

}



Measured memory_bytes: 13396
def get_value(n):
    return int(n) / sum(map(int, n))


def solve(k):
    buf = set()
    for z in range(14):
        suffix = '9' * z
        for h in range(1, 10000):
            n = str(h) + suffix
            buf.add((get_value(n), int(n)))
    buf = sorted(buf)
    tmp_max = 0
    ret = []
    for v, n in buf:
        if tmp_max > n:
            continue
        ret.append(str(n))
        tmp_max = n
    return ret[:k]


k = int(input())
print('\n'.join(solve(k)))


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

using namespace std;

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(s, v, it) for (s::iterator it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(s) freopen(s".in", "r", stdin), freopen(s."out", "w", stdout)
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
const double eps = 1e-7 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

int n, m, las ;

struct mtr {
	ll a[3][3] ;
	mtr () { clr(a) ; }
	void unit() {
		rep(i, 0, 3) a[i][i] = 1 ;
	}
} ans, trn, cou ;

mtr operator * (const mtr &u, const mtr &v) {
	mtr w ;
	rep(i, 0, 2)
	rep(j, 0, 2)
	rep(k, 0, 2)
	w.a[i][j] = (w.a[i][j] + u.a[i][k] * v.a[k][j]) % MOD ;
	return w ;
}

mtr operator ^ (mtr a, int b) {
	mtr ret ; ret.unit() ;
	for (; b; b >>= 1, a = a * a) if (b & 1) ret = ret * a ;
	return ret ;
}

void init() {
	ans.a[0][0] = 1 ;
	cou.a[0][0] = 1, cou.a[0][1] = 0, cou.a[0][2] = 0 ;
	cou.a[1][0] = 2, cou.a[1][1] = 1, cou.a[1][2] = 0 ;
	cou.a[2][0] = 1, cou.a[2][1] = 1, cou.a[2][2] = 1 ;
	trn.a[0][0] = 1, trn.a[0][1] = 0, trn.a[0][2] = 1 ;
	trn.a[1][0] = 2, trn.a[1][1] = 1, trn.a[1][2] = 2 ;
	trn.a[2][0] = 1, trn.a[2][1] = 1, trn.a[2][2] = 2 ;
}

signed main(){
	scanf("%d%d", &n, &m) ;
	init() ;
	rep(i, 1, m) {
		int x ; scanf("%d", &x) ;
		ans = (trn ^ (x - las)) * ans ;
		ans = cou * ans, las = x + 1 ;
	}
	ans = (trn ^ (n - las)) * ans ;
	cout << ans.a[2][0] << endl ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/



Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	i64 a, b; scanf("%lld%lld", &a, &b);
	
	printf("%lld\n", a / std::__gcd(a, b) * b);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    int n, ac = 0, wa = 0, tle = 0, re = 0;
    cin >> n;
    string a;
    rep(i,n){
        cin >> a;
        if(a[0] == 'A') ac++;
        else if(a[0] == 'W') wa++;
        else if(a[0] == 'T') tle++;
        else re++;
    }
    cout << "AC x " << ac << endl; 
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

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

using namespace std;


int main()
{
  string beet;
  while(cin >> beet, beet != "#") {
    string S[6][3];
    S[0][0] = beet;
    for(int i = 0; i < 6; i++) {
      for(int j = i == 0; j < 3; j++) {
        cin >> S[i][j];
      }
    }

    int ret = 114514;
    bool l = 0, r = 0;
    for(int i = 0; i < 3; i++) {
      if(S[0][2][i] == '*') l = true;
      if(S[2][2][i] == '*') r = true;
    }
    if(l & r) ret = min(ret, 0);

    l = r = 0;
    for(int i = 0; i < 3; i++) {
      if(S[0][i][0] == '*') l = true;
      if(S[2][i][2] == '*') r = true;
    }
    if(l & r) ret = min(ret, 1);

    l = r = 0;
    for(int i = 0; i < 3; i++) {
      if(S[0][i][2] == '*') l = true;
      if(S[2][i][0] == '*') r = true;
    }
    if(l & r) ret = min(ret, 1);

    l = r = 0;
    for(int i = 0; i < 3; i++) {
      if(S[4][2][i] == '*') l = true;
      if(S[5][0][i] == '*') r = true;
    }
    if(l & r) ret = min(ret, 1);

    l = r = 0;
    for(int i = 0; i < 3; i++) {
      if(S[4][0][i] == '*') l = true;
      if(S[5][2][i] == '*') r = true;
    }
    if(l & r) ret = min(ret, 1);

    l = r = 0;
    for(int i = 0; i < 3; i++) {
      if(S[0][0][i] == '*') l = true;
      if(S[2][0][i] == '*') r = true;
    }
    if(l & r) ret = min(ret, 2);

    l = r = 0;
    for(int i = 0; i < 3; i++) {
      if(S[1][i][0] == '*') l = true;
      if(S[3][i][2] == '*') r = true;
    }
    if(l & r) ret = min(ret, 2);

    l = r = 0;
    for(int i = 0; i < 3; i++) {
      if(S[1][i][2] == '*') l = true;
      if(S[3][i][0] == '*') r = true;
    }
    if(l & r) ret = min(ret, 2);

    for(int i = 0; i < 3; i++) {
      if(S[4][i][0] == '*') l = true;
      if(S[5][i][0] == '*') r = true;
    }
    if(l & r) ret = min(ret, 2);

    for(int i = 0; i < 3; i++) {
      if(S[4][i][2] == '*') l = true;
      if(S[5][i][2] == '*') r = true;
    }
    if(l & r) ret = min(ret, 2);

    l = r = 0;
    for(int i = 0; i < 3; i++) {
      if(S[1][0][i] == '*') l = true;
      if(S[3][0][i] == '*') r = true;
    }
    if(l & r) ret = min(ret, 3);

    for(int i = 0; i < 3; i++) {
      if(S[1][2][i] == '*') l = true;
      if(S[3][2][i] == '*') r = true;
    }
    if(l & r) ret = min(ret, 3);


    cout << ret << endl;
  }
}

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

int main () {
  int a, b, ans = 0;
  cin >> a >> b;
  if (a > b) {
    ans += a;
    a--;
    if (a > b) {
      ans += a;
    }
    else {
      ans += b;
    }
  }
  else {
    ans += b;
    b--;
    if (b > a) {
      ans += b;
    }
    else {
      ans += a;
    }
  }

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


Measured memory_bytes: 256
N, Y = map(int, input().split())

x_lst = []
y_lst = []
z_lst = []
for x in range(N+1):
	for y in range(N+1):
		z = N -(x + y)
		if 0<=z<=N:
			en_sum = 10000*x + 5000*y + 1000*z
			if en_sum==Y:
				x_lst.append(x)
				y_lst.append(y)
				z_lst.append(z)
if x_lst:
	print(x_lst[0], y_lst[0], z_lst[0])
else:
	print(-1, -1, -1)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

bool ifchr(string S, char x){
    bool d=0;
    rep(i, S.len) if(S.at(i) == x) d=1;
    return d;
}

int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans=0;
    rng(i,1,N){
        string X, Y;
        X = S.substr(0,i);
        Y = S.substr(i);
        int c=0;
        rep(j,26) if(ifchr(X, j + 'a') && ifchr(Y, j + 'a')) c++;
        ans = max(ans,c);
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  ll n,a,b; cin >> n >> a >> b;

  ll l = a*(n-1)+b;
  ll r = a+(n-1)*b;
  cout << max(0LL, r-l+1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int cost[6] = {600, 800, 1000, 1200, 1400, 1600};
int sc[6] = {60, 80, 100, 120, 140, 160};
int we[6] = {2, 5, 10, 15, 20, 25};

int main(int argc, char **argv)
{
	long long int w, x, y, z, n, sum;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		sum = 0;
		for(int i = 0; i < n; i++){
			cin >> x >> y >> z >> w;
			
			x = x + y + z;
			if(w > 25 || x > 160){
				continue;
			}
			
			y = z = 0;
			for(int i = 0; i < 6; i++){
				if(x <= sc[i]){
					y = i;
					break;
				}
			}
			
			for(int i = 0; i < 6; i++){
				if(w <= we[i]){
					z = i;
					break;
				}
			}
			
			sum += cost[((y < z)? z : y)];
		}
		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int a, b;
	cin >> a>> b ;
	int c = 1;
	for (int i = 1; i <= a; i++) {
		c = c * 100;
	}
	if (b != 100) {
		cout << c * b;
	}
	else {
		cout << c * 101;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

static const int MAX = 100001;

/******* c++14 don't include *******/

template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }

/*******                      *******/

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    int x, a, b, n;
    cin >> x >> a >> b >> n;
    
    rep(i, n){
        string s;
        cin >> s;
        if(s == "nobiro"){
            x+=a;
        }
        else if( s== "tidime"){
            x+=b;
        }
        else x = 0;
        if(x<0)x = 0;
    }
    
    cout << x << endl;
    
    return 0;
}



Measured memory_bytes: 3176