akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>


int main()
{
    // std::cout << std::fixed << std::setprecision(10);
    int n; std::cin >> n;
    std::vector<std::pair<std::pair<std::string, int>, int>> pa(n);
    for(int i=0; i<n; i++)
    {
        std::string a; int b;
        std::cin >> a >> b;
        pa[i].first.first = a;
        pa[i].first.second = -b;
        pa[i].second = i+1;
    }
    std::sort(pa.begin(), pa.end());
    
    for(int i=0; i<n; i++)
    {
        std::cerr << pa[i].first.first << " " << pa[i].first.second 
        << " " << pa[i].second << std::endl;
    }
    for(int i=0; i<n; i++)
        std::cout << pa[i].second << std::endl;
    
    return 0;
}

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

int main()
{
  int R;
  cin >> R;
  char AxC[] = "AxC";
  char & x = AxC[1];
  if (R < 1200)
    x = 'B';
  else if (R < 2800)
    x = 'R';
  else
    x = 'G';
  cout << AxC;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int counter(int x)
{
	if (x == 0) {
		return 0;
	}

	return counter(x >> 1) + (x & 1);
}

int main(int argc, char *argv[])
{
	int N;
	int A[20], x[20][20], y[20][20];

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		for (int j = 1; j <= A[i]; j++) {
			cin >> x[i][j] >> y[i][j];
		}
	}
	int ans = 0;
	for (int bits = 1; bits < (1 << N); bits++) {
		bool ok = true;
		for (int i = 1; i <= N; i++) {
			if (!(bits & (1 << (i - 1)))) {
				continue;
			}
			for (int j = 1; j <= A[i]; j++) {
				if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) {
					ok = false;
				}
			}
		}
		if (ok) {
			ans = max(ans, counter(bits));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
module String = struct
  include String

  let split str delim =
    let rec doit s acc =
      match
        try Some (String.rindex s delim) with _ -> None
      with
      | None -> s :: acc
      | Some i ->
          let s1 = String.sub s 0 i in
          let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
          doit s1 (s2 :: acc)
    in
    doit str []

end

let linear_search x lst =
  let rec doit = function
    | [] -> None
    | hd :: _ when x = hd -> Some hd
    | _ :: tl -> doit tl
  in
  doit lst

let () =
  let _ = read_int () in
  let s = List.map int_of_string (String.split (read_line ()) ' ') in
  let _ = read_int () in
  let t = List.map int_of_string (String.split (read_line ()) ' ') in
  let rec doit cnt = function
    | [] -> cnt
    | hd :: tl -> begin
        match linear_search hd s with
        | None -> doit cnt tl
        | Some _ -> doit (cnt + 1) tl
      end
  in
  Printf.printf "%d\n" (doit 0 t)

Measured memory_bytes: 8868
from collections import defaultdict
N,X = map(int,input().split())
S = list(map(int,input().split()))
S.sort()
mod = 10**9+7

fact_memo = [0]*201
fact_memo[0] = 1
def fact(n):
    if fact_memo[n] == 0:
        fact_memo[n] = n*fact(n-1)%mod
    return fact_memo[n]

fact_inv_memo = [0]*201
fact_inv_memo[0] = 1
def fact_inv(n):
    if fact_inv_memo[n] == 0:
        fact_inv_memo[n] = pow(fact(n),mod-2,mod)
    return fact_inv_memo[n]

dp = defaultdict(lambda :[-1]*(X+1))
for n in range(N):
    for x in range(X+1):
        if n == 0:
            dp[n][x]=x%S[0]
        else:
            dp[n][x]=(dp[n-1][x%S[n]]+n*dp[n-1][x])%mod

print(dp[N-1][X])


Measured memory_bytes: 190984
using System;

public class hello
{
    public static void Main()
    {
        var c = new int[] { 1, 5, 10, 50, 100, 500 };
        string[] line = Console.ReadLine().Trim().Split(' ');
        var coin = Array.ConvertAll(line, int.Parse);
        var p = 0;
        for (int i = 0; i < 6; i++)
            p += c[i] * coin[i];
        if (p >= 1000) Console.WriteLine(1);
        else Console.WriteLine(0);
    }
}

Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
    

inline void solve(){
  int n,a[100005];
  ll dp[100005][2]={};
  cin >> n;
  cinf(n,a);
  dp[0][0] = 0;
  dp[0][1] = -INF;

  FOR(i,n){
    dp[i+1][0] = max(dp[i][0]+a[i],dp[i][1]-a[i]);
    dp[i+1][1] = max(dp[i][0]-a[i],dp[i][1]+a[i]);
  }

  cout << dp[n][0] fin;
  
}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#include<unordered_map>
#define M 1000000007
#define T 998244353
#define PI 3.142
#define ll long long

using namespace std;

ll maxi(ll a, ll b)
{
    if(a>b){
        return a;
    }
    return b;
}

ll dp[100001][100];

ll knapsack(int W, ll val[], int w[], int i, int n)
{
    if(W==0 || i==n){
        return 0;
    }
    if(dp[W][i]!=-1){
        return dp[W][i];
    }
    if(W<w[i]){
        dp[W][i] = knapsack(W, val, w, i+1, n);
    }
    else {
        dp[W][i] = maxi(val[i]+knapsack(W-w[i], val, w, i+1, n), knapsack(W, val, w, i+1, n));
    }
    return dp[W][i];
}

void ini()
{
    for(int i=0; i<100001; i++){
        for(int j=0; j<101; j++){
            dp[i][j]=-1;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, W;
    cin >> n >> W;
    ini();
    int w[n];
    ll val[n];
    for(int i=0; i<n; i++){
        cin >> w[i] >> val[i];
    }
    cout << knapsack(W, val, w, 0, n) << endl;
    return 0;
}

Measured memory_bytes: 78336
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
  int N, A, B, C;
  int l[8];
  scanf("%d %d %d %d\n",&N,&A,&B,&C);
  for(int i=0;i<N;i++) scanf("%d\n",&l[i]);
  int i[8];
  int mptmp ,mpmin=100000000;
  int tmpa,tmpb,tmpc;
  for(i[0]=0;i[0]<4;i[0]++) {
  for(i[1]=0;i[1]<4;i[1]++) {
  for(i[2]=0;i[2]<4;i[2]++) {
  for(i[3]=0;i[3]<4;i[3]++) {
  for(i[4]=0;i[4]<4;i[4]++) {
  for(i[5]=0;i[5]<4;i[5]++) {
  for(i[6]=0;i[6]<4;i[6]++) {
  for(i[7]=0;i[7]<4;i[7]++) {
    mptmp = -30;
    tmpa = 0;
    tmpb = 0;
    tmpc = 0;
    for(int j=0;j<N;j++) {
      if(i[j] == 0) {
        tmpa += l[j];
        mptmp += 10;
      }
      if(i[j] == 1) {
        tmpb += l[j];
        mptmp += 10;
      }
      if(i[j] == 2) {
        tmpc += l[j];
        mptmp += 10;
      }
    }
    if((tmpa!=0)&(tmpb!=0)&(tmpc!=0)) {
      mptmp += abs(tmpa-A);
      mptmp += abs(tmpb-B);
      mptmp += abs(tmpc-C);
      mpmin = (mpmin > mptmp) ? mptmp : mpmin;
    }
  }}}}}}}}
  printf("%d",mpmin);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;
const int mod = 1e9+7;
int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int lcs(string a, string b) {
  int n = a.size(), m = b.size();
  int dp[2][m+1];
  for(int i = 0;i <= n;i++) {
    for(int j = 0;j <= m;j++) {
      if(i==0||j==0) dp[i%2][j] = 0;
      else {
        if(a[i-1] == b[j-1]) dp[i%2][j] = 1 + dp[1-i%2][j-1];
        else dp[i%2][j] = max(dp[i%2][j-1], dp[1-i%2][j]);
      }
    }
  }
  return dp[n%2][m];
}

int sum(int x) {
  int s = 0;
  while(x) {
    s += x%10;
    x /= 10;
  }
  return s;
} 

bool equal(string s) {
  for(int i = 0,j = s.size()/2;j < s.size();i++,j++) {
    if(s[i] != s[j]) return false;
  }
  return true;
}

ll fact(int n) {
  ll ans = 1;
  fr(i,2,n+1) ans = (ans*i)%mod;
  return ans;
}

ull f(ll a, ll x) {
  if(a < 0) return 0;
  return (a/x+1);
}

int main() {
  int n,l;
  cin>>n>>l;
  string s[n];
  frn(i,n) cin>>s[i];
  sort(s,s+n);
  frn(i,n) cout<<s[i];
}



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

int main(){
  string s;
  cin >> s;
  int count = 0;
  for(int i = 0; i < 4; i++){
    if(s[i] =='-'){
      count--;
    } else {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int size=200000+10;
char ans[size];
int main(int argc, char** argv) {
	char temp;
	int count=0;
	while(scanf("%c",&temp)&&temp!='\n')
	{
		if(count!=0&&temp=='T'&&ans[count-1]=='S')
			count--;
		else
			ans[count++]=temp;
	}
	printf("%d\n",count);
	return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

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 DEBUG

int main()
{
	int n, m;
	cin >> n >> m;
	vector<P> p(m);
	rep(i, m) cin >> p[i].first >> p[i].second;

	rep(x, 1000)
	{
		int nx = x / 10;
		vi dig(1, x % 10);
		while(nx)
		{
			dig.push_back(nx % 10);
			nx /= 10;
		}
		if(dig.size() != n) continue;
		bool ok = true;
		reverse(all(dig));

		rep(i, m)
		{
			if(dig[p[i].first-1] != p[i].second) ok = false;
		}

		if(ok)
		{
			cout << x << endl;
			return 0;
		}
	}
	cout << NIL << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

ll pw(ll a,ll b){
	ll ret=1;
	rep(i,b)ret*=a;
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	map<ll,ll> mp;
	ll ans=0;
	rep(i,m){
		ll s,c;
		cin>>s>>c;
		if(mp.count(s)!=0&&mp[s]!=c){
			puta(-1);
			return 0;
		}
		mp[s]=c;
		
	}
	ll st=pw(10,n-1);
	if(st==1)st=0;
	range(i,st,pw(10,n)){
		ll ans=true;
		for(auto x:mp){
			ans&=((i/pw(10,n-x.fs))%10==x.sc);
		}
		if(ans) {
			puta(i);
			return 0;
		}
	}
	puta(-1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second

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

signed main(){
	int a[3];
	r(i,3)cin>>a[i];
	sort(a,a+3);
	cout<<a[2]*10+a[1]+a[0]<<endl;
}

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

int main(){
	int i,j,k;
	int count,counter;
	int hairetsu[2][10];
	int memo1,memo2;
	char d[]=" ";
	char c[30];
	char *tok;
	int now;
	
	scanf("%d\n",&counter);
	count=0;
	while(count<counter){
		for(i=0;i<2;i++){
			for(j=0;j<10;j++){
				hairetsu[i][j]=0;
			}
		}
		memo1=0;
		memo2=0;
		gets(c);
		tok=strtok(c,d);
		int flag=1;
		while(tok!=NULL){
			now=atoi(tok);
			if(hairetsu[0][memo1]<now){
				memo1++;
				hairetsu[0][memo1]=now;
			}else{
				if(hairetsu[1][memo2]<now){
					memo2++;
					hairetsu[1][memo2]=now;
				}else{
					flag=0;
					break;
				}
			}
			tok=strtok(NULL,d);
		}
		if(flag){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
		count++;
	}
	return 0;
}

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

#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int  long long

#define x first
#define y second

using pii = pair<int, int>;
using ld  = long double;

const int mxn = 1e5 + 5;
const int mod = 1e9 + 7;

int dp[mxn], h[mxn];

int32_t main()
{
    IOS
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 1; i < n; i++)
    {
        dp[i] = 1e15;
        for(int j = 1; j <= k; j++)
        {
            if(i - j >= 0) dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 5160
//２つの整数 a, b と１つの演算子 op を読み込んで、a op b を計算するプログラム
#include <stdio.h>

int main(void)
{
    //変数定義
    int iCount;
    int iInputA;
    int iInputB;
    int iCalcResult;
    char chOperand;

    //変数の初期化
    iInputA = 0;
    iInputB = 0;
    iCalcResult = 0;
    chOperand = '0';

    //iInputA,chOperand,iInputBの標準入力
    while (chOperand != '?')
    {
        scanf("%d %c %d",&iInputA,&chOperand,&iInputB);
        if (chOperand == '?')
        {
            //何もしない
        }
        else if (chOperand == '+')
        {
            iCalcResult = iInputA + iInputB;
            printf("%d\n",iCalcResult);
        }
        else if (chOperand == '-')
        {
            iCalcResult = iInputA - iInputB;
            printf("%d\n",iCalcResult);
        }
        else if (chOperand == '*')
        {
            iCalcResult = iInputA * iInputB;
            printf("%d\n",iCalcResult);
        }
        else if (chOperand == '/')
        {
            iCalcResult = iInputA / iInputB;
            printf("%d\n",iCalcResult);
        }
    }


    return 0;
}


Measured memory_bytes: 2100
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  long double a, b; cin >> a >> b;
  ll res = (a * b);
  print(res);
}

int main() {
  int t; t = 1;
  while(t--) solve();
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

template<typename D, class... A> class BinarySearch {
    D left;
    D right;
    function<bool(D, A...)> func;

    public:
        BinarySearch(D l, D r, function<bool(D, A...)> f) {
            left = l;
            right = r;
            func = f;
        }

        D calc(A... args) {
            while (abs(right - left) > 1) {
                D middle = (left + right) / 2;
                if (func(middle, args...)) {
                    left = middle;
                } else {
                    right = middle;
                }
            }
            return left;
        }
};

void solve() {
    ll a, b, n;
    cin >> a >> b >> n;

    auto f = [&](ll x) {
        return a * x / b - a * (x / b);
    };

    if (n <= b - 1) cout << f(n) << endl;
    else cout << f(b - 1) << endl;

    // REP1(i, n) cout << f(i) << endl;

    // BinarySearch<ll> bs(-1LL, n + 1, f);
    // cout << bs.calc() << endl;
}


Measured memory_bytes: 3648
#define ll long long
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#include <bits/stdc++.h>
using namespace std;
ll gcd(ll a, ll b)
{
  if (!b)
    return a;
  return gcd(b, a % b);
}
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x %= p;
  while (y > 0)
  {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
ll po(ll base, ll powerRaised)
{
  if (powerRaised != 0)
    return (base * po(base, powerRaised - 1));
  else
    return 1;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll h, n;
  cin >> h >> n;
  ll a[n + 1], sum = 0;
  for (int i = 0; i < n; i++)
  {
    ll x;
    cin >> x;
    sum += x;
  }
  if (sum >= h)
    cout << "Yes";
  else
    cout << "No";
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}

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

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

	check=n%10;

	if(check==2||check==4||check==5||check==7||check==9){
		cout<<"hon"<<endl;
	}
	else if(check==0||check==1||check==6||check==8){
		cout<<"pon"<<endl;
	}
	else if(check==3){
		cout<<"bon"<<endl;
	}

	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int N;
string s;
int ac, wa, tle, re;
int main(void){
    cin >> N;
    REP(i,N) {
        cin >> s;
        if (s=="AC") ac++;
        if (s=="WA") wa++;
        if (s=="TLE") tle++;
        if (s=="RE") 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: 3556
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int acum[108000];
Int dp[108000];
vector<Int> pos[3];
string s;
vector<Int> rep;
int main(){
  cin >> s;
  for(int i = 0;i < s.size();i++){
    if(s[i] == 'a')acum[i+1] = acum[i] + 1;
    else acum[i+1] = acum[i] + 2;
    acum[i+1]%=3;
    pos[acum[i+1]].push_back(i);
    if(i && s[i] == s[i-1])rep.push_back(i);
  }
  if(rep.empty()){
    cout << 1 << endl;
    return 0;
  }
  dp[0] = 1;
  for(int i = 0;i < s.size();i++){
    dp[i+1] = (dp[i+1] + dp[i]) % MOD;
    auto nxtrep = upper_bound(rep.begin(), rep.end(), i);
    if(nxtrep == rep.end())continue;
    int k = *nxtrep;
    for(int j = 1;j <= 2;j++){
      if(s[i] == 'a' && j == 1)continue;
      if(s[i] == 'b' && j == 2)continue;
      int to = (acum[i] + j) % 3;
      auto nxtpos = lower_bound(pos[to].begin(), pos[to].end(), k);
      if(nxtpos == pos[to].end())continue;
      dp[*nxtpos+1] = (dp[*nxtpos+1] + dp[i]) % MOD;
    }
  }
  Int res = 0;
  for(int i:pos[acum[s.size()]]){
    res = (res + dp[i+1]) %MOD;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4340
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    int n;
    cin >> n;
    vector<int> h(n);
    VCIN(h);

    vector<int> ans(n, 0);
    ans[1] = abs(h[1] - h[0]);
    for(int i=2; i<n; i++){
        ans[i] = min(ans[i-1] + abs(h[i]-h[i-1]), ans[i-2] + abs(h[i]-h[i-2]));
    }

    COUT(ans.back());

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#define rep(i, a, n) for (int i = a; i <= n; ++i)
using namespace std;
const int m = 1000000007;
int N, K, a[1001], c[1001][1001];
long d[21][1001];
int main() {
	cin >> N >> K;
	rep(k, 1, K) cin >> a[k];
	rep(n, 0, N) rep(r, 0, n) c[n][r] = r == 0 ? 1 : (c[n - 1][r - 1] + c[n - 1][r]) % m;
	d[0][0] = 1;
	rep(k, 1, K) rep(n, 0, N) rep(x, 0, min(n, a[k])) d[k][n] = (d[k][n] + d[k - 1][n - x] * c[N - n + x][x] % m * c[N - x][a[k] - x]) % m;
	cout << d[K][N] << endl;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod=1000000007;
constexpr ll INF=(1ll<<60);
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<typename T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}


int main(){
    ll a,b;cin>>a>>b;
    cout<<max(0ll,a-2*b)<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    string S;
    cin >> N >> S;
    
    bool looping;
    if(N%2 == 0)
        looping = true;
    else
        looping = false;
        
    for(int i = 0; i<N/2 && looping; i++){
        if(S.at(i) != S.at(i+N/2))
            looping = false;
    }
    
    if(looping)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		int ac = 0;
		int wa = 0;
		int tle = 0;
		int re = 0;
		for(int i = 0; i < n; i++) {
			s[i] = sc.next();
			if(s[i].equals("AC"))ac++;
			else if(s[i].equals("WA"))wa++;
			else if(s[i].equals("TLE"))tle++;
			else if(s[i].equals("RE"))re++;
		}
		System.out.println("AC x " + ac);
		System.out.println("WA x " + wa);
		System.out.println("TLE x " + tle);
		System.out.println("RE x " + re);
	}
}

Measured memory_bytes: 55656
#include <bits/stdc++.h>
using namespace std;
int main(){
    int ans=0, cont=0;
    int n, i;
    cin >> n;
    int lastT=-1, t;
    for(i=0; i<n; i++){
        cin >> t;
        if(t>lastT){
            cont=0;
        }
        else{
            cont++;
        }
        ans=max(ans, cont);
        lastT=t;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
    int x,c=0,a[10010]={0};
        fr(i,3)
        {
            cin>>x;
            a[x]++;
        }
        fr(i,1000)
        {
            if(a[i]!=0)
                c++;
        }
        cout<<c<<"\n";
        return 0;

}




Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args)throws IOException{
		String a;
		BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
		a=buf.readLine();
		int x=Integer.parseInt(a);
	//	if(x/3600<10)System.out.print("0");
		System.out.print(x/3600);
		System.out.print(":");
		int y;
		int g=x;
		g=g/60;
		while(true){
			if(g>=60){
				g-=60;
				
			}else{
				break;
			}
			
		}
	//	if(g<10)System.out.print("0");
		System.out.print(g);
		System.out.print(":");
		while(true){
			if(x>=60){
				x-=60;
			}else{
				break;
			}
		}
	//	if(x<10)System.out.print("0");
		System.out.println(x);
		
	}

}

Measured memory_bytes: 17052
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N, D;
  while (~scanf("%d %d", &N, &D)) {
    vector<int> d(N);
    for (int i = 0; i < N; i++) scanf("%d", &d[i]);
    vector<int> A(N + 1);
    A[0] = D;
    for (int i = 0; i < N; i++) {
      if (d[i] < 2 * A[i]) {
        A[i + 1] = abs(A[i] - d[i]);
      } else {
        A[i + 1] = A[i];
      }
    }
    vector<int> B(N + 1);
    B[N] = 1;
    for (int i = N - 1; i >= 0; i--) {
      if (d[i] >= 2 * B[i + 1]) {
        B[i] = B[i + 1];
      } else {
        B[i] = B[i + 1] + d[i];
      }
    }
    int Q;
    scanf("%d", &Q);
    for (int i = 0; i < Q; i++) {
      int q;
      scanf("%d", &q);
      --q;
      bool res = A[q] >= B[q + 1];
      puts(res ? "YES" : "NO");
    }
  }
  return 0;
}


Measured memory_bytes: 7808
import kotlin.math.max

fun main() {
    val s = readLine() ?: return
    var c = 0
    var t = 0
    s.forEach {
        if (it == 'R') {
            c++
        } else {
            t = max(c, t)
            c = 0
        }
    }
    t = max(c, t)
    println(t.toString())
}


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

int n;
num ans;

int main() {
	scanf("%d", &n);
	cont (i, n) {
		int cnt = n / i;
		ans += (num) (1 + cnt) * cnt / 2 * i;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3720
'use strict'

function main(input){
  const lines = input.split('\n')
  const N = parseInt( lines.shift() );
  const F = [];
  for(let i=0; i<N;i++){
    F.push( lines[i].split(' ').map( x => parseInt(x) ) );
  }

  const P=[];
  for(let i=0; i<N;i++){
    P.push(lines[i+N].split(' ').map( x => parseInt(x)) );
  }

  let result = -Infinity;
  for(let i=1; i<1024;i++){
    let score = 0;
    for(let j=0; j<N;j++){
      let store = F[j];
      let p_index = (parseInt(store.join(''), 2) & i).toString(2).split('').map(x=>Number(x)).reduce((a,b)=>a+b,0)
      score += P[j][p_index];
    }
    if(score > result){result = score;}
  }

  console.log(result);
}



main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 10832
#include<bits/stdc++.h>
using namespace std;
pair<int, int> x, y;
char ch[101010 * 2];
int main(){
    int n, a, b, c, d;
    scanf("%d", &n);
    scanf("%d%d%d%d", &a, &b, &c, &d);
    scanf("%s", ch + 1);
    x = make_pair(a, c);
    y = make_pair(b, d);
    bool flag = true;
    for(int i = a; i <= c; i ++){
        if(ch[i] == '#' && ch[i+1] == '#'){
            flag = false;
        }
    }
    for(int i = b; i <= d; i ++){
        if(ch[i] == '#' && ch[i+1] == '#'){
            flag = false;
        }
    }   
    if(x.second > y.second){
        bool temv_flag = false;
        for(int i = b-1; i < d; i ++){
            if(ch[i] == '.' && ch[i+1] == '.' && ch[i+2] == '.')
                temv_flag = true;
        }
        flag = (flag & temv_flag);
    }
    printf("%s", flag ? "Yes" : "No");
}

Measured memory_bytes: 384
#pragma GCC optimize(3)
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
//#include<windows.h>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define INF 1e9
#define EPS 1e-7
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,b) for(int a=1;a<=b;a++)
#define frev(a,m,n) for(int a=m;a>=n;a--)
#define REP(a,m,n) for(int a=m;a<n;a++)
#define REPN(a,m,n,p) for(int a=m;a<n;a+=p)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define iofopen(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define ifopen(a) freopen(a,"r",stdin);
#define ofopen(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
using namespace std;

double n;
double dp[350][350][350];
int main(){
	cin>>n;
	int x=0,y=0,z=0;
	rep(i,n){
		int a;
		cin>>a;
		if(a==1)x++;
		if(a==2)y++;
		if(a==3)z++;
	}
	rep(k,302){
		rep(j,302){
			rep(i,302){
				double sum=i+j+k;
				if(!sum){
					continue;
				}
				if(i){
					dp[i][j][k]+=(dp[i-1][j][k])*i/n;
				}
				if(j){
					dp[i][j][k]+=(dp[i+1][j-1][k])*j/n;
				}
				if(k){
					dp[i][j][k]+=(dp[i][j+1][k-1])*k/n;
				}
				dp[i][j][k]=(dp[i][j][k]+1)*n/sum;
			}
		}
	}
	cout<<fixed<<setprecision(12)<<dp[x][y][z];
	return 0;
} 

Measured memory_bytes: 290816
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define pi acos(-1)
using ll = long long;
using namespace std;
using namespace __gnu_pbds;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

int counter = 0;


void solve(){
	int n,x,y,q;
	cin>>n;
	vl a(n+1);
	ll sum = 0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum += a[i];
	}
	cin>>q;
	for(int i=0;i<q;i++){
		int x,y;
		cin>>x>>y;
		cout<<sum - a[x] + y<<endl; 
	}
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  int n; cin>>n; for (counter = 0; counter < n; ++counter)
    solve();
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPS(i,n) for(int i=0; i<(n); i++)
#define REPinit(a,n) for(int i=a; i<(n); i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main(int argc, char const *argv[])
{
  int N,D,X;
  cin >> N >> D >> X;

  int Ai;
  int sum = 0;
  REP(N) {
    cin >> Ai;
    sum += ((D+Ai-1)/Ai);
  }
  cout << (X+sum) << endl;

  return 0;
}


Measured memory_bytes: 256
#define pb push_back
#define MX 1e18
#define mod 1000000009
#define ff first
#define ss second
#define for1(i,n) for(int i=1;i<=n;i++)
#define for0(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long unsigned  ll;
int a[100][100];
int main(int argc, char const *argv[]) {
  int n,m;
  cin>>n>>m;
  char c;
  for1(i,n)for1(j,m){
    cin>>c;
    if(c=='#')a[i][j] = 1;
  }
  for1(i,n)for1(j,m){
    if(a[i][j]){
      if(!a[i+1][j] && !a[i-1][j] && !a[i][j+1] && !a[i][j-1]){
        cout<<"No";
        return 0;
      }
    }
  }
  cout<<"Yes";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int fact(int n) {
    int ans = n;
    for (int i = 2; i < n; i++) {
        ans = (ans * i) % MOD;
    }
    return ans;
}

signed main() {
    int n, m;
    cin >> n >> m;
    if (abs(n - m) > 1) {
        cout << 0 << "\n";
        return 0;
    }
    if (n == m) {
        int ans = fact(n);
        cout << (ans * ans * 2) % MOD << "\n";
    }
    else {
        int ans_n = fact(n);
        int ans_m = fact(m);
        cout << (ans_n * ans_m) % MOD << "\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="SUN")
    cout<<7<<endl;
  else if(s=="MON")
    cout<<6<<endl;
  else if(s=="TUE")
    cout<<5<<endl;
  else if(s=="WED")
    cout<<4<<endl;
  else if(s=="THU")
    cout<<3<<endl;
  else if(s=="FRI")
    cout<<2<<endl;
  else if(s=="SAT")
    cout<<1<<endl;
}

Measured memory_bytes: 256
N = int(input())
tList = list(map(int, input().split()))
M = int(input())
pLst = [list(map(int, input().split())) for i in range(M)]
ansLst = [0] * M

for i in range(M):
    tmp = 0
    for j in range(N):
        if j == (pLst[i][0] - 1):
            tmp += pLst[i][1]
        else:
            tmp += tList[j]

    ansLst[i] = tmp

for i in ansLst:
    print(i)

Measured memory_bytes: 3064
a = [int(input())]
flg = False
while flg == False:
    now = a[-1] 

    if a[-1] % 2 == 0:
        new = int(a[-1] / 2)
    else:
        new = int(a[-1] * 3 + 1)

    if new in a:
        flg = True
    else:
        a.append(new)
print(len(a)+1)

Measured memory_bytes: 3060
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
#define waru 1000000000+7

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);     vector<int> b(n);
    rep(i,n){
        cin >> a[i];
        b[i] = a[i];
    }
    // int b = a[0];
    sort(all(a));
    if(a[n-1] == a[n-2]){
        rep(i,n){
            cout << a[n-1] << endl;
        }
    }
    else{
        rep(i,n){
            if(b[i] != a[n-1]){
                cout << a[n-1] << endl; 
            }
            else{
                cout << a[n-2] << endl;
            }
        }
    }

}

Measured memory_bytes: 3200
#include <stdio.h>

int main(){
    int k;
    scanf("%d", &k);
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    printf("%d\n", a[k-1]);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
int main(){
	int n, k, c;
    cin >> n >> k >> c;
    string s; cin >> s;
    vector<int> L, R;
    // L[0] = min possible day to do 1st day work.
    // L[k - 1] = min possible day to do kth day work;
    // R[0] = max possible day to do kth day work;
    // R[k - 1] = max possible day to do (k - (k - 1)) = 1st day work;
    for(int i = 1; i <= n;){
        if(L.size() == k) break;
    	if(s[i - 1] == 'x') i++;
        else{
        	L.push_back(i); i += c + 1;
        }
    }
    for(int i = n; i >= 1;){
    	if(R.size() == k) break;
        if(s[i - 1] == 'x') i--;
        else{
        	R.push_back(i); i -= (c + 1);
        }
    }
    for(int i = 0; i < k; i++){
        if(L[i] == R[k - 1 - i]){
        	cout << (L[i]) << endl;
        }
    }
    return 0;
}

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

namespace atcoderBeginnerContest134
{
    class Program
    {
        static void Main(string[] args)
        {
            IDictionary<int, int> mp = new Dictionary<int, int>();
            int n = Convert.ToInt32(Console.ReadLine());
            int[] A = new int[n];
            for (int i = 0; i < n; ++i)
            {
                 A[i] = Convert.ToInt32(Console.ReadLine());
                if (!mp.ContainsKey(A[i]))
                    mp.Add(A[i], 0);
                ++mp[A[i]];
            }
            int[] mxl = new int[n];
            int[] mxr = new int[n];
            mxl[0] = A[0];
            mxr[n - 1] = A[n - 1];

            for (int i = 1; i < n; ++i)
            {
                mxl[i] = Math.Max(mxl[i - 1], A[i]);
                mxr[n - i - 1] = Math.Max(mxr[n - i], A[n - i - 1]);
            }

            int mx = 0;
            for(int i = 0; i < n; ++i)
            {
                if (i > 0)
                    mx = mxl[i - 1];
                if (i < n - 1)
                    mx = Math.Max(mxr[i + 1], mx);
                Console.WriteLine(mx);
            }
        }
    }
}


Measured memory_bytes: 24276
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;


signed main(){
    
    while(1){
        int n; cin >> n;
        if(n == 0) break;

        vector<pair<int, int>> vec(n);
        for(int i = 0; i < n; i++){
            int a, b, c; cin >> a >> b >> c;
            vec[i] = {b + c, a};
        }

        sort(vec.rbegin(), vec.rend());
        cout << vec[0].second << " " << vec[0].first << endl;
    }
    return 0;
}



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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  int n; cin >> n;
  int as[n];
  map<int, int> input_mp;
  int total = 0;
  REP(i,n) {
    cin >> as[i];
    total += as[i];
    ++input_mp[as[i]];
  }
  int q; cin >> q;
  int bs[q], cs[q];
  REP(i,q) {
    cin >> bs[i] >> cs[i];
  }
  REP(i,q) {
    int b = input_mp[bs[i]];
    total += b * (cs[i] - bs[i]);
    input_mp[bs[i]] = 0;
    input_mp[cs[i]] += b;
    cout << total;
    cout << "\n";
  }
  
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 11872
//abc095_a.cpp
//Sat Apr 21 20:18:11 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

int main(){
	string s;
	cin >> s;

	int cost = 0;
	if (s[0] == 'o'){
		cost = cost+100;
	}
	if (s[1] == 'o'){
		cost = cost+100;
	}
	if (s[2] == 'o'){
		cost = cost+100;
	}

	cost = cost+700;

	cout << cost << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    g = defaultdict(lambda : None)
    g[(0,0)] = 0
    def grundy(w,b):
        if g[(w,b)] != None:
            return g[(w,b)]
        s = set()
        if w:
            s.add(grundy(w-1,b))
        if b:
            s.add(grundy(w+1,b-1))
        for i in range(1,min(w,b)+1):
            s.add(grundy(w,b-i))
        i = 0
        while i in s:
            i += 1
        g[(w,b)] = i
        return i

    n = I()
    ans = 0
    for _ in range(n):
        w,b = LI()
        ans ^= grundy(w,b)
    print(0 if ans else 1)
    return

#Solve
if __name__ == "__main__":
    solve()



Measured memory_bytes: 7960
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	String name;
	int len;
	boolean[] position = new boolean[101];
	
	boolean check(String s,int index, int pos) {
		if (index == len) {
			int c = -1, d = -1;
			for (int i = 0; i < s.length(); i++) {
				if (position[i]) {
					if (c < 0)
						c = i;
					else {
						if (d < 0) {
							d = i - c;
							c = i;
						} else {
							if (d != i - c) return false;
							else c = i;
						}
					}
				}
			}
			return true;
		} else {
			boolean flag = false;
			while (pos < s.length()) {
				if (s.charAt(pos) == name.charAt(index)) {
					position[pos] = true;
					flag = flag || check(s, index+1, pos+1);
					position[pos] = false;
				}
				pos++;
			}
			return flag;
		}
	}
	
	void run() {
		int n = sc.nextInt();
		name = sc.next();
		len = name.length();
		int res = 0;
		for (int i = 0; i < n; i++)
			if (check(sc.next(), 0, 0))
				res++;
		out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 21684