akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <cstdlib>
#include <typeinfo>

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

using namespace std;

template<class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

void trace(int A[], int N) {
  for (int i = 0; i < N; ++i) {
    if (i > 0) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

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

const unsigned long long INF = 1LL << 60;

string str_tolower(string s) {
  transform(s.begin(), s.end(), s.begin(),
            [](unsigned char c) { return tolower(c); });
  return s;
}

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

string W, T;

int main() {
  cin >> W;
  int ans = 0;
  bool is_match = false;
  while (true) {
    cin >> T;
    if (T == "END_OF_TEXT") break;

    for (int i = 0; i < T.length(); ++i) {
      // 単語の先頭ではない
      if (i > 0 && T[i - 1] != ' ') continue;

      // 先頭文字が異なる
      if (tolower(T[i]) != towlower(W[0])) continue;

      // 単語を切り出し、一致するか調べる
      string w;
      int j = 0;
      while (i + j < T.length()) {
        char c = T[i + j];
        if (c == ' ' || c == '\n') break;

        w.push_back(c);
        j++;
      }
      i += j;
      if (str_tolower(W) == str_tolower(w)) {
        ans++;
      }
    }
  }

  cout << ans << endl;
}



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

int main() {
  int A, B, ans = 0;
  cin >> A >> B;

  while (A <= B) {
    A / 10000 % 10 == A % 10 && A / 1000 % 10 == A / 10 % 10 ? ans += 1 : 0;
    A += 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
S = list(input())
L = len(S)
M = 13
MOD = 10**9 + 7
dp = [[0]*M for _ in range(L+1)]
dp[0][0]=1
for i in range(L):
    p = pow(10, L-1-i, 13)
    if S[i] == "?":
        for j in range(M):
            for k in range(10):
                s = k*p
                dp[i+1][(j+s)%13] += dp[i][j]
                dp[i + 1][(j + s) % 13] %= MOD
    else:
        s = int(S[i])
        s *= p
        for j in range(M):
            dp[i+1][(j+s)%13] += dp[i][j]
            dp[i + 1][(j + s) % 13] %= MOD

print(dp[L][5])

Measured memory_bytes: 100500
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef vector<bool> vec;
typedef vector<vec> mat;
typedef long long ll;

mat mul(mat A, mat B) {
  mat C(A.size(), vec(B[0].size()));
  REP(i,A.size())
    REP(j,B[0].size())
    REP(k,B.size())
    C[i][j] = (C[i][j] | A[i][k]*B[k][j]);
  return C;
}

mat pow(mat A, ll n) {
  mat B(A.size(), vec(A.size()));
  REP(i,A.size())
    B[i][i] = 1;
  while(n) {
    if (n&1) B = mul(B, A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}

typedef pair<int,int> pii;
int main() {
  int n,m,z;
  while(cin>>n>>m>>z,n||m||z) {
    pii arr[2*m];
    int cnt = 0;
    int id2[n][n];
    memset(id2,-1,sizeof(id2));
    REP(i,m) {
      int s,d;
      cin >> s >> d;
      s--;d--;
      arr[cnt] = pii(s,d);
      id2[s][d] = cnt++;
      arr[cnt] = pii(d,s);
      id2[d][s] = cnt++;
    }

    mat G(cnt+1,vec(cnt+1));
    REP(i,cnt) {
      int s = arr[i].first;
      int d = arr[i].second;
      REP(j,n) {
        if (id2[j][s]>=0 && j!=d) {
          G[id2[j][s]][id2[s][d]] = 1;
        }
      }
    }
    REP(i,n)
      if (i&&id2[0][i]>=0)
        G[cnt][id2[0][i]] = 1;
    // REP(i,cnt+1) {
    //   REP(j,cnt+1)
    //     cout << G[i][j] << " ";
    //   cout << endl;
    // }cout << endl;
    mat res = pow(G,z);
    // REP(i,cnt+1) {
    //   REP(j,cnt+1)
    //     cout << res[i][j] << " ";
    //   cout << endl;
    // }
    bool f = 0;
    REP(i,n) {
      if (id2[i][n-1]>=0 && res[cnt][id2[i][n-1]]) {
        f = 1;
        break;
      }
    }
    if (f)
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
}

Measured memory_bytes: 940
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

int main(void){
	string A,B;
	cin>>A>>B;

	int lenA = A.size(), lenB = B.size();
	bool equal = false;
	if(lenA > lenB) printf("GREATER\n");
	else if(lenA < lenB) printf("LESS\n");
	else{
		for(int i=0;i<A.size();i++){
			if(A[i] == B[i]) continue;
			if(A[i] > B[i]){
				printf("GREATER\n");
				return 0;
			}
			else if(A[i] < B[i]){
				printf("LESS\n");
				return 0;
			}
		}
		equal = true;
	}

	if(equal) printf("EQUAL\n");


	return 0;
}

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

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    set<int,greater<>>s;
    for (int i = 1; i*i <=m ; ++i) {
        if(m%i==0)
        {
            s.insert(i);
            s.insert(m/i);
        }
    }

    for(auto i:s)
    {
        int z=m/i;
        if(z>=n)
        {
            cout<<i;
            return 0;
        }

    }

}

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

int main(){
  int n;
  ll m;
  cin>>n>>m;
  vector<ll> res;
  for(ll i=1;i*i<=m;i++){
    if(m%i==0){
      res.push_back(i);
      if(i!=m/i){
        res.push_back(m/i);
      }
    }
  }
  sort(res.begin(),res.end());
  int a=res.size();
  rep(i,0,a){
    if(m/res[a-1-i]>=n){
      cout<<res[a-1-i]<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(i, m, n) for(int i = m; i < n; i++)
    #define rep3(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    #define COUT(N) cout<<fixed<<setprecision(N)
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    lint A,B,N;
    cin >>A >> B >>N;
    if(N>=B)cout << A-(A+B-1)/B;
    else    cout << (A*N)/B;
}


Measured memory_bytes: 3644
import java.lang.reflect.Array;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String S = sc.next();                
		String T = sc.next();
		ArrayList<Character> x = new ArrayList<Character>();		
		for (int i = 0; i < S.length(); i++) {
			if (S.charAt(i) != T.charAt(i)) {
				if (x.contains(T.charAt(i))) {
					System.out.println("No");
					return;
				}
				x.add(T.charAt(i));
				S = S.replace(S.charAt(i), '*').replace(T.charAt(i), S.charAt(i)).replace('*', T.charAt(i));
			}
		}
		if(S.equals(T)){
			System.out.println("Yes");			
		} else {
			System.out.println("No");			
		}
	}	
}


Measured memory_bytes: 44608
<?php
list($n,$m)=explode(' ',trim(fgets(STDIN)));
for($i=0;$i<$n;$i++)$a[$i]=explode(' ',trim(fgets(STDIN)));
for($i=0;$i<$m;$i++)$b[$i]=trim(fgets(STDIN));
 
for($i=0;$i<$n;$i++){
  $c=0;
  for($j=0;$j<$m;$j++) $c+=$a[$i][$j]*$b[$j];
  $o[]=$c;
}
print implode(PHP_EOL,$o);
?>

Measured memory_bytes: 17204
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll x,y;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>x>>y;
    ll ans=1e17;
    if(-x<=y) ans=min(ans,1+y+x);
    if(-x<=-y) ans=min(ans,2+x-y);
    if(x<=y) ans=min(ans,y-x);
    if(x<=-y) ans=min(ans, 1-y-x);
    cout<<ans<<"\n";
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	auto A=in(),B=in();
	string S=in<string>();
	if(S[A]!='-'){
		out("No");
		return 0;
	}
	REP(i,A){
		if(S[i]=='-'){
			out("No");
			return 0;
		}
	}
	for(int i=A+1;i<A+B+1;i++){
		if(S[i]=='-'){
			out("No");
			return 0;
		}
	}
	
	out("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <limits>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <vector>
#include <deque>
#include <cmath>

using namespace std;
int n;

int main() {

    scanf("%d", &n);
    vector<int> l(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &l[i]);
    }

    int cnt = 0;
    sort(l.begin(), l.end(), greater<>());
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if (l[i] == l[j] || l[i] == l[k] || l[j] == l[k]) continue;
                if (l[i] < l[j] + l[k]) {
                    // valid combination
                    cnt++;
                }
            }
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 3788
#include <stdio.h>
#include<math.h>
int isPrime(int x){
  int i;

  if(x == 2)    return 1;
  if(x < 2 || x % 2 == 0)    return 0;

  i = 3;
  while(i <= sqrt(x)){
    if(x % i == 0)    return 0;
    i += 2;
  }

  return 1;
}

int main(){
  int n, x, i;
  int cnt = 0;
  scanf("%d", &n);
  for ( i = 0; i < n; i++){
    scanf("%d", &x);
    if(isPrime(x))cnt++;
  }
  printf("%d\n", cnt);

  return 0;
}

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

char k[10005];
int l;
int d;
long long M=1000000007;
long long memo[10005][105][2];

long long dp(int i,int mod,int flag){
	if(i==l){
		if(mod==0)return 1;
		return 0;
	}
	if(memo[i][mod][flag]!=-1)return memo[i][mod][flag];
	if(flag==0){
		long long ans=0;
		for(int j=0;j<=9;j++){
			ans+=dp(i+1,(mod+j)%d,0);
			ans%=M;
		}
		return memo[i][mod][flag]=ans;
	}else{
		long long ans=0;
		int x=k[i]-'0';
		for(int j=0;j<x;j++){
			ans+=dp(i+1,(mod+j)%d,0);
			ans%=M;
		}
		ans+=dp(i+1,(mod+x)%d,1);
		ans%=M;
		return memo[i][mod][flag]=ans;
	}
}

int main(){
	scanf("%s %d",k,&d);
	l=strlen(k);
	memset(memo,-1,sizeof(memo));
	printf("%lld",(dp(0,0,1)-1+M)%M);
}

Measured memory_bytes: 17408
#include <stdio.h>

int main(void){
  int n;
  char S[7];
  char s[3][7] = {"Sunny", "Cloudy", "Rainy"};
  scanf("%s", S);
  if(S[0] == 'S') n = 1;
  else if(S[0] == 'C') n = 2;
  else n = 0;
  printf("%s\n", s[n]);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
const string el = "\n";
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
template<class T> T gcd(T a,  T b) {return b ? gcd(b, a % b) : a;}
template<class U> U lcm( U m, U n ){if((0 == m )||( 0 == n ))return 0; return ((m / gcd(m, n)) * n); }
signed main(){
    fast_io();
    int N; cin >> N;
    vector<int>d(N);
    for(auto& e : d) cin >> e;
    sort(all(d));
    int ans = 0;
    for(int i = 1; i <= d.back(); ++i){
        auto t = lower_bound(all(d),i);
        if(distance(d.begin(),t) == distance(t, d.end()))++ans;
    }
    cout << ans << endl;
}


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


void solve(long long D, long long G, std::vector<long long> p, std::vector<long long> c){
    int ans = 1e9;

    // 同じ得点グループを全て解いたパターンをbit全探索
    for (int s=0; s < (1<<D); s++) {
        int solve = 0, score = 0;
        // 部分的に解きたい場合
        int partial = -1;

        // i番目の得点が同じ問題グループは全て解く
        for (int i=0; i<D; i++) {
            if (s & (1<<i)) {
                solve += p[i];
                score += 100 * (i+1) * p[i] + c[i];
            } else {
                /* こうすることで、最終的に部分的に解きたい問題のうち
                   得点が最大の問題のiがpartialに入る */
                partial = i;
            }
        }
        // 残スコア
        int less = G - score;
        if (less > 0) {
            // 部分的に解きたい問題の1問分の点数
            long long prob_score = 100*(partial + 1);
            if (less > prob_score*p[partial]) continue;
            solve += min(p[partial], (less+(prob_score-1)) / prob_score);
        }
        ans = min(ans, solve);
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long D;
    scanf("%lld",&D);
    long long G;
    scanf("%lld",&G);
    std::vector<long long> p(D);
    std::vector<long long> c(D);
    for(int i = 0 ; i < D ; i++){
        scanf("%lld",&p[i]);
        scanf("%lld",&c[i]);
    }
    solve(D, G, std::move(p), std::move(c));
    return 0;
}


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

int main() {
  int n;
  std::cin >> n;
  int cnt = 0;
  for (int i = 1; i <= n; ++i)
    if (std::to_string(i).length() % 2 != 0)
      cnt++;
  std::cout << cnt << std::endl;
}


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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int a[m];
    for(int i = 0; i < m; i++) {
        cin >> a[i];
    }
    int play_days = n;
    for(int j = 0; j < m; j++) {
        play_days -= a[j];
    }
    if(play_days >= 0) cout << play_days << endl;
    else cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF INT_MAX
#define endl '\n'
#define ll long long int
#define N 200006
using namespace std;

inline int redi() {
	int ret = 0,f = 0;char ch = getchar_unlocked();
	while (!isdigit (ch)) {
		if (ch == '-') f = 1;
		ch = getchar_unlocked();
	}
	while (isdigit (ch)) {
		ret = ret*10  + ch - 48;
		ch = getchar_unlocked();
	}
	return f?-ret:ret;
}
inline void print(int x) {
	if(x<0) {putchar_unlocked('-');x=-x;}
	int y=10,len=1;
	while(y<=x)    {y*=10;len++;}
	while(len--){y/=10;putchar_unlocked(x/y+48);x%=y;}
}

inline void init()
{
	multiset<int> s;
	ll n,num[N];
	cin >> n;
	for(int i=0;i<n;++i){
		cin >> num[i];
		s.insert(num[i]);
	}
	auto iter=s.end();
	--iter;
	for(int i=0;i<n;++i)
		if(num[i]!=*iter)
			cout << *iter << endl;
		else
			cout << *prev(iter) << endl;

}

inline void solve()
{
}

int main()
{
	//freopen("input.in","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	init();
	solve();
	cout << flush;

	return 0;
}


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

#define ll long long
#define UN unsigned
#define pb push_back
#define mod 1000000007
#define mt make_tuple
typedef tuple<int, int> tii;
typedef pair<int, int> pii;

const int N = 1e5 + 1;

void solve(){
    int n, W;
    cin >> n >> W;

    int w[105], v[105];
    for(int i=1; i<=n; i++){
        cin >> w[i] >> v[i];
    }

    ll dp[101][N];
    
    for(int i=1; i<=n; i++){
        for(int j=1; j<=W; j++){
            if(j < w[i]){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = max(dp[i-1][j], v[i] + dp[i-1][j-w[i]]);
            }
        }
    }

    cout << dp[n][W];
}

int main(void){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 78464
#include<cstdio>
#include<algorithm>

const int N=100;
int n,a[N+5][N+5];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
			a[i][j]+=std::max(a[i-1][j],a[i][j-1]);
		}
	printf("%d",a[2][n]);
	return 0;
}

Measured memory_bytes: 128
S = gets.strip

if S=='zyxwvutsrqponmlkjihgfedcba'
    puts '-1'
    exit
end

ans=''
if S.size==26
    j=-1
    (0..S.size-2).reverse_each do |i|
        key=S[i]
        nokori=S[i,99]
        nokorisortedrev=S[i,99].split("").sort.reverse.join
        if nokori!=nokorisortedrev
            nokorisorted=S[i,99].split("").sort
            nokorisorted.each do |s|
                if s>key
                    ans=S[0,i]+s
                    puts ans
                    exit
                end
            end
            
        end
    end

else
    arr=S.split("")
    ('a'..'z').each do |a|
        if !arr.include?(a)
            ans=S+a
            break
        end
    end
end

puts ans


Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

const double PI = 3.14159265358979323846;

int map[16][16];

inline int get(int x, int y) {
    if (map[x][y] == -1) {
        return -1;
    }
    int r = 0;
    if ((0 < x) && (map[x - 1][y] != -1)) {
        r += map[x - 1][y];
    }
    if ((0 < y) && (map[x][y - 1] != -1)) {
        r += map[x][y - 1];
    }

    return r;
}

int main() {
    while (true) {
        int n, w, h;
        cin >> w >> h >> n;
        if ((w == 0) && (h == 0)) {
            return 0;
        }
        for (int i = 0; i < w; ++i) {
            for (int j = 0; j < h; ++j) {
                map[i][j] = 0;
            }
        }
        for (int i = 0; i < n; ++i) {
            int x, y;
            cin >> x >> y;
            map[x - 1][y - 1] = -1;
        }
        map[0][0] = 1;

        for (int mw = 1; mw < w; ++mw) {
            for (int mh = 1; mh < h; ++mh) {
                for (int x = 0; x < mw; ++x) {
                    map[x][mh] = get(x, mh);
                }
                for (int y = 0; y < mh; ++y) {
                    map[mw][y] = get(mw, y);
                }
                map[mw][mh] = get(mw, mh);
            }
        }

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

Measured memory_bytes: 1160
#include<cstdio>
#include<iostream>

#define rep(i,a,b) for (int i = a ; i < b ; i ++)

using namespace std;

char a[100];

int main()
{
    cin>> a;
    a[5] = ' ';
    a[13] = ' ';
    cout<< a <<endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.string;
import std.conv;
import std.typecons;
import std.math;
import std.numeric;

void main() {
    int[] input;
    foreach (i; 0 .. 5) {
        input ~= readln().chomp().to!int;
    }

    solve(input).writeln();
}

int solve(int[] foods) {
    foods.sort!((f1, f2) {
        auto f1_1 = f1 % 10;
        auto f2_1 = f2 % 10;
        return (10 - f1_1) % 10 < (10 - f2_1) % 10;
    });
    int time = 0;
    foreach (food; foods) {
        if (time % 10 != 0) {
            time = 10 * (time / 10 + 1);
        }
        time += food;
    }
    return time;
}

unittest {
    assert(solve([29, 20, 7, 35, 120]) == 215, solve([29, 20, 7, 35, 120]).to!string);
    assert(solve([101, 86, 119, 108, 57]) == 481, solve([101, 86, 119, 108, 57]).to!string);
    assert(solve([123, 123, 123, 123, 123]) == 643, solve([123, 123, 123, 123, 123]).to!string);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<bool>	vb;

ll mod = 1e9 + 7;
ll fact[(ll)2000005];
ll infact[(ll)2000005];

ll bin_exp(ll a, ll b){
    a = a % mod;
    ll ans = 1;
    while(b > 0){
        if((b & 1) == 1) ans = (a * ans) % mod;
        a = (a * a) % mod;
        b = b >> 1; 
    }
    return ans;
}

ll mod_inv(ll n){
    ll a = bin_exp(n,mod - 2);
    return a;
}

void fac(){
    fact[0] = 1;
    infact[0] = 1;
    rep(i,1,2000002){
        fact[i] = (fact[i - 1] * i) % mod;
        infact[i] = (mod_inv(i) * infact[i - 1]) % mod;
    }
}



int main(){  
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll k;
    string s;
    cin >>  k >> s;
    ll n = s.length();
    fac();
    ll ans = 0;
    rep(i,0,k + 1){
        ll res = (fact[n + k - i - 1] * ((infact[k - i] * infact[n - 1]) % mod)) % mod;
        ll bin = (bin_exp(26,i) * bin_exp(25,k - i)) % mod;
        ans = (ans + ((res * bin) % mod)) % mod;
    }
    cout << ans << endl;

    
    
}

Measured memory_bytes: 35580
#include <bits/stdc++.h>
#define ll long long int
#define N 100000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
#define square(x) x*x
using namespace std;
/**
        * @author :: Sawlani
        *
        */

ll check(ll i,ll j,ll x,ll y)
{
    if(j<=x||i>=y)
    return 0;

    if(i<x&&j>x&&j<=y)
    return 1;
    
    if(i>=x&&i<y&&j>y)
    return 2;

    if(i>=x&&j<=y)
    return 3;

    return 4;


}
int main()
{
    ll n,x,y;
    cin >>  n >>  x >>  y;

     
     ll dis[n]={0};
     f(i,1,n)
     {
         f(j,i+1,n)
         {  
            //  cout <<  i << " " <<  j <<  "  " << check(i,j,x,y) << endl;
             ll res=check(i,j,x,y);
             if(res==0)//out
             {
                  dis[j-i]++;  
             }
             else if(res==1)//cut
             {
                dis[min(j-i,x-i+1+y-j)]++;
             }
             else if(res==2)//cut
             {
                dis[min(j-i,i-x+1+j-y)]++;
             }
             else if(res==3)//in
             {
                 dis[min(j-i,i-x+1+y-j)]++;
             }
             else//cov
             {
                 dis[min(j-i,x-i+1+j-y)]++;
             }
             
             
         }
     }

     f(i,1,n-1)
     cout << dis[i] <<  endl;
}

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

C = list()
A = list()
for i in range(N):
	temp = list(map(int,input().split()))
	C.append(temp[0])
	A.append(temp[1:])	


MAX = 100000000000	

def func(cost,a,i):
	if min(a) >= X:
		return cost
	elif i == N:
		return MAX
	total_A = [x+y for (x,y) in zip(a,A[i])]
    
	return min(func(cost + C[i],total_A,i+1),func(cost,a,i+1))
	
ans = func(0,[0]*M,0)

if ans == MAX:
	print(-1)
else:
	print(ans)


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

using namespace std; 

using ll = long long;

const int N = 1000005, INF = 1000000005;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int animals, legs;
    cin >> animals >> legs;
    if((legs % 2 == 1) || legs < (animals * 2) || (animals * 4) < legs) 
        cout << "No";
    else
        cout << "Yes";
    
    return 0;
}

Measured memory_bytes: 3128
def search(n):
    res = 0
    while n:
        n %= bin(n).count("1")
        res += 1
    return res


def main():
    n = int(input())
    x = list(input())
    x_decimal = int("".join(map(str, x)), 2)
    first_mod = sum(map(int, list(x)))
    increase_mod = first_mod + 1
    increase_base = x_decimal % increase_mod  # 反転させる桁が元々0だった場合
    decrease_mod = first_mod - 1
    if decrease_mod:
        decrease_base = x_decimal % decrease_mod  # 反転させる桁が元々1だった場合
    for i in range(n):
        cnt = 0
        if x[i] == "1" and decrease_mod:
            cnt = 1 + search((decrease_base - pow(2, n - i - 1, decrease_mod)) % decrease_mod)
        elif x[i] == "0":
            cnt = 1 + search((increase_base + pow(2, n - i - 1, increase_mod)) % increase_mod)
        print(cnt)


if __name__ == '__main__':
    main()



Measured memory_bytes: 107132
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;
 
class DandA {
    static void Main(string[] args) {
        int[] nk = ReadLineIntArray();
        int[] hList = ReadLineIntArray();
        Array.Sort(hList);
        int i = 0;
        for (i = 0;i < nk[0]; i++) {
            if (hList[i] >= nk[1]) {break;}
        }
        Console.WriteLine(nk[0] - i);
    }
 
    static string[] ary = new string[] {"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", "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"};
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private long ReadLineLong() {return long.Parse(Console.ReadLine());}
    static private double ReadLineDouble() {return double.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private double[] ReadLineDoubleArray() {return Console.ReadLine().Trim().Split().Select(a => double.Parse(a)).ToArray();}
    static private decimal[] ReadLineDecimalArray() {return Console.ReadLine().Trim().Split().Select(a => decimal.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
 
    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
}

Measured memory_bytes: 19296
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);

int main(){
	ll a,b,c;
	cin>>b>>c>>a;
	cout<<a<<" "<<b<<" "<<c<<endl;

	
}

Measured memory_bytes: 256
<?php
// $n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$a = (int)$input[0];
$b = (int)$input[1];

echo lcm($a, $b);




// 最大公約数（ユークリッドの互除法）
function gcd($large, $small){
	while($small !== 0){
		$tmp_n = $small;
		$small = $large % $small;
		$large = $tmp_n;
	}
	return $large;
}
// 最小公倍数（gcd依存）
function lcm($m,$n){
	$large = max($m, $n);
	$small = min($m, $n);
	return ($m * $n) / gcd($large, $small);
}

Measured memory_bytes: 4856
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < s.size(); i++){
        s[i] = 'A' + ((s[i] - 'A' + n) % 26);
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
 using namespace std;
 
 int a[101];
 int main()
 {
   int n,x,s=0,i;
   cin>>n;
   for(i=1;i<=n;i++)
   {
     cin>>x;
     a[x]=1;
   }
   for(i=1;i<=100;i++)
   if(a[i]==1) s++;
   
   cout<<s<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

int op(int x,int y){return max(x,y);}
int e(){return 0;}

void solve() 
{
    int n,k;cin>>n>>k;
    segtree<int,op,e>st(300010);
    REP(i,n){
        int a;cin>>a;
        st.set(a,st.prod(max(0,a-k),min(300010,a+k+1))+1);
    }
    cout<<st.all_prod()<<endl;
}

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

Measured memory_bytes: 8512
N=int(input())
box={}
if N<10:
  ans=N
if N>=10:
  for i in range(1,100):
    box[i]=0
  for i in range(1,N+1):
    A_first=str(i)[0]
    if i<=9:
      A_first=0
    A_back=i%10
    index=int(A_first)*10+int(A_back)
    box[index]+=1
  ans=0
  a=0
  b=0
  for i in range(1,100):
    if len(str(i))==1:
      ans+=(box[i]+box[i*11])**2
    if i>10 and str(i)[0]!=str(i)[1] and i%10!=0:
      t=i//10+(i%10)*10
      ans+=(box[i]*box[t])
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <functional>
#include <list>

#define MOD (1000000000 + 7)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 3000000;

long long fac[MAX], finv[MAX], inv[MAX];

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
            prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
} 

vector<ll> divisor;
void list_divisor(ll n) {
    divisor.clear();
    for(int i = 1; i*i <= n; i++) {
        if(n % i == 0) {
            divisor.push_back(i);
            if(i*i != n) divisor.push_back(n/i);
        }
    }
    sort(divisor.begin(), divisor.end());
}

int main() {
    ll N, P;
    cin >> N >> P;
    ll even = 0, odd = 0;
    COMinit();

    for(ll i = 0; i < N; i++) {
        ll tmp;
        cin >> tmp;
        if(tmp%2 == 0) even++;
        else odd++;
    }

    ll base = pow(2, even);
    ll odd_sum = 0, even_sum = 0;
    for(ll i = 0; i <= odd; i++) {
        if(i%2 == 1) odd_sum += COM(odd, i);
        else even_sum += COM(odd, i);
    }
    if(P == 0) cout << base * even_sum << endl;
    else cout << base * odd_sum << endl;
}



Measured memory_bytes: 74328
#include<stdio.h>

int main(void){
  int i;
  char rome[100];
  int arabia[100];
  int ans;

  for(;scanf("%s",rome)==1;){
    for(i=0;rome[i];i++)
      if(rome[i]=='I')
        arabia[i]=1;
      else if(rome[i]=='V')
        arabia[i]=5;
      else if(rome[i]=='X')
        arabia[i]=10;
      else if(rome[i]=='L')
        arabia[i]=50;
      else if(rome[i]=='C')
        arabia[i]=100;
      else if(rome[i]=='D')
        arabia[i]=500;
      else if(rome[i]=='M')
        arabia[i]=1000;

    ans=0;
    for(i=0;rome[i+1];i++)
      if(arabia[i]>=arabia[i+1])
        ans+=arabia[i];
      else if(arabia[i]<arabia[i+1])
        ans-=arabia[i];
    ans+=arabia[i];

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

Measured memory_bytes: 0
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);
    
    const h = arg[1].split(" ").map(n=>parseInt(n));
    
    console.log(h.filter(n=>n>=K).length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 28608
#include<bits/stdc++.h>
using namespace std;
int a[100000],n,dp[100000];
int _read(){
    int sum=0;char ch=getchar();
    while(!(ch>='0'&&ch<='9'))ch=getchar();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=getchar();
    return sum;
}
int main()
{
	n=_read();
	for (int i=0;i<n;i++)
	  a[i]=_read();
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for (int i=2;i<n;i++)
	  dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	cout<<dp[n-1]<<endl;
	return 0;
}

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

typedef long long ll;

ll A,B; string S;
void input()
{
    cin>>A>>S;
    B=(ll)((S[0]-'0')*100+(S[2]-'0')*10+(S[3]-'0'));
}

void solve()
{
    ll ans=A*B;
    cout<<ans/100<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

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

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

int main()
{
    long long int a, b, c, d, ans, CuA, DuA, CDuA, CuB, DuB, CDuB;
    cin >> a >> b >> c >> d;

    CuA = (a - 1) / c;
    DuA = (a - 1) / d;
    CDuA = (a - 1) / ((c * d) / gcd(c,d));
    CuB = b / c;
    DuB = b / d;
    CDuB = b / ((c * d) / gcd(c,d));

    ans = (b - a + 1) - ((CuB + DuB - CDuB) - (CuA + DuA - CDuA));

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[] t = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += t[i] = scanner.nextInt();
        }
        int m = scanner.nextInt();
        for (int i = 0; i < m; i++) {
            int p = scanner.nextInt() - 1;
            int x = scanner.nextInt();
            System.out.println(sum - t[p] + x);
        }
    }
}

Measured memory_bytes: 23380
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 998244353

N, S = MAP()
A = LIST()

dp0 = [0] * (S+1)
dp1 = [0] * (S+1)
dp2 = [0] * (S+1)
nxt0 = [0] * (S+1)
nxt1 = [0] * (S+1)
nxt2 = [0] * (S+1)
dp0[0] = 1
for i, a in enumerate(A):
    for j in range(S+1):
        # aを総和に足さない遷移は全部OK
        nxt0[j] += dp0[j]
        nxt1[j] += dp0[j] + dp1[j]
        nxt2[j] += dp0[j] + dp1[j] + dp2[j]
        # aを総和に足す遷移は、遷移元が状態2と遷移先が状態0は無理
        if j+a <= S:
            nxt1[j+a] += dp0[j] + dp1[j]
            nxt2[j+a] += dp0[j] + dp1[j]
        nxt0[j] %= MOD
        nxt1[j] %= MOD
        nxt2[j] %= MOD
    dp0 = nxt0[:]
    dp1 = nxt1[:]
    dp2 = nxt2[:]
    nxt0 = [0] * (S+1)
    nxt1 = [0] * (S+1)
    nxt2 = [0] * (S+1)
ans = dp2[S]
print(ans)


Measured memory_bytes: 50140
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num,init) vector<ll> name((num),(init));
#define op(i) cout<<(i)<<endl;
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define mat(name,fnum,snum,init); vector<vector<ll>> name((fnum),vector<ll>((snum),(init)));

int main(){
    ll n;
    cin>>n;
    ll y;
    cin>>y;
    rep(i,n+1){
        rep(j,n+1-i){
            if(y==(i*10000+j*5000+(n-(i+j))*1000)){
                cout<<i<<" "<<j<<" "<<n-(i+j)<<endl;
                return 0;
            }else if((i*10000+j*5000+(n-(i+j))*1000)>y)break;
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;

}

Measured memory_bytes: 256
using System;

class program
{
    public static void Main()
    {
        Console.ReadLine();
        var strs = Console.ReadLine().Split(' ');

        Console.Write(strs[strs.Length-1]);
        for (int i = strs.Length - 2; i >= 0; i--)
        {
            Console.Write(" {0}", strs[i]);
        }
        Console.WriteLine();
    }
}

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


int main() {

  int64_t L,R,d;
  cin>>L>>R>>d;


  int cnt=0;
  for(int i=L;i<=R;i++){
    if(i%d==0)
      cnt++;
  }


  cout<<cnt<<endl;

	return 0;
}

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

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

using namespace std;
using lint=long long;

template<class T> struct edge{
	int to;
	T wt;
	edge(int to,const T& wt):to(to),wt(wt){}
};
template<class T> using wgraph=vector<vector<edge<T>>>;

template<class T>
vector<T> Bellman_Ford(const wgraph<T>& G,int s){
	const T INF=numeric_limits<T>::max();

	int n=G.size();
	vector<T> d(n,INF);
	d[s]=0;
	rep(_,n-1){
		bool upd=false;
		rep(u,n) if(d[u]<INF) for(const auto& e:G[u]) {
			int v=e.to;
			if(d[v]>d[u]+e.wt) d[v]=d[u]+e.wt, upd=true;
		}
		if(!upd) return d;
	}

	queue<int> Q;
	rep(u,n) if(d[u]<INF) Q.emplace(u);
	while(!Q.empty()){
		int u=Q.front(); Q.pop();
		for(const auto& e:G[u]){
			int v=e.to;
			if(d[v]>-INF && (d[u]==-INF || d[v]>d[u]+e.wt)) d[v]=-INF, Q.emplace(v);
		}
	}
	return d;
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	wgraph<lint> G(n);
	rep(i,m){
		int u,v;
		lint c; scanf("%d%d%lld",&u,&v,&c); u--; v--;
		G[u].emplace_back(v,-c);
	}

	lint ans=Bellman_Ford(G,0)[n-1];

	if(ans>-LLONG_MAX) cout<<-ans<<endl;
	else               cout<<"inf"<<endl;

	return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	class Node {
		int parent;
		public Node(int x) {
			this.parent = x;
		}
	}
	
	class DisjointSet {
		Node[] p;
		int[] rank;
		
		public DisjointSet(int size) {
			p = new Node[size];
			rank = new int[size];
			for (int i = 0; i < size; i++) {
				makeSet(i);
			}
		}

		private void makeSet(int x) {
			p[x] = new Node(x);
			rank[x] = 0;
		}
		
		private int findSet(int x) {
			while (x != p[x].parent) {
				x = p[x].parent;
			}
			return x;
		}
		
		public boolean same(int x, int y) {
			return findSet(x) == findSet(y);
		}
		
		public void unite(int x, int y) {
			link(findSet(x), findSet(y));
		}

		private void link(int x, int y) {
			if (rank[x] > rank[y]) {
				p[x].parent = y;
			} else {
				p[y].parent = x;
				if (rank[x] == rank[y]) {
					rank[y]++;
				}
			}
		}
	}
	
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int q = Integer.parseInt(st.nextToken());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int c = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int y = Integer.parseInt(st.nextToken());
			if (c == 0) {
				ds.unite(x, y);
			} else {
				System.out.println(ds.same(x, y)?"1":"0");
			}
		}
		reader.close();
	}
}



Measured memory_bytes: 61092
#include <iostream>
#include <sstream>
#include <cstring>
using namespace std;

int main(void){
	int n,t[102][102];
	char ch;
	string s;

	for(n=0;cin>>s;n++){
		stringstream ss(s);
		for(int j=0;;j++){
			ss>>t[n][j];
			if(!(ss>>ch)) break;
		}
	}

	int dp[102][102];
	memset(dp,-1,sizeof(dp));

	//ツ陳可崢づ個δ可イツδ督づ慊づ繰ツづィツ陛板つキ
	dp[0][0] = t[0][0];
	for(int i=0;i<n/2;i++){
		for(int j=0;j<=i;j++){
			dp[i+1][j] = max(dp[i+1][j],dp[i][j]+t[i+1][j]);
			dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+t[i+1][j+1]);
		}
	}

	//ツ陳可崢づ個δ可イツδ督づ個可コツつゥツづァツ催古」ツづ慊づ繰ツづィツ陛板つキ
	for(int i=n/2+1;i<n;i++){
		for(int j=0;j<n-i;j++){
			dp[i][j] = max(dp[i-1][j]+t[i][j], dp[i-1][j+1]+t[i][j]);
		}
	}

	cout<<dp[n-1][0]<<endl;

	return 0;
}

Measured memory_bytes: 0
import sys
import math
from collections import deque
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

input = sys.stdin.readline
S,W = MI()
if S<=W:
    print('unsafe')
else:
    print('safe')


Measured memory_bytes: 70932
N, M = map(int, input().split())
C = [list(map(int, input().split())) for i in range(M)]
D = [0 for i in range(max(C[i][0] for i in range(M)))]
for i in range(M):
  C[i].append(i)
  C[i][0], C[i][1] = C[i][1], C[i][0]
C.sort()
for i in range(M):
  D[C[i][1]-1] += 1
  C[i].append('{}'.format(C[i][1] * 1000000 + D[C[i][1]-1]))
  if len(C[i][3]) != 12:
    for x in range(12-len(C[i][3])):
      C[i][3] = '0' + C[i][3]
  C[i][0] = C[i][2]
  
C.sort()
for i in range(len(C)):
  print(C[i][3])

Measured memory_bytes: 39456
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin >> N;
    typedef complex<long double> cpx;
    vector<cpx> V(N);
    cpx sum = cpx(0, 0);
    rep(i,N) {
        long double a, b;
        cin>>a>>b;
        V[i] = cpx(a, b);
        sum += V[i];
    }
    vec ord(N);
    rep(i,N) ord[i] = i;
    sort(ord.begin(), ord.end(), [&](ll x, ll y){
        return arg(V[x]) < arg(V[y]);
    });
    /*rep(i,N) {
        long double a = V[ord[i]].real(), b = V[ord[i]].imag();
        cout<<a<<' '<<b<<endl;
    }*/
    long double ans = 0;
    rep(i,N) {
        reps(j,i,N+1){ //区間[i,j)およびその逆方向
            cpx temp = cpx(0, 0);
            reps(k,i,j) temp += V[ord[k]];
            ans = max(ans, temp.real()*temp.real() + temp.imag()*temp.imag());
            temp = sum - temp;
            ans = max(ans, temp.real()*temp.real() + temp.imag()*temp.imag());
        }
    }
    cout<<fixed<<setprecision(15)<<sqrt(ans)<<endl;
}

Measured memory_bytes: 384
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int L;
int N, M;
struct edge {
  int from, to, cost;
  edge(int f, int t, int c) {
    from = f; to = t; cost = c;
  }
};

int main() {
  cin >> L;
  vector<edge> es;
  while ((1 << N) <= L) ++N;
  for (int i = 1; i < N; ++i) {
    es.push_back(edge(i, i+1, (1 << (i-1))));
    es.push_back(edge(i, i+1, 0));
  }

  for (int i = N-1; i >= 1; --i) {
    if ((L>>(i-1)) & 1) {
      es.push_back(edge(i, N, L >> i << i));
    }
  }
  
  cout << N << ' ' << es.size() << endl;
  for (int i = 0; i < es.size(); ++i) {
    cout << es[i].from << ' ' << es[i].to << ' ' << es[i].cost << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<int> x;

int main()
{
  int n, k, ans = MOD;
  cin>>n>>k;

  REP(i,n) {
    int t;
    cin>>t;
    x.push_back(t);
  }

  REP(i,n-k+1) {
    if (x[i] < 0) {
      if (x[i+k-1] < 0) {
        ans = min(ans, -x[i]);
      } else {
        ans = min(ans, -x[i] + x[i+k-1] + min(-x[i], x[i+k-1]));
      }
    } else {
      ans = min(ans, x[i+k-1]);
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 892