akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int64_t power(int64_t a, int64_t b) {
  if(b==0)
    return 1;
  int64_t c=power(a,b/2)%1000000007LL;
  if(b%2==0)
    return c*c%1000000007LL;
  else
    return a*c%1000000007LL*c%1000000007LL;
}

int main() {
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> x(K+1);
  int64_t s=0;
  for(int64_t i=K;i>=1;i--) {
    x.at(i)=(int64_t)power(K/i, N);
    for(int j=2;j<=K/i;j++)
      x.at(i) -= x.at(j*i);
    s += i*x.at(i);
  }
  cout << s%1000000007LL << endl;
}

Measured memory_bytes: 4004
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

class Main {
  public static int cnt = 0;
  
  public static void main(String[] args) {
  	Scanner sc = new Scanner(System.in);
  	int n = sc.nextInt();
  	int[] a = new int[n];
  	for(int i = 0; i < n; ++i) {
  		a[i] = sc.nextInt();
  	}

  	//insertionSort(a, 1);
  	shellSort(a);
  	System.out.println(cnt);
  	for(int i = 0; i < n; ++i) {
  		System.out.println(a[i]);
  	}
  }
  
  public static void insertionSort(int[] a, int g){
  	for(int i = g; i < a.length; ++i) {
  		int v = a[i];
  		int j = i - g;
  		while(j >= 0 && a[j] > v) {
  			a[j + g] = a[j];
  			j = j - g;
  			cnt += 1;
  		}
  		a[j + g] = v;
  	}
  }
  
  public static void shellSort(int[] a) {
  	List<Integer> g = new ArrayList<Integer>();
  	for(int t = 1; t < a.length; t = 3*t + 1){
  		g.add(0, t);
  	}
  	
	if(g.size() == 0){
		g.add(0, 1);
	}
  	
  	int m = g.size();
  	System.out.println(m);
	
	for(int i = 0; i < m; ++i) {
		System.out.print(i == 0 ? "" : " ");
		System.out.print(g.get(i));
	}
  	System.out.println();
  	
  	for(int i = 0; i < m; ++i) {
  		insertionSort(a, g.get(i));
  	}
  }
}

Measured memory_bytes: 298168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define N 100010
ll n;
vector<P> v[N];
class FindCentored{
  public:
  vector<ll> res;
  ll dfs(ll x,ll from){
   ll sum=1;bool ok=1;
   for(auto y:v[x]){
    ll to=y.first;
    ll cost=y.second;
    if(to==from)continue;
    ll siz=dfs(to,x);
    if(siz>n/2)ok=0;
    sum+=siz;
   }
   if(n-sum>n/2)ok=0;
   if(ok)res.push_back(x);
   return sum;
  }
  void main(){
   dfs(1,0);   
  }
};FindCentored fc;
class Distance{
    public:
    ll d[N];
    void dfs(ll x,ll from,ll sum){
        d[x]=sum;
        for(auto y:v[x]){
         ll to=y.first;
         ll cost=y.second;
         if(to==from)continue;
         dfs(to,x,sum+cost);
        }
    }
    void main(){
        dfs(fc.res[0],0,0);
    }
};Distance ds;
int main(){
    cin>>n;
    for(int i=0;i<n-1;i++){
     ll a,b,c;cin>>a>>b>>c;
     v[a].push_back(make_pair(b,c));
     v[b].push_back(make_pair(a,c));
    }
    fc.main();
    ds.main();
    ll ans=0;
    for(int i=1;i<=n;i++)ans+=ds.d[i]*2;
    if(fc.res.size()==2){
        ans-=ds.d[fc.res[1]];
    }
    if(fc.res.size()==1){
        ll mini=1e18;
     for(auto y:v[fc.res[0]]){
         mini=min(mini,y.second);
     }
     ans-=mini;
    }
  //cout<<fc.res.size()<<" "<<fc.res[0]<<endl;
  //for(int i=1;i<=n;i++)cout<<ds.d[i]<<" ";cout<<endl;
    cout<<ans<<endl;
 return 0;   
}

Measured memory_bytes: 12544
#include <iostream> 
#include <vector> 
using namespace std; 
  
int main() 
{
  float d,t,s;
  cin>>d>>t>>s;
  float speed=d/t;
  if(speed<=s)
  {
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	string s;
	cin >> s;
	bool ok = 1;
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			if(s[i] != 'R' && s[i]!='U' && s[i]!='D')ok = 0;
		}else{
			if(s[i] !='L' && s[i] != 'U' && s[i] != 'D')ok = 0;
		}
	}
	if(ok)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

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

    char a = A.at(0);
    char b = B.at(0);
    char c = C.at(0);

    int d = (int)a - 32;
    int e = (int)b - 32;
    int f = (int)c - 32;

    cout << (char)d << (char)e << (char)f << endl;
}

