akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
int queue[400005];
int vis[100005], dis[100005];
int done[100005];

int main(){
    int k;
    scanf("%d",&k);
    for(int i = 0; i < k; i++) vis[i] = done[i] = 0;
    vis[1] = 1, dis[1] = 1;
    int h = 200000, t = 199999;
    queue[++t] = 1;
    while(h<=t){
        int u = queue[h++];
        if(done[u]) continue;
        else done[u] = 1;
        int v = u*10%k;
        if(!vis[v] || dis[u]<dis[v]){
            vis[v] = 1;
            dis[v] = dis[u];
            queue[--h] = v;
        }
        v = (u+1)%k;
        if(!vis[v] || dis[u]+1<dis[v]){
            vis[v] = 1;
            dis[v] = dis[u]+1;
            queue[++t] = v;
        }
    }
    printf("%d\n",dis[0]);
    return 0;
}


Measured memory_bytes: 3176
#include<iostream>
#include<queue>
using namespace std;
struct node
{
	int x,y,step;
}old,news;
int main()
{
	int x,y,max=0,temp;
	char mp[25][25];
	bool np[25][25];
	queue<struct node>q;
	scanf("%d%d",&x,&y);
	for(int i=0;i<x;i++)scanf("%s",mp[i]);
	for(int i=0;i<x;i++)
	{
		for(int j=0;j<y;j++)
		{
			if(mp[i][j]=='#')continue;
			temp=0;
			for(int m=0;m<25;m++)for(int n=0;n<25;n++)np[m][n]=false;
			np[i][j]=true;
			old.x=i;old.y=j;old.step=0;
			q.push(old);
			while(!q.empty())
			{
				old=q.front();
				q.pop();
				for(int p=0;p<4;p++)
				{
					news=old;
					if(p==0&&news.x>0&&mp[news.x-1][news.y]!='#'&&np[news.x-1][news.y]!=true)
					{
						news.x--;
						news.step++;
						np[news.x][news.y]=true;
						q.push(news);
						if(news.step>max)max=news.step;
					}
					if(p==1&&news.x<x-1&&mp[news.x+1][news.y]!='#'&&np[news.x+1][news.y]!=true)
					{
						news.x++;
						news.step++;
						np[news.x][news.y]=true;
						q.push(news);
						if(news.step>max)max=news.step;
					}
					if(p==2&&news.y>0&&mp[news.x][news.y-1]!='#'&&np[news.x][news.y-1]!=true)
					{
						news.y--;
						news.step++;
						np[news.x][news.y]=true;
						q.push(news);
						if(news.step>max)max=news.step;
					}
					if(p==3&&news.y<y-1&&mp[news.x][news.y+1]!='#'&&np[news.x][news.y+1]!=true)
					{
						news.y++;
						news.step++;
						np[news.x][news.y]=true;
						q.push(news);
						if(news.step>max)max=news.step;
					}
				}
			}
			if(temp>max)max=temp;
		}
	}
	printf("%d\n",max);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String[] a=new String[200];
		int num=0;
		while(sc.hasNext()) {
			a[num]=sc.nextLine();
			/*if(a[num].equals("0")) {
				break;
			}*/
			num++;
		}
		String[] ama;
		int sq=(num+1)/2;
		int[][] square=new int[num][sq];
		int[][] dp=new int[num][sq];
		for(int i=0; i<num; i++) {
			ama=a[i].split(",");
			for(int j=0; j<sq; j++) {
				if(j<ama.length) {
					square[i][j]=Integer.parseInt(ama[j]);
				}
				else {
					square[i][j]=0;
				}
				dp[i][j]=0;
			}
		}
		dp[0][0]=square[0][0];

		int counter=1;
		for(int i=1; i<num; i++) {
			if(i<sq) {
				counter=i+1;
				for(int j=0; j<counter; j++) {
					if(j==0) {
						dp[i][j]=dp[i-1][0]+square[i][0];
					}
					else if(counter>=3 && j>=1 && j<=counter-2) {
						dp[i][j]=Math.max(dp[i-1][j-1]+square[i][j], dp[i-1][j]+square[i][j]);
					}
					if(j==counter-1) {
						dp[i][j]=dp[i-1][j-1]+square[i][j];
					}
				}
			}
			else {
				counter=2*sq-1-i;
				for(int j=0; j<counter; j++) {
					dp[i][j]=Math.max(dp[i-1][j]+square[i][j], dp[i-1][j+1]+square[i][j]);
				}
			}
		}
		pl(dp[num-1][0]);
	}
	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: 27376
