akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mid (tl+tr)/2
#define mod 1000000007
#define fain(arr) for(ll i=0;i<n;i++)cin>>arr[i];
#define all(x) x.begin(),x.end()
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bugv(n1) if(DEBUG)cout<<#n1<<" is "<<n1<<'\n';
#define buga(A) cout<<#A<<" is :"<<endl ; for(auto x:A)cout<<x<<" "; cout<<endl;
#define FILE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ll long long 
#define pii pair<ll,ll>
#define pll pair<long long ,long long >
#define pi acos(-1)
#define sz(x) ((ll)x.size())
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define DEBUG true
using namespace std;

char getleft(char a,char b){
	if(a!='R'&&b!='R')return 'R';
	else if(a!='G'&&b!='G') return 'G';
	return 'B';
}

int main(){
	// FILE;
	SPEED;
	ll n;
	cin>>n;

	string s;
	cin>>s;
 	
 	ll arr[n][3];

 	arr[n-1][0]=(s[n-1]=='R');
 	arr[n-1][1]=(s[n-1]=='G');
 	arr[n-1][2]=(s[n-1]=='B');

 	for(ll i=n-2;i>=0;i--){
 		for(ll j=0;j<3;j++){
 			arr[i][j]=arr[i+1][j];
 		}
	 	arr[i][0]+=(s[i]=='R');
	 	arr[i][1]+=(s[i]=='G');
	 	arr[i][2]+=(s[i]=='B');
 	}

 	ll ans=0;

 	unordered_map<char,ll> m1;

 	m1['R']=0;
 	m1['G']=1;
 	m1['B']=2;

	for(ll i=0;i<s.length();i++){
		for(ll j=i+1;j<s.length()-1;j++){
			if(s[i]==s[j])continue;
			char req = getleft(s[i],s[j]);
			ll nks = arr[j+1][m1[req]];

			if((j-i+j<n)&&s[j-i+j]==req)nks--;

			ans+=nks;

		}
	}

	cout<<ans<<endl;
}


Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (true) {
            String m = scan.next();
            if (m.equals("-")) break;
            int x = scan.nextInt();
            for (int i = 0; i < x; i++) {
                int h = scan.nextInt();
                m = m.substring(h) + m.substring(0, h);
            }
            System.out.println(m);
        }
    }
}

Measured memory_bytes: 26396
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#define Endl endl

typedef  long long ll ;
using namespace  std;
ll mod=1e9+7;