Measured memory_bytes: 3628
// ~maqsat~
/*
*/

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 1e10 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int main() {
    fre("");
    ACCELERATE;
	
	int n, m;
	cin >> n >> m;

	priority_queue<int> a;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a.push(x);
	}

	while(m) {
		int x = a.top();
		a.pop();
		x /= 2;
		m--;
		a.push(x);
	}

	ll ans = 0;
	while(!a.empty()) {
		ans += a.top();
		a.pop();
	}

	cout << ans;
    return 0;
}
/*
 
*/


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define pb push_back
#define fst first
#define snd second
#define ALL(cont) cont.begin(), cont.end()
#define mset(a,b) memset(a,b,sizeof(a));
#define fore(i, a, b) for (int i = a, almo5t = b; i < almo5t; ++i)
#define SZ(x) ((int)x.size())
#define FIN ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
struct objects{
    int weight,value;
};

int main()
{
    FIN;
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
#define endl '\n'
#endif
int n,w;
   cin>>n>>w;
   objects object[n];
   int totalvalue=0;
   for(int i=0;i<n;i++){
       cin>>object[i].weight>>object[i].value;
       totalvalue+=object[i].value;
   }
   ll dp[n+1][totalvalue+1];
   dp[0][0]=0;
   int ans=0;
   for(int i=1;i<=totalvalue;i++){
       dp[0][i]=1e18;
   }
   for(int i=0;i<n;i++){
       for(int j=0;j<=totalvalue;j++){
           if(j>=object[i].value){
                dp[i+1][j]=min(dp[i][j], dp[i][j-object[i].value]+object[i].weight);
           }
           else{
               dp[i+1][j]=dp[i][j];
           }
           if(dp[i+1][j]<=w){
               ans=max(ans,j);
           }
       }
   }
   cout<<ans;
    return 0;
}


Measured memory_bytes: 82420
#include<bits/stdc++.h>
using namespace std;
long long b[1000000];
int main()
{
  long long n, i, x, s = 0, mx = 0, q, l, r, y;
  cin >> n;
  long long a[n + 3];
  for (i = 1; i <= n; i++)
  {
    cin >> a[i];
    b[a[i]]++;
    s += a[i];
  }
  cin >> q;
  while (q--)
  {
    cin >> l >> r;
      s += b[l] * (r-l);
      b[r] += b[l];
      b[l]=0;
    cout << s << endl;
  }
}

Measured memory_bytes: 5140
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            
            if(H==0 && W==0) return;
            for(int y=0; y<H; y++){
                for(int x=0; x<W; x++){
                    if(y==0 || y==H-1 || x==0 || x==W-1){
                        System.out.print("#");
                    }
                    else{
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  if(a+b == c+d){
    cout<<"Balanced"<<endl;
  }else if(a+b > c+d){
    cout<<"Left"<<endl;
  }else{
    cout<<"Right"<<endl;
  }
}

Measured memory_bytes: 256
use std::collections::*;
use std::*;
// template {{{
macro_rules ! get {($ ($ t : tt ) ,*; $ n : expr ) => {{let stdin = std :: io :: stdin () ; let ret = std :: io :: BufRead :: lines (stdin . lock () ) . take ($ n ) . map (| line | {let line = line . unwrap () ; let mut it = line . split_whitespace () ; _get ! (it ; $ ($ t ) ,* ) } ) . collect ::< Vec < _ >> () ; ret } } ; ($ ($ t : tt ) ,* ) => {{let mut line = String :: new () ; std :: io :: stdin () . read_line (& mut line ) . unwrap () ; let mut it = line . split_whitespace () ; _get ! (it ; $ ($ t ) ,* ) } } ; }
macro_rules ! _get {($ it : ident ; [char ] ) => {_get ! ($ it ; String ) . chars () . collect ::< Vec < _ >> () } ; ($ it : ident ; [u8 ] ) => {_get ! ($ it ; String ) . bytes () . collect ::< Vec < _ >> () } ; ($ it : ident ; usize1 ) => {$ it . next () . unwrap () . parse ::< usize > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) - 1 } ; ($ it : ident ; [usize1 ] ) => {$ it . map (| s | s . parse ::< usize > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) - 1 ) . collect ::< Vec < _ >> () } ; ($ it : ident ; [$ t : ty ] ) => {$ it . map (| s | s . parse ::<$ t > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) ) . collect ::< Vec < _ >> () } ; ($ it : ident ; $ t : ty ) => {$ it . next () . unwrap () . parse ::<$ t > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) } ; ($ it : ident ; $ ($ t : tt ) ,+ ) => {($ (_get ! ($ it ; $ t ) ) ,* ) } ; }
mod unionfind {
    pub struct Unionfind {
        par: Vec<i32>,
        group_count: usize,
    }
    impl Unionfind {
        pub fn new(n: usize) -> Self {
            Unionfind {
                par: vec![-1; n as usize],
                group_count: n as usize,
            }
        }
        fn find_root(&mut self, mut x: usize) -> usize {
            while self.par[x] >= 0 {
                x = self.par[x] as usize;
            }
            x
        }
        pub fn unite(&mut self, x: usize, y: usize) {
            let mut rx = self.find_root(x);
            let mut ry = self.find_root(y);
            if rx == ry {
                return;
            }
            if self.par[rx] > self.par[ry] {
                std::mem::swap(&mut rx, &mut ry);
            }
            self.par[rx] += self.par[ry];
            self.par[ry] = rx as i32;
            self.group_count -= 1;
        }
        pub fn is_same_group(&mut self, x: usize, y: usize) -> bool {
            self.find_root(x) == self.find_root(y)
        }
        pub fn get_group_size(&mut self, x: usize) -> usize {
            let rx = self.find_root(x);
            (-self.par[rx]) as usize
        }
        pub fn get_num_of_groups(&self) -> usize {
            self.group_count
        }
    }
}
// }}}