#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<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

void dfs(vector<vll> &G, vb &checked, ll u){
    if(checked[u]){
        return;
    }
    checked[u] = true;
    for(auto v: G[u]){
        dfs(G, checked, v);
    }
    return;
}

void solve(long long N, long long M, std::vector<long long> X, std::vector<long long> Y, std::vector<long long> Z){
    ll V = 2*N;
    vector<vll> G(V);
    REP(m, M){
        if(Z[m]){ //* X[m], Y[m] different
            G[X[m]*2].push_back(Y[m]*2+1);
            G[Y[m]*2+1].push_back(X[m]*2);
            G[X[m]*2+1].push_back(Y[m]*2);
            G[Y[m]*2].push_back(X[m]*2+1);
        }
        else{//* X[m], Y[m] same
            G[X[m]*2].push_back(Y[m]*2);
            G[Y[m]*2].push_back(X[m]*2);
            G[X[m]*2+1].push_back(Y[m]*2+1);
            G[Y[m]*2+1].push_back(X[m]*2+1);
        }
    }
    REP(i, N){
        G[i*2].push_back(i*2+1);
        G[i*2+1].push_back(i*2);
    }
    ll cnt = 0;
    vb checked(V, false);
    REP(v, V){
        if(!checked[v]){
            cnt++;
            dfs(G, checked, v);
        }
    }
    cout<<cnt<<endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> X(M);
    std::vector<long long> Y(M);
    std::vector<long long> Z(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
        scanf("%lld",&Z[i]);
        X[i]--; Y[i]--;
        Z[i] %= 2;
    }
    solve(N, M, std::move(X), std::move(Y), std::move(Z));
    return 0;
}


