akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
const ll mod = 1e9 + 7;

int main()
{
    string s;
    cin >> s;
    ll count = 0, ans = 0;
    rep(i, s.length())
    {
        if (s[i] == 'W')
            ans += count;
        else
            count++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,wa,s;
	long long ans=0;
	cin>>n;
	vector<int>h(n),sa(500000);
	rep(i,n)cin>>h[i];
	for(int i=n-1;i>=0;i--){
	    wa=i+h[i];
	    if(wa<500000)ans+=sa[wa];
	    s=i-h[i];
	    if(s>=0)sa[s]++;
	}
	cout<<ans;
	
	
	return 0;
}


Measured memory_bytes: 5896
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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 namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	VE a(n); rep(i, n)cin >> a[i];
	sort(ALLR(a));
	rep(i, min(k,n))a[i] = 0;
	int ans = 0;
	rep(i, n)ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
s = gets.chop
len = s.size()
bit_len = 1 << (len - 1)
ans = 0
for b in 0..bit_len-1 do
    num= s[0].ord - '0'.ord
    for i in 0..len-2 do
        if (1 << i) & b != 0 then
            ans += num
            num= 0
        end
        num= num* 10 + s[i+1].ord - '0'.ord
    end
    ans += num
end
 
p ans 

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int N = 200005;

int n;
int A[N];

int main() {
    
    scanf("%d", &n);
    
    for (int i = 1; i <= n; i++) {
        scanf("%d", &A[i]);
    }
    
    sort(A + 1, A + 1 + n);
    
    long long ans = 0;
    int ptr = n;
    for (int i = 2; i <= n; i++) {
        ans += A[ptr];
        if (i % 2 == 0) ptr--;
    }
    printf("%lld\n", ans);

    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  auto good = [](int n) {return n % 3 == 0 || n % 5 == 0;};

  int n; cin >> n;
  bool ok = true;
  for (int i = 0; i < n; i++) 
  {
    int a;
    cin >> a;
    if (a % 2 == 0)
      ok &= good(a);
  }

  cout << (ok ? "APPROVED" : "DENIED") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <math.h>
#include <deque>
#include <stack>

using namespace std;

typedef long long ll;

int main(void){
    double a,b;
    cin >> a >> b;
    ll k = (a + b) / 2;
    if((double)k == (double)((a + b) / 2)){
        cout << k << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSData *stdinData = [[NSFileHandle fileHandleWithStandardInput] availableData];
        NSString *s = [[NSString alloc] initWithData:stdinData encoding:NSUTF8StringEncoding];
        NSArray *l = [s componentsSeparatedByString:@" "];
        NSInteger A = [[l objectAtIndex:0] integerValue];
        NSInteger B = [[l objectAtIndex:1] integerValue];
        NSInteger C = [[l objectAtIndex:2] integerValue];
        NSInteger D = [[l objectAtIndex:3] integerValue];
        
        NSString *answer;
        if(A+B==C+D){answer=@"Balanced";}
        else if(A+B>C+D){answer=@"Left";}
        else{answer=@"Right";}
        
        NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
        [fileHandle writeData:[answer dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle writeData:[@"\n" dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle closeFile];
    }
    return 0;
}


Measured memory_bytes: 4140
s = input()

A = [1,0]
AB = 0
ABC = 0
D = 10**9 + 7
for c in s:
    if c == 'A':
        A[1] += A[0]
    elif c == 'B':
        AB += A[1]
    elif c == 'C':
        ABC += AB
    elif c == '?':
        ABC = (((ABC%D) *3)%D + (AB)%D)%D
        AB = (((AB%D) *3)%D + (A[1])%D)%D
        A[1] = (((A[1]%D)*3)%D + A[0]%D)%D
        A[0] = ((A[0]%D) * 3)%D

print(ABC%D) 


Measured memory_bytes: 3188
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let rec f i b =
  if i >= n then if b then 1 else 0
  else let ft, fb = f (i + 1) true, f (i + 1) b in if a_s.(i) mod 2 = 0 then ft + 2 * fb else fb + 2 * ft
let _ = Printf.printf "%d\n" @@ f 0 false

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define REP(type,i,n) for(type i=0;i<(n);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second

typedef long long int lli;
typedef pair<int,int> Pi;

const int INF=100000000;
const long long int INF_=1000000000000000000;

int dy[4]={0,1,0,-1},dx[4]={1,0,-1,0}; 
vector<int> parent,rank;

void Init(int n){
	parent.resize(n);
	rank.resize(n);
	REP(int,i,n){
		parent[i]=i;
		rank[i]=0;
	}
}

int Find(int x){
	if(parent[x]==x) return x;
	else return parent[x]=Find(parent[x]);
}

void Unite(int x,int y){
	x=Find(x);
	y=Find(y);
	if(x==y) return;
	if(rank[x]<rank[y]){
		parent[x]=y;
	} else {
		parent[y]=x;
		if(rank[x]==rank[y]) ++rank[x];
	}
}

bool Same(int x,int y){
	return Find(x)==Find(y);
}

int serialize(const int y,const int x,const int width){
    return y*width + x;
}

bool IsIn(const int y,const int x,const int height,const int width){
	return 0<=y&&y<height&&0<=x&&x<width;
}

int main(){
	int W,H;
	cin >> W >> H;
	Init(W*H);
	vector<string> field(H);
	int goal_id;
	int start_id=serialize(0,0,W);
	REP(int,i,H){
		cin >> field[i];
		int idx=field[i].find('t');
		if(idx!=string::npos){
			goal_id=serialize(i,idx,W);
		}
	}
	REP(int,i,H){
		REP(int,j,W){
			if(field[i][j]=='#') continue;
			REP(int,k,4){
				int ny=i+dy[k],nx=j+dx[k];
				if(!IsIn(ny,nx,H,W)||field[ny][nx]=='#') continue;
				Unite(serialize(i,j,W),serialize(ny,nx,W));
			}
		}
	}
	int N;
	cin >> N;
	vector<Pi> query(N);
	REP(int,i,N){
		cin >> query[i].S_ >> query[i].F_;
	}
	int ans=-1;
	if(Same(start_id,goal_id)){
		ans=0;
	} else {
		REP(int,i,N){
			int y=query[i].F_,x=query[i].S_;
			if(field[y][x]=='.') continue;
			field[y][x]='.';
			REP(int,j,4){
				int ny=y+dy[j],nx=x+dx[j];
				if(!IsIn(ny,nx,H,W)||field[ny][nx]=='#') continue;
				Unite(serialize(y,x,W),serialize(ny,nx,W));
			}
			if(Same(start_id,goal_id)){
				ans=i+1;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

ll mod_add(ll a, ll b)
{
    a%=MOD;
    b%=MOD;
    return (a+b+MOD)%MOD;
}

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

    ll n,k;
    cin >> n >> k;

    ll ans = 0;

    REP(i,k,n+2)
    {
        // [k,n+1]
        // cout << i << endl;
        ans = mod_add(ans, i*(n-i+1)+1);
    }
    cout << ans << endl;
}




Measured memory_bytes: 3652
#include <stdio.h>          // printf(), scanf()

#define MAX_M 8

const char NUL = '\0';

int
main(int argc, char **argv)
{
	char field[2][MAX_M][MAX_M + 1];

	for (int i = 0; i < MAX_M; ++i)
		scanf("%s", &field[0][i][0]);

	printf("90\n");
	for (int y = 0; y < MAX_M; ++y)
	{
		for (int x = 0; x < MAX_M; ++x)
			field[1][x][MAX_M - y - 1] = field[0][y][x];
	}

	for (int x = 0; x < MAX_M; ++x)
		field[1][x][MAX_M] = NUL;

	for (int y = 0; y < MAX_M; ++y)
		printf("%s\n", &field[1][y][0]);

	printf("180\n");
	for (int y = 0; y < MAX_M; ++y)
	{
		for (int x = 0; x < MAX_M; ++x)
			field[1][MAX_M - 1 - y][MAX_M - 1 - x] = field[0][y][x];

		field[1][MAX_M - 1 - y][MAX_M] = NUL;
	}

	for (int y = 0; y < MAX_M; ++y)
		printf("%s\n", &field[1][y][0]);

	printf("270\n");
	for (int y = 0; y < MAX_M; ++y)
	{
		for (int x = 0; x < MAX_M; ++x)
			field[1][MAX_M - 1 - x][y] = field[0][y][x];
	}

	for (int x = 0; x < MAX_M; ++x)
		field[1][x][MAX_M] = NUL;

	for (int y = 0; y < MAX_M; ++y)
		printf("%s\n", &field[1][y][0]);

	return 0;
}

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

int main()
{
    int x;
    int t = 0;
    cin >> x;
    while (x > 0)
    {
        t++;
        x -= t;
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
const int INF = 1e9;
const double pi = acos(-1.0);
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
int main(){
    ll h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    ll time = h2*60 + m2 - h1*60 - m1;
    //cout << time << endl;
    cout << time - k << endl;

    return 0;
}  

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long cnt = 0;
		long sum1 = 0;
		long sum2 = 0;
		while(sc.hasNext()) {
			String[] s = sc.nextLine().split(",");
			cnt++;
			int a = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);
			sum1 += a * b;
			sum2 += b;
		}
		sc.close();
		long mean = (long)Math.round((double)sum2 / cnt);
		System.out.printf("%d\n%d\n", sum1, mean);
	}
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long result = 0;
    if (a[0] != 0) {
        result = -1;
    } else {
        for (int i = 1; i < n; i++) {
            if (a[i] == a[i - 1] + 1) {
                result++;
            } else if (a[i] - a[i - 1] > 1) {
                result = -1;
                break;
            } else {
                result += a[i];
            }
        }
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
struct node
{
	int x,y;
	bool operator < (const node &b) const{
		return atan2(y,x)<atan2(b.y,b.x);
	}
}a[109];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=0;i<n;i++)
		scanf("%d%d",&a[i].x,&a[i].y);
	sort(a,a+n);
	long long ans=-1;
	for (int i=0;i<n;i++)
	{
		int x=0,y=0;
		for (int j=0;j<n;j++)
		{
			x+=a[(i+j)%n].x;
			y+=a[(i+j)%n].y;
			ans=max(ans,1ll*x*x+1ll*y*y);
		}
	}
	printf("%.16lf\n",sqrt(ans));
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;

signed main() {
    V(string) c(3);
    rep(i, 3) cin >> c[i];
    cout << c[0][0] << c[1][1] << c[2][2] << endl;

    return 0;
}

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


int main(){
    int N; cin >> N;
    int dp[100001]; rep(i,100001) dp[i] = N+1;
    dp[0] = 0;
    for (int i = 0; i <= N; i++)
    {
        for (int six = 1; i -six >= 0; six *= 6)
        {
            dp[i] = min(dp[i],dp[i - six] + 1);
        }
        for (int nine = 9; i - nine >= 0; nine *= 9)
        {
            dp[i] = min(dp[i],dp[i - nine] + 1);
        }
    }
    cout << dp[N] << endl;
}

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

int main(){
  string S;
  cin >> S;
  
  if(S == "Sunny"){
    cout << "Cloudy" << endl;
  } else if(S == "Cloudy"){
    cout << "Rainy" << endl;
  } else {
    cout  << "Sunny" << endl;
  }
  
}

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

int main() {
    int a, b, c, s;
    cin >> a >> b >> c;
    s = a + b + c;

    if (s >= 22) {
        cout << "bust" << endl;
    }

    else {
        cout << "win" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		
		long min = 2, max = 2;
		for (int i = n - 1; i >= 0; i--) {
			min = (min + a[i] - 1) / a[i] * a[i];
			max = max / a[i] * a[i];
			if (min > max) {
				out.println(-1);
				return;
			}
			
			max += a[i] - 1;
		}
		out.println(min + " " + max);
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


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

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

typedef long long ll;

using namespace std;

int dp[101000];

int main(){
  int x;
  cin >> x;
  dp[0] = 1;
  rep(i,100000){
    if(dp[i] == 1){
      dp[i+100] = 1;
      dp[i+101] = 1;
      dp[i+102] = 1;
      dp[i+103] = 1;
      dp[i+104] = 1;
      dp[i+105] = 1;
    }
  }
  if(dp[x] == 1) cout << 1 << endl;
  else           cout << 0 << endl;
}


Measured memory_bytes: 640
#include <cstdio>

using namespace std;

int n, m, q;
struct student{
  bool canBeExempted;
  int next;
  int before;
};
student students[200000];

int main(){
  scanf("%d %d %d", &n, &m, &q);
  for(int i = 0; i < n; i++){
    students[i].canBeExempted = true;
    students[i].next = (i + 1) % n;
    students[i].before = (i + n - 1) % n;
  }
  int haveBaton = 0;
  for(int i = 0; i < m; i++){
    int a;
    scanf("%d", &a);
    if(a % 2){
      while(a--){
        haveBaton = students[haveBaton].before;
      }
    }
    else{
      while(a--){
        haveBaton = students[haveBaton].next;
      }
    }
    students[haveBaton].canBeExempted = false;
    students[students[haveBaton].before].next = students[haveBaton].next;
    students[students[haveBaton].next].before = students[haveBaton].before;
    haveBaton = students[haveBaton].next;
  }
  for (int i = 0; i < q; i++) {
    int num;
    scanf("%d", &num);
    printf("%d\n", students[num].canBeExempted ? 1 : 0);
  }
  return 0;
}

  

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

public class Remainder
{
    static public void Main ()
    {
        var N  = int.Parse(Console.ReadLine());
        var inf = new long[N-1,3];
        
        for(int i = 0;i < N-1; i++){
            var CSF = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            inf[i,0] = CSF[0];
            inf[i,1] = CSF[1];
            inf[i,2] = CSF[2];
        }
        
        //1の駅からN-1の駅までスタートした時
        for(int i =1;i < N ;i++){
            
            //乗車時間
            var time = 0L;
            //現在位置
            var point = i;
            
            //スタート地点からN駅につくまでの電車の乗車時間を求める
            while(point < N){
                //pointからpoint+1への移動
                
                //始発に間に合うか
                if(time <= inf[point-1,1]){
                    time = inf[point-1,1] + inf[point-1,0];
                }else{
                    var f = inf[point-1,2];
                    if(time%f ==0){
                        time += inf[point-1,0];
                    }else{
                        time += inf[point-1,0]+(f-(time%f));
                    }
                }
               
                
                point++;
            }
            Console.WriteLine(time);
        }
        
        Console.WriteLine(0);

    }

}


Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//ダイクスト①
//O(n^2)
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

#define V_MAX   1010
#define E_MAX   V_MAX(V_MAX-1)/2

int N, M;
int A, B, C;
int s, g;
priority_queue< cp2, vector<cp2>, greater<cp2> >pq;
vector< cp2 >P[V_MAX];
int d[V_MAX];
bool flag[V_MAX];
cp2 base;
int idx;
int dist;
int num;

void dijkstra( int S ){
	fill( d, d+V_MAX, -1 );
	fill( flag, flag+V_MAX, 1 );
	
	d[S] = 0;
	pq.push( cp2( 0, S ) );
	while( !pq.empty() ){
		base = pq.top();
		pq.pop();
		if( !flag[base.se] ) continue;
		flag[base.se] = 0;
		REP( i, P[base.se].size() ){
			idx = P[base.se][i].se;
			dist = P[base.se][i].fi;
			if( d[idx] < 0 ) d[idx] = dist+base.fi;
			d[idx] = min( d[idx], dist+(int)base.fi );
			if( flag[idx] ) pq.push( cp2( d[idx], idx ) );
		}
	}	
}

int ans = 0;

int main(){
	
	cin>>N>>M;
	//cin>>s>>g;
	
	REP( i, M ){
		scanf("%d %d %d", &A, &B, &C);
		P[A].push_back( cp2( C, B ) );
		P[B].push_back( cp2( C, A ) );
	}
	
	FOR( i, 1, N+1 ){
		dijkstra( i );
		REP( j, P[i].size() ){
			if( P[i][j].fi != d[P[i][j].se] ) ans++;
		}
	}
	
	ans /= 2;
	
	cout<<ans<<endl;
	
	return 0;
	
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
  long n,k,x,y;
  cin >> n >> k >> x >> y;
  if(n<=k){
    cout << x*n << endl;
    return 0;
  }
  cout << x*k+y*(n-k) << endl;
} 
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int  
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define fi first
#define se second
#define mp make_pair
int main() {
ll i,n;
bool flag=1;
int a[26],b[26];
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
string s,t;
cin>>s;
cin>>t;
n=s.length();
if(s!=t)
{
for(i=0;i<s.length();i++)
{
    //swap(s[i],s[n-1-i]);
    char sc=s[n-1];
    string ss=s.substr(0,n-1);
    ss=sc+ss;
    s=ss;
    //cout<<"s "<<s<<endl;

     if(s==t)
     {
       break;
     }
}
if(s!=t)
{
  flag=0;
}

}
if(flag)
{
  cout<<"Yes"<<endl;
}
else
{
  cout<<"No"<<endl;
}


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define nl cout<<'\n'
#define pb push_back
#define vi vector<lli>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

void solve(){
	lli n, x, t; cin >> n;
	cin >> x >> t;
	lli ans = (n/x + (n%x!=0)) * t;
	cout << ans;
	return;
}

int main(){
    fastIO;
    lli t = 1;
	// cin >> t;
	NA(i,0,t) solve();
	return 0;
}



Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <cassert>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
int main(){

	int N;
	cin >> N;
	int W[N];
	for(int i = 0; i < N; i++){
		cin >> W[i];
	}
	int ans = 100;
	for(int j = 0; j < N; j++){
		int x = 0, y = 0;
		for(int k = 0; k < j; k++){
			x = x + W[k];
		}
		for(int l = j; l < N; l++){
			y = y + W[l];
		}
		if(abs(x - y) < ans){
			ans = abs(x - y);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<numeric>
#include<limits>
#include <cstdint>
#include<stack>
#include<queue>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define rep2(N1,N2) for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)for(ll k=0;k<N3;k++)
#define For(i,N) for(ll i=0;i<N;i++)

void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll kai(ll x) {
	ll a = 1;
	if (x <= 0)
		return 1;
	else {
		for (ll i = 0; i < x; i++)
			a = a * (i + 1);
		return a;
	}
}

ll rui(ll x, ll y) {
	ll a = 1;
	for (ll i = 0; i < y; i++)
		a = a * x;
	return a;
}
const int nmax = 150;
int cccc[nmax][nmax];
ll comb(ll n, ll k) {
	if (n < k) {
		cout << "error n<k" << endl;
		return -1;
	}
	if (cccc[n][k] > 0)return cccc[n][k];
	if (k == 0 || n == k)return 1;
	return cccc[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}

ll keta(ll a) {
	ll i = 1;
	while (1) {
		if (a < pow((ll)10, i))
			return i;
		i++;
	}
}
vector<ll> v;
ll n, m;
//m進数全探索
ll inc(ll a = n - 1) {
	if (a == 0 && v[0] == m) {
		v[0] = -1;
		return v[0];
	}
	if (v[a] == m) {
		v[a] = 0;
		inc(a - 1);
		return v[a];
	}
	else {
		++v[a];
		return v[a];
	}
}

ll mod = 1e9+7;

ll modkai(ll a) {
	ll ret = 1;
	rep(a) {
		ret *= (i + 1);
		ret %= mod;
	}
	return ret;
}

ll modpowl(ll a, ll b) {
	if (b == 0) {

		return 1;
	}
	if (b == 1) {

		return a;
	}
	if (b >= 2) {
		if (b % 2 == 0) {
			ll c = modpowl((a*a) % mod, b / 2);
			c = c % mod;

			return c;
		}
		else {
			ll c = (modpowl((a*a) % mod, b / 2) % mod)*a;
			c = c % mod;

			return c;
		}
	}
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

ll llpow(ll a, ll b) {
	if (b == 0) {

		return 1;
	}
	if (b == 1) {

		return a;
	}
	if (b >= 2) {
		if (b % 2 == 0) {
			ll c = llpow((a*a), b / 2);
			c = c;

			return c;
		}
		else {
			ll c = (llpow((a*a), b / 2))*a;
			c = c;

			return c;
		}
	}
}
std::vector<ll> Eratosthenes(ll N)
{
	std::vector<bool> is_prime(N + 1);
	for (ll i = 0; i <= N; i++)
	{
		is_prime[i] = true;
	}
	std::vector<ll> P;
	for (ll i = 2; i <= N; i++)
	{
		if (is_prime[i])
		{
			for (ll j = 2 * i; j <= N; j += i)
			{
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

int main() {
	ll A, B, K;
	cin >> A >> B >> K;
	if (A >= K)
		cout << A - K << " " << B;
	else if (A + B >= K)
		cout << 0 <<" " <<A + B - K;
	else
		cout<<0<<" " <<0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll mp[3][3];
  ll N;
  REP(i,3) {
    REP(j,3) {
      cin >> mp[i][j];
    }
  }
  cin >> N;
  REP(k, N) {
    ll b; cin >> b;
    REP(i, 3) REP(j, 3) if (b == mp[i][j]) mp[i][j] = 0;
  }
  REP(i, 3) {
    bool ok = true;
    REP(j, 3) {
      ok = ok && mp[i][j] == 0;
    }
    if (ok) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  REP(j, 3) {
    bool ok = true;
    REP(i, 3) {
      ok = ok && mp[i][j] == 0;
    }
    if (ok) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if (mp[0][0] == 0 && mp[1][1] == 0 && mp[2][2] == 0) {
    cout << "Yes" << endl;
    return 0;
  }    
  if (mp[0][2] == 0 && mp[1][1] == 0 && mp[2][0] == 0) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    double x, y;
    cin >> x >> y;
    printf("%.10f\n", x*y/(x+y));
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInts >>= putStrLn . which "Yay!" ":(" . ( <= 8 ) . maximum

Measured memory_bytes: 508
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
	int n;
	cin >> n;
	double d = 100000;
	while (n--)
	{
		d += 5. / 100 * d;
		d = ceil(d / 1000) * 1000;
	}
	cout << fixed << setprecision(0) << d << endl;
	return 0;
}

Measured memory_bytes: 3244
/*
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
//*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) cout << x , exit(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

string s;
int n;
int nxt[maxn] , prv[maxn];

int32_t main(){
    migmig
    cin >> s;
    for(int i = 0 ; i < s.size() ; i ++)
        prv[i] = i-1 , nxt[i] = i + 1;
    int cur = 0;
    while(1){
        int ans = -1;
        for(int i = nxt[0] ; i < s.size()-1 ; i = nxt[i]){
            if(s[prv[i]] != s[nxt[i]]){
                ans = i;
                break;
            }
        }
        if(ans == -1){
            if(cur == 0)
                dokme("Second")
            else
                dokme("First")
        }
        nxt[prv[ans]] = nxt[ans];
        prv[nxt[ans]] = prv[ans];
        cur = 1 - cur;
    }
    return(0);
}

Measured memory_bytes: 4576
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define Swap(a,b) {int temp=a;a=b;b=temp;}
typedef long long ll;
typedef unsigned long long ull;

int main(){
    string x;
    cin>>x;
    if(x[x.length()-1]=='s') cout<<x<<"es";
    else cout<<x<<'s';
}


Measured memory_bytes: 3624
import java.util.*;
import java.io.*;

public class Main {
	static FastReader in = new FastReader();

	public static void main(String[] args) {
		solve();
	}

	static void solve() {
		String[] n = in.nextLine().split("");
		long x = 0l;
		for(int i = 0; i < n.length; i++)
		{
			x += Integer.valueOf(n[i]);

		}
		System.out.println(x % 9 == 0 ? "Yes" : "No");
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		int[] readarr(int abc) {
			int[] a = new int[abc];
			for (int i = 0; i < abc; i++)
				a[i] = nextInt();
			return a;
		}
	}
}





Measured memory_bytes: 49664
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;
int n ; 
bool ok(vector<int> &v,vector<int> &ans){
	for(int i=0;i<n;i++){
		if ( v[i] != ans[i] ) return false ;
	}
	return true ; 
}

int main(){
    cin >> n ; 
    vector<int> v(n) ;
    for(int &x : v){
    	cin >> x ; 
    }
    int ans = 0 ; 
    while((int)v.size()){
    	debug() << "Before : " imie(v) ; 
    	while( (int) v.size() && v[0] == 0 ){
    		v.erase(v.begin()) ; 
    	}
    	while( (int) v.size() && v[(int)v.size()-1] == 0 ){
    		v.pop_back() ; 
    	}
    	for(int i=0;i<(int)v.size()-1;i++){
    		while ( v[i] == 0 && v[i+1] == 0 ) {
    			v.erase(v.begin()+i) ; 
    		}
    	}
    	debug() << "After : " imie(v) ; 
    	int cnt = 0 ; 
    	bool ok = false ; 
    	for(int i=0;i<(int)v.size();i++){
    		ok = true ; 
    		if ( v[i] > 0 ) v[i]--;
    		else cnt++ ; 
    	}
    	if ( ok ) ans += cnt + 1 ; 
    	debug() << imie(ans) ; 
    }
    cout << ans << endl;
    return 0 ;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int amax;
  int amin;
  
  if(a >= b+c){
    amin = 0;
  }else{
    amin = b+c - a;
  }
  amax = min(b,c);
  cout << amax << " " << amin << endl;
  return 0;
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a;
		a = Integer.parseInt(sc.next());
		a = Integer.parseInt(sc.next());
		a = Integer.parseInt(sc.next());
		a = Integer.parseInt(sc.next());

		System.out.println(a == 1 ? 1 : 0);

	}
}


Measured memory_bytes: 35316
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
    public static void main(String[] args) throws IOException{
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            StringBuilder sb = new StringBuilder();
            int[] counter = new int[26];
            String line; 
            //line = br.readLine();
            char ch = 'a';
            //char[] c = line.toCharArray();
            while((line = br.readLine())!=null){
                char[] c = line.toCharArray();
                for(int i = 0; i < c.length; i++){
                    if( c[i] >= 'A' && c[i] <= 'z' ){
                        if( Character.isUpperCase(c[i]) ){
                            c[i] = Character.toLowerCase(c[i]);
                        }
                        int num = c[i] - 'a';
                        counter[num]++;
                    }
                }
            }
             
            for(int i = 0; i < counter.length; i++){
                System.out.println( ch++ + " : " + counter[i]);
            }
        }catch(IOException e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 24160
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
int n;
struct data{
    int a,b;
}a[N];
bool operator<(const data&a,const data&b){
   return a.b<b.b;
}
int main(){
    cin>>n;
    for(int i=1;i<=n;++i){
        scanf("%d%d",&a[i].a,&a[i].b);
	}
	sort(a+1,a+n+1);
	int sum=0;
	for(int i=1;i<=n;++i){
	    sum+=a[i].a;
	    if(sum>a[i].b){
	        puts("No");
	        return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

int main() {
  long long a,ans;
  cin >> a;
  ans = abs(a%1000-753);
  for(long long i = 10;i < 10000000000000;i = i*10){
    if(abs((a%(i*1000)/i)-753) < ans){
      ans = abs((a%(i*1000)/i)-753);
    }
    if(a/(i*1000) == 0){
      break;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

vector<int_fast64_t> divisor(int_fast64_t n) {
    vector<int_fast64_t> ret;
    for (int_fast64_t i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    size_t N, M;
    cin >> N >> M;
    int64_t maxv = 0;
    for (auto &e : divisor(M)) {
        if (e * N <= M) {
            maxv = max(maxv, e);
        }
    }
    cout << maxv << "\n";
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
V = list(map(int, input().split()))
ret = 0

m = min(N, K)
for l in range(m+1):
    for r in range(m+1-l):
        hold = V[:l] + V[N-r:]
        hold.sort()
        for d in range(K+1-l-r):
            ret = max(ret, sum(hold[d:]))

print(ret)

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

int main(){
  int N;
  vector<vector<int> > A;
  cin >> N;
  A.resize(2);
  for(int i=0;i<2;i++) A[i].resize(N);
  for(int i=0;i<2;i++){
    for(int j=0;j<N;j++){
      cin >> A[i][j];
    }
  }


  int MAX=-1;
  for(int num=0;num<N;num++){
    int sum=0.0;
    int i=0;
    for(int j=0;j<N;j++){
      sum+=A[i][j];
      if(j==num){
	i+=1;
	sum+=A[i][j];
      }
    }
    if(sum>MAX)MAX=sum;
  }
  cout <<MAX<<endl;
  
}


Measured memory_bytes: 256
def main():
    K=int(input())
    total=[9, 35, 110, 327, 956, 2782, 8089, 23527, 68468, 199368]
    if K<10:
        print(K)
    else:
        for i in range(9):
            if total[i]<K and total[i+1]>=K:
                a=[1,2,3,4,5,6,7,8,9]
                for j in range(i+1):
                    b=[]
                    for k in range(len(a)):
                        if a[k]%10==0:
                            b.append(10*a[k])
                            b.append(10*a[k]+1)
                        elif a[k]%10==9:
                            b.append(10*a[k]+8)
                            b.append(10*a[k]+9)
                        else:
                            b.append(10*a[k]+a[k]%10-1)
                            b.append(10*a[k]+a[k]%10)
                            b.append(10*a[k]+a[k]%10+1)
                    a,b=b,a
                print(a[K-total[i]-1])
if __name__=="__main__":
    main()

Measured memory_bytes: 10724
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>

 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

int N;
int ans=0;
signed main(){
    scanf("%lld",&N);
    printf("%lld\n",180*(N-2));
}




Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
	chutiyaap;
	int i,n;cin>>n;
	string s;cin>>s;
	int cnt=0,r=0,cnt2=0,w=0;
	for(i=0;i<n;i++)if(s[i]=='R')r++;
	for(i=0;i<n;i++)
	{
		if(r==0)break;
		if(s[i]=='W')
		{
			r--;
			cnt++;
		}
		else r--;
	}
	cout<<cnt;
}


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

int main() {
	// your code goes here
	string in;
	while(cin >> in){
		int len=in.length();
		int joi=0,ioi=0;
		for(int i=0;i<len-2;i++){
			if(in.at(i)=='J'&&
			 in.at(i+1)=='O'&&
			 in.at(i+2)=='I')
				joi++;
		}
		for(int i=0;i<len-2;i++){
			if(in.at(i)=='I'&&
			 in.at(i+1)=='O'&&
			 in.at(i+2)=='I')
				ioi++;
		}
		cout << joi << endl << ioi << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a;
int main()
{
	  cin>>a;
	  if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
	  {
	  	cout<<"vowel"<<endl;
	  }
	  else
	  cout<<"consonant"<<endl;
 
 
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    n, m = rl()
    roads = dd(set)
    heights = rl()
    for i in range(m):
        u, v = rl()
        roads[u].add(v)
        roads[v].add(u)

    good = 0
    for i in range(1, n + 1):
        for nbr in roads[i]:
            if heights[nbr - 1] >= heights[i - 1]:
                break
        else:
            good += 1

    print (good)






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


Measured memory_bytes: 121096
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define MEM(a,b) memset(a,b,sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	REP(i, n) {
		int x;
		cin >> x;
		while (x >= 2){
			if (x % 2 == 0) {
				x /= 2;
				ans++;
			}
			else break;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
 	int D, T, S;
    cin >> D >> T >> S;
 
    
    int dist = S * T;
 
    
    if (dist >= D) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li sum[200200];

int main() {
    string s;
    cin >> s;
    li n = sz(s);
    sum[0] = 0;
    li ju = 1;
    rin{
        li pos = n - 1 - i;
        sum[i + 1] = (sum[i] + (s[pos] - '0') * ju) % 2019;
        ju = (ju * 10) % 2019;
    }

    li res = 0;
    map<li, li> cnt;
    rep(i, n + 1) {
        res += cnt[sum[i]];
        cnt[sum[i]]++;
    }
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 5140
S = input()
digits = list(map(int, S))
divisor = 2019

rem_count = [0] * divisor
rem_count[0] = 1
num = 0
pow10 = 1
total = 0

for digit in reversed(digits):
    num += digit * pow10
    rem = num % divisor
    total += rem_count[rem]
    pow10 *= 10
    rem_count[rem] += 1

    # optimization to not deal with big integers
    num = rem
    pow10 %= divisor

print(total)


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

/*void sort(int* array, int index){
    bool finish = true;
    while(finish){
        finish = false;
        for(int i = 1; i < index; i++){
            if(array[i - 1] > array[i]){
                int temp = array[i - 1];
                array[i - 1] = array[i];
                array[i] = temp;
                finish = true;
            }
        }
    }
}*/

int main(void){
    while(true){
        int n;
        cin >> n;
       if(n == 0){
          break;
       }
        int players[n];
        for(int i = 0; i < n; i++){
            players[i] = 0;
        }
        char deck[100];
        cin >> deck;
        int field = 0;
        for(int i = 0; i < 100; i++){
            if(deck[i] == 'S'){
                field += players[i%n] + 1;
                players[i%n] = 0;
            }else if(deck[i] == 'M'){
                players[i%n]++;
            }else if(deck[i] == 'L'){
                players[i%n]++;
                players[i%n] += field;
                field = 0;
            }
        }
        sort(players, players + n);
        for(int i = 0; i < n; i++){
            cout << players[i] << ' ';
        }
        cout << field << endl;
    }
}

Measured memory_bytes: 3152