fn main() {
    let (n, m) = get!(usize, usize);
    let edge = get!(usize1, usize1;m);
    let mut uf = unionfind::Unionfind::new(n);
    for (a, b) in edge {
        uf.unite(a, b);
    }
    println!("{}", uf.get_num_of_groups() - 1);
}


Measured memory_bytes: 4008
A, B, C, X, Y = map(int, input().split())
mxy = max(X, Y)
ans = 10**10
for i in range(mxy+1):
    X_i = max(X-i, 0)
    Y_i = max(Y-i, 0)

    ans = min(C*i*2 + A*X_i + B*Y_i, ans)
print(ans)





Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(vec) vec.begin(), vec.end()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define repc(bit, k, n) for (ll bit = (1 << k) - 1; bit < (1 << n); bit = next_combination(bit))
#define repi(itr, vec) for (auto itr = vec.begin(); itr != vec.end(); ++itr)
#define lb(bec, val) lower_bound(ALL(bec), val)
using namespace std;

struct UnionFind
{
  //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
  //そうでなければ親のid
  vector<int> r;

  UnionFind(int N)
  {
    r = vector<int>(N, -1);
  }

  int root(int x)
  {
    if (r[x] < 0)
      return x;
    return r[x] = root(r[x]);
  }

  bool unite(int x, int y)
  {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (r[x] > r[y])
      swap(x, y);
    r[x] += r[y];
    r[y] = x;
    return true;
  }