Measured memory_bytes: 27392
#include<iostream>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	string s="";
	for(int i=0;i<n;++i)
		s+='0';
	bool c[n];
	for(int i=0;i<n;++i)
		c[i]=false;
	bool flag=true;
	for(int i=0;i<m;++i){
		int a;
		char cc;
		cin>>a>>cc;
		if(a==1&&cc=='0')
			flag=false;
		if(c[a-1]!=false&&s[a-1]!=cc){
			cout<<-1;
			return 0;
		}
		c[a-1]=true;
		s[a-1]=cc;
	}
	if(s.size()>1&&s[0]=='0'){
		if(flag)
			s[0]='1';
		else{
			cout<<-1;
			return 0;
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readLine,readInt}

object Main {
  def main(args: Array[String]) = {
    val l = readLine().split(" ").map(_.toDouble)
    val (vx, vy) = (l(2)-l(0), l(3)-l(1))
    val n = readInt()
    val sqr = vx*vx + vy*vy
    val (vsqxx, vsqxy, vsqyy) = (2*(vx*vx)/sqr,2*(vy*vx)/sqr, 2*(vy*vy)/sqr)

    val str = new StringBuilder
    for( i <- 1 to n ) {
      val l2 = readLine().split(" ").map(_.toDouble)
      val (vx2, vy2) = (l2(0)-l(0),l2(1)-l(1))
      val (xt, yt) = ( vsqxx*vx2 + vsqxy*vy2 + 2*l(0)-l2(0), vsqxy*vx2 + vsqyy*vy2 + 2*l(1)-l2(1) )

      str ++= xt + " "+ yt + "\n"
    }
    print(str.toString)
  }
}

Measured memory_bytes: 47744
#include <iostream>
using namespace std;
int main(){
        int D=0;
        
        cin>>D;
        
        if(D==25){cout<<"Christmas";}
        if(D==24){cout<<"Christmas Eve";}
        if(D==23){cout<<"Christmas Eve Eve";}
        if(D==22){cout<<"Christmas Eve Eve Eve";}
    
}


Measured memory_bytes: 256
def main():
    n, k, q = [int(x) for x in input().split()]

    cleared = [0]*n
    for _ in range(q):
        cleared[int(input()) - 1] += 1

    sum_up = sum(cleared)
    point = [k]*n
    for i in range(n):
        print("Yes" if k + (cleared[i] - sum_up) > 0 else "No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 5448
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 2*1e5;
const ll LINF = 1LL<<61;

int main()
{
    string s, t;
    cin >> s >> t;
    s += "X";
    t += "Y";
    int n = s.size(), m = t.size();
    auto dp = make_vec(n+1, m+1, 0); //i文字見た時の～
    rep(i,n) rep(j,m)
    {
        chmax(dp[i+1][j], dp[i][j]);
        chmax(dp[i][j+1], dp[i][j]);
        if(s[i] == t[j])
        {
            chmax(dp[i+1][j+1], dp[i][j] + 1);
        }
    }
    // cout << dp << endl;
    // cout << dp[n-1][m-1] << endl;
    string ans;
    int si = n-1;
    int ti = m-1;
    while(si + ti)
    {
        if(si && dp[si][ti] == dp[si-1][ti])
        {
            si--;
            continue;
        }
        else if(ti && dp[si][ti] == dp[si][ti-1])
        {
            ti--;
            continue;
        }
        // if(/*s[si] == t[ti]*/)
        // {
            si--;
            ti--;
            ans += s[si];
            continue;
        // }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}

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

map<int,int> mp;

void prime_factor(int n) {
  if (n == 1) mp[n]++;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      mp[i]++;
      while (n % i == 0) n /= i;
    }
  }
  if (n != 1) mp[n]++;
  return;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  rep(i,N) prime_factor(A[i]);
  bool pairwise = true, setwise = true;
  for (auto x : mp) {
    if (x.second != 1 && x.first != 1) pairwise = false;
    if (x.second == N) setwise = false;
  }
  if (pairwise) {
    cout << "pairwise coprime" << endl;
  } else if (!pairwise && setwise) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}

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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) (int)x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define ss(str) scanf("%s",str)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define piii(x,y,z) printf("%d %d %d",x,y,z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define plll(x,y,z) printf("%lld %lld %lld",x,y,z)
#define NL printf("\n")
#define Max 505
#define INF 1e9
#define un(x) x.erase(unique( x.begin() , x.end() ), x.end())
#define mod 1000000007

#define FI freopen("in.txt","r",stdin)

#define D(x) cout << #x << " = " << x << endl
#define DD(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl
#define DDD(x,y,z) cout << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << endl

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

int setb(int n,int pos)
{
    return n=n | (1 << pos);
}
int resb(int n,int pos)
{
    return n=n & ~(1 << pos);
}
bool checkb(int n,int pos)
{
    return (bool)(n & (1 << pos));
}

LL bigmod(LL b,LL p,LL m)
{
    if( p == 0 ) return 1;
    LL ret = bigmod(b,p/2,m);
    ret = ( ret * ret ) % m;
    if( p & 1 ) ret = ( ret * b ) % m;
    return ret;
}

#define N 2000

int n,ara[N+5],m;
//bool dp[N+5][N*N + N + 5];
bitset <N*N+5> dp[2],z;

int solve()
{
    dp[0][0] = 1;
    for(int pos = 1; pos <= n; pos++)
    {
        dp[1] = dp[0]; dp[1] |= (dp[0] << ara[pos]);
        dp[0] = dp[1]; dp[1] = z;
    }
    for(int i = (m + 1) / 2; i <= m; i++) if( dp[0][i] ) return i;
}

int main()
{
    //FI;
    int i;
    si(n);
    rep(i,n) si(ara[i]), m += ara[i];
    int ret = solve();
    pi(ret); NL;
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define LI long int
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int LINF=1e18;
const int MOD=1e9+7;
//

int main(){
    int n; cin>>n;
    string s; cin>>s;
    int a=0,m=0;
    FOR(i,0,s.size()){
        if(s[i]=='(') a++;
        else a--;
        m=min(a,m); 
    }
    FOR(i,0,-m){
        cout<<"(";
    }
    cout<<s;
    FOR(i,0,a-m){
        cout<<")";
    }
    return 0;
}

Measured memory_bytes: 256
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を2と3以上の奇数で順次割っていくする（下から計算したら、素数判定は不要）
# 3. 2.の結果に含まれる数の種類の数＋１が答え

def main():
  a, b = map(int, input().split())
  while b != 0: a, b = b, a % b #最大公約数を求める
  print(num_facto(a) + 1)  
  
def num_facto(n):
  ans = 0
  
  if n == 1: return ans
  
  cursor = 2
  if n % cursor == 0: ans += 1
  while n % cursor == 0: n = n // cursor
  
  cursor = 3
  while cursor ** 2 <= n: # リストを作成して探索範囲を先に作ってforで回す処理だと、リスト生成時の計算量やメモリ消費が多いからwhileで都度計算
    if n == 1: break # 終了条件を入れて計算量を間引く
    if n % cursor == 0: ans += 1
    while n % cursor == 0: n = n // cursor
    cursor += 2
  
  if n != 1: ans += 1
    
  return ans

if __name__ == "__main__":
  main()


Measured memory_bytes: 38512
import java.util.*;

public class Main{
    
    static final int MOD = (int)1e9+7;
    
    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 m = Integer.parseInt(sc.next());
        
        int[] reizouko = new int[a];
        int[] densirenji = new int[b];
        
        for(int i=0; i<a; i++){
            reizouko[i] = Integer.parseInt(sc.next());
        }
        
        for(int i=0; i<b; i++){
            densirenji[i] = Integer.parseInt(sc.next());
        }
        
        int ans = (int)1e9;
        
        for(int i=0; i<m; i++){
            int x = Integer.parseInt(sc.next())-1;
            int y = Integer.parseInt(sc.next())-1;
            int c = Integer.parseInt(sc.next());
            ans = Math.min(ans, reizouko[x] + densirenji[y] - c);
        }
        
        Arrays.sort(reizouko);
        Arrays.sort(densirenji);
        
        ans = Math.min(ans, reizouko[0]+densirenji[0]);
        
        System.out.println(ans);
    }
    
}


Measured memory_bytes: 65672
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=2e5+10;
const ll MOD=1e9+7;
ll _gcd(ll a,ll b)
{
    if(b==0)return a;
    return _gcd(b,a%b);
}
ll gcd(ll a,ll b)
{
    a=abs(a),b=abs(b);
    if(a<b)swap(a,b);
    return _gcd(a,b);
}
int N;
ll A[MAXN];
ll B[MAXN];
map<pair<ll,ll>,int>cnt;
ll qpow(ll a,ll n)
{
    ll rt=1;
    while(n){
        if(n&1)rt=(rt*a)%MOD;
        a=a*a%MOD;
        n>>=1;
    }
    return rt;
}
ll factor[MAXN];
void calfact()
{
    factor[0]=1;
    for(int u=1;u<MAXN;u++){
        factor[u]=factor[u-1]*u%MOD;
    }
}
ll C(int n,int m)
{
    assert(n>=m);
    return factor[n]*qpow(factor[m],MOD-2)*qpow(factor[n-m],MOD-2);
}
ll collect(ll a,ll b)
{
    ll rt=0;
    rt+=cnt[{a,b}];
    rt+=cnt[{-a,-b}];
    return rt;
}
void erase(ll a,ll b)
{
    cnt[{a,b}]=0;
    cnt[{-a,-b}]=0;
}
int zero=0;
void read()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    calfact();
    cin>>N;
    for(int u=1;u<=N;u++){
        ll a,b;
        cin>>a>>b;
        if(a==0&&b==0){
            zero++;
            continue;
        }
        ll g=gcd(a,b);
        assert(g!=0);
        cnt[{a/g,b/g}]++;
        A[u]=a/g;
        B[u]=b/g;
    }
}
void solve()
{
    read();
    ll ans=1;
    for(int u=1;u<=N;u++){
        if(cnt[{A[u],B[u]}]==0)continue;
        ll t1=collect(A[u],B[u])
        ,t2=collect(-B[u],A[u]);
        ans=ans*((qpow(2,t1)+qpow(2,t2)-1)%MOD)%MOD;
        erase(A[u],B[u]);
        erase(-B[u],A[u]);
    }
    ans=(ans+zero-1+MOD)%MOD;
    cout<<ans;
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

Measured memory_bytes: 58300
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, b[105], ans;
int main(){
	scanf("%d", &n);
	rep(i,n-1){
		scanf("%d", b+i);
		if(i) ans += min(b[i-1], b[i]);
		else ans += b[i];
	}
	ans += b[n-2];
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    ll N; cin >> N;
    cout << N * (N - 1) / 2 << endl;   
}

Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();
            int iN = int.Parse(sS);
            sS = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "red";
            if (iN >= 3200) { sOut = sS; }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<complex>
typedef long long int llint;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

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

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int n;
	int result = 0;

	scanf("%d", &n);

	int i_flag, j_flag, k_flag;
	for (int cor = 1; cor <= n; cor++)
	{
		result = 0;
		i_flag = 0, j_flag = 0, k_flag = 0;
		for (int i = 1; i_flag == 0; i++)
		{
			j_flag = 0;
			for (int j = 1; j_flag == 0; j++)
			{
				k_flag = 0;
				for (int k = 1; k_flag == 0; k++)
				{
					int cal = i * i + j * j + k * k + i * j + j * k + k * i;
					if (cal == cor) {
						result += 1;
					}
					else if (cal > cor) {
						k_flag = 1;
						if (k == 1) {
							j_flag = 1;
							if (j == 1) {
								i_flag = 1;
								printf("%d\n", result);
							}
						}
					}
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int K;
	cin >> K;
	vector<string> str;
	rep(j, K) {
		rep(i, S.length() - j) {
			string tmp;
			rep(k, j + 1) tmp += S[k + i];
			// dump(tmp);
			str.push_back(tmp);
		}
	}
	sort(str.begin(), str.end());
	string tmp = str[0];
	int cnt = 0;
	while (K != 1) {
		cnt++;
		if (tmp == str[cnt]) continue;
		tmp = str[cnt];
		K--;
	}

	cout << tmp << endl;




    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(void){
    
    int n, m;
    int a;
    
    cin >> n >> m;
    
    for(int i=1; i<=m; i++){
        
        cin >> a;
        n -= a;
        
    }
    
    cout << max(n, -1) << endl;
    
    return 0;
    
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

using namespace std;


int ans,ans2;
int n,m;

signed main(){

	int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        if(s.size()%2==1){
            ans++;
        }
    }
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  ll l=s.length(),x=-1,y=-1;
  rep(i,l-1) {
    if(s[i]==s[i+1]) {x=i+1,y=i+2;break;}
    if(i+2<l&&(s[i]==s[i+2])) {x=i+1,y=i+3;break;}
  }
  printf("%lld %lld\n",x,y);
  return 0;
}

Measured memory_bytes: 3840
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}


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

	string ans;
	switch (S[0]) {
	case 'S':
		ans = "Cloudy";
		break;
	case 'C':
		ans = "Rainy";
		break;
	case 'R':
		ans = "Sunny";
		break;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

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

	int w[n];
	for(int i=1;i<=n;i++)
		w[i-1]=0;
	int e[n];
	for(int i=1;i<=n;i++)
		e[i-1]=0;


	for(int i=2;i<=n;i++)
	{
		w[i-1]=(i>2 ? w[i-1-1]:0)+(s[i-1-1]=='W' ? 1:0);
	}
	for(int i=n-1;i>=1;i--)
	{
		e[i-1]=(i<n-1 ? e[i-1+1]:0)+(s[i-1+1]=='E' ? 1:0);
	}

	int value[n];
	for(int i=1;i<=n;i++)
		value[i-1]=w[i-1]+e[i-1];

	int ans=n;
	for(int i=1;i<=n;i++)
		ans=min(ans,value[i-1]);

	cout << ans << endl;
}

Measured memory_bytes: 4228
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    ll n,k;
    cin>>n>>k;
    ll num=k;
    ll i=0;
    while(n>0)
    {
        n/=k;
        i++;
    }
    cout<<i;  
  }
  return 0;
}

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

#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<

int main(){
  ll n,k;
  ll i,j;
  cin >> n>>k;
  vector<ll> w(n),v(n);
  for(i = 0; i < n; i++)
    cin >> w[i] >> v[i];
  ll dp[n+1][k+1];
  for(i=0;i<n+1;i++){
    for(j=0;j<k+1;j++)
      dp[i][j] = 0;
  }
  for(i=1;i<n+1;i++){
    for(j=1;j<w[i-1];j++)
      dp[i][j] = dp[i-1][j];
    for(j=w[i-1];j<k+1;j++)
     dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
  } 
  ll result=0;
  for(i=1;i<k+1;i++){
    //cout<<dp[n][i]<<endl;
    if(dp[n][i]>result){
      
      result=dp[n][i];
    }
  }
  cout << result << endl;
  
       
      
    
  

  return 0;
}

Measured memory_bytes: 79104
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

const P: i64 = 1_000_000_007;

fn main() {
    let (N, M) = read!(usize, usize);
    let A = read![usize; M];
    let A = A.into_iter().collect::<BTreeSet<_>>();

    let mut prev = 0;
    let mut cur = 1;
    for i in 1..N + 1 {
        if A.contains(&i) {
            prev = cur;
            cur = 0;
            continue;
        }

        let next = (cur + prev) % P;
        prev = cur;
        cur = next;
    }

    println!("{}", cur)
}


Measured memory_bytes: 6396
#include <iostream>
#include <array>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::array;
using std::sort;
using std::reverse;

int main()
{
  int A, B, C;
  array<int, 3> ary;
  cin >> ary[0] >> ary[1] >> ary[2];

  sort(ary.begin(), ary.end());
  reverse(ary.begin(), ary.end());
  
  cout << (( ary[0] == ary[1] + ary[2] ) ? "Yes" : "No") << endl;
}

// better answer


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

int main() {
    int N;
    cin >> N;

    double probabilites[N];
    for (int i = 0; i < N; i++) {
        cin >> probabilites[i];
    }

    // i-1番目までのコインを投げて表がj枚でるときの確率
    double dp[N + 1][N + 1];

    for (int i = 0; i < N + 1; i++) {
        for (int j = 0; j < N + 1; j++) {
            dp[i][j] = 0.0;
        }
    }

    dp[0][0] = 1.0;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            dp[i + 1][j + 1] += dp[i][j] * probabilites[i];
            dp[i + 1][j] += dp[i][j] * (1.0 - probabilites[i]);
        }
    }

    /*
    for (int i = 0; i < N + 1; i++) {
        cout << dp[N][i] << " ";
    }
    cout << endl;
     */

    double sum = 0.0;
    for (int i = (N + 1)/2; i < N + 1; i++) {
        sum += dp[N][i];
    }
    cout << setprecision(10) << sum << endl;
    return 0;
}

Measured memory_bytes: 70528
#include<algorithm>
#include<cstdio>
using namespace std;
int r,D,sl,fh;
long long x;
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	r=rd();D=rd();x=rd();
	for(int i=1;i<=10;++i) x=r*x-D,printf("%lld\n",x);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <typeinfo>
#include <memory>
#include <cassert>
using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define SINV(t) greater<t>()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP2(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;
#define vv(t) vector<t>

template<typename T>
void SV(vector<T> v){
    REP(i,v.size()){
        #ifdef LOCAL
            cout << i << " : " << v[i] << endl;
        #endif
    }
}

int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}

int div_ct(int n) {
    int c = 0;
    int k;
    for ( k = 1; k <= n; k++ ) { 
        if ( n % k == 0 ) { c++; } 
    }
    return c;
}

int main(){
    ll N;
    cin >> N;
    ll cnt = 0;
    for(int i=105; i<=N; i+=2){
        if(div_ct(i) == 8)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3


def judge(n, xs):
    o0 = sum(x % 2 for x in xs)
    e0 = n - o0
    o = o0 % 2
    e = o0 // 2 + e0 // 2 + e0 % 2
    while e > 1:
        d, m = divmod(e, 2)
        e = d + m
    rest = o + e
    return rest == 1


def main():
    n = int(input())
    xs = [int(x) for x in input().split()]
    print("YES" if judge(n, xs) else "NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 14108
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int k,n;
  cin >> k >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int d = 0;
  rep(i,n-1) d = max(d, a[i+1] - a[i]);
  d = max(d, a[0]+k-a[n-1]);
  if(d==0) {
    cout << 0 << endl;
  } else {
    cout << (k-d) << endl;
  }
}


Measured memory_bytes: 1024
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> i2;
typedef pair<ll,ll> ll2;

ll n;

ll arr[100000];

bool larger(ll num)
{
    
    for (ll i = 0; i < n; i++)
    {
        num -= num%arr[i];
    }
    
    return (num>2);
}

bool smaller(ll num)
{
    
    for (ll i = 0; i < n; i++)
    {
        num -= num%arr[i];
    }
    
    return (num<2);
}

bool works(ll num)
{
    
    for (ll i = 0; i < n; i++)
    {
        num -= num%arr[i];
    }
    return (num==2);
}

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    
    cin >> n;
    
    for (ll i = 0; i < n; i++) cin >> arr[i];
    
    ll s, l;
    
    ll lo = 1;
    ll hi = 1e18;
    
    while (hi > lo)
    {
        ll mid = (lo+hi)/2;
        if (smaller(mid)) lo = mid+1; //needs more
        else hi = mid;
    }
    
    s = lo;
    
    lo = 1;
    hi = 1e18;
    
    while (hi > lo)
    {
        ll mid = (lo+hi+1)/2;
        if (larger(mid)) hi = mid-1;
        else lo = mid;
    }
    
    l = lo;
    
    if (works(s) && works(l)) cout << min(s,l) << ' ' << max(s,l) << '\n';
    else cout << -1 << '\n';

    
    
    return 0;
    
}




Measured memory_bytes: 1024
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
// #define mpp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 3e5 + 5;
const int LG = 20;
const int mod = 1e9 + 7;

int arr[N];
 
void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	int ret = 0;
	for(int i = 0; i <= 61; i++)
	{
		int z = 0;
		int o = 0;
		for(int j = 0; j < n; j++)
		{
			if((arr[j] >> i) & 1)
			{
				o += 1;
			}
			else
			{
				z += 1;
			}
		}
		o *= z;
		o %= mod;
		int poww = (1LL << i);
		poww %= mod;
		poww *= o;
		poww %= mod;
		ret += poww;
		ret %= mod;
	}
	cout << ret << endl;
}
 
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 2560
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int N,M,R;
ll d[210][210];
const ll INF=1e9;
void wf(){

	int i,j,k;

    for(k=1;k<=N;k++){
       for(i=1;i<=N;i++){
          for(j=1;j<=N;j++){
        	  if(d[i][j]>d[i][k]+d[k][j]){
        		  d[i][j]=d[i][k]+d[k][j];
        	  }
          }
       }
    }
}

int main(void){
	          int i,j,k;

	      	  cin.tie(0);  ios_base::sync_with_stdio(false);

	      	  cin >> N >> M >> R;

	      	  vector<int> v(R);
	      	  REP(i,R) cin >> v[i];

	          for(i=1;i<=N;i++){
	      	    for(j=1;j<=N;j++){
	      		    if(i==j) d[i][j]=0;
	      		    else d[i][j]=INF;
	      	    }
	          }

	      	  REP(i,M){
	      		  int a,b;
	      		  ll c;
	      		  cin >> a >> b >> c;
	      		  d[a][b]=c;
	      		  d[b][a]=c;
	      	  }

	      	  wf();
	      	sort(v.begin(),v.end());
	      	ll ans=1e9;
	      	do{

	      		if(d[v[0]][v[R-1]]==INF) continue;

	      		ll x=0;
	      		bool f=true;
	      		for(i=1;i<R;i++){
	      			if(d[v[i-1]][v[i]]!=INF) x+=d[v[i-1]][v[i]];
	      			else{
	      				f=false; break;
	      			}
	      		}
	      		if(f) ans=min(ans,x);

	      	}while(next_permutation(v.begin(),v.end()));

	      	cout << ans << endl;

	          return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define inp(a) int a; cin>>a;
#define inpa(a,n) vector<int>a(n); FOR(i,0,n-1) cin>>a[i];
#define PI 3.141592653589793238
#define QUICK ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vec(x) vector<x>
#define pii pair<int,int>
#define mem(a,b) memset(a, b, sizeof a)
#define FOR(i,j,n) for(int i= j; i<=n; i++)
#define srt(a); sort(a.begin(), a.end())
#define CASE int t; cin>>t; while(t--)
#define setBits(n) __builtin_popcountll(n)
#define prec(n) fixed<<setprecision(n)
#define print(x) for(auto c : x) cout << c << " ";
#define dbg(x) cerr << #x << " :: "<< x << endl;
#define dbg2(x,y) cerr << #x << " :: "<<x <<"\t" << #y << " :: "<<y <<endl;
#define upcase(s)  transform(s.begin(), s.end(), s.begin(), ::toupper)
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define int ll
const int INF = 1e9 + 7;
const int SIZE = 1e9 + 5;
const int MOD = 1e9 + 7; 
//////////// template ends here //////////////////////////

void solve(){	
	
	inp(n); inp(w);
	vec(int)wt(n+1,0),val(n+1,0);
	vec(vec(int))dp(n+1, vec(int)(w+1, 0));

	FOR(i,1,n)
		cin>>wt[i] >> val[i];
	dp[1][wt[1]] = val [1];

	FOR(i,2,n){
		FOR(j,0,w){
			dp[i][j] = dp[i-1][j];
			if(j-wt[i] >= 0)
				dp[i][j] = max(dp[i][j], dp[i-1][j-wt[i]] + val[i]);
		}
	}
	int ans = 0;
	FOR(i,0,w){
		ans = max(ans, dp[n][i]);
	}

	cout << ans << endl; 

	
}



int32_t main(){
	#ifndef ONLINE_JUDGE 
		freopen ("input.txt","r",stdin);
		freopen ("output.txt","w",stdout);
	#endif	
	QUICK;
	
	solve();
	printclock;
}

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

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



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

class Program
{
    static void Main(string[] args)
    {
        // 入力
        var n = long.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        var b = new List<long>() { };
        if (n % 2 == 0)
        {
            for (long i = n - 1; i >= 0; i--)
            {
                if (i % 2 == 1)
                {
                    b.Add(a[i]);
                }
            }
            for (long i = 0; i < n; i++)
            {
                if (i % 2 == 0)
                {
                    b.Add(a[i]);
                }
            }
        }
        else
        {
             for (long i = n - 1; i >= 0; i--)
            {
                if (i % 2 == 0)
                {
                    b.Add(a[i]);
                }
            }
            for (long i = 0; i < n; i++)
            {
                if (i % 2 == 1)
                {
                    b.Add(a[i]);
                }
            }


        }

        for (int i = 0; i < n; i++)
        {
            Console.Write(b[i]);
            Console.Write(" ");
        }
    }
}


Measured memory_bytes: 44600
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.Exception
import java.util.*

fun gcd(a:Int, b:Int):Int {
    val c = a % b
    if (c == 0) return b
    return gcd(b, c)
}

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val lst = mutableListOf<Int>()
    var i = 1
    var sum = 0
    while (lst.count() < n - 1) {
        if (i % 2 == 0 || i % 3 == 0 || i % 5 == 0) {
            lst.add(i)
            sum += i
        }
        i++
        if (lst.count() == n - 1 && sum % 2 != 0 && sum % 3 != 0 && sum % 5 != 0) {
            sum -= lst[0]
            lst.removeAt(0)
        }
    }
    while (i <= 30000) {
        val m = sum + i
        if (m % 30 == 0 && (i % 2 == 0 || i % 3 == 0 || i % 5 == 0)) {
            lst.add(i)
            break
        }
        i++
    }
    println(lst.joinToString(" "))
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 39780
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"\Case #"<<x<<"\:"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}


void virus(){
    ll a,b;
    cin>>a>>b;
    cout<<a*b;
}


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

    ll t=1;
   // cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  int x = n / 100;
  bool add = false;
  n %= 100;
  if (x < n/10) add = true;
  if (x == n/10 && x < n%10) add = true;
  x += add;
  cout << x*111 << endl;
}

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

int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  long long count = n/(a + b)*a;
  long long key = n%(a + b);
  if (key < a)
    count += key;
  else
    count += a;
  cout << count << endl;
}

Measured memory_bytes: 256