int main(){


    int n;cin>>n;
    map<string,int>mp;

    for(int i=0;i<n;i++){
        string tt;cin>>tt;
        mp[tt]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;

    return 0;
}


Measured memory_bytes: 3256
/*** akshaykumar99 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 1e5+1;
 
typedef long long ll;
typedef long double ld;

ll n, m, x, ans=LINF;
vector<ll> v[14], tot(14);

void combinationUtil(ll arr[], ll n, ll r, ll index, ll data[], ll i)  
{  
    if (index == r)  
    {  
        ll tott[m+1] = {0}, flag = 0;
        for (ll j = 0; j < r; j++)  
        {
            for(ll i = 0; i <= m; i++)
            {
                tott[i] += v[data[j]][i];
            }  
        }
        for(ll i=1; i<=m; i++)
        {
            if(tott[i] < x)
            {
                flag = 1;
                break;
            }
        }
        if(!flag)
            ans = min(ans, tott[0]);
        return;  
    }  
    if (i >= n)  
        return;  
    data[index] = arr[i];  
    combinationUtil(arr, n, r, index + 1, data, i + 1);  
    combinationUtil(arr, n, r, index, data, i+1);  
}
void printCombination(ll arr[], ll n, ll r)  
{   
    ll data[r];  
    combinationUtil(arr, n, r, 0, data, 0);  
}  

void test_case()
{
    ll i,j;
    cin>>n>>m>>x;
    f(i,0,n)
    {
        f(j,0,m+1)
        {
            ll y;
            cin>>y;
            v[i].pu(y);
            tot[j]+=y;
        }
    }
    f(i,1,m+1)
    {
        if(tot[i] < x)
        {
            cout<<"-1\n";
            return ;
        }
    }
    ll aa[n];
    f(i,0,n)
        aa[i] = i;
    f(i,1,n+1)
    {
        printCombination(aa, n, i);
    }
    cout<<ans<<'\n';

}

int32_t main()
{
    IOS(); 
   
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3660
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    string s;
    cin>>s;
    int d;
    cin>>d;
    int n = s.length();
    vector<vi> dp(d, vector<int> (2));
    dp[0][0] = 1;

    for(int i=0;i<n;i++){
        vector<vi> new_dp(d, vector<int>(2));

        for(int sum = 0; sum<d; sum++){
            for(int did = 0; did<2; did++){ // it signifies whether or not we have taken a smaller value before
                for(int digits = 0; digits<10; digits++){
                    if(!did && digits > (s[i] - '0')) break;

                    int arg1 = (sum + digits) % d, arg2 = (did || (digits < s[i] - '0'));

                    new_dp[arg1][arg2] = (new_dp[arg1][arg2] + dp[sum][did]) % M; 
                }
            }
        }
        dp = new_dp;
    }

    int ans = (dp[0][0] + dp[0][1]) % M;
    ans = (ans - 1 + M) % M;

    cout<<ans;
} 

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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

template<typename T>
struct Dijkstra{
  struct Edge{
    int to;
    T cost;
    Edge(int to,T cost):to(to),cost(cost){}
    bool operator<(const Edge &o)const{return cost>o.cost;}
  };

  vector< vector<Edge> > G;
  vector<T> ds;
  vector<int> bs;
  Dijkstra(int n):G(n){}

  void add_edge(int u,int v,T c){
    G[u].emplace_back(v,c);
  }

  void build(int s){
    int n=G.size();
    ds.assign(n,numeric_limits<T>::max());
    bs.assign(n,-1);

    priority_queue<Edge> pq;
    ds[s]=0;
    pq.emplace(s,ds[s]);

    while(!pq.empty()){
      auto p=pq.top();pq.pop();
      int v=p.to;
      if(ds[v]<p.cost) continue;
      for(auto e:G[v]){
        if(ds[e.to]>ds[v]+e.cost){
          ds[e.to]=ds[v]+e.cost;
          bs[e.to]=v;
          pq.emplace(e.to,ds[e.to]);
        }
      }
    }
  }

  T operator[](int k){return ds[k];}

  vector<int> restore(int to){
    vector<int> res;
    if(bs[to]<0) return res;
    while(~to) res.emplace_back(to),to=bs[to];
    reverse(res.begin(),res.end());
    return res;
  }
};


struct RangeToRange{
  const int n;
  int ptr;
  RangeToRange(int n):n(n),ptr(3*n){}

  // (0n, 2n) : top segtree (to)
  // (2n, 4n) : bottom segtree (from)

  // map [3n, 4n) -> [n, 2n)
  template<typename F>
  void add_edge(int u,int v,F f){
    if(3*n<=u and u<4*n) u-=2*n;
    f(u,v);
  }

  template<typename F>
  void init(F f){
    for(int i=1;i<n;i++){
      int l=(i<<1)|0;
      int r=(i<<1)|1;
      add_edge(0*n+i,0*n+l,f);
      add_edge(0*n+i,0*n+r,f);
      add_edge(2*n+l,2*n+i,f);
      add_edge(2*n+r,2*n+i,f);
    }
  }

  // [l1, r1) -> [l2, r2)
  template<typename F,typename G>
  void add_edge(int l1,int r1,int l2,int r2,F f,G g){
    int k=ptr++;
    for(l1+=n,r1+=n;l1<r1;l1>>=1,r1>>=1){
      if(l1&1) add_edge(2*n+(l1++),k,f);
      if(r1&1) add_edge(2*n+(--r1),k,f);
    }
    for(l2+=n,r2+=n;l2<r2;l2>>=1,r2>>=1){
      if(l2&1) g(k,l2++);
      if(r2&1) g(k,--r2);
    }
  }
  int idx(int v)const{return 1*n+v;}
  size_t size()const{return ptr;}
};

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  using ll = long long;

  int n,m;
  cin>>n>>m;

  RangeToRange G(n);
  Dijkstra<ll> D(G.size()+m);
  G.init([&](int u,int v){D.add_edge(u,v,0);});

  for(int i=0;i<m;i++){
    int l,r,c;
    cin>>l>>r>>c;
    l--;
    auto f=[&](int u,int v){D.add_edge(u,v,0);};
    auto g=[&](int u,int v){D.add_edge(u,v,c);};
    G.add_edge(l,r,l,r,f,g);
  }

  D.build(G.idx(0));
  if(D.bs[G.idx(n-1)]<0) drop(-1);

  cout<<D[G.idx(n-1)]<<newl;
  return 0;
}


Measured memory_bytes: 92276
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);
	cout.tie(0);
 	
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		long long int a,b,k;cin>>a>>b>>k;
 		if(k>=(a+b)) cout<<0<<" "<<0<<endl;
 		else if(k<=a) cout<<a-k<<" "<<b<<endl;
 		else if(k>a) cout<<0<<" "<<b-k+a<<endl;
 	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
    int h, n, maxa=0;
    cin >> h >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        maxa = max(maxa, a[i]);
    }
    vector<long long> dp(h+maxa, 1001001001);
    dp[0] = 0;
    for (int i = 0; i < h+maxa; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if(i-a[j] < 0) continue;
            dp[i] = min(dp[i- a[j]] + b[j], dp[i]);
        }
    }
    long long ans = 1001001001;
    for(int i = h; i<h+maxa ; i++){
        ans = min(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;
//__int128


signed main() {
  // freopen("in.txt", "r", stdin);
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(10);
  string s, t;
  cin >> s >> t;
  cout << t + s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
  int main(){
	long long n;
	cin >> n;
	cout << n * (n - 1) / 2 << endl;
	return 0;
}


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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;

const ll MOD = 1e9 + 7;

// 繰り返し二乗法
ll modPow(ll x, ll a){
    if(a == 1) return x;
    if(a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return (t * t) % MOD;
}

ll modInv(ll x){
    return modPow(x, MOD - 2);
}

ll modPerm(ll n, ll k){
    ll ret = 1;
    for(int i = 0; i < k; i++){
        ret = (ret * (n - i)) % MOD;
    }
    return ret;
}

ll modComb(ll n, ll k){
    ll a, b;
    a = modPerm(n, k);
    b = modPerm(k, k);
    return (a * modInv(b)) % MOD;
}

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

    ll ans = (modPow(2, n) - 1 - modComb(n, a) - modComb(n, b)) % MOD;
    ans = (ans + MOD) % MOD;
    cout << ans << endl;
}


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

int main () {
  int N;
  int A;
  int B;
  cin >> N;
  cin >> A;
  cin >> B;
   if ( A * N < B ) {
     cout << A * N << endl;
   }
    else { 
      cout << B << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <algorithm>
#include <map>
#include <numeric>
#include <iomanip>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int MAX = 100;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */

/* main */
int main() {

    int n; cin >> n;
    vector< stack<int> > v(n, stack<int>());
    int q; cin >> q;
    while (q--) {

        int op; cin >> op;
        int t; cin >> t;

        if (op == 0) {
            int x; cin >> x;
            v[t].push(x);

        }
        else if (op == 1) {
            if (v[t].empty())
                continue;
            cout << v[t].top() << '\n';
        }
        else {
            if (v[t].empty())
                continue;
            v[t].pop();
        }
    }
}



Measured memory_bytes: 4400
import java.util.Scanner;

public class Main {

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

        final int x = sc.nextInt();

        long ans = 0;
        for (int i = 1; i <= x; i++) {
            for (int j = 1; j <= x; j++) {
                for (int k = 1; k <= x; k++) {
                    ans += gcd(gcd(i, j), k);
                }
            }
        }

        System.out.println(ans);
    }

    private static long gcd(long a, long b) {
        if (b == 0) return a;
        return gcd(b, a % b);
    }
}