  bool same(int x, int y)
  {
    return root(x) == root(y);
  }
  int size(int x)
  {
    return -r[root(x)];
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, m)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
  }
  int ans = -1;
  rep(i, n)
  {
    if (i == uf.root(i))
      ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3728
s=input()
ans=[0]
atgc=["A","T","G","C"]
for i in range(len(s)):
    for k in range(i,len(s)):
        check=s[i:k+1]
        complete=0
        for i in range(len(check)):
            if check[i] in atgc:
                complete+=1
        if complete==len(check):
            ans.append(len(check))
print(max(ans))

Measured memory_bytes: 61852
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int N, A, B;

int main() {
    cin >> N >> A >> B;
//    vector<int> P(N);
    int count1 = 0, count2 = 0, count3 = 0;
    for (int i = 0; i < N; i++) {
        int p;
        cin >> p;
        if (p <= A) {
            count1++;
        } else if (p > B) {
            count3++;
        } else {
            count2++;
        }
    }
    cout << min(count1, min(count2, count3)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    ll res = INF;
    for(ll i=-100; i<=100; i++){
        ll pres = 0;
        rep(j,n){
            pres += (a.at(j)-i)*(a.at(j)-i);
        }
        res = min(res,pres);
    }
    cout << res << endl;
}

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

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());

            int sum = 0;

            var _x = X / 500;
            sum += _x * 1000;
            sum += (X - _x * 500) / 5 * 5;

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 17628
#include <stdio.h>
#include <string.h>

int main(){
	int K, N; 
	scanf("%d %d", &N, &K);
	long long int num[N] = {0};
	
	for (int i=0; i<N; i++){
		scanf ("%lld", &num[i]);
	}
	
	for (int i=0; i < N-K ; i++){
		if (num[i] < num[i+K]){   // misal 0 1 2 3 4 5  dan K nya 2
			printf ("Yes\n");	// bandingin aja arr 0 dan arr 2 karena ngebandingin 0*1 dan 1*2
		}
		else {
			printf ("No\n");
		}
	}
return 0;
}

Measured memory_bytes: 3220
#include <stdio.h>

int main(void){
    int i,k,n,a,b,c,max;
    max=0;
    scanf("%d %d",&k,&n);
    scanf("%d",&c);
    b=c;
    for(i=1;i<n;i++){
        scanf("%d",&a);
        if(a-b>max)max=a-b;
        b=a;
    }
    if((k+c-a)>max){
            max=k+c-a;
    }
    printf("%d",k-max);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
const int maxn = 100001;

vector<int> G[maxn];
int vis[maxn];

void DFS(int u, int k)
{
    vis[u] = k;
    for(vector<int>::iterator it = G[u].begin(); it != G[u].end(); it++)
        if(vis[*it] == -1)
            DFS(*it, k);
}

int main()
{
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    for(int j = 0; j < n; j++)
            vis[j] = -1;
    for(int i = 0; i < n; i++)
        if(vis[i] == -1)
            DFS(i, i);
    int q;
    cin >> q;
    for(int i = 0; i < q; i++)
    {
        int x, y;
        cin >> x >> y;
        if(vis[y] == vis[x])
            cout << "yes" <<endl;
        else
            cout << "no" <<endl;
    }
    return 0;
}



Measured memory_bytes: 12040
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n][m];
    set <int> bn;
    int f[n];
    for (int j = 0; j < n; j++) {
        for (int i = 0; i < m; i++) {
            cin >> a[j][i];
        }
        f[j] = 0;
    }
    int mn = 1e9;
    for (int j = 0; j < m; j++) {
        int mx = 0, id = 0;
        vector <int> sp(m, 0);
        for (int i = 0; i < n; i++) {
            sp[a[i][f[i]] - 1]++;
            if (sp[a[i][f[i]] - 1] > mx) {
                id = a[i][f[i]];
                mx = sp[id - 1];
            }
        }
        mn = min(mn, mx);
        bn.insert(id);
        for (int j = 0; j < n; j++) {
            while (bn.find(a[j][f[j]]) != bn.end() && f[j] < m - 1) {
                f[j]++;
            }
        }
    }
    cout << mn;
}


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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n, m;
  string s, t;
  cin >> n >> m >> s >> t;
  int gcd = __gcd(n, m);
  for (int i = 0, j = 0; i < n && j < m; i += n / gcd, j += m / gcd) {
    if (s[i] != t[j]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << (long long)n * m / gcd << endl;
  return 0;
}


Measured memory_bytes: 512
g = 0
p = 0

ans = 0
for i in input():
    if i == "g":
        if p < g:
            ans += 1
            p += 1
        else:
            g += 1
    else:
        if p < g:
            p += 1
        else:
            g += 1
            ans -= 1

print(ans)

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

int A, B, C, X;

int main() {
  cin >> A >> B >> C >> X;

  int res = 0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        if (500 * a + 100 * b + 50 * c == X) ++res;
      }
    }
  }
  cout << res << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
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;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


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

int main() {

ll x;
cin>>x;

ll k=100;
ll cnt=0;
while(k<x){
	ll p=k/100;
	k=k+p;
	cnt++;
}
cout<<cnt<<endl;
return 0;

}



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

using namespace std;

#define MAX 20000

struct edge{
  int from, to, cost;

  edge(int from = -1, int to = -1, int cost = -1) 
    : from(from), to(to), cost(cost) {}

  bool operator < (const edge &e)const{
    return cost < e.cost;
  }
};

