akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int main()
{
    char S[101],T[101];
    char R[202];
    scanf("%s",S);
    scanf("%s",T);
    int n=strlen(S);
    int q=strlen(T);
    int i,k,j=0;
    for(i=0; i<(n+q); i++)
    {
        R[i]=T[i];
        if(i==q)
        {
        for(j=0;j<n;j++){
            R[i]=S[j];
            i++;
            if(i==(n+q)){
                break;
            }
        }

        }
    }
    for(i=0; i<(n+q); i++)
    {
        printf("%c",R[i]);
        if(i==(n+q))
        {
            printf("\n");
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 128
H,W = map(int,input().split())

canvas = []

for i in range(H):
  canvas.append(list(input()))
  
#print(canvas)
for i in range(H):
  for j in range(W):
    cnt = 0
    if canvas[i][j] == "#":
      for h in range(-1,2):
        for w in range(-1,2):
          if canvas[min(max(i+h,0),H-1)][min(max(j+w,0),W-1)]=="#" and (abs(h)+abs(w))%2==1:
            cnt+=1
      if cnt==0:
        print("No")
        exit()
print("Yes")

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long 
#define db double
#define pii pair <int, int> 
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T& a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T& a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T& a) { return 1ll * a * a; }
template <class T> void compress(vector <T> &a){
  sort(all(a));
  a.resize(unique(all(a)) - a.begin());
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

int main()
{
  fastio;
  vector <int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  int k; cin >> k;
  int x, res = 0; 
  x = min(a[0], k); res += x; k -= x;
  x = min(a[1], k); k -= x;
  x = min(a[2], k); k -= x; res -= x;
  cout << res;
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

#define BIT_MAX 15

int main(){

    int N, M;
    cin >> N >> M;
    vector<vector<int>> k(M);

    rep(i,M){
        int tmp;
        cin >> tmp;
        rep(j,tmp){
            int s;
            cin >> s;
            k[i].push_back(s);
        }
    }

    vector<int> p(M);
    rep(i,M){
        cin >> p[i];
    }

    int sum = 0;

    for (int bit = 0; bit < (1<<N); ++bit)
    {
        bitset<BIT_MAX> bs(bit);
        bool ok = true;
        rep(i,M){
            int count = 0;
            rep(j,k[i].size()){
                if(bs[k[i][j]-1]){
                    count++;
                }
            }

            // cout << count << endl;

            ok = ok & (count % 2 == p[i]);

        }

        if(ok) sum++;

    }

    cout << sum << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
    int x;
    cin >> x;
    
    REP(i, 10000000){
        if( IsPrime(x) == true){
            cout << x << endl;
            return 0;
        }
        x++;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007

using namespace std;

int n,m;
bool matrica[1010][1010];
int dp[1010][1010];

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

    cin>>n>>m;
    string s;
	for(int i=0;i<n;i++)
    {
        cin>>s;
        for(int j=0;j<m;j++)
            matrica[i][j]=(s[j]=='.');
    }

    dp[0][0]=1;
    for(int i=1;i<n;i++)
        if(matrica[i][0])
            dp[i][0]=dp[i-1][0];

    for(int j=1;j<m;j++)
        if(matrica[0][j])
            dp[0][j]=dp[0][j-1];

	for(int i=1;i<n;i++)
        for(int j=1;j<m;j++)
            if(matrica[i][j])
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;

	cout<<dp[n-1][m-1];

	return 0;
}


Measured memory_bytes: 5248
n = int(input())
h = list(map(int,input().split()))
flag = 1
cnt = 0
for i in range(n):
    for j in range(i+1):
        if h[i]>=h[j]:
            flag = 1
        else:
            flag = 0
            break
    if flag == 1:
        cnt+=1
print(cnt)


Measured memory_bytes: 2940
import sys
import itertools
# import numpy as np
import time
import math
import heapq
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

accA = [0] * (N + 1)
for i in range(1, N + 1):
    accA[i] = accA[i - 1] + A[i - 1]
accB = [0] * (M + 1)
for i in range(1, M + 1):
    accB[i] = accB[i - 1] + B[i - 1]


ans = 0
for i in range(N + 1):
    remains = K - accA[i]
    if remains < 0:
        break
    left = 0
    right = M + 1
    while right - left > 1:
        mid = left + (right - left) // 2
        if accB[mid] <= remains:
            left = mid
        else:
            right = mid
    j = 0
    if left >= 0:
        j = left
    ans = max(ans, i + j)
print(ans)



Measured memory_bytes: 47892
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    auto a = aryread();
    a.sort().uniq().array().length.writeln();
}


Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int cnt = 0;
int N, M;
int main(){
    string x, y;
    cin >> x >> y;
    reverse(y.begin(), y.end());
    if(x == y) cout <<"YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n;
const long long mod=1e9+7;
map<long long , long long>dp;
long long DP(long long x)
{
	if(dp[x]) return dp[x];
	else
	{
		return dp[x]=(( DP(x/2) + DP((x-1)/2) + DP((x-2)/2) )) % mod;
	}
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin>>n;
	dp[0]=1;
	dp[1]=2;
	cout<<DP(n)<<endl;
	return 0;
} 

Measured memory_bytes: 256
local n, m = io.read("*n", "*n")
local edge = {}
local color = {}
local searched_len = {}
for i = 1, n do
  edge[i] = {}
  color[i] = 0
  searched_len[i] = -1
end
for i = 1, m do
  local a, b = io.read("*n", "*n")
  table.insert(edge[a], b)
  table.insert(edge[b], a)
end
local q = io.read("*n")
local query = {}
for iq = 1, q do
  query[iq] = {io.read("*n", "*n", "*n")}
end
for iq = q, 1, -1 do
  local tasks = {{unpack(query[iq])}}
  while 0 < #tasks do
    local src, d, c = unpack(tasks[#tasks])
    if searched_len[src] < d then
      searched_len[src] = d
    end
    table.remove(tasks)
    if color[src] == 0 then
      color[src] = c
    end
    if 0 < d then
      for i = 1, #edge[src] do
        local dst = edge[src][i]
        if searched_len[dst] < d - 1 then
          table.insert(tasks, {dst, d - 1, c})
        end
      end
    end
  end
end
for i = 1, n do
  print(color[i])
end


Measured memory_bytes: 59344
#include <algorithm>
#include <array>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
#define vint vector<int>

int main() {
    int N;
    cin >> N;
    vint a(N);
    rep(i, N) cin >> a[i];
    vint bit(N, 0);
    bit[N - 1] = 1, bit[N - 2] = 1;
    int sum = 0;
    do {
        int takoyaki = 1;
        for (int i = 0; i < N; i++) {
            if (bit[i] == 1)
                takoyaki *= a[i];
        }
        sum += takoyaki;
    } while (next_permutation(all(bit)));
    cout << sum << endl;
    return 0;
}

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

using namespace std;
char a[10010];
int main() {
	scanf("%s", a);
	int n = strlen(a);
	int s = 0; 
	for (int i = 0; i < n; i++) {
		if (a[i] == '7') {
			s = 1;
			break;
		}
	}
	if (s) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 3760
#include<cstdio>
#include<algorithm>
#define N_ 101000
using namespace std;
long long D[N_];
int w[N_], n;
int main() {
	scanf("%d", &n);
	int i, j;
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
	}
	for (i = 2; i <= n; i++) {
		D[i] = 1e18;
		for (j = i - 1; j >= i - 2 && j >= 1; j--) {
			D[i] = min(D[i], D[j] + abs(w[j] - w[i]));
		}
	}
	printf("%lld\n", D[n]);
}

Measured memory_bytes: 1280
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(new InputStreamReader(System.in));
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a+b>23){
			System.out.println(a+b-24);
		}else {
			System.out.println(a+b);
		}

	}
}


Measured memory_bytes: 21844
import sys


def process(A, B, N, K, Turn):
    if N == K:
        return A, B
    else:
        if Turn:
            return process(int(A/2), B + int(A/2), N + 1, K, False)
        else:
            return process(A + int(B/2), int(B/2), N + 1, K, True)


def main(A, B, K):
    A, B = process(A, B, 0, K, True)
    return "{} {}".format(A, B)


if __name__ == "__main__":
    A, B, K = sys.stdin.readline().split()
    print(main(int(A), int(B), int(K)))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,k=0,ans=0,x[2]={0};
        cin>>n;
        ll A[n];
        map<int,int> B;
        for(ll i=0;i<n;i++)
        {
            cin>>A[i];
            B[A[i]]++;
        }
        sort(A,A+n);
        for(ll i=n-1;i>=0;i--)
        {
             if(B[A[i]]>=2)
            {
                if((B[A[i]]>=4 && k==0))
                {
                    ans=A[i]*A[i];
                    break;
                }
                x[k]=A[i];
                i=i-B[A[i]]+1;
                k++;
                if(k==2)
            	{
	              ans=x[0]*x[1];  
	              cout<<ans;
	              return 0;
            	}
            }
        }
        cout<<ans;
    } 
    return 0;
}

Measured memory_bytes: 8956
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>

using namespace std;
using ll = long long;
const ll res = 1000000007;


int main() {
	ll n;
	cin >> n;
	if (n % 2 == 0)
		cout << n / 2 << endl;
	else
		cout << (n + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int sx, sy, tx, ty;
 
int main() {
    std::ios::sync_with_stdio(false);
    while( scanf( "%d%d%d%d", &sx, &sy, &tx, &ty ) != EOF ) {
        string ans;
        for( int i = 0; i < ty-sy; ++i ) {
            ans += 'U';
        }
        for( int i = 0; i < tx-sx; ++i ) {
            ans += 'R';
        }
        for( int i = 0; i < ty-sy; ++i ) {
            ans += 'D';
        }
        for( int i = 0; i < tx-sx; ++i ) {
            ans += 'L';
        }
        ans += 'L';
        for( int i = 0; i < ty-sy+1; ++i ) {
            ans += 'U';
        }
        for( int i = 0; i < tx-sx+1; ++i ) {
            ans += 'R';
        }
        ans += 'D';
        ans += 'R';
        for( int i = 0; i < ty-sy+1; ++i ) {
            ans += 'D';
        }
        for( int i = 0; i < tx-sx+1; ++i ) {
            ans += 'L';
        }
        ans += 'U';
        cout<<ans<<endl;
    }
 
    
    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a;
	cin>>a;
	if(a==1){
		cout<<1<<endl;
	}else if(a<4){
		cout<<2<<endl;
	}else if(a<8){
		cout<<4<<endl;
	}else if(a<16){
		cout<<8<<endl;
	}else if(a<32){
		cout<<16<<endl;
	}else if(a<64){
		cout<<32<<endl;
	}else {
		cout<<64<<endl;
	}
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T&a , T b){
    if(a<b){
        a=b; return true;
    }else{
        return false;
    }
}
template<class T> inline bool chmin(T&a , T b){
    if(a>b){
        a=b; return true;
    }else{
        return false;
    }
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[1002][1002];
vector<string> a;

int main(){
    int h,w;
    cin >> h >> w;
    a.resize(h);
    rep(i,h) cin >> a[i];

    rep(i,h)rep(j,w) dp[i][j]=0;
    dp[0][0]=1;

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i+1<h && a[i+1][j]=='.'){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
            if(j+1<w && a[i][j+1]=='.'){
                dp[i][j+1] += dp[i][j];
                dp[i][j+1] %= MOD;
            }
        }
    }

    cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 9088
#include <string>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>

#define MOD 1000000007

using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
 
	string x,y;
	cin >> x >> y;
    int z = x.size();
    int ans = 0;
    if(x==y){
      cout << "0";
      return 0;
    }
    for(int i=0; i<z; i++){
      if(x[i]!=y[i]){
        ans++;
      }
    }
    cout << ans;
  
}

Measured memory_bytes: 3792
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = Math.min(a*n,b);
        System.out.println(ans);
    }
}


Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

void solve(){
  int d; cin >> d;
  string s = "Christmas";
  for(int i = d; i < 25; i++){
    s += " Eve";
  }
  cout << s << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1000

int calc(int a, int op, int b){
  if(op == -1) return a + b;
  return a * b;
}

bool isop(int c){
  return c <= -1;
}

bool solve(){
  int n;

  scanf("%d", &n);

  if(n == 0) return false;

  stack<pair<int,int> > st;
  
  for(int i=0;i<=n;i++){
    char s[200];
    int counter = 0;

    if(i < n){
      scanf("%s", s);  
      while(s[counter] == '.') counter++;
    }else{
      counter = 0;
    }

    //debug(s[counter]);
    
    vector<int> vec;
    while(st.size() && (st.top().first > counter || (st.top().first == counter && isop(st.top().second) ))){
      auto p = st.top(); st.pop();

      if(isop(p.second)){
        int res = vec[0];
        for(int j=1;j<vec.size();j++) res = calc(res, p.second, vec[j]);
        st.push({p.first, res});
        vec = vector<int>();
      }else{
        vec.push_back(p.second);
      }
    }

    if(s[counter] == '+')
      st.push({counter, -1});
    else if(s[counter] == '*')
      st.push({counter, -2});
    else
      st.push({counter, s[counter]-'0'});
  }

  st.pop();
  
  printf("%d\n", st.top().second);

  return true;
}

int main(){
  while(solve());
  
  return 0;
}



Measured memory_bytes: 3188
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (unsigned long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (unsigned long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    int n;
    string s;
    cin >> n >> s;

    constexpr ll p = 1000000007;
    constexpr ll alph = 'z' - 'a' + 1;
    ll ans = 1;
    vector<ll> anum(alph, 0);
    REP(i, n) anum[s[i] - 'a']++;
    REP(i, alph) {
        ans *= anum[i] + 1;
        ans %= p;
    }
    ans--;

    cout << ans << endl;
    
}

Measured memory_bytes: 512
# ベン図的にみると赤と青の両方にかかれているやつは考えなくていい（+1円-1円なので）
# と思ったけど複数枚に同じのが書かれている場合があるなこれ
# なので辞書でカウントしつつリストとってxnor
# と思ったけど問題文よく読んだら最悪でも0とれるので青を基準に考えればいいだけだった
blues = {}
for _ in range(int(input())):
    r = input()
    if r in blues:
        blues[r] += 1
    else:
        blues[r] = 1
reds = {}
for _ in range(int(input())):
    b = input()
    if b in reds:
        reds[b] += 1
    else:
        reds[b] = 1

ans = 0
for k, v in blues.items():
    if k in reds:
        ans = max(ans, blues[k] - reds[k])
    else:
        ans = max(ans, v)

print(ans)


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


using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<string, string> pss;
typedef vector<LL> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;




int main()
{

	LL line;cin>>line;
	while(line--){
            cout<<"ACL";
	}
	cout<<endl;
}


Measured memory_bytes: 3604
#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>;

int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    for(int i = 0; i < n - 2; i++) {
        if(p[i] < p[i + 1] and p[i + 1] < p[i + 2])
            ans++;
        else if(p[i] > p[i + 1] and p[i + 1] > p[i + 2]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
x, y = map(int, raw_input().split())

a = [1, 3, 5, 7, 8, 10, 12]

b = [4, 6, 9, 11]

if x == 2 or y == 2:
    if x == 2 and y == 2:
        print 'Yes'
    else:
        print 'No'
else:
   if x in a and y in a:
       print 'Yes'
   elif x in b and y in b:
       print 'Yes'
   else:
       print 'No'

Measured memory_bytes: 2568
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A, B;
    B.pb(0);
    rep(i, N) {
        int x;
        cin >> x;
        if(x < 0) {
            A.pb(-x);
        } else {
            B.pb(x);
        }
    }
    A.pb(0);
    reverse(All(A));
    int res = INF;
    for(int i = 0; i < min(K + 1, (int)A.size()); i++) {
        if((K - i < B.size()) && (K - i >= 0)) {
            res = min(res, A[i] * 2 + B[K - i]);
        }
    }
    for(int i = 0; i < min(K + 1, (int)B.size()); i++) {
        if((K - i < A.size()) && (K - i >= 0)) {
            res = min(res, B[i] * 2 + A[K - i]);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  string S;
  cin>>N;
  for(int i=0 ; i<N ; i++){
  cin>>S;
    if(S == "Y"){
    cout<<"Four";
      break;
    }
    if(i==N-1){
    cout<<"Three";
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,w;
    cin>>n>>w;
    long long* wet=new long long[n];
    long long* val=new long long[n];
    for(int i=0;i<n;i++)
    cin>>wet[i]>>val[i];
    long long  dp[n+2][w+2];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0||j==0)dp[i][j]=0;

            else if(j>=wet[i-1])
            {
                dp[i][j]=max(val[i-1]+dp[i-1][j-wet[i-1]],dp[i-1][j]);
            }
            else dp[i][j]=dp[i-1][j];
        }
    }
    // for(int i=0;i<=n;i++)
    // {
    //     for(int j=0;j<=w;j++)
    //     cout<<dp[i][j]<<"\t ";
    //     cout<<endl;
    // }
    cout<<dp[n][w];
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    int m;
    cin >> m;
    cout << 24 - m + 24 << endl;

    return 0;
}


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

x = list(map(int,input().split()))

y = list(map(int,input().split()))
flag = 0

Z_max = min(y)
Z_min = max(x)
Z = X + 1
while Z < Y:
    if Z_min < Z and Z <= Z_max:
        break
    Z += 1

for i in range(N):
    if x[i] >= Z:
        flag = 1
        break

if flag == 0:
    for i in range(M):
        if y[i] < Z:
            flag = 1
            break

if flag == 0:
    print('No War')

else:
    print('War')


Measured memory_bytes: 3064
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n):
    if i>=1 and i <n-1:
        if (p[i-1]<p[i] and p[i] < p[i+1]) or (p[i-1]>p[i] and p[i] > p[i+1]):
            ans += 1

print(ans)

Measured memory_bytes: 38384
#include<stdio.h>
int main()
{
	int h,w,i,j,x[100],y[100];
	char a[100][100];

	scanf("%d%d",&h,&w);
	for(i=0;i<h;i++)
		scanf("%s",a[i]);

	for(i=0;i<h;i++){
		for(j=0;j<w;j++)
			if(a[i][j]=='#'){
				x[i]=1;
				y[j]=1;
			}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(x[i]==1&&y[j]==1)
				printf("%c",a[i][j]);
		}
		if(x[i]==1)
			printf("\n");
	}
	return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int m;
  ll k;
  cin >> m >> k;

  if(k >= 1<<m) {
    cout << -1 << endl;
    return 0;
  }
  if(m == 0) {
    if(k == 0) cout << 0 << " " << 0 << endl;
    else cout << -1 << endl;
    return 0;
  }

  if(m == 1) {
    if(k == 0) cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
    else cout << -1 << endl;
    return 0;
  }
  vector<int> b, ans;
  rep(i, 1<<m) if(i != k) b.push_back(i);

  for(auto x : b) ans.push_back(x);
  ans.push_back(k);
  reverse(ALL(b));
  for(auto x : b) ans.push_back(x);
  ans.push_back(k);

  line_out(ans);
}


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

const LL inf = 1e15+10;
const LL maxn = 1e5+10;
LL n,w;
LL dp[105][maxn+5];
LL val[105];
LL wet[105];


int32_t main()
{

    // reading input
    cin >> n >> w;
    for(int i = 1;i<=n;i++){
        cin >> wet[i] >> val[i];
    }



    // filling with infinity
    for(int i = 0;i<=n;i++){
        for(int j = 1;j<=maxn;j++){
            dp[i][j] = inf;
        }
    }



    // updating dp
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=maxn;j++){
            if(val[i] > j){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = min(dp[i-1][j-val[i]]+wet[i],dp[i-1][j]);
            }
        }
    }


    // output
    LL ans = 0;

    for(int i = 0;i<=maxn;i++){
        if(dp[n][i] <= w && i > ans){
            ans = i;
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 82468
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
  int N, A, B;
  scanf("%d %d %d", &N, &A, &B);
  printf("%d\n", min(N * A, B));
  
  return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> pll;
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
const ll maxn=200005;
pll a[maxn];
int main()
{  
	int n;
	int T;
	cin>>n;
	REP(i,n) cin>>a[i].S>>a[i].F;
	sort(a,a+n);
	T=0;
    REP(i,n) {
    	T+=a[i].S;
    	if (T>a[i].F) {
    		cout << "No\n";
    		return 0;
		}    	
	}
	cout << "Yes\n";
    //REP(i,n) cout << a[i].F << " ... " << a[i].S << endl; 
   	return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	public static int sumarea(String str, int sdepth, int edepth) {
		int i, len, start = sdepth, end = edepth, depth = 0;
		double area = 0;
		len = str.length();
		for (i = 0; i < len; i++) {
			if (start > end && str.charAt(i) == '\\') {
				start--;
			} else {
				switch (str.charAt(i)) {
					case '\\':
						area += depth - 0.5;
						depth -= 1;
						break;
					case '/':
						area += depth + 0.5;
						depth += 1;
						break;
					case '_':
						area += depth;
						break;
					default:
						continue;
				}
			}
		}
		return (int) -area;
	}

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i = 0, j = 0, len, start = -1, end = -1, depth = 0, sdepth = 0, edepth = 0, count = 0, memo = 0;
		int sum = 0;
		String str;
		str = scan.next();
		len = str.length();
		j = len / 2 + 1;
		int[] area = new int[j];
		j = 0;
		while (i < len) {
			for (i = memo; i < len; i++) {
				if (start == -1 && str.charAt(i) == '\\') {
					start = i;
					depth = 0;
					sdepth = 0;
				}
				if (start != -1) {
					switch (str.charAt(i)) {
						case '\\':
							depth -= 1;
							break;
						case '/':
							if (end == -1) {
								end = i;
								edepth = depth;
							}
							depth += 1;
							if (depth > edepth) {
								end = i;
								edepth = depth;
							}
							if (edepth == 0) {
								area[j] = sumarea(str.substring(start, end + 1), sdepth, edepth);
								sum += area[j];
								count++;
								j++;
								start = -1;
								end = -1;
							}
							break;
						default:
							continue;
					}
				}
			}
			if (start < end  && sdepth > edepth) {
				area[j] = sumarea(str.substring(start, end + 1), sdepth, edepth);
				sum += area[j];
				count++;
				i = end + 1;
				j++;
				memo = end;
				start = -1;
				end = -1;
			}
			if (i >= len)
				break;
		}
		System.out.print(sum + "\n" + count);
		for (i = 0; i < count; i++) {
				System.out.print(" "+area[i]);
		}
		System.out.println("");
		scan.close();
	}
}


Measured memory_bytes: 29144
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in_v(int, a, 3);
	sort_v(a);
	YESNO(a[0] == 5 && a[1] == 5 && a[2] == 7);
}

Measured memory_bytes: 256
def way9(ball, box):
    """ball: True / box: False / constraints: 1 or more
    -> ans = S(ball, box)  Sはスターリング数 / 計算量 O(ball * box)
    """
    if ball < box:
        return 0

    # S[i][j] := i個(区別する)をkグループ(区別しない)に分ける場合の数
    S = [[0] * (box + 1) for i in range(ball + 1)] 
    S[0][0] = 1
    for i in range(ball):
        for j in range(box):
            S[i + 1][j + 1] = S[i][j] + S[i][j + 1] * (j + 1)
            S[i + 1][j + 1] %= MOD

    return S[ball][box]


n, k = map(int, input().split())
MOD = 10 ** 9 + 7

print(way9(n, k))


Measured memory_bytes: 29348
<?php
$K = (int)trim(fgets(STDIN));
$S = trim(fgets(STDIN));
//list($N,$M,$K) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$s = trim(fgets(STDIN));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

if (strlen($S)<=$K) {
  printf("%s\n",$S);
}
else {
  printf("%s...\n",substr($S,0,$K));
}


Measured memory_bytes: 16044
from collections import deque
H,W,K=map(int,input().split())
s=[list(input()) for i in range(H)]
ans=[[0 for j in range(W)] for i in range(H)]
q=deque([])
cnt=1
for i in range(H):
    for j in range(W):
        if s[i][j]=="#":
            ans[i][j]=cnt
            cnt+=1
            q.appendleft((i,j))
while(len(q)>0):
    x,y=q.popleft()
    if 0<y:
        if ans[x][y-1]==0:
            q.append((x,y-1))
            ans[x][y-1]=ans[x][y]
    if y<W-1:
        if ans[x][y+1]==0:
            q.append((x,y+1))
            ans[x][y+1]=ans[x][y]
for i in range(H):
    if ans[i][0]!=0:
        q.append(i)
while(len(q)>0):
    k=q.popleft()
    if 0<k:
        if ans[k-1][0]==0:
            for j in range(W):
                ans[k-1][j]=ans[k][j]
            q.append(k-1)
    if k<H-1:
        if ans[k+1][0]==0:
            for j in range(W):
                ans[k+1][j]=ans[k][j]
            q.append(k+1)
for line in ans:
    print(*line)

        

Measured memory_bytes: 54876
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<vector> 
#include<iomanip>
#include<cmath>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	int n;
	while( cin>>n )
	{
		if( n<1200 )
			cout<<"ABC\n";
		else if( n<2800 )
			cout<<"ARC\n";
		else
			cout<<"AGC\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,h,max1;
char ch;
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>ch;
		if (ch=='I') h++; else h--;
		max1=max(max1,h);
	}
	cout<<max1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int vmax = 1e5 + 5;
int dp[vmax];
const int inf = 1e18;

signed main() {
  int n, W;
  cin >> n >> W;
  vector<int> w(n), v(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }
  // for (auto&& w : w) cout << w << " ";
  // cout << endl;
  // for (auto&& w : v) cout << w << " ";
  // cout << endl;

  fill(dp, dp + vmax, inf);
  dp[0] = 0ll;
  for (int i = 0; i < n; i++) {
    for (int j = vmax - 1; j >= 0; j--) {
      if (dp[j] == inf) continue;
      dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
    }
  }
  // for (int i = 0; i < vmax; i++) {
  //   if (dp[i] == inf) continue;
  //   cout << i << " " << dp[i] << endl;
  // }

  int ans = 0ll;
  for (int i = 0; i < vmax; i++) {
    if (dp[i] <= W) ans = i;
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
	char masu[3][4];
	cin >> masu[0] >> masu[1] >> masu[2];

	for (int i = 0; i < 3; i++)
		cout << masu[i][i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())

N = int(input())
print(N*(N+1)//2)


Measured memory_bytes: 6160
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define pf push_front
#define eb emplace_back 
#define all(v) (v).begin(), (v).end()
#define mod 100000
#define mi multiset<int>
#define mii multiset<pii>
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

int modp(int a,int m,int n)
{
    n=n%(m-1);
    a=a%m;
    int res=1;
    while(n>0)
    {
        if(n&1) res=(res*a)%m;
        a=(a*a)%m;
        n>>=1;
    }
    return res;
}



void solve()
{
    int t,n,m,i,k,l,r,u,v,w,j,s,pos,sum=0,flag=0,count=0;
    string S,T,U;
    // int h1,m1,h2,m2;
    long double a,b;
    cin>>a>>b;
    int ans=a*b;
    cout<<ans;
}



signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3784
#include <stdio.h>

char good[15];

int main(){

	int N;

	scanf("%d",&N);

	int cnt=0;
	while(N>0){
	good[cnt]=(N%10)+'0';
	N/=10;
	cnt++;
	}

	if((good[0]==good[1]&&good[0]==good[2]) ||(good[1]==good[2]&&good[1]==good[3])){
	printf("Yes\n");
	}
	else{
	printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 256
N=int(input())
lista=["a","b","c","d","e","f","g","h","i","j","k","l","m","n"
             ,"o","p","q","r","s","t","u","v","w","x","y","z"]
amari=[]
ans=""
while N!=0:
    (x,y)=divmod(N,26)
    amari.append(y)
    N=x
amari=amari[::-1]
while 0 in amari[1:]:
    for i in range(len(amari)-1):
        if amari[i+1]==0:
            amari[i]-=1
            amari[i+1]=26
if amari[0]==0:
    amari.pop(0)
for i in amari:
    ans+=lista[i-1]
print(ans)

Measured memory_bytes: 9072
/*
By Tianyi Chen. All rights reserved.
Date: 2018-07-07
*/
#include<bits/stdc++.h>
#include<queue>
using namespace std;
int n,m,s,t;
multiset<int64_t>ms;
deque<multiset<int64_t>::iterator>q;
int64_t ds[100001],dt[100001];
vector<pair<int,int64_t>>es[100001],et[100001];
void sh(vector<pair<int,int64_t>>*e,int s,int64_t*d){
 memset(d,0x33,100001*8);
 d[s]=0;
 priority_queue<pair<int64_t,int>,vector<pair<int64_t,int>>,greater<pair<int64_t,int>>>q;
 q.emplace(0,s);
 while(q.size()){
  int p;int64_t dd;
  tie(dd,p)=q.top();q.pop();
  if(dd!=d[p])continue;
  for(auto&&x:e[p])if(d[x.first]>dd+x.second){
   q.emplace(d[x.first]=dd+x.second,x.first);
  }
 }
}
int main(){
 scanf("%d%d%d%d",&n,&m,&s,&t);
 while(m--){
  int u,v,a,b;
  scanf("%d%d%d%d",&u,&v,&a,&b);
  es[u].emplace_back(v,a);
  es[v].emplace_back(u,a);
  et[u].emplace_back(v,b);
  et[v].emplace_back(u,b);
 }
 sh(es,s,ds);sh(et,t,dt);
 for(int i=1;i<=n;++i)q.emplace_back(ms.insert(ds[i]+dt[i]));
 for(int i=0;i<n;++i){
  printf("%lld\n",int64_t(1e15)-*ms.begin());
  ms.erase(q[i]);
 }
}

Measured memory_bytes: 23680
n = int(input())
a = list()
for i in range(120):
	a.append(0)
for i in range(n):
	b, f, r, v = map(int, input().split())
	a[(b - 1) * 30 + (f - 1) * 10 + (r - 1)] += v
for i in range(4):
	if i >= 1:
		print("#" * 20)
	for j in range(3):
		for k in range(10):
			print(' ', end = '')
			print(a[i * 30 + j * 10 + k], end = '')
		print()


Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
ll n, h[200005], a[200005];
//~ struct node{
	//~ ll s, e, m, v;
	//~ node *l, *r;
	//~ node (ll _s, ll _e){
		//~ s = _s;e=_e; m=(s+e)/2;
		//~ if (s!=e){
			//~ l = new node(s, m);
			//~ r = new node(m+1, e);
			//~ v = max(l->v, r->v);
		//~ }else v = 0;
	//~ }
	//~ ll query(ll x, ll y){
		//~ if (s == x && e == y)return v;
		//~ if (x > m)return (r->query(x, y));
		//~ if (y <= m)return (l->query(x, y));
		//~ return (max(l->query(x, m), r->query(m+1, y)));
	//~ }
	//~ void update(ll x, ll val){
		//~ if (s == x && e == x){v = val; return;}
		//~ if (x > m)r->update(x, val);
		//~ else l->update(x, val);
		//~ v = max(l->v, r->v); 
	//~ }
//~ }*root;
struct node{
    ll s,e,m,v; //global variables
    node *l, *r; //global pointers
    node(ll _s, ll _e){ //init
        s=_s;e=_e;m=(s+e)/2;
        if (s!=e){
            l=new node(s,m);
            r=new node(m+1,e);
            v=max(l->v, r->v);
        }else v=0; //starts off with 0 before any updates
    }
    
    ll query(ll x, ll y){
        if (s == x && e == y)return v; //leaf
        if (x > m)return(r->query(x, y)); //only part of right
        if (y <= m)return(l->query(x, y)); //only part of left
        return(max(l->query(x, m),r->query(m+1, y))); //in between nodes
    }
    void update(ll x, ll val){
        if (s == x && e == x){v = val;return;} //leaf node
        if (x > m)r->update(x, val); //update the right child
        else l->update(x, val); //update the left child
        v=max(l->v,r->v); //updates all above nodes when leaf is updated
    }
}*root;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	//~ ll maxhi = 0;
	for(ll i  = 1; i <= n; i++){
		cin >> h[i];
	}
	for (ll i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	root = new node(0, n);
	//~ for (ll i = 1; i <= n; i++){
		//~ root->update(h[i], a[i]);
	//~ }
	//~ cout << root->query(1, n);
	//~ for (ll i= 1; i <= n; i++)cout << h[i] <<  ' ';
	//~ dp[i] stores the max sum for flower that has height h[i]
	for (ll i = 1; i<= n; i++){
		//for each flower
		//~ for (ll j = 0; j< h[i]; j++){
			//~ dp[h[i]] = max(dp[h[i]], dp[j]+h[i]);
		//~ }
		//~ root->update(h[i],  a[i]);
		ll vv = root->query(0, h[i]-1ll);
		root->update(h[i], vv+a[i]);
	}
	cout << root->query(1, n);
}


Measured memory_bytes: 30336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7; 
const int SIZE=1<<21;
string s;
int k;
ll fac[SIZE],rev[SIZE];
inline ll Pow(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1){
			res=res*x%mod;
		}
		y>>=1;
		x=x*x%mod;
	}
	return res;
}
inline ll C(int x,int y){
	if(y<0||y>x){
		return 0;
	}
	return fac[x]*rev[y]%mod*rev[x-y]%mod;
} 
inline void build(){
	fac[0]=1;
	for(int i=1;i<SIZE;++i){
		fac[i]=fac[i-1]*i%mod;
	}
	rev[SIZE-1]=Pow(fac[SIZE-1],mod-2);
	for(int i=SIZE-2;i>=0;--i){
		rev[i]=rev[i+1]*(i+1)%mod;
	}
}
int main(){
	cin>>k>>s;
	build();
	int n=s.size();
	long long ans=0;
	for(int i=n;i<=k+n;++i){
		ans+=C(k+n,i)*Pow(25,k+n-i)%mod;
		ans%=mod;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 37212
#include <iostream>
#include <vector>
#define BIG_SIZE 100000
using namespace std;

typedef struct edge { int l,r;} ed;

int check(int k){
    int i=k*2-1;
    int j;
    for(j=3;j<i/2;j+=2){
        if(k%j==0||i%j==0)break;
    }
    if(j>i/2)return 1;
    else return 0;
}

int main()
{
    vector<int> vec={0};
    int Q, count = 0;
    cin >> Q;
    ed es[BIG_SIZE];
    
    for (int i = 0; i < Q; i++)
    {
        cin >> es[i].l >> es[i].r;
    }
    int minl=BIG_SIZE , maxr=0;
    for(int i=0; i<Q; i++ ){
        if(minl>es[i].l)minl=es[i].l;
        if(maxr<es[i].r)maxr=es[i].r;
    }
    int k=0;
    for(int i=minl;maxr >=i;i+=2){
        k=(i+1)/2;

        if(k==2)count++;
        if(k==1){}
        else if(k%2==1) count += check(k);
        
        vec.push_back(count);
    }
    
    for(int i=0;i<Q;i++){
        cout << vec[(es[i].r - minl)/2+1] - vec[(es[i].l - minl)/2] <<"\n";
    }

}

Measured memory_bytes: 1788
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{int p, l, r; };
struct Node T[MAX];
int n;

void Preparse(int u){
  if(u == NIL) return;
  printf(" %d", u);
  Preparse(T[u].l);
  Preparse(T[u].r);
}

void inParse(int u){
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main()
{
  int i, v, l, r, root;
  
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    T[i].p = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if (l != NIL) T[l].p = v;
    if (r != NIL) T[r].p = v;
  }
  
  for (i = 0; i < n; i++) if(T[i].p == NIL) root = i;

  printf("Preorder\n");
  Preparse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

 return 0;
}
 

Measured memory_bytes: 1856
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod = 1000000007;
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */
 
int main(void){
    int n;
    cin  >> n;
    vector<int> a;
    for(int i=0; i<n; i++){
        ll x;
        cin >> x;
        a.push_back(x);
    }
 
    int flag = 0;
 
    // 全てのxor==0ならok
    ll tmp=0;
    for(int i=0; i<n; i++){
        tmp ^= a[i];
    }
 
    // 出力
    if(tmp != 0) cout << "No" << "\n";
    else if(tmp == 0) cout << "Yes" << "\n";
    return 0;
}

Measured memory_bytes: 892
#include<iostream>
using namespace std;
 int main()
{
   
// 旅行する人数 整数Nの入力を変数へ代入
       int N;
       cin >> N;
// 一人あたりの電車代Aの入力
       int A;
       cin >> A;
// グループタクシー代Bの入力
       int B;
       cin >> B;
   
// 交通費の最小値を出力
   
   if(A * N < B) { // A*N が B 以下のときは
 		cout << A * N << endl;
    }
   
	else { //BがA*N以下の場合はBを出力
    	  cout << B << endl;
    }
    return 0;
 }


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

int main(){
    int64_t a, b;
    cin >> a >> b;
    for(int64_t i = 1; i <= b; i++){
        if(i*a%b == 0){
            cout << i*a << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256