Measured memory_bytes: 35792
class ModCombination:
    def __init__(self,n,m=10**9+7):
        self.num = n
        self.mod = m
        self.f = self.factorials()
        self.g = self.inverse()

    def factorials(self):
        # 0~n!のリスト
        f = [1, 1]
        for i in range(2, self.num + 1):
            f.append(f[-1] * i % self.mod)
        return f

    def inverse(self):
        # 0~n!の逆元のリスト
        g = [1]
        for i in range(self.num):
            g.append(pow(self.f[i + 1], self.mod - 2, self.mod))
        return g

    def combination(self, n, r):
        # nCr mod mを求める
        nCr = self.f[n] * self.g[n - r] * self.g[r]
        nCr %= self.mod
        return nCr

    def permutation(self, n, r):
        # nPr mod mを求める
        nPr = self.f[n] * self.g[n - r]
        nPr %= self.mod
        return nPr

n,m,k = map(int, input().split())
mod = 998244353

a = ModCombination(n,mod)

ans = 0
for i in range(k+1):
    ans += a.combination(n-1,i)*pow(m-1,n-1-i,mod)*m

print(ans%mod)




Measured memory_bytes: 86000
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
const int dy[] = { 1, 0, -1, 0}, dx[] = { 0, 1, 0, -1};
int h, w, mas[90][90];
bool used[90][90];