int main(){
  int N, M, t, s, d;

  while(cin >> N >> M , N){
    edge e[MAX];

    for(int i = 0 ; i < M ; i++){
      cin >> t >> s >> d;
      e[i] = edge(s-1, d-1, t);
    }
    
    sort(e, e+M);
    bool check[MAX] = {false};
    check[0] = true;

    for(int i = 0 ; i < M ; i++){
      if(check[e[i].from]){
	check[e[i].to] = true;
      }
    }
    
    int ans = 0;
    for(int i = 0 ; i < N ; i++){
      if(check[i]) ans++;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1424
//bismillahir rahmanir rahim
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    if(s.size()<=n) cout<<s<<endl;
    else
    {
        for(int i=0; i<n; i++)
            putchar(s[i]);
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c - '0';}


// TODO: write
int main() { 
  ll h;cin>>h;
  ll ans = 0;

  ll now = 1;
  ll cnt = 0;
  while(h){
    cnt++;
    ans += now;

    now *= 2;
    h /= 2;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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;
    cout<<48 - N<<endl;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val M = sc.nextInt
    val a = Array.fill(N + 1)(false)
    for (_ <- 0 until M) {
      a(sc.nextInt) = true
    }
    val ans = new Array[Long](N + 1)
    ans(0) = 1
    if (!a(1)) ans(1) = 1 else ans(1) = 0

    for (i <- 2 to N) {
      if (a(i)) {
        ans(i) = 0
      } else {
        ans(i) = (ans(i - 1) + ans(i - 2)) % 1000000007
        if (ans(i) == 0) {
          println(0)
          sys.exit()
        }
      }
    }
    println(ans(N))
  }

}

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

int main(){
  int R;
  cin >> R;
  if(R<1200){
    cout << "ABC" << endl;
  }
  else if(R<2800){
    cout << "ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n;
int d[100000];

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

	cin >> n;
	rep(i, n)cin >> d[i];
	sort(d, d + n);

	int k = d[n / 2];

	int num = lower_bound(d, d + n, k) - d;
	if (num*2 != n) {
		cout << 0 << endl;
	}
	else {
		cout << d[n / 2] - d[n / 2 - 1] << endl;
	}



	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC095
{
    class ProblemA
    {
            
        static void Main(string[] args)
        {
            string input = Console.ReadLine().ToString();

            int price = 700;
            if (input[0] == 'o') price += 100;
            if (input[1] == 'o') price += 100;
            if (input[2] == 'o') price += 100;

            Console.WriteLine(price);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int cost=10*b;
  for(int i=cost;i-cost<10;i++){
    if((i*2)/25==a){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

#define uint unsigned int
#define ull unsigned long long
#define ll long long
#define vint vector<int>
#define vuint vector<unsigned int>
#define vull vector<ull>
#define vll vector<ll>
#define init(type,var) type var;cin>>var;
#define vinit(vtype,var,n) vtype var(n);loop(i,0,n)cin>>var[i];
#define range(container) container.begin(),container.end()
#define loop(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(data) cout<<data<<endl;

const ull MOD = 1000000007ULL;
const ull INF = (ull)(-1LL);

int main(void){
	init(string, s);

	ull index = 1;
	ull count = 1;
	string taboo = s.substr(0, 1);
	while (index < s.size()){
		if (s.substr(index, 1) == taboo){
			if (index + 1 < s.size()){
				taboo = s.substr(index, 2);
				index++;
			}
			else break;
		}
		else{
			taboo = s.substr(index, 1);
		}
		count++;
		index++;
	}

	outl(count);

	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
struct Job
{
	int time, deadline;
	bool operator<(const Job& y)const {
		return deadline > y.deadline;
	}
};
int main() {
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/

	int n;
	cin >> n;
	priority_queue<Job> all_jb;
	Job cur;
	for (int i = 0; i < n; i++) {
		cin >> cur.time >> cur.deadline;
		all_jb.push(cur);
	}
	int time = 0;
	while (!all_jb.empty()) {
		cur = all_jb.top();
		all_jb.pop();
		time += cur.time;
		if (time > cur.deadline) {
			cout << "No";
			exit(0);
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
 
using namespace std;
 
#define BOOST        std::ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define sp           <<" "<<
#define ll           long long
#define ld           long double
#define AZI(i,x)     for(auto i=x.begin();i!=x.end();i++)
#define AZ(x)        x.begin(),x.end()
#define P(x,y)       pair < x,y >
#define V(x)         vector < x >
#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define PI           3.14159265358979323846264338327950288419716939937510
 
const ll mod=1e9+7,N=1e5+5,INF = 1e18;

ll power(ll a,ll b)
{
    a = a%mod;
    ll result = 1;

    while(b)
    {
        if(b&1)
            result = (result*a)%mod;
        b >>= 1, a = (a*a)%mod;
    }
    return result;
} 



int main() 
{ 
    BOOST

    int a,p;
    cin>>a>>p;
    int num = 3*a + p;

    num = num/2;
    cout<<num<<"\n";    
    

    return 0;    
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;

    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    for(int i = 0; i < M; i++){
        int a, b; cin >> a >> b; a--; b--;
        uf.unionSet(a, b);
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3984
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<map>
#include<stack>
using namespace std;
int dx[] = { -1,0,0,1,-1,-1,1,1,0 };
int dy[] = { 0,1,-1,0,1,-1,1,-1,0 };
/*
int main()
{
int r, c;
cin >> r >> c;
int sy, sx, gy, gx;
vector<vector<char>>field(r,vector<char>(c));
sy--, sx--, gy--, gx--;
for (int i = 0; i < r; i++)
{
for (int j = 0; j < c; j++)
{
cin >> field[i][j];
}
}
queue<pair<int,int>>q;
q.push({ sx,sy });
vector<vector<int>>d(c, vector<int> (r, -1));
d[sx][sy] = 0;

while (!q.empty())
{
pair<int, int>p = q.front;
q.pop();
for (int i = 0; i < 4; i++)
{
int nx = p.first + dx[i], ny = p.second + dy[i];
if (nx < 0 || ny < 0 || nx >= c || ny >= r || d[nx][ny] != -1 || field[nx][ny] == '#')continue;
q.push({ nx,ny });
d[nx][ny] = d[p.first][p.second] + 1;
}
}

cout << d[gx][gy] << endl;
}*/


int main()
{
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	vector<int>st(n);
	int x = 0;
	for (int i = 0; i < n; i++)
	{
		st[a[i] - 1] = i + 1;
	}

	for (int i = 0; i < n; i++)
	{
		cout << st[i]<<" ";
	}
}



Measured memory_bytes: 3552
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let mut a:Vec<i64> = (0..3).map(|_| read()).collect();
    let mx = *a.iter().max().unwrap();

    let mut ans:i64 = 0;
    let mut cnt:i64 = 0;
    for el in a.iter_mut() {
        loop {
            if *el + 2 > mx {
                if *el == mx-1 {cnt+=1;}
                break;
            }
            ans += 1;
            *el += 2;
        }

    }
    //debug!(ans,cnt);
    println!("{}", if cnt==0 {ans} else if cnt==1 {ans+2} else {ans+1});
    
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
#define pll pair<ll, ll>
#define vpl vector<pll>
#define vb vector<bool>
#define PB push_back
#define MP make_pair
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=s; i>=e; i--)
#define vasort(v) sort(v.begin(), v.end())
#define vdsort(v) sort(v.begin(), v.end(),greater<ll>())
#define F first
#define S second

#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6

#define mz(a)   memset(a,0,sizeof(a))
#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const ll mod=1e9+7;
ll fast_expo(ll n,ll m, ll md)
{
    ll a=1;
    while(m>0)
    {
        if(m&1) a=(a*n)%md;
        n=(n*n)%md;
        m/=2;
    }
    return a%md;
}
int main() {
    zoom;
    ll n;
    in1(n);
    if (n==1) out1(0);
    else{
        ll x=fast_expo(10,n,mod);
        ll x1=fast_expo(9,n,mod);
        ll x2=fast_expo(8,n,mod);
        ll ans=(x-x1-x1+x2+mod+mod)%mod;
        out1(ans);
    }
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int main() {
	int A, B;
	scanf("%d %d", &A, &B);
	if (A <= 8 && B <= 8) printf("Yay!\n");
	else printf(":(\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=2e5+10;
int fa[MAXN],p[MAXN];
ll ans;
int n,x;
struct node{
		int x,s,id;
		bool operator <(const node &a)const{
		if (x*a.s!=s*a.x) return (ll)x*a.s<(ll)s*a.x;
		return id<a.id;
	}
	   bool operator ==(const node &a)const{
	   	return (a.x==x&&a.s==s&&a.id==id);
	   }
}a[MAXN];
set<node>q;
int getfather(int x)
{
	if (fa[x]==x) return x;
	fa[x]=getfather(fa[x]);
	return fa[x];
}
int main(){
	scanf("%d",&n);
	for (int i=2;i<=n;i++) 
	{
		scanf("%d",&p[i]); 
	}
	for (int i=1;i<=n;i++) fa[i]=i;
	for (int i=1;i<=n;i++) {
		scanf("%d",&x);
		a[i]=(node){x,1,i};
		q.insert(a[i]);
	}
	while (!q.empty())
	{
		node t=*q.begin(); q.erase(t);
		if (p[t.id]==0) continue;
		int f=getfather(p[t.id]);
        ans+=(ll)(t.s-t.x)*a[f].x;
        q.erase(a[f]);
        fa[t.id]=f;
        a[f].x+=t.x; a[f].s+=t.s; q.insert(a[f]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
const int INF = 1e8;

int main(){
  int H,W; cin >> H >> W;
  int dx[] = {1,0,0,-1};
  int dy[] = {0,1,-1,0};
  vector<vector<char>> fi(H,vector<char>(W));
  vector<vector<int>>  dist(H,vector<int>(W,-1));
  rep(i,H)rep(j,W) cin >> fi[i][j];
  queue<pair<int,int>> que;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(fi[i][j] == '#'){
        dist[i][j] =0;
        que.push({i,j});
      }
    }
  }
   
  while(!que.empty()){
    auto cur = que.front();que.pop();
    for(int dir = 0;dir<4;dir++){
      int nx = cur.first + dx[dir];
      int ny = cur.second + dy[dir];
       if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (dist[nx][ny] == -1) {
                dist[nx][ny] = dist[cur.first][cur.second] + 1;
                que.push({nx, ny});
            }
    }
  }
  int res = 0;
  rep(i,H)rep(j,W){
    res = max(res,dist[i][j]);
  }
  cout << res << endl;
}

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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

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

ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}

int main()
{
  char A, B;
  cin >> A >> B;
  if (A > B){
    cout << ">" << endl;
  }else if (A < B){
    cout << "<" << endl;
  }else{
    cout << "=" << endl;
  }
  return 0;
}

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

void chmin (int& a, int b) {
  if (a > b) a = b;
}
int main() {
  string S;
  cin >> S;
  
  int ans = 999;
  for (int i = 0; i < S.size()-2; i++) {
    if (S[i] > '7') {
      chmin(ans, (S[i]-'7') * 100 + (S[i+1]-'5') * 10 + S[i+2]-'3');
    } else if (S[i] < '7') {
      chmin(ans, ('7'- S[i]) * 100 + ('5'-S[i+1]) * 10 + '3'-S[i+2]);
    } else {
      if (S[i+1] > '5') {
        chmin(ans, (S[i]-'7') * 100 + (S[i+1]-'5') * 10 + S[i+2]-'3');
      } else if (S[i+1] < '5') {
        chmin(ans, ('7'- S[i]) * 100 + ('5'-S[i+1]) * 10 + '3'-S[i+2]);
      } else {
        if (S[i+2] >= '3') {
          chmin(ans, (S[i]-'7') * 100 + (S[i+1]-'5') * 10 + S[i+2]-'3'); 
        } else {
          chmin(ans, (S[i]-'7') * 100 + (S[i+1]-'5') * 10 + '3'-S[i+2]);
        }
      }
    }
  }
  
  cout << ans << endl;

}

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

int main()
{
  int N;scanf("%d",&N);
  long long A[N],asum[N];fill(asum,asum+N,0);
  for(int i=0;i<N;i++){scanf("%lld",&A[i]);asum[i]=A[i];}
  for(int i=1;i<N;i++)asum[i]=(asum[i]+asum[i-1])%mod;
  long long ans=0;
  for(int i=N-1;i>0;i--)ans=ans+asum[i-1]*A[i]%mod;
  printf("%lld",ans%mod);
}

Measured memory_bytes: 6876
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	a := readInt()
	_ = readInt()
	_ = readInt()
	_ = readInt()
	e := readInt()
	k := readInt()
	if e - a > k {
		fmt.Println(":(")
	} else {
		fmt.Println("Yay!")
	}
	
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
	int n, k; cin >> n >> k;
	int ans = 1;
	for (int i = 0; i < n; i++) {
		if (i) {
			ans *= k - 1;
		}
		else {
			ans *= k;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int,int> P;

const int INF = 100000008;
int w,h;
int dist[102][102];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

void solve() {
    vector<string> vec(2*h-1);
    rep(i,102) rep(j,102) dist[i][j]=INF;

    getchar();
    rep(i,2*h-1) {
        string ss;
        getline(cin,ss);
        vec[i] = ss;
    }

    queue<P> que;
    que.push(P(0,0));
    dist[0][0] = 0;

    while(que.size()) {
        P p = que.front(); que.pop();
        int x = p.first;
        int y = p.second;
        //cout<<"s : "<<x<<","<<y<<endl;
        rep(i,4) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            //if(0<=nx && 0<=ny ) cout<<nx<<","<<ny<<" : "<<vec[nx][ny]<<endl;
            if(0<=nx&&nx<2*h-1 && 0<=ny&&ny<vec[nx].size() && 
                    vec[nx][ny]=='0' && dist[nx+dx[i]][ny+dy[i]] == INF) {
                //cout<<nx<<","<<ny<<" : "<<vec[nx][ny]<<endl;
                dist[nx+dx[i]][ny+dy[i]] = dist[x][y] + 1;
                que.push(P(nx+dx[i],ny+dy[i]));
            }
        }

    }
    int ans = dist[2*(h-1)][2*(w-1)];
    ans = ans == INF? 0 : ans + 1;
    cout<<ans<<endl;
    /*
    rep(i,2*h) {
        rep(j,2*w) {
            cout<<dist[i][j++]<<" ";
        }
        i++;
        cout<<endl;
    }
    */



}

int main() {
    while(cin>>w>>h) {
        if(w+h==0) return 0;
        solve();
    }

    return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define mod 1000000007
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, m;
	cin >> n >> m;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int sum = 0;
	for (int i = 0; i < m; i++) {
		sum += a[i];
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.next());
    int M = Integer.parseInt(sc.next());

    String S = sc.next();
    String T = sc.next();

    long ans = lcm(N, M);
    int times = (int) gcd(N, M);

    int n = (int) (ans / N);
    int m = (int) (ans / M);

    for (int i = 0; i < times; i++) {
      if (S.charAt(i * m) != T.charAt(i * n)) {
        ans = -1;
      }
    }

    System.out.println(ans);
  }

  private static long gcd(long m, long n) {
    if (m < n)
      return gcd(n, m);
    if (n == 0)
      return m;
    return gcd(n, m % n);
  }

  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
  }
}

Measured memory_bytes: 27732
#include<bits/stdc++.h>
using namespace std;
#define el '\n'
#define ull unsigned long long
#define ui unsigned int
#define ll long long
#define forl(is,ie) for(int i=is;i<ie;i++)
#define sf(n) scanf("%d",&n);
#define pf(n) printf("%d",n);
int main()
{
    int n,m;
    cin>>n>>m;
    int sum=n+m;
    int mn=n-m;
    int mul=n*m;
    if(sum>=mn && sum>=mul)
        pf(sum)
    else if(mn>=sum && mn>=mul)
        pf(mn)
    else
        pf(mul);



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORALL(i, m) for( auto i = m.begin(); i != m.end() ; ++i )
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define TM_T template <class T>
#define MOD 1000000007
using namespace std;
typedef long long ll;
TM_T T inp(){T it;cin >> it;return it;}

ll N;
vector<vector<ll>> ed;
vector<vector<ll>> rv;
vector<ll> wh;
vector<ll> bl;

int input(){
  cin >> N;
  REP(i,N) ed.push_back( vector<ll>() );
  REP(i,N) rv.push_back( vector<ll>() );
  
  REP(i,N-1) {
    ll a = inp<ll>()-1;
    ll b = inp<ll>()-1;
    ed[a].push_back(b);
    ed[b].push_back(a);
  }
}

//set<ll> mita;

ll ret(ll nd,ll from){ 
  //if (wh[nd]>-1) return wh[nd]+bl[nd];
  
  ll w_ = 1;
  ll b_ = 1;
  FORALL(pit,ed[nd]){
    ll it = *pit;
    if (from == it) continue;
    ret(it,nd);
    w_ = (w_*(wh[it]+bl[it]))%MOD;
    b_ = (b_*(wh[it]))%MOD;
  }
  wh[nd] = w_%MOD;
  bl[nd] = b_%MOD;
  return (wh[nd]+bl[nd])%MOD;
}

int main()
{
  input();
  
  REP(i,N) wh.push_back(-1);
  REP(i,N) bl.push_back(-1);
  
  
  cout << ret(0,-1) << endl;
}

Measured memory_bytes: 17648
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

VI Y = {0, 0, 1, -1};
VI X = {1, -1, 0, 0};

int clear_maze(auto &maze, auto &H, auto &W, auto &visited)
{
  int sy = 0, sx = 0, gy = H-1, gx = W-1;
  queue<PII> que;
  que.push(PII(sy, sx));
  visited[sy][sx] = 0;
  while (!que.empty())
  {
    int y = que.front().first;
    int x = que.front().second;
    que.pop();
    REP(i, 4)
    {
      int yy = y + Y[i];
      int xx = x + X[i];
      if (yy == gy && xx == gx) return visited[y][x];
      if (0 <= yy && yy < H && 0 <= xx && xx < W && visited[yy][xx] == -1 && maze[yy][xx] != '#')
      {
        visited[yy][xx] = visited[y][x] + 1;
        que.push(PII(yy, xx));
      }
    }
  }
  return -1;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  VS grid(H);
  INPUT(grid);
  VVI visited(H, VI(W, -1));
  int white = -2;
  REPx(x, grid) REPx(y, x) if (y == '.') white++;
  int path = clear_maze(grid, H, W, visited);
  if (path == -1) cout << -1 << endl;
  else cout << white - path << endl;

  return 0;
}

Measured memory_bytes: 256