akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;

template <typename T> inline T read(){
    T sum = 0;
    int fl = 1, ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') fl = -1;
    for(; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
    return sum * fl;
}

const int maxn = 100000 + 5;

int n,k;
LL h[maxn];
LL dp[maxn];

int main(){
	n = read<int>();
	k = read<int>();
	for(int i = 1; i <= n; i++){
		h[i] = read<LL>();
	}
	for(int i = 1; i <= n; i++) dp[i] = 0x7fffffffffffff;
	dp[1] = (LL)0;
	for(int i = 2; i <= n; i++){
		for(int j = 1; j <= min(i - 1, k); j++){
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	printf("%lld\n",dp[n]);
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int prime_no(int n)
{
  if(n==2)
    return n;
  int i=n;
  while(1)
  {
    bool tag=false;
    for(int j=2;j<i;j++)
    {
      if(i%j==0)
      {
        tag=true;
        break;
      }
    }
    if(tag==false)
      return i;
    i++;
  }
  return 0;
}
int main()
{
  int n;
  cin>>n;
  cout<<prime_no(n)<<endl;
  return 0;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
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; }
int n, m;
vector<int> a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    m=n;
  	n/=100;
  	int mo=n%10;
  	int ans=mo*100+mo*10+mo;
  	if(ans>=m){
      cout<<ans<<"\n";
    }
  	else{
     	cout<<ans+111<<"\n";
    }

}



Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

vector<int> G[100+1];
vector<int> dist(100+1,-1);

void bfs(int x){
    dist[x] = 0;
    queue<int> PQ;
    PQ.push(x);

    while (!PQ.empty()){
        int tmp; tmp = PQ.front(); PQ.pop();
        for (int i = 0; i < G[tmp].size(); ++i) {
            if(dist[G[tmp][i]]==-1){
                dist[G[tmp][i]] = dist[tmp] + 1;
                PQ.push(G[tmp][i]);
            }
        }
    }

}


int main(void) {

    int n; cin>>n;

    for (int i = 1; i <= n; ++i) {
        int u,k; cin>>u>>k;
        for (int j = 1; j <= k; ++j) {
            int v; cin>>v;
            G[u].push_back(v);
        }
    }

    bfs(1);

    for (int i = 1; i <= n; ++i) {
        cout<<i<<" "<<dist[i]<<endl;
    }

    return 0;
}


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


int main(int argc, char const *argv[])
{
    int A;
    int B;
    cin>>A>>B;

    
    if (A+B>=24) {
        cout<<(A+B)-24;
    }
    else
    {
        cout<<A+B;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin>>d[i];
  }
  sort(d.begin(),d.end());
  if(d[N/2]==d[N/2-1]){
    cout<<0<<endl;
  }
  else{
    cout<<d[N/2]-d[N/2-1]<<endl;
  }
}

Measured memory_bytes: 3756
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    int k;
    cin >> k;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    bool dp[k + 1] = {};
    for (int i = 0; i <= k;i++){
        if (!dp[i])
        {
            for (int j = 0; j < n; j++)
            {                
                if(i+a[j]<=k)dp[i + a[j]] = true;                
            }
        }
    }
    if(dp[k])
        cout << "First" << endl;
    else
        cout << "Second" << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i;
		int j;
		int k;
		int c=0;
		for( i = 0; i<n; i++) {
			for( j = 0; j<n; j++) {
				for( k = 0; k<n; k++) {
					c++;
				}
			}
		}
		System.out.println(c);
		sc.close();
		
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> v(n);
    for(int i=0; i<n;++i)
        v[i]=i+1;
    do{
        for (int i = 0; i < n-1; ++i) {
            cout<<v[i]<<" ";
        }
        cout<<v[n-1]<<endl;
    }while(next_permutation(v.begin(),v.end()));
    return 0;
}


Measured memory_bytes: 3108
use proconio::input;

fn main() {
    input! {
        n: usize,
        aa: [usize; n-1],
    };

    let mut ans = vec![0; n];

    for a in aa {
        ans[a-1] += 1;
    }

    for a in ans {
        println!("{}", a);
    }
}


Measured memory_bytes: 5628
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>

using namespace std;

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

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin

  ll A, B, C;
  cin >> A >> B >> C;

  if(A==B && B==C) cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    ll L, R;
    cin >> L >> R;
    if (R - L >= 2019) {
        cout << 0 << endl;
    }
    else {
        ll ans = 2018;
        for (ll i = L; i < R; i++) {
            for (ll j = i + 1; j <= R; j++) {
                ans = min(ans, (i * j) % 2019);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3576
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


D,T,S = LI()

j = D / S

if j <= T:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9272
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;

const int dx44[5] = { 0,-1,-1,1,1 };
const int dy44[5] = { 0,-1,1,-1,1 };

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 2e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

int x1,x2,yy1,yy2;
vector<pair<int,int> >val;
int n;
int a[maxn];
int dp[maxn];

int lis()
{
    memset(dp, 0, sizeof(dp));
    int len = 0;
    for (int i = 1; i <= n; ++i)
    {
        int pos = lower_bound(dp, dp + len, a[i]) - dp;
        if(pos==len)
        {
        	dp[len++]=a[i];
        }
        else
        {
        	dp[pos]=a[i];
        }
        len = max(len, pos + 1);
    }
    return len;
}
void solve()
{
	sa(x1),sa(yy1);
	sa(x2),sa(yy2);
	
	if(x1>x2)
	{
		swap(x1,x2);
		swap(yy1,yy2);
	}
	int flag=0;
	if(yy1>yy2)
	{
		flag=1;
	}
	sa(n);
	repp(i,1,n)
	{
		int x,y;
		sa(x),sa(y);
		if(min(x1,x2)<=x&&x<=max(x1,x2)&&min(yy1,yy2)<=y&&y<=max(yy1,yy2))
		{
			if(flag==0)
				val.push_back(mp(x,y));
			else
				val.push_back(mp(x,1e9-y));
		}
	}
	double res = 1.0*(abs(x2-x1)+abs(yy2-yy1))*100;
	if(val.size()==0)
	{
		printf("%.20lf\n", res);
		return;
	}

	sort(val.begin(),val.end());
	n=val.size();
	//DE(n)
	rep(i,0,val.size())
	{
		a[i+1]=val[i].second;
		//cout<<a[i+1]<<endl;
	}
	int d=lis();
	//DE(d)
	if(d==min(abs(x1-x2),abs(yy1-yy2))+1)
	{
		res=res-(20.0-5*PI)*(d-1)+(10*PI-20);
	}
	else
	{
		res=res-(20.0-5*PI)*d;
	}
	printf("%.20lf\n", res);
}

int main()
{
	solve();
	// system("pause");
	return 0;
}





Measured memory_bytes: 3440
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll xs(n);
    forn(i, n) cin>>xs[i];
    ll sum=accumulate(all(xs), 0ll);
    ll z=n*(n+1)/2;
    if (sum%z) return cout<<"NO\n", 0;
    ll k=sum/z;
    ll drops=0;
    forn(i, n) {
        ll d=xs[i]-xs[(i+1)%n]+k;
        if (d%n || d<0) return cout<<"NO\n", 0;
        drops += d/n;
    }
    if (drops!=sum/z) cout<<"NO\n";
    else cout<<"YES\n";
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    ll cnt[100010];
    mem0(cnt);
    cin >> N;
    for (int i = 0; i < N; i++) {
        ll a; cin >> a;
        cnt[a+1]++;
    }
    ll ans = 0;
    for (int i = 1; i <= 100000; i++) {
        ans = max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4324
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;//1e9
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数
    intl a = 1;
    for(int i = 2; i <= k; i++){ a *= i; }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{ a /= 10; b++; }while(a);
    return b;
}

signed main(){
    cout << fixed << setprecision(10);
    intl n,W;
    cin >> n >> W;
    intl w[n],v[n];
    rep(i,n)cin >> w[i] >> v[i];
    intl sum = 0;
    rep(i,n)sum += v[i];
    intl dp[n + 1][sum + 1];
    rep(i,n + 1)rep(j,sum + 1)dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i,n){
        rep(j,sum + 1){
            if(j - v[i] >= 0)chmin(dp[i + 1][j],dp[i][j - v[i]] + w[i]);
            chmin(dp[i + 1][j], dp[i][j]);
        }
    }
    intl ans = 0;/*
    rep(i,n + 1){
        rep(j, sum + 1)cout << dp[i][j] << " ";
        cout << endl;
    }*/
    rep(i,sum + 1){
        if(dp[n][i] <= W){
            ans = i;
            //debug(ans);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 82512
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin>>s;
    
    for(int i=0;i<s.size();i++){
        if(s[i]=='A')s[i]='X';
        
        else if(s[i]=='B')s[i]='Y';
        
        else if(s[i]=='C')s[i]='Z';
        
        else s[i]=s[i]-3;
    }
    cout<<s<<endl;
}

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

int main(){
    int n;
    cin>>n;
    int heights[n], dp[n];
    for (int i=0; i<n; i++)
        cin>>heights[i];
    dp[n-1]=0;
    dp[n-2]=abs(heights[n-2]-heights[n-1]);
    for (int i=n-3; i>=0; i--){
        int poss1 = abs(heights[i+1]-heights[i]) + dp[i+1];
        int poss2 = abs(heights[i+2]-heights[i]) + dp[i+2];
        dp[i] = min(poss1, poss2);
    }
    cout<<dp[0];
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
#define line cout << "------------------------\n" 
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n, sum = 0; cin >> n;
    eFOR(i, 1, n) {
        sum += i;
        if (n <= sum) {
            erFOR(j, 1, i) {
                if (j <= n) {
                    cout << j << "\n";
                    n -= j;
                }
            }
            break;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
ll a[100000], b[100000], inf = 999999999999999999;
int c[100000];
int main() {
	ll n, t, q;
	cin >> n >> t >> q;
	for (ll i = 0; i < n; i++) {
		cin >> a[i] >> c[i];
		b[i] = inf;
	}
	for (ll i = 0; i < n - 1; i++) {
		if (c[i]== 1 && c[i + 1] == 2) {
			ll t = (a[i] + a[i + 1]) / 2, j;
			j = i;
			while (j>=0&&c[j] == 1) {
				b[j] = t;
				j--;
			}
			j = i + 1;
			while (j<n&&c[j] == 2) {
				b[j] = t;
				j++;
			}
		}
	}
	for (ll i = 0; i < q; i++) {
		ll d;
		cin >> d;
		d -= 1;
		if (abs(b[d] - a[d]) <= t&&b[d]!=inf) {
			cout << b[d] << endl;
		}
		else {
			if (c[d] == 1) cout << a[d] + t << endl;
			else cout << a[d] - t << endl;
		}
	}
}

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

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

    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys
import copy
import math
import itertools
import numpy as np
l = [int(c) for c in input().split()]
A = l[0]
B = l[1]
cnt=0
for i in range(A,B+1):
    if str(i)[0]==str(i)[4] and str(i)[1]==str(i)[3]:
        cnt+=1
print(cnt)

Measured memory_bytes: 26892
/*input
1071 1029
5 5
0 0
*/
fn gcd(a: u64, b: u64, c: u64) -> Vec<u64> {
    if b == 0 {
        return vec![a, c];
    }
    return gcd(b, a % b, c + 1);
}

fn main() {
    let mut input;
    let mut v: Vec<u64>;
    loop {
        input = format!("");
        std::io::stdin().read_line(&mut input).expect("");
        v = input
            .trim()
            .split_whitespace()
            .map(|x| x.parse().expect(""))
            .collect();
        if v[0] == 0 && v[1] == 0 {
            break;
        }
        let gcd_ = if v[0] > v[1] {
            gcd(v[0], v[1], 0)
        } else {
            gcd(v[1], v[0], 0)
        };
        println!("{} {}", gcd_[0], gcd_[1]);
    }
}



Measured memory_bytes: 5036
#include<iostream>
using namespace std;
int main(){
	 long long a,b,x,n;
	 scanf("%lld %lld %lld ",&a,&b,&x);
	 if(a==0)
	   n=(b/x)+1;
	   else{
	   	n=(b/x)-(a-1)/x;
	   }
	   cout<<n;
	    
	    return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define l(i,a,b) for(ll i=a;i<b;i++)
#define PI 3.14159265358979323846
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	cout<<t<<s<<"\n";
}

Measured memory_bytes: 3568
#include <cstdio>

int a,b,k;

int main()
{
  scanf("%d%d%d",&a,&b,&k);
  if(b-a+1<=2*k)
    {
      for(register int i=a; i<=b; ++i)
        {
          printf("%d\n",i);
        }
    }
  else
    {
      for(register int i=0; i<k; ++i)
        {
          printf("%d\n",a+i);
        }
      for(register int i=k-1; i>=0; --i)
        {
          printf("%d\n",b-i);
        }
    }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define jyldam ios_base::sync_with_stdio;cin.tie(NULL);cout.tie(NULL);

#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define sz size()
#define fi first
#define se second
 
#define cmp_all(x) (x).begin(), (x).end(), cmp
#define batr ONLINE_JUDGE
#define all(x) (x).begin(),(x).end()
#define skip continue
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
const int N = 1e6 + 17, maxN = 4 * N, darr = 1e3 + 17, mod = 1e9 + 7;

int n;
int a[N];
int q;
int ct;
 
int main () {
	jyldam;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int res = 0;
	vector <int> v;

	for (int i = 1; i <= n + 1; i++) {
		if (a[i] == a[i-1]) {
			ct++;
		}
		else {
			v.pb(ct);
			ct = 1;
		}
	}
	for (int i = 0; i < v.sz; i++) {
		res += v[i] / 2;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

int main() {
    double n;
    double a[101];
    cin>>n;
    REP(i, 0, n) cin>>a[i];

    double sum=0;
    REP(i, 0, n){
        sum+=(1.0/a[i]);
    }
    printf("%.7lf\n", 1.0/sum);
    return 0;
}

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

typedef long long int ll;

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

    ll cnt = 0;
    vector<ll> ans;
    
    for(ll i = 1;;i++){
        if(a < i || b < i){
            break;
        }
        if(a % i == 0 && b % i == 0){
            ans.push_back(i);
        }
    }

    cout << ans[ans.size() - k];

    return 0;
}


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

char S[ 20 ];

int main()
{
int i;
int A;
int B;

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

	cin >> A;
	cin >> B;
	cin >> S;

	for( i = 0; i < A; i++ )
	{
		if( S[ i ] < '0' || S[ i ] > '9' )
		{
			cout << "No" << endl;

			return 0;
		}
	}

	if( S[ A ] != '-' )
	{
		cout << "No" << endl;

		return 0;
	}

	B += A + 1;
	for( i = A + 1; i < B; i++ )
	{
		if( S[ i ] < '0' || S[ i ] > '9' )
		{
			cout << "No" << endl;

			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
long long a[100007];
int n,m;long long ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
	{
	int x;
	scanf("%d",&x);
	++a[x];
	ans+=x;
	}
	cin>>m;
	for(int i=1;i<=m;++i)
	{
		long long x,y;
		scanf("%lld%lld",&x,&y);
		ans+=(y-x)*a[x];
		a[y]+=a[x];
		a[x]=0;
		printf("%lld\n",ans);
	}
	return 0;
	
}

Measured memory_bytes: 3952
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll inf = 1e18;
ll mod=1e9+7;
//LLONG_MIN


//ユークリッドの互除法
long long gcd(long long a,long long b){
	if(b==0)return a;
	return gcd(b,a%b);
}

ll A,B,k,g,ans;

int main(void){
	cin>>A>>B>>k;
	g=min(A,B);
	ireg(i,1,g){
		if(A%i==0 && B%i==0){
			// cout<<i<<endl;
			k--;
			if(k==0){
				ans=i;
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using str = string;

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

    str s;
    cin>>s;

    vector<int> cnt(3);

    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='a')cnt[0]++;
        else if(s[i]=='b')cnt[1]++;
        else if(s[i]=='c')cnt[2]++;
    }

    sort(cnt.begin(),cnt.end());
    
    cnt[1]-=cnt[0];
    cnt[2]-=cnt[0];

    puts(cnt[2]<=1&&cnt[1]<=1?"YES":"NO");

    return 0;
}


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

/* 
 * * stuff you should look for
 * * int overflow, array bounds
 * * special cases (n=1?), set tle
 * */

ll go(ll n, ll p){
    if(n/p == 0) return 0;
    return n / p + go(n, 5*p);
}

int main(){
    fcin;

    ll n;
    cin >> n;
    if(n&1) return cout << 0, 0;

    // qtt(5) + qtt(50) + qtt(250) + ...

    ll ans = go(n, 10LL);

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
ll comb(ll n, ll k) {
    map<string, ll> memo;
    if (n == k || k == 0)
        return 1;
    else {
        string key = to_string(n) + to_string(k);
        if (memo.count(key) != 0) {
            return memo[key];
        } else {
            ll out = comb(n - 1, k - 1) + comb(n - 1, k);
            memo[key] = out;
            return out;
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    ll cnt = 0;
    ll k_0 = 0, k_2 = 0;
    if (k % 2 == 1) {
        for (int i = 1; i <= n; i++) {
            if (i % k == 0) {
                k_0++;
            }
        }
        if (k_0 == 1) {
            cnt = 1;
        } else {
            cnt = pow(k_0, 3);
        }
    } else {
        for (int i = 1; i <= n; i++) {
            if (i % k == 0) {
                k_0++;
            }
            if (i % k == k / 2) {
                k_2++;
            }
        }
        if (k_2 <= 1 && k_0 <= 1) {
            cnt = k_2 + k_0;
        } else if (k_2 <= 1 && k_0 > 1) {
            cnt = k_2 + pow(k_0, 3);
        } else {
            cnt = pow(k_2, 3) + pow(k_0, 3);
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string str;
    cin >> str;
    
    int ans=0;
    char pre=' ';
    int cur=0;
    for(int i=0; i<str.size(); i++) {
        if(pre==' ') {
            ans++;
            cur=1;
            pre=str[i];
        } else if(pre==str[i]) {
            if(i+1<str.size()) {
                pre=' ';
                cur=0;
                ans++;
            }
            i++;
        } else {
            ans++;
            cur=1;
            pre=str[i];
        }
    }
    
    cout << ans << endl;


    return 0;
    
}

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

int main()
{
  int h, w;
  cin >> h >> w;
  char c[h][w];
  vector<int> a(h);
  vector<int> b(w);
  rep(i, h){
    rep(j, w) {
      cin >> c[i][j];
      if (c[i][j] == '#') {
        a[i] = 1;
        b[j] = 1;
      }
    }
  }
  
  rep(i, h){
    rep(j, w) {
      if(a[i] && b[j]) cout << c[i][j];
    }
    if(a[i])cout << endl;
  }                
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
struct wz
{
	int xh,rs;
};
wz a[N];
bool cmp(wz a,wz b)
{
	return a.rs<b.rs;
}
int main()
{
	int n;
	while(cin>>n)
	{
		int t;
		for(int i=1;i<=n;i++)
		{
			cin>>t;
			a[i].xh=i;
			a[i].rs=t;
		}
		sort(a+1,a+n+1,cmp);
		for(int i=1;i<=n;i++)
		{
			if(i==1)
				cout<<a[i].xh;
			else
				cout<<" "<<a[i].xh;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N, T;
    cin >> N >> T;
    int A[100000];
    int g[100000];
    cin >> A[0];
    int m = A[0];
    g[0] = 0;
    int m_idx = 0;
    for(int i = 1; i < N; i++){
        cin >> A[i];
        g[i] = A[i] - m;
        if(A[i] < m){
            m = A[i];
            m_idx = i;
        }
    }
    sort(g, g+N, greater<int>());
    int ans = 0;
    for(int i = 0; i <= m_idx; i++){
        if(g[i] == g[0]) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {

    int floor;
    double t, y, speed;

    while(cin >> speed) {

        t = speed / 9.8;
        y = 4.9 * t * t;

        for(floor = 1; (double)5 * floor - 5 < y; floor++);

        cout << floor << endl;

    }

}

Measured memory_bytes: 1224
import java.util.*;

class Main {
    class Dot {
        double x;
        double y;

        public Dot(double x, double y) {
            this.x = x;
            this.y = y;
        }
    }

    public static void main(String[] args) {
        new Main().main();
    }

    public void main() {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        List<Dot> list = new ArrayList<>();
        list.add(new Dot(0.0, 0.0));
        list.add(new Dot(100.0, 0.0));
        this.growKochCurve(list, n);

        for (Dot val : list) {
            System.out.printf("%f %f\n", val.x, val.y);
        }
    }

    private void growKochCurve(List<Dot> list, int level) {
        if (level == 0) {
            return;
        }

        Dot[] array = list.toArray(new Dot[list.size()]);
        for (int i = array.length - 2; i >= 0; i--) {
            Dot left = array[i];
            Dot right = array[i+1];

            Dot firstVector = new Dot((right.x - left.x) / 3.0, (right.y - left.y) / 3.0);

            Dot firstDot  = new Dot(left.x + firstVector.x, left.y + firstVector.y);
            Dot secondDot = this.makeSecondDot(left, right);
            Dot thirdDot  = new Dot(left.x + 2.0 * firstVector.x, left.y + 2.0 * firstVector.y);
            list.add(i + 1, thirdDot);
            list.add(i + 1, secondDot);
            list.add(i + 1, firstDot);
        }

        this.growKochCurve(list, level - 1);
    }

    private Dot makeSecondDot(Dot left, Dot right) {
        Dot firstVector = new Dot((right.x - left.x) / 3.0, (right.y - left.y) / 3.0);
        Dot secondVector = new Dot(
                firstVector.x * Math.cos(Math.toRadians(60)) - firstVector.y * Math.sin(Math.toRadians(60)),
                firstVector.x * Math.sin(Math.toRadians(60)) + firstVector.y * Math.cos(Math.toRadians(60)));
        return new Dot(
                left.x + firstVector.x + secondVector.x,
                left.y + firstVector.y + secondVector.y);
    }
}



Measured memory_bytes: 42688
// AtCoder Begginer Contest 140 C - Maximal Value
// https://atcoder.jp/contests/abc140/tasks/abc140_c

#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
using uint = unsigned int;

int main() {
	uint N;
	cin >> N;
	
	vector<uint> B(N-1);
	for (uint i=0; i<N-1; i++) {
		cin >> B[i];
	}

	vector<uint> A(N);
	for (uint i=1; i<N-1; i++) {
		A[i] = min(B[i-1], B[i]);
	}
	
	A[N-1] = B[N-2];
	A[0] = B[0];
	
	uint sum = accumulate(A.begin(), A.end(), 0);
	cout << sum;
	
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    if(x<1200){
        puts("ABC");
    }else{
        puts("ARC");
    }

    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
const int N=1e7;
ll ppow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res%m;
}
int get(ll n)
{
	if(n==0)return 0;
	int ans=0;
	while(n)
	{
		int pc=__builtin_popcount(n);
		n%=pc;
		ans++;
	}
	return ans;
}
void solve()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int c=count(all(s),'1');
	int m1=c+1,m2=c-1;
	if(c==0)
	{
		forn(i,n)
		{
			cout<<1<<endl;
		}
		return;
	}
	vii v1,v2;
	int x=n-1;

	while(x!=-1)
	{
		v1.pb(ppow(2,x,m1));
		x--;
	}

	ll ans1=0,ans2=0;
	forn(i,n)
	{
		if(s[i]=='1')ans1+=v1[i],ans1%=m1;
	}
	if(m2==0)
	{
		forn(i,n)
		{
		ll cur=0;
		int ans=1;
		if(s[i]=='1')
		{
			cout<<0<<endl;
			continue;
		}
		else
		{
			cur=ans1;
			cur+=v1[i];
			cur%=m1;

		}
		ans+=get(cur);

		cout<<ans<<endl;


		}
		return;
	}
	

	x=n-1;
	while(x!=-1)
	{
		v2.pb(ppow(2,x,m2));
		x--;
	}

	//for(auto i:v1)cout<<i<<" ";
	//	cout<<endl;
	//for(auto i:v2)cout<<i<<" ";

	
	forn(i,n)
	{
		if(s[i]=='1')ans2+=v2[i],ans2%=m2;
	}
	vi aa;
	forn(i,n)
	{
		ll cur;
		int ans=1;
		if(s[i]=='1')
		{
			cur=ans2;
			cur+=m2;
			cur-=v2[i];
			cur+=m2;
			cur%=m2;
		}
		else
		{
			cur=ans1;
			cur+=v1[i];
			cur%=m1;

		}
		ans+=get(cur);

		aa.pb(ans);

	}

	for(auto i:aa)cout<<i<<endl;
}
int main()
{

    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
  	//cin>>t;
    while(t--)
   	solve();
}


Measured memory_bytes: 8364
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

LL pow_mod(LL a, LL n)
{
    LL res = 1;

    while(n)
    {
        if(n & 1) res = (res * a) % MOD;
        n = n / 2;
        a = (a * a) % MOD;
    }

    return res;
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    LL n;
    cin>>n;
    LL mn = (2 * pow_mod(9,n)) % MOD;
    mn = (mn + MOD - pow_mod(8,n)) % MOD;
    LL ans = (pow_mod(10,n) + MOD - mn) % MOD;
    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3604
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//------------------------------------------
//------------------------------------------

constexpr int MAX_N = 2525;
constexpr LL INF = 1e15;

vector<int> go[MAX_N];
vector<int> back[MAX_N];
vector<bool> go_state(MAX_N, false);
vector<bool> back_state(MAX_N, false);

void dfs(int v, vector<int> way[], vector<bool> &state) {
    if (state[v])return;
    state[v] = true;
    for (auto to: way[v]) {
        dfs(to, way, state);
    }
}


int main() {

    int N, M, P;
    cin >> N >> M >> P;

    vector<int> A(M), B(M), C(M);
    vector<tuple<int, int, int>> edges(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--, B[i]--;
        C[i] -= P;
        edges[i] = make_tuple(A[i], B[i], C[i]);
        go[A[i]].push_back(B[i]);
        back[B[i]].push_back(A[i]);
    }

    dfs(0, go, go_state);
    dfs(N - 1, back, back_state);

    vector<bool> sects(MAX_N, false);
    for (int i = 0; i < N; i++) sects[i] = go_state[i] & back_state[i];

    vector<LL> dist(N, -INF);
    dist[0] = 0;
    for (int i = 0; i < N; i++) {
        for (auto &e: edges) {
            int a, b, c;
            tie(a, b, c) = e;
            if (dist[a] != -INF) {
                dist[b] = max(dist[b], dist[a] + c);
            }
        }
    }

    auto cp = dist;
    for (int i = 0; i < N; i++) {
        for (auto &e: edges) {
            int a, b, c;
            tie(a, b, c) = e;
            if (dist[a] != -INF) {
                dist[b] = max(dist[b], dist[a] + c);
            }
        }
    }

    for (int i = 0; i < N; i++) {
        if (sects[i] && (cp[i] != dist[i])) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << max(0LL, dist[N - 1]) << endl;

}
























Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
//以下雛形を記す
long long INF =  10000000000000000;
struct edge{
    int from;
    int to;
    long long cost;
};

int main(){
    int N, M;//Vは頂点、Kは辺の数
    cin >> N >> M;
    vector<edge> es(M);
    for(int i = 0; i < M; i++){
        cin >> es[i].from >> es[i].to >> es[i].cost;
        es[i].from--;
        es[i].to--;
        es[i].cost *= -1;
    }
    vector<long long> d(N);//各頂点までの距離
    for(int i = 0; i < N; i++) d[i] = INF;
    d[0] = 0;
    int n = 0;
    while(true){
        bool flag = false;
        bool flag2 = true;
        for(int i = 0; i < M; i++){
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                if(n >=N && e.to == N - 1) flag2 = false;
                flag = true;
            }
        }
        n++;
        if(!flag){
            cout << -d[N - 1] << endl;
            break;
        }
        if(n >= N && flag2 == false){
            cout << "inf" << endl;
            break;
        }
        else if(n >= 2*N && flag2 == true){
            cout << -d[N - 1] << endl;
            break;
        }
    }
}

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int r,g,b;
    cin >> r >> g >> b;
    int n = r*100 + g*10 + b;
    if(n%4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
	return 0;
}



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

int main() {
 int n; cin >> n;
  if(n>81)cout << "No" << endl;
  else if(n>72 && n<81) cout << "No" << endl;
  else if(n>64 && n<72) cout << "No" <<endl;
  else if(n>56 && n<63) cout << "No" << endl;
  else if(n==55) cout << "No" << endl;
  else if(n>49 && n<54) cout << "No" << endl;
  else if(n==46 || n==47) cout << "No" << endl;
  else if(n==11 || n==13 || n==17 || n==19 || n==22 || n==23 || n==26 || n==29 || n==31 || n==33 || n==33 || n==34 || n==37 || n==38 || n==39 || n==41 || n==43 || n==44) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int; //任意長整数 
using Real32 = mp::number<mp::cpp_dec_float<32>>;
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
using Rat = boost::rational<Bint>;//有理数*/
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

long long modpow(long long a, long long n, long long mod) {//a^n(mod)を求める
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;//次の準備
        n >>= 1;
    }
    return res;
}

signed main(){
    string s;
    ll ans=0;
    cin>>s;
    vector<int> a(siz(s)+1,0),c,q;
    c=a;q=a;

    for(int i=1;i <= siz(s);i++)
    {
        a.at(i)=a.at(i-1);
        if(s.at(i-1)=='A')a.at(i)++;
        c.at(i)=c.at(i-1);
        if(s.at(i-1)=='C')c.at(i)++;
        q.at(i)=q.at(i-1);
        if(s.at(i-1)=='?')q.at(i)++;
    }

    for(int i=0;i < siz(s);i++)
    {
        if(s.at(i)=='B' || s.at(i)=='?'){
            ll ql=modpow(3,q.at(i),mod);
            ll ql2=modpow(3,q.at(i)-1,mod);
            ll qr=modpow(3,q.at(siz(s))-q.at(i+1),mod);
            ll qr2=modpow(3,q.at(siz(s))-q.at(i+1)-1,mod);
            ans+=((a.at(i)*ql + q.at(i)*ql2)%mod)*(((c.at(siz(s))-c.at(i+1))*qr + (q.at(siz(s))-q.at(i+1))*qr2)%mod);
            ans%=mod;
            //cout << ans << endl;
        }
    }
    cout << ans << endl;

}



Measured memory_bytes: 1664
#include <stdio.h>

#define SQ(x)	((x) * (x))

int main(void)
{
	int a, b, c, i, n;
	int sub1, sub2, max;
	
	scanf("%d", &n);
#if 1
	for (i = 0; i < n; i++){
		scanf("%d %d %d", &a, &b, &c);
		if (a >= b && a >= c){
			max = a * a;
			sub1 = b * b;
			sub2 = c * c;
		}
		else if (b >= c){
			max = b * b;
			sub1 = a * a;
			sub2 = c * c;
		}
		else {
			max = c * c;
			sub1 = b * b;
			sub2 = a * a;
		}
		
		if (sub1 + sub2 == max){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
#else
	for (i = 0; i < n; i++){
		int ps[3];
		int j;
		for (j = 0; j < 3; j++){
			scanf("%d", &ps[j]);
		}
		for (j = 1; j < 3; j++){
			if (ps[0] < ps[j]){
				int t = ps[0];
				ps[0] = ps[j];
				ps[j] = t;
			}
		}
		if (SQ(ps[0]) == SQ(ps[1]) + SQ(ps[2])){
			puts("YES");
		}
		else {
			puts("NO");
		}
	}
#endif
	return (0);
}

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

int main() {
  int n;
  cin>>n;
  string get[n];
  for(int i=0; i<n; i++) cin>>get[i];

  sort(get, get+n);

  int ans = 1;
  for(int i=1; i<n; i++) {
    if(get[i]!=get[i-1]) ans++;
  }

  cout<<ans<<endl;


  return 0;
}

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

int main()
{
ll n ;
cin >> n ;
vector<pair<ll,ll>> a(n);
rep(i, n){
  cin >> a[i].first;
  a[i].second=i+1;
}
sort(a.begin(),a.end());
reverse(a.begin(),a.end());

vector<vector<ll>> v(n+1, vector<ll>(n,0) );
rep(i,n){
  rep(j,n-1){
    if(i<j)continue;
    v[i+1][j]=max(v[i+1][j],v[i][j]+a[i].first*abs(n-i+j-a[i].second));
    v[i+1][j+1]=max(v[i+1][j+1],v[i][j]+a[i].first*abs(j+1-a[i].second));
  }
}
rep(i,n){
  ans=max(ans,v[n][i]);
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 34680
// AOJ 0504: Card Game II
// 2017.12.6 bal4u@uu

#include <stdio.h>
#include <string.h>

#define N 6
char d[10005+N], s[10005+N];

void frac(char *d, int a, int b, int n)
{
	int i;

	*d++ = a/b, a %= b;
	for (i = 1; a > 0 && i <= n; i++) {
		a *= 10;
		*d++ = a / b;
		a %= b;
	}
}

void sum(char *s, char *d, int n)
{
	int ca = 0;
	char *s0 = s;

	s += n, d += n;
	while (s >= s0) {
		*s += ca + *d, ca = 0;
		if (*s >= 10) *s -= 10, ca = 1;
		s--, d--;
	}
}

int main()
{
	int n, k, m, r, i;
	char *ss = s+1, *dd = d+1;

	while (scanf("%d%d%d%d", &n, &k, &m, &r) && n > 0) {
		r += N;

		memset(s, 0, sizeof(s));
		frac(ss, 1, n, r);

		if (m == 1) {
			for (i = 1; i < n; i++) {
				memset(d, 0, sizeof(d));
				frac(dd, 1, n*i, r);
				sum(ss, dd, r);
			}
		}
		s[0] = s[1] + '0', s[1] = '.';
		for (i = 1; i <= r; i++) s[i+1] += '0';
		s[r-N+2] = 0;
		puts(s);
	}
	return 0;
}

Measured memory_bytes: 1700
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>

#define mod 1000000007

using namespace std;
using ll = long long;

void solve() {
    string n;
    cin >> n;
    for(int i = 0; i < n.length(); i++){
        if(n[i] == '9'){
            cout << "Yes" << endl;
            return ;
        }
    }
    cout << "No" << endl;
}

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int h = Integer.parseInt(str[0]);
    int w = Integer.parseInt(str[1]);
    String st = "";
    for(int i=0; i<h; i++) {
      st = in.readLine();
      System.out.println(st);
      System.out.println(st);
    }
  }
}

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

int main() {
  string s ,t;
  cin >> s >> t;
  int count=0;
  for (int i=0; i<s.size(); i++){
    if (s.at(i) == t.at(i)){
      count++;
    }
  }
  if (count == s.size()){
    cout << "Yes " <<endl;
  }else{
    cout << "No" << endl;
  }
}

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

const int mod = 998244353;
#define ll long long
ll K(ll x,ll y=mod-2){
	ll t=1;
	for (;y;y>>=1,x=x*x%mod)
		if (y&1) t=t*x%mod;
	return t;
}

int n, a[303000], b[303000], sum;

void fwt(int *a){
	for (int i=0;i<n;++i)
		for (int j=0;j<(1<<n);++j)
			if (!(j>>i&1)){
				int &x=a[j], &y=a[j|1<<i];
				tie(x,y)=make_tuple((x+y)%mod,(x-y+mod)%mod);
			}
}

int main(){
	cin>>n;
	for (int i=0;i<(1<<n);++i){
		scanf("%d",&a[i]); sum+=a[i];
	}
	for (int i=0;i<(1<<n);++i){
		a[i]=a[i]*K(sum)%mod;
	}
	fwt(a);
	memcpy(b,a,sizeof a);
	for (int i=0;i<(1<<n);++i){
		if (a[i]==1){
			a[i]=0; b[i]=1;
			continue;
		}
		a[i]= (ll)(a[i]-1+mod)*K((1ll-a[i])*(1ll-a[i])%mod)%mod;
		b[i]= 0;
	}
	fwt(a);
	fwt(b);
	ll inv=K(1<<n);
	for (int i=0;i<(1<<n);++i){
		if (i==0){
			puts("0"); continue;
		}
		ll f1=a[i]*inv%mod, f0=b[i]*inv%mod, g1=a[0]*inv%mod, g0=b[0]*inv%mod;
		int ans= (f1*g0%mod-f0*g1%mod+mod)*K(g0*g0%mod)%mod;
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 4992