int  dfs(int y,int x){
  if(used[y][x]) return 0;
  used[y][x] = true;
  int ret = 0;
  for(int i = 0 ; i < 4 ; i++ ){
    int ny = y + dy[i], nx = x + dx[i];
    if(ny >= 0 && ny < h && nx >= 0 && nx < w && mas[ny][nx] && !used[ny][nx]){
      ret = max( ret, dfs( ny, nx));
    }
  }
  used[y][x] = false;
  return ret + 1;
}
int main(){
  while(cin >> w >> h , w){
    for(int i = 0 ; i < h ; i++ ){
      for(int j = 0 ; j < w ; j++ ){
        cin >> mas[i][j];
      }
    }
    int ret = 0;
    for(int i = 0 ; i < h ; i++ ){
      for(int j = 0 ; j < w ; j++ ){
        if(mas[i][j]) ret = max( ret, dfs(i,j));
      }
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1200
#include <math.h>
#include <stdio.h>

int main() {
	int a, b, c, k, max;

	scanf("%d%d%d%d", &a, &b, &c, &k);
	max = 0;
	if (max < a)
		max = a;
	if (max < b)
		max = b;
	if (max < c)
		max = c;
	printf("%d\n", a + b + c - max + (max * (int) pow(2, k)));
	return 0;
}


Measured memory_bytes: 128
N, M, Q = map(int, input().split())

ABCD = [list(map(int, input().split())) for i in range(Q)]

import itertools

max_point = 0
for i in itertools.combinations_with_replacement(range(1, M+1), N):
    # print(i)
    point = 0
    for abcd in ABCD:
        if i[abcd[1]-1] - i[abcd[0]-1] == abcd[2]:
            point += abcd[3]
    max_point = max(max_point, point)
print(max_point)

Measured memory_bytes: 80528
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np
from fractions import gcd


def main():
    n, X = map(int, input().split())
    x = np.array(list(map(int, input().split())))
    x -= X

    x = np.abs(x)

    M = x[0]

    for i in x[1:]:
        M = gcd(M, i)

    print(M)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25000
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,k; cin >> n >> k;
  	string s; cin >> s;
    if(s[k-1] == 'A') s[k-1] = 'a';
    else if(s[k-1] == 'B') s[k-1] = 'b';
    else s[k-1] = 'c';
    rep(i,n) cout << s[i];
    
    return 0;
}

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

int main(){
  ll N, M, Q;
  cin >> N >> M >> Q;

  vector<vector<ll>> X(N+1), S1(N+1), S2(N+1);
  vector<ll> row(N+1, 0);
  for(ll i=0; i<N+1; ++i) X[i] = S1[i] = S2[i] = row;

  for(ll m=0; m<M; ++m) {
    ll L, R;
    cin >> L >> R;
    ++X[L][R];
  }

  for(ll l=1; l<N+1; ++l) for(ll r=l; r<N+1; ++r) S1[l][r] = S1[l][r-1] + X[l][r];
  for(ll r=1; r<N+1; ++r) for(ll l=1; l<N+1; ++l) S2[l][r] = S2[l-1][r] + S1[l][r];

  for(ll iq=0; iq<Q; ++iq) {
    ll p,q;
    cin >> p >> q;
    cout << S2[q][q]-S2[p-1][q]-S2[q][p-1]+S2[p-1][p-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 6912
def main():
    from itertools import product
    import sys
    input = sys.stdin.buffer.readline
    N, M, P = (int(i) for i in input().split())
    adj_list = [[] for _ in range(N)]
    radj_list = [[] for _ in range(N)]
    ok = [False]*N
    edge = []
    for i in range(M):
        a, b, c = (int(i) for i in input().split())
        c -= P
        adj_list[a-1].append(b-1)
        radj_list[b-1].append(a-1)
        edge.append((a-1, b-1, -c))

    def dfs(G, v):
        seen = [False]*N
        todo = [v]
        seen[v] = True
        while todo:
            u = todo.pop()
            for next_v in G[u]:
                if seen[next_v]:
                    continue
                seen[next_v] = True
                todo.append(next_v)
        return seen

    i = 0
    for s, rs in zip(dfs(adj_list, 0), dfs(radj_list, N-1)):
        ok[i] = s and rs
        i += 1

    # Bellman_ford
    d = [10**12]*N
    d[0] = 0
    update = True
    step = 0
    while update:
        update = False
        for a, b, c in edge:
            if not(ok[a]) or not(ok[b]):
                continue
            newD = d[a] + c
            if newD < d[b]:
                update = True
                d[b] = newD
        step += 1
        if step > N:
            return print(-1)
    print(max(0, d[N-1]*-1))


if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int ans=0;
    int a1=a+b,a2=a+c,a3=b+c;
    ans=min(min(a1,a2),a3);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    final static long mod = 1000000007;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        sc.close();
        long[] d = new long[k + 1];
        for(int i = 1; i < k + 1; i++) {
            //d[i] = (long)Math.pow(k / i, n);
            d[i] = powmod(k / i , n);
        }
        for(int i = k; 0 < i; i--) {
            for(int j = 2 * i; j < k + 1; j += i) {
                d[i] -= d[j];
                d[i] %= mod;
            }
        }
        long ans = 0;
        for(int i = 1; i < k + 1; i++) {
            ans += d[i] * i;
            ans %= mod;
        }
        System.out.println(ans);
    }

    public static long powmod(long a, long n){
        long ans = 1;
        while(n > 0){
            if((n & 1) == 1){
                ans *= a;
            }
            n >>= 1;
            a *= a;
            a %= mod;
            ans %= mod;
        }
        return ans;
    }
}

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

using namespace std;
typedef long long ll;

int main(void) {
    int n, a, prev, ans = 1, da = 0;
    scanf("%d", &n);
    scanf("%d", &prev);

    for(int i=1; i<n; i++) {
        scanf("%d", &a);
        if(da == 0) {
            if(prev < a) da = 1;
            if(prev > a) da = -1;
        }
        else if((da == 1 && prev > a) || (da == -1 && prev < a)) {
            da = 0;
            ans++;
        }
        prev = a;
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, std::vector<std::string> s){
    ll Atail=0, Bhead=0, ans=0;
    ll isBad = true;
    rep(i, N){
        if(s[i].at(0)=='B')
            Bhead++;
        if(s[i].back()=='A')
            Atail++;
        for(ll j=0; j< s[i].length()-1; j++){
            if(s[i].at(j)=='A' && s[i].at(j+1)=='B')
                ans ++;
        }
        if(!(s[i].back()=='A' && s[i].at(0)=='B') && !(s[i].back()!='A' && s[i].at(0)!='B'))
            isBad = false;
    }
    if(Atail == 0 || Bhead == 0)
        isBad = false;
    ans += min(Atail,Bhead);
    if(isBad)
        ans --;
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> s(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> s[i];
    }
    solve(N, std::move(s));
    return 0;
}


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

ll prime5(const ll n)
{
    ll ans = 0;
    for (ll value = 5; value <= n; value *= 5)
        ans += n / (value * 2);
    return ans;
}

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

    if (n % 2 == 1)
        cout << 0 << endl;
    else
        cout << prime5(n) << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n;
  cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++)
    cin>>a[i];
  
  for(ll i=n-1;i>=1;i--)
  {
  	if(a[i]>=a[i-1])
     	continue;
    else
    {
      if(a[i-1]-1>a[i])
      {
      	cout<<"No\n";
        return 0;
      }
     
      else
      {
        a[i-1]--;
      }
    }
  }
  for(ll i=0;i<n-1;i++)
  {
      
      if(a[i]>a[i+1])
        {
            cout<<"No\n";
            return 0;
        }
    
    
  }
  cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  vector<vector<int>> v;
  rep(i,S.size()){
    int j = i;
    while(j+1<S.size() && S[j+1] == S[i]) j++;
    v.push_back({S[i]-'0', i, j});
    i = j;
  }

  int ret = 0;
  int sum = 0;
  int j = -1;
  int k = 0;
  rep(i,v.size()){
    while(true){
      if(j+1>=v.size()) break;
      if(v[j+1][0] == 0 && k+1 > K) break;
      j++;
      if(v[j][0] == 0) k++;
      sum += v[j][2] - v[j][1] + 1;
    }
    ret = max(ret, sum);

    if(v[i][0] == 0) k--;
    sum -= v[i][2] - v[i][1] + 1;
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 6964
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>]
#include <map>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(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; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

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

int main() {

	int R;
	cin >> R;

	float ans = R * 2 * 3.14;

	cout << ans << endl;

}


Measured memory_bytes: 3264
import java.util.*;

class Main {
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int a = Integer.parseInt(sc.next());
  int b = Integer.parseInt(sc.next());
  int c = Integer.parseInt(sc.next());
  sc.close();

  if (a<b) {
   if (b<c) {
    System.out.println("Yes");
    return;
   }
  }
  System.out.println("No");
 }
}


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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans = 0;
  long long ans_1 = a*c;
  long long ans_2 = a*d;
  long long ans_3 = b*c;
  long long ans_4 = b*d;
  ans = max(ans_1,ans_2);
  ans = max(ans,ans_3);
  ans = max(ans,ans_4);
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
 
int main()  {

  int A,B,C;
  std::cin >> A >> B >> C;
  int a,b,c;
  //printf("a=%d,b=%d,c=%d",a,b,c);
  if(B/A>=C){
	printf("%d",C);
	return 0;
  }
  else{
	printf("%d",B/A);
  }
  
	
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define MAX (1 << 29)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s)
    ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

unordered_set<ll> enum_div(ll n)  // nの約数を列挙
{
  std::unordered_set<ll> ret;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.insert(i);
      if (i * i != n) {
        ret.insert(n / i);
      }
    }
  }
  return ret;
}
int main() {
  ll A, B;
  cin >> A >> B;
  unordered_set<ll> va = enum_div(A), vb = enum_div(B);
  vector<ll> div;
  for (ll x : va)
    if (vb.count(x))
      div.push_back(x);
  sort(ALL(div));
  int N = div.size();
  vector<int> ans(N, 1);
  for (int i = 1; i < N; ++i) {
    if (ans[i] == 0)
      continue;
    unordered_set<ll> list = enum_div(div[i]);
    for (ll x : list) {
      if (x == 1)
        continue;
      for (int j = i + 1; j < N; ++j) {
        if (div[j] % x == 0)
          ans[j] = 0;
      }
    }
  }
  print(accumulate(ALL(ans), 0));
  return 0;
}

Measured memory_bytes: 896
#[allow(dead_code)]
fn main() {
    let w = i::s();
    let mut v = vec![0; 1000];
    for c in w {
        v[c as usize] += 1;
        //        *ss.entry(c).or_insert(0) += 1;
    }
    for i in v {
        if i % 2 != 0 {
            println!("{}", "No");
            return;
        }
    }
    println!("{}", "Yes");
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
//constexpr int MOD = 10e9+7;
//constexpr int INF = 1LL << 60;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int K = in();
  out(K/2 * ((K+1)/2));
}


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

int main(void){
    int N;
    cin >> N;
    long long sum=0;
    for(int i=1;i<N+1;i++){
        if(i%3!=0 && i%5!=0) sum += i;
    }
    cout << sum << endl;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define pb push_back
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define INF 300000000000001
#define ll_max 9000000000000000000
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<pair<ll,ll> > vll;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll N = 1001;
const ll M = log2(N);

struct point {
    ll x, y, i;
    bool operator == (const point b)
    {
        if(this -> x == b.x && this -> y == b.y) return 1;
        return 0;
    }
    bool operator != (const point b) {return !(*this == b);}
    friend bool operator < (const point a, const point b)
    {
        if(a.x != b.x)
            return a.x < b.x;
        return a.y < b.y;
    }
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cerr << word << " = " << a << endl;
    debug(s, args...);
}
bool overflow;
ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    ll ans;
    if(n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         if(ans > ans * ans % mod)
                overflow = 1;
         ans = ans * ans % mod;
    }
    else
    {
        ans = fast_exp(x, n - 1);
        if(ans > ans * x % mod)
            overflow = 1;
        ans = ans * x % mod;
    }
    return ans;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n = 0, m = 0, x = 0, y = 0, ans = 1, k;
        cin >> n;
        map<string,ll> mp;
        for(int i = 0; i < n; i++)
        {
            string s;
            cin >> s;
            mp[s]++;
        }
        cout << "AC" << " x " << mp["AC"] << "\n";
        cout << "WA" << " x " << mp["WA"] << "\n";
        cout << "TLE" << " x " << mp["TLE"] << "\n";
        cout << "RE" << " x " << mp["RE"] << "\n";
       // cout << ans << "\n";
    }
    return 0;
}


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

int main(){
  while(true){
    string brd[3];
    bool bWin=false;
    bool wWin=false;
    for(int i = 0; i < 3; ++i){
      cin >> brd[i];
      if( brd[i] == "0") return 0;
    }
    
    // row
    for(int i = 0; i < 3; ++i){
      int b=0,w=0;
      for(int j = 0; j < 3; ++j){
	if(brd[i][j]=='b')++b;
	else if(brd[i][j]=='w')++w;
      }
      if(b==3)bWin=true;
      if(w==3)wWin=true;
    }
    
    // col
    for(int j = 0; j < 3; ++j){
      int b=0,w=0;
      for(int i = 0; i < 3; ++i){
	if(brd[i][j]=='b')++b;
      if(brd[i][j]=='w')++w;
      }
      if(b==3)bWin=true;
      if(w==3)wWin=true;
    }
    
    // diagonal
    int b=0,w=0;
    for(int i = 0; i < 3; ++i){
      if( brd[i][i] == 'b' ) ++b;
    if( brd[i][i] == 'w' ) ++w;
    }
    if(b==3)bWin=true;
    if(w==3)wWin=true;
    
    b=0,w=0;
    for(int i = 0; i < 3; ++i){
      if( brd[i][2-i] == 'b' ) ++b;
      if( brd[i][2-i] == 'w' ) ++w;
    }
    if(b==3)bWin=true;
    if(w==3)wWin=true;
    
    if( (bWin && wWin) || (!bWin && !wWin) ){
      cout << "NA" << endl;
    }else if(bWin)
      cout << 'b' << endl;
    else
      cout << 'w' << endl;
  }
  
  return 0;
}

Measured memory_bytes: 0
s = int(input())

a = []
a.append(s)
b = {}

ans = 1000000
for i in range(1, 1000000):
    if a[i - 1] % 2 == 0:
        a.append(int(a[i - 1] / 2))
        if a[i - 1] in b:
            b[a[i - 1]] = b[a[i - 1]] + 1
            if b[a[i - 1]] > 1:
                ans = i
                break
        else:
            b[a[i - 1]] = 1
    else:
        a.append(3 * a[i - 1] + 1)
        if a[i - 1] in b:
            b[a[i - 1]] = b[a[i - 1]] + 1
            if b[a[i - 1]] > 1:
                ans = i
                break
        else:
            b[a[i - 1]] = 1

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
	int h, w;
	char str[101];

	scanf("%d %d", &h, &w);

	for (int i = 0; i < h; i++) {
		scanf("%s", str);
		printf("%s\n%s\n", str, str);
	}

	return 0;
}


Measured memory_bytes: 128
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;
use std::thread;

fn exec() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    let s = sc.ne::<String>().into_bytes();
    fn yes(a: &Vec<u8>) {
        for &x in a {
            print!("{}", x as char);
        }
        println!("");
        std::process::exit(0);
    }
    for k in 0..4 {
        let mut ans = vec![0; n];
        ans[0] = match k & 1 {
            0 => b'S',
            _ => b'W',
        };
        ans[n - 1] = match k & 2 {
            0 => b'S',
            _ => b'W',
        };
        let mut ok = true;
        for i in 0..n {
            let l = (i + n - 1) % n;
            let r = (i + 1) % n;
            let same = match s[i] {
                b'o' => ans[i] == b'S',
                _ => ans[i] == b'W',
            };
            let rin = match same {
                true => ans[l],
                _ => if ans[l] == b'S' { b'W' } else { b'S' },
            };
            if ans[r] == 0 {
                ans[r] = rin;
            } else {
                if ans[r] != rin {
                    ok = false;
                    break;
                }
            }
        }
        if ok {
            yes(&ans);
        };
    }
    println!("-1");
}
fn main() {
    const DEFAULT_STACK: usize = 16 * 1024 * 1024;
    let builder = thread::Builder::new();
    let th = builder.stack_size(DEFAULT_STACK);
    let handle = th.spawn(|| { exec(); }).unwrap();
    let _ = handle.join();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => return None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!("parse error, {:?}",
                       String::from_utf8(self.buf[l..r].to_owned()))
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


Measured memory_bytes: 8572
#include <iostream>

signed main() {
  int n;
  std::cin >> n;

  int a[n];
  int xo = 0;
  for(int i = 0; i < n; i++) {
    std::cin >> a[i];
    xo ^= a[i];
  }

  for(int i = 0; i < n; i++)
    std::cout << (a[i]^xo) << " ";

  std::cout << std::endl;
  return 0;
}




Measured memory_bytes: 4368
#include <algorithm>
#include <iostream>
#include <iterator>
#include <limits>
#include <sstream>
#include <vector>

using namespace std;
int main() {
  cin.ignore(numeric_limits<streamsize>::max(), '\n');
  string s;
  getline(cin, s);
  istringstream is{s};
  istream_iterator<int> ii{is}, eol;
  vector<int> v{ii, eol};
  cin.ignore(numeric_limits<streamsize>::max(), '\n');
  int c, b, e;
  while (cin >> c >> b >> e) {
    if (c == 0) {
      cout << *min_element(v.begin() + b, v.begin() + e) << endl;
    } else {
      cout << *max_element(v.begin() + b, v.begin() + e) << endl;
    }
  }
}


Measured memory_bytes: 3192
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <stdio.h>
    
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
const int INF = 1000*1000*1000;
const ll LINF = (ll)1e19;
int xv[4] = {-1, 1, 0, 0};
int yv[4] = {0, 0, -1, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, K;
    cin >> N >> K;
    vector<pair<ll,ll>> d;
    long double cx = 0;
    long double cy = 0;
    REP(i, N){
        ll x, y;
        cin >> x >> y;
        d.push_back(make_pair(x,y));
    }
    ll ans = LINF;
    REP(i1, N){
        REP(i2, N){
            REP(i3, N){
                REP(i4, N){
                    if(i1 != i2){
                        ll minx = min(d[i1].first, min(d[i2].first, min(d[i3].first, d[i4].first)));
                        ll maxx = max(d[i1].first, max(d[i2].first, max(d[i3].first, d[i4].first)));
                        ll miny = min(d[i1].second, min(d[i2].second, min(d[i3].second, d[i4].second)));
                        ll maxy = max(d[i1].second, max(d[i2].second, max(d[i3].second, d[i4].second)));
                        //cout << minx << "," << maxx << "," << miny << "," << maxy << endl;
                        int cnt = 0;
                        REP(l, N){
                            if(minx <= d[l].first && d[l].first <= maxx &&
                               miny <= d[l].second && d[l].second <= maxy){
                                cnt++;
                            }
                        }
                        if(cnt >= K){
                            ans = min(ans, abs((maxx-minx)*(maxy-miny)));
                            //cout << abs((maxx-minx)*(maxy-miny)) << endl;
                        }
//                        cout << cnt << endl;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int

	var x int

	var t int

	fmt.Scanf("%d %d %d",&n, &x, &t)

	var count = n / x

	if (n % x) > 0 {
		count += 1
	}

	var time = count * t

	fmt.Printf("%d", time)
}

Measured memory_bytes: 1836
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	static int[] zahyo;
	static int[] zahyoN;
	static int N;
	static int M;
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		while(true) {
			M=sc.nextInt();
			if(M==0) {
				System.exit(0);
			}
			zahyo=new int[M*2];
			for(int i=0; i<M; i++) {
				zahyo[i*2]=sc.nextInt();
				zahyo[i*2+1]=sc.nextInt();
			}
			N=sc.nextInt();
			zahyoN=new int[N*2];
			for(int i=0; i<N; i++) {
				zahyoN[i*2]=sc.nextInt();
				zahyoN[i*2+1]=sc.nextInt();
			}
			for(int i=0; i<N; i++) {
				int xz=zahyo[0]-zahyoN[2*i];
				int yz=zahyo[1]-zahyoN[2*i+1];
				if(check(xz,yz)) {
					break;
				}
				else {
					//
				}
			}
		}
	}
	static boolean check(int xz,int yz) {
		for(int h=0; h<M; h++) {
			for(int i=0; i<N; i++) {
				if(zahyo[h*2]-xz==zahyoN[i*2] && zahyo[h*2+1]-yz==zahyoN[i*2+1]) {
					break;
				}
				else if(i==N-1 &&  !(zahyo[h*2]-xz==zahyoN[i*2] && zahyo[h*2+1]-yz==zahyoN[i*2+1])) {
					return false;
				}
			}
		}
		pl((-xz)+" "+(-yz));
		return true;
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}



Measured memory_bytes: 28648