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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long A, long long B){
    if(A<=9 && B<=9) cout<<A*B<<endl;
    else cout<<-1<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    int X;
    cin >> X;
    double ans=0.0, x=0.0, y=0.0;
    double pi = 3.141592653589793238;
    double t_angle = pi/2;
    double dx = pi*(double)X/180.0;
    while(1){
        t_angle = t_angle + dx;
        if(t_angle > 2*pi){
            t_angle -= 2*pi;
        }
        //printf("tangle:%.16f dx:%.16f x:%.16f y:%.16f ans:%.16f\n", t_angle, dx, x, y, ans);
        if(t_angle>0.0 && t_angle<=(pi/2)){
            x = x + cos(t_angle);
            y = y + sin(t_angle);
            //printf("1:tangle:%lf x:%lf y:%lf cos:%lf sin %lf\n", t_angle, x, y, cos(t_angle), sin(t_angle));
        }
        else if(t_angle>(pi/2) && t_angle<=(pi)){
            x = x - cos(pi-t_angle);
            y = y + sin(pi-t_angle);
            //printf("2:tangle:%lf x:%lf y:%lf cos:%lf sin %lf\n", t_angle, x, y, cos(pi-t_angle), sin(pi-t_angle));
        }
        else if(t_angle>pi && t_angle<=(3*pi/2)){
            x = x - sin((3*pi/2)-t_angle);
            y = y - cos((3*pi/2)-t_angle);
            //printf("3:tangle:%lf x:%lf y:%lf cos:%lf sin %lf\n", t_angle, x, y, cos((3*pi/2)-t_angle), sin((3*pi/2)-t_angle));
        }
        else if(t_angle>(3*pi/2) && t_angle<=(2*pi)){
            x = x + cos((2*pi)-t_angle);
            y = y - sin((2*pi)-t_angle);
            //printf("4:tangle:%lf x:%lf y:%lf cos:%lf sin %lf\n", t_angle, x, y, cos((2*pi)-t_angle), sin((2*pi)-t_angle));
        }
        ans++;
        //printf("ans:%.16f x:%.16f y:%.16f fabx:%.16f faby:%.16f DBL:%.16f\n", ans, x, y, fabs(x), fabs(y), DBL_EPSILON);
        if(fabs(x)<2e-9 && fabs(y)<2e-9){
            //printf("ans:x:%lf y:%lf DBL:%lf\n", x, y, DBL_EPSILON);
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4160
# 2019/10/10
# 解答かんにんぐ
# 前回WAの原因は、u,vのいずれかが訪問済みである必要があった。
# edge参照順序によっては、u,vのいずれも未訪問となり、このときWAとなる。

import sys
sys.setrecursionlimit(10**7)

n=int(input())
node=[None]*n
edge=[[] for _ in range(n)]


for i in range(n-1):
    u,v,w=map(int,input().split())
    u-=1;v-=1
    edge[u].append((v,w))
    edge[v].append((u,w))


def dfs(v,p,c):
    node[v]=c
    for vv,w in edge[v]:
        if vv==p:continue
        dfs(vv,v,1-c) if w%2 else dfs(vv,v,c)


dfs(0,-1,0)

for e in node:
    print(e)

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

int main(){
	int n;
  	scanf("%d", &n);
	if(n < 600) puts("8");
	else if(n < 800) puts("7");
	else if(n < 1000) puts("6");
	else if(n < 1200) puts("5");
	else if(n < 1400) puts("4");
	else if(n < 1600) puts("3");
	else if(n < 1800) puts("2");
	else if(n < 2000) puts("1");
}


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

using namespace std;

int main() {
  int a[3], count = 0;
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  } 

  int o = 0, e = 0;
  for (int i = 0; i < 3; i++) {
    a[i] % 2 ? o++ : e++;
  }

  if (o == 3 || e == 3) {
    int m = max(a[0], max(a[1], a[2]));
    for (int i = 0; i < 3; i++) {
      count += (m - a[i]) / 2;
    }
  } else if (e < o) {
    for (int i = 0; i < 3; i++) {
      if (a[i] % 2) {
        a[i]++;
      }
    }
    count++;
    int m = max(a[0], max(a[1], a[2]));
    for (int i = 0; i < 3; i++) {
      count += (m - a[i]) / 2;
    }
  } else if (e > o) {
    for (int i = 0; i < 3; i++) {
      if (!(a[i] % 2)) {
        a[i]++;
      }
    }
    count++;
    int m = max(a[0], max(a[1], a[2]));
    for (int i = 0; i < 3; i++) {
      count += (m - a[i]) / 2;
    }
  }

  cout << count << '\n';
  return 0;
}


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

#define pb push_back
#define ppp pop_back
#define pii pair<int,int>
#define fi first
#define se second

const int N = 2e5 + 5;
const int p = 1e9 + 7;

int dp[N], pref[N];
vector<int> a = {0};

void add(int &a, int b) {
	a += b;
	if (a > p) a -= p;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n;
	cin >> n;
	for (int i=1; i<=n; i++) {
		int cur;
		cin >> cur;
		if (cur != a.back()) a.pb(cur);
	}
	n = a.size();
	n--;
	for (int i=0; i<N; i++) pref[i] = 0;
	dp[0] = 1;
	for (int i=1; i<=n; i++) {
		dp[i] = dp[i-1];
		add(dp[i], pref[a[i]]);
		add(pref[a[i]], dp[i-1]);
	}
	cout << dp[n];
    return 0;
}


Measured memory_bytes: 2676
import java.util.Scanner;

class Main {
    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();
        }

        print(a, n);
        sort(a, n);
        sc.close();
    }

    private static void print(int[] a, int n) {
        StringBuilder sb = new StringBuilder();

        for (int k = 0; k < n; k++) {
            sb.append(a[k]);
            if (k < n - 1)
                sb.append(" ");
        }

        System.out.println(sb);
    }

    private static void sort(int[] a, int n) {
        for (int i = 1; i < n; i++) {
            int v = a[i];
            int j = i - 1;
            while (j >= 0 && a[j] > v) {
                a[j + 1] = a[j];
                j--;
            }
            a[j + 1] = v;
            print(a, n);
        }
    }
}


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

int main(){
  int a, b, n;
  cin >> a >> b;
  n = b - a;
  int count = 0;
  for(int i = 0; i < n + 1; i++, a++){
    if(a % 10 == a / 10000 && (a / 10) % 10 == (a / 1000) % 10){
      count++;
    }
  }
  cout << count << endl;
}

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

vector<int> g[100000];
ll h[100000];

int main()
{
	int n,m;
	cin >> n >> m;
	for(int i = 0;i<n;i++)
	{
		cin >> h[i];
	}
	for(int i = 0;i<m;i++)
	{
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	int cnt = 0;
	for(int i =0;i<n;i++)
	{
		int now = h[i];
		bool ans = true;
		for(auto i:g[i])
		{
			if(h[i]>=now)ans=false;
		}
		if(ans)cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 9492
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double N = sc.nextDouble();
        double ans = 0;
        if(N%1000 == 0){
            ans = 0;
        }else{
            ans = (int)Math.ceil(N/1000)*1000-N;
        }
        
        System.out.println((int)ans);
    }
}


Measured memory_bytes: 37460
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>

using namespace std;

typedef vector< vector< pair<int, string> > > Graph;

class Node{
public:
    int pos; string str; int prev;
    Node(int pos, string str, int prev) : pos(pos), str(str), prev(prev) {}
    bool operator < (const Node &nd) const { return str > nd.str; }
};

int main(){
    int n, a, s, g;
	int prev[480][40];
	string str[480][40];
	while(cin >> n >> a >> s >> g, n){
		Graph graph(n);
		for(int i=0;i<a;i++){
			int x, y; string lab; cin >> x >> y >> lab;
			graph[x].push_back(make_pair(y,lab));
		}
		memset(prev, -1, sizeof(prev));
		for(int i=0;i<12*n;i++)
			for(int j=0;j<n;j++) str[i][j] = "";
		priority_queue<Node> qu; qu.push(Node(s, "", -2));
		while(!qu.empty()){
			Node nd = qu.top(); qu.pop();
			int pos = nd.pos, size = nd.str.size();
			if(prev[size][pos]!=-1) continue;
			prev[size][pos] = nd.prev;
			str[size][pos] = nd.str;
			for(int i=0;i<graph[pos].size();i++){
				int npos = graph[pos][i].first;
				if(size + graph[pos][i].second.size() >= 12*n) continue;
				string nstr = nd.str + graph[pos][i].second;
				if(str[nstr.size()][npos]==""||nstr<str[nstr.size()][npos]){
					str[nstr.size()][npos] = nstr;
					qu.push(Node(npos, nstr, size*n+pos));
				}
			}
		}
		int minpos = -1;
		string ans = "";
		for(int i=0;i<12*n;i++){
			if(str[i][g]=="") continue;
			if(ans == ""||ans > str[i][g]){
				ans = str[i][g];
				minpos = i;
			}
		}
		bool flag = (minpos != -1);
		bool visit[40];
		memset(visit, false, sizeof(visit));
		int cur = minpos*n+g;
		while(flag&&cur!=-2){
			if(visit[cur%n]) flag = false;
			visit[cur%n] = true;
			cur = prev[cur/n][cur%n];
		}
		cout << (flag ? ans : "NO") << endl;
	}
}

Measured memory_bytes: 10000
N = int(input())
a = list(map(int, input().split()))
set_a = set()
cnt = 0 

for i in range(N):
    if(a[i] < 3200):
        set_a.add(a[i]//400)
    else:
        cnt += 1

print(max(len(set_a), 1), min(len(set_a)+cnt, N))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll x,y;cin >> x >> y;
  if(x*y < 0) cout << abs(abs(x) - abs(y))+1 << endl;
  else{
    if(y-x>=0) cout << y-x << endl;
    else if(x==0) cout << abs(y)+1 << endl;
    else if(y==0) cout << abs(x)+1 << endl;
    else cout << abs(y-x)+2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 101
 
int main(){
  int G[MAX][MAX],A[MAX],key[MAX],p[MAX];
  int i,j,n,count=0,cost,u=0;
 
  scanf("%d",&n);
 
  for(i=0 ; i<n ; i++){
    for(j=0 ; j<n ; j++){
      scanf("%d",&G[i][j]);
    }
  }
 
  for(i=0 ; i<n ; i++){
    A[i] = 0;
    p[i] = -1;
 
    if(i==0)key[i] = 0;
    else key[i] = 2001;
     
  }
 
 
  while(cost != 2001){
    cost = 2001;
    for(i=0 ; i<n ; i++){
      if(A[i]!=2 && key[i]<cost){
        cost = key[i];
        u = i;
      }
    }
 
    A[u]=2;
    for(i=0 ; i<n ; i++){
      if(G[u][i] != -1 && A[i] != 2 && G[u][i]<key[i]){
        p[i] = u;
        key[i] = G[u][i];
        A[i] = 1;
      }
    }
  }
 
  for(i=0 ; i<n ; i++){
    if(p[i] != -1){
      count += G[i][p[i]];
    }
  }
 
  printf("%d\n",count);
 
  return 0;
}

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

int dp[101][100001];

int main() {
    int n,wmaks;
    cin >> n >> wmaks;
    int w[n+1],v[n+1];
 //   int dp[n+1][100001]; //dp[cnt][val]=weight
    
    for (int i=1;i<=n;i++){
        cin >> w[i] >> v[i];
    }
    
    for (int i=0;i<=100000;i++){
        dp[0][i]=1000000001;
        dp[1][i]=1000000001;
    }
    
    dp[0][0]=0;
    dp[1][0]=0;
    dp[1][v[1]]=w[1];
    
    for (int i=2;i<=n;i++){
        for (int j=0;j<=100000;j++)
            dp[i][j]=dp[i-1][j];
            
        for (int j=v[i];j<=100000;j++)
            dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i][j]);
        
    }
    
    int ans=0;
    for (int i=100000;i>=0;i--){
        if (dp[n][i]<=wmaks){
            ans=i;
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 39680
#include <stdio.h>

int n;

int main(void){
    while(scanf("%d", &n) && n){
        int count = 0;
        while(n != 1){
            ++count;
            if(n%2 == 0) n /= 2;
            else n = 3 * n + 1;
        }
        printf("%d\n", count);
    }
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include<stdio.h>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;
int main()
{

    int t,n,i,arra[1000];
    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
#include <bits/stdc++.h>
using namespace std;

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

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

ll f[3000010],finv[3000010];

ll comb(ll n,ll r){
  if(n<0||r<0||n<r)return 0;
  return (f[n]*finv[r]%mod)*finv[n-r]%mod;
}

ll A,B,C;
ll SX,SY;

int main(){
  f[0]=1;
  rep(i,3000001)f[i+1]=f[i]*(i+1)%mod;
  rep(i,3000001)finv[i]=mod_pow(f[i],mod-2);
  while(1){
    cin>>A>>B>>C>>SX>>SY;
    if(A+B+C==0)break;
    ll res=0;
    rep(i,SX+1){
      ll j=SY-SX+i;
      if(i<A||j<0)continue;
      ll b1=0;
      if(i>0) b1=comb(i-1,A-1);
      else b1=(A==0?1:0);
      ll b2=0;
      if(j>0) b2=comb(j-1,B-1);
      else b2=(B==0?1:0);
      ll k=(((finv[A]*finv[B])%mod)*finv[C]%mod)*f[A+B+C]%mod;
      ll p=(b1*b2%mod)*k%mod;
      ll b3=comb(SX-i+A+B+C-1,A+B+C-1);
      (res+=p*b3%mod)%=mod;
    }
    cout<<res<<endl;
  }
  return 0;
}



Measured memory_bytes: 49944
import std.stdio;
import core.stdc.stdio;
import std.algorithm;

void main(){
	int[] map = new int[100000];
	int[] t = new int[10000];
	while(1){
		int r,c;
		scanf("%d%d",&r,&c);
		if(r==0&&c==0)
			break;
		t[] = 0;
		for(int i=0;i<r;i++){
			for(int j=0;j<c;j++){
				scanf("%d",&map[i*c+j]);
				t[j] += 1-map[i*c+j];
			}
		}
		int ans=0;
		for(int i=0;i<(1<<r);i++){
			int a=0;
			for(int j=0;j<c;j++){
				int s = t[j];
				for(int k=0;k<r;k++){
					if(i&(1<<k)){
						if(map[k*c+j]==0)
							s--;
						else
							s++;
					}
				}
				a += max(s,r-s);
			}
			ans = max(a,ans);
		}
		printf("%d\n",ans);
	}
}

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

int main()
{
	long long int h,a;
	cin>>h>>a;
	if(h%a==0)
	{
		cout<<h/a;
	}
	else{
		cout<<(h/a + 1);
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
use std::collections::BTreeSet;

fn main() {
    let (n,q) = read_pair();
    let events: Vec<(i32,i32,i32)> = {
        let mut events = Vec::new();
        for _ in 0..n {
            let (s,t,x) = read_triple();
            events.push((s-x, 2, x));
            events.push((t-x, 1, x));
        }
        for _ in 0..q {
            let d = read();
            events.push((d, 3, 0));
        }
        events.sort();
        events
    };

    let mut closed = BTreeSet::new();
    for (t, k, x) in events {
        match k {
            2 => {closed.insert(x);},
            1 => {closed.remove(&x);},
            3 => match closed.iter().next() {
                None => println!("-1"),
                Some(x) => println!("{}", x)
            },
            _ => ()
        }
    }
}

fn get_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_owned()
}
fn read<T: std::str::FromStr>() -> T{
    get_line().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T>{
    get_line().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_pair<T: std::str::FromStr + Copy>() -> (T,T){
    let v:Vec<T> = read_vec(); (v[0], v[1])
}
fn read_triple<T: std::str::FromStr + Copy>() -> (T,T,T){
    let v:Vec<T> = read_vec(); (v[0], v[1], v[2])
}

Measured memory_bytes: 15988
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	
	long N,M; cin >> N >> M;

	vector<pair<long,long>> drink(N,make_pair(0,0));
	for (int i = 0; i < N; i++) {
		long a,b; cin >> a >> b;
		drink[i] = make_pair(a,b);
	}
	sort(drink.begin(),drink.end());

	long ans = 0;	
	for (int i = 0; i < N; i++) {
		if (drink[i].second <= M) {
			ans += drink[i].first * drink[i].second;	
			M -= drink[i].second;
		}else {
			ans += drink[i].first * M;		
			M -= M;
		}
		if (M == 0) {
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B; cin >> A >> B;
    if (abs(A - B) > 1) {
        cout << max(A, B) * 2- 1 << endl;
    } else {
        cout << A + B << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// C - Same Integers

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int X[3];
	cin >> X[0] >> X[1] >> X[2];

	int ans = 0;

	while(1) {
		sort(X, X+3);

		if (X[0] == X[1] && X[1] == X[2]) break;

		if (X[0] == X[1]) {
			X[0]++;
			X[1]++;
		} else if (X[1] - X[0] == 1) {
			X[0]++;
			X[2]++;
		} else {
			X[0] += 2;
		}

		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define repeat(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, T;
    cin >> N >> T;
    int t[N];
    rep(i, N) cin >> t[i];
    ll int r = 0;
    rep(i, N - 1){
        if(t[i + 1] - t[i] > T) r += T;
        else r += t[i + 1] - t[i];
    }
    cout << r + T<< endl;

}

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

using namespace std;
int main(){
    int A,B;
    cin >> A;

    for (int i = 1; i < 10; i++)
    {
        for (int k = 1; k < 10; k++)
        {
            if (i*k==A)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
            
        }
        
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
students = [int(i) for i in input().split()]

shusseki_dict = {}
for i in range(N):
    key = str(i+1)
    shusseki_dict.setdefault(key, '')
    shusseki_dict[key] = students[i]

sorted_shusseki = sorted(shusseki_dict.items(), key=lambda x:x[1])

sorted_students = [i[0] for i in sorted_shusseki]

print(' '.join(sorted_students))

Measured memory_bytes: 28316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct hi{
	ll a;int b;
} cnt[200005];
int id[200005],id2[200005],p[200005]
,n,k,l,i,j,m;

int find(int x){
	while (x!=id[x]){
		id[x]=id[id[x]];
		x=id[x];
	}
	return x;
}

int find2(int x){
	while (x!=id2[x]){
		id2[x]=id2[id2[x]];
		x=id2[x];
	}
	return x;
}

void connect(int x,int y){
	x=find(x);y=find(y);
	if (x!=y) id[x]=y;
}

void connect2(int x,int y){
	x=find2(x);y=find2(y);
	if (x!=y) id2[x]=y;
}

bool cmp(hi a,hi b){
	return a.a<b.a;
}

int main(){
	scanf("%d%d%d",&n,&k,&l);
	for (i=1;i<=n;i++){
		id[i]=i;id2[i]=i;
	}
	for (i=1;i<=k;i++){
		scanf("%d%d",&j,&m);
		connect(j,m);
	}
	for (i=1;i<=l;i++){
		scanf("%d%d",&j,&m);
		connect2(j,m);
	}
	for (i=1;i<=n;i++){
		id[i]=find(id[i]);id2[i]=find2(id2[i]);
		cnt[i].a=ll(id[i])*200001+ll(id2[i]);cnt[i].b=i;
	}
	sort(cnt+1,cnt+n+1,cmp);
	j=0;k=0;
	for (i=1;i<=n;i++){
		if (cnt[i].a!=cnt[i-1].a) j++;
		p[j]++;
		id[cnt[i].b]=j;
	}
	for (i=1;i<n;i++) printf("%d ",p[id[i]]);
	printf("%d\n",p[id[n]]);
}

Measured memory_bytes: 9076
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>; using vvi = vector<vector<int>>;
using vl = vector<ll>; using vvl = vector<vector<ll>>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
//#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n;
  cin >> n;
  int ans;
  cin >> ans;
  REP(i,n-1){
    int t;
    cin >> t;
    ans = __gcd(ans,t);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
	double d,g,x,y,n,t;

	while(1){
		d=0;
		scanf("%lf",&n);
			if(n==-1){
				return 0;
			}
			n--;

		for(t=1;t<=n;t++){
			g=asin(1/sqrt(t+1));
			d+=g;
		}

		x=sqrt(n+1)*cos(d);
		y=sqrt(n+1)*sin(d);

		printf("%f\n%f\n",x,y);
	}


}

Measured memory_bytes: 692
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Nikkei_A solver = new Nikkei_A();
        solver.solve(1, in, out);
        out.close();
    }

    static class Nikkei_A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();

            out.print(Math.min(a, b) + " " + Math.max(0, (a + b - n)));
        }

    }
}



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

int main() {
    int n, m;
    cin >> n >> m;
    int s[n], t[m];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    long table[n + 1][m + 1];
    table[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        table[i][0] = 1;
    }
    for (int j = 1; j <= m; j++) {
        table[0][j] = 1;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            table[i][j] = (table[i - 1][j] + table[i][j - 1]) % BASE;
            if (s[i - 1] != t[j - 1]) {
                table[i][j] = (BASE + table[i][j] - table[i - 1][j - 1]) % BASE;
            }
        }
    }
    /*
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cout << table[i][j] << ((j == m) ? '\n' : ' ');
        }
    }
    */
    cout << table[n][m] << endl;
    return 0;
}


Measured memory_bytes: 31488
N, Y = map(int, input().split())

# 拘束条件を用い、探索をO(N^3)からO(N^2)へ！
a, b, c = -1, -1, -1
flag = False
for i in range(0, N+1):
  for j in range(0, N+1-i):
    k = N - i - j
    if 10000*i + 5000*j + 1000*k == Y:
      a, b, c = i, j, k
      break
  if flag: break
  
print(a, b, c)



Measured memory_bytes: 9160
using System;

namespace ABC104A
{
    class ABC104A
    {
        static void Main(string[] args)
        {
            int R = int.Parse(Console.ReadLine());

            string s;
            if (R < 1200)
            {
                s = "ABC";
            } else if (R <2800)
            {
                s = "ARC";
            } else
            {
                s = "AGC";
            }
            

            Console.WriteLine(s);
        }
    }
}


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

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

    string res;
    if(R >= 2800) res = "AGC";
    else if(R >= 1200) res = "ARC";
    else res = "ABC";

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void);
void printList(void);
void deleteNode(Node *);
void deleteFirst(void);
void deleteLast(void);
void deleteKey(int);
void insert(int);


int main(void) {
  int key, n, i;
  int size = 0;
  int np = 0, nd = 0;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') {
      insert(key);
      np++;
      size++;
    } else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L')
          deleteLast();
      } else {
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}



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

using namespace std;

int main(){
  int N;cin>>N;
  vector<string>  s_v(N);
  for (int i = 0; i < N; i++) {
    cin>>s_v[i];
  }

  sort(s_v.begin(),s_v.end());
  vector<string>  ans_s;
  int s_max=0;
  for (int i = 0; i < N;){
    int count=0;
    string str=s_v[i];
    while(str==s_v[i]){
      count++;
      i++;
      if(i==N){
        break;
      }
    }
    if(count>s_max){
      s_max=count;
      ans_s ={str};
      continue;
    }
    if(count==s_max){
      ans_s.push_back(str);
    }
  }
  for (int i = 0; i < ans_s.size(); i++)
  {
    cout<< ans_s[i]  << "\n";
  }

}

Measured memory_bytes: 15988
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    void run(){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();

            if(n == 0) break;

//            TreeSet<Integer> member[] = new TreeSet<Integer>[];
            int member[][] = new int[n+1][];
            for(int i=1; i<=n; i++){
                int m = sc.nextInt();
                member[i] = new int[m];
                for(int j=0; j<m; j++){
                    int p = sc.nextInt();
                    member[i][j] = p;
                }
            }

            int k = sc.nextInt();
            TreeSet<Integer> outflow = new TreeSet<Integer>();
            for(int i=0; i<k; i++){
                int l = sc.nextInt();
                outflow.add(l);
            }

            int culprit = -1;
            for(int i=1; i<=n; i++){
                TreeSet<Integer> tmp = new TreeSet<Integer>();
                for(int j=0; j<member[i].length; j++){
                    tmp.add(member[i][j]);
                }
                if(tmp.containsAll(outflow)){
                    if(culprit == -1){
                        culprit = i;
                    }
                    else{
                        culprit = -1;
                        break;
                    }
                }
            }
            System.out.println(culprit);
        }
    }
    public static void main(String[] args) {
        //new AOJ2399().run();
        new Main().run();
    }
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  set<ll> s;
  ll now = n;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      s.insert(i);
      s.insert(n / i);
    }
  }
  s.erase(1);
  
  ll ans = 0;
  for (auto i : s) {
    i--;
    if (n / i == n % i) ans += i;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
using namespace std;

#define MAX 256

int f(int x, int y){
	if (y != 0){
		f(y, x%y);
	}
	else{
		return x;
	}
}

int main(void){

	int a, b;
	scanf("%d%d", &a, &b);
	if (a < b){
		int c = a;
		a = b;
		b = c;
	}

	printf("%d\n", f(a, b));

	return 0;
}

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

int main(){
  int i,j;
  int N,M;
  char U[260][12];
  char T[260][12];
  int flag1=0,flag2=0;
  
  scanf("%d",&N);
  
  for(i=0;i<N;i++) scanf("%s",U[i]);
  
  scanf("%d",&M);
  
  for(j=0;j<M;j++){
    scanf("%s",T[j]);
    for(i=0;i<N;i++){
      if(strcmp(U[i],T[j])==0){
	flag1=1;
      }
    }
    if(flag1==1){
      if(flag2==1){
	printf("Closed by %s\n",T[j]);
	flag2=0;
      }else if(flag2==0){
	printf("Opened by %s\n",T[j]);
	flag2=1;
      }
    }else if(flag1==0){
      printf("Unknown %s\n",T[j]);
    }
    flag1=0;
  }

  return 0;
}

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

using namespace std;

typedef long long int ll;

void solve()
{
	int r;
	cin >> r;
	cout << fixed << setprecision(3) << 2*3.141592*r;
}

int main()
{
	int t = 1;
	//cin >> t;
	for(int i = 0; i < t; i++)
	{
		//cout << "Case #" << i + 1 << ": ";
		solve();
	}
	return 0;
}



Measured memory_bytes: 3788
n = int(input())
L = 'MARCH'
S = []
for i in range(n):
    s = input()
    if s[0] in L:
        S.append(s[0]) #頭文字を入れ込む

import collections
c = collections.Counter(S)#それぞれの出現回数を辞書型で返してくれる
 
ans = 0
import itertools
for i,j,k in itertools.combinations(c.values(), 3):#辞書型の値をリスト化して，それを三つ取るcombinaeion
    ans += i*j*k
print(ans)

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

int main()
{
	std::string n;
	std::cin >> n;
	for (int i = 0; i < 3; i++)
	{
		if (n[i] == '7')
		{
			std::cout << "Yes\n";
			return (0);
		}
	}
	std::cout << "No\n";
	return (0);
}

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

int main(){
    int gyou, retsu;
    int array1[100][100], array2[100][1], array3[100][1] = {{}};
    
    cin >> gyou >> retsu;
    for(int i = 0; i < gyou; i++){
        for(int j = 0; j < retsu; j++){
            cin >> array1[i][j];
        }
    }
    
    for(int i = 0; i < retsu; i++){
    cin >> array2[i][0];
  }
    
     for(int i = 0; i < gyou; i++){
        for(int j = 0; j < retsu; j++){
               array3[i][0] += array1[i][j] * array2[j][0];
            }
             cout << array3[i][0] << endl;
        }
    return 0;
}


Measured memory_bytes: 3136
n=int(input())
a=str(input())
b=str(input())
c=str(input())
ans=0
for i in range(n):
  if(a[i]==b[i] and b[i]==c[i]):
    continue
  elif(a[i]==b[i] or b[i]==c[i] or c[i]==a[i]):
    ans+=1
  else:
    ans+=2
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;


int main(){
    int N, K; cin >> N >> K;
    double P=0;
    for(int i = 1; i <= N; i++){
        //何回降ればいいか
        if(i < K){
            double t = (double)K/(double)i;
            double tmp = log2(t);
            int temp = ceil(tmp);
            //cout << t << " " << tmp << " " << temp << endl;
            double p = pow(0.5, temp) / N;
            P += p;
        }
        else {
            double p = 1.0/N;
            P += p;
        }

    }
    cout << setprecision(10) << P << endl;
    
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 * 100 + 47;

vector<PII> g[MAX];
int S[MAX];
LL res = 0;
int n;

void dfsSZ(int v, int p)
{
	//cout << v << ": " << p << endl;
	S[v] = 1;
	FOR(i, 0, SZ(g[v]))
	{
		int to = g[v][i].first;
		int w = g[v][i].second;

		if (to == p) continue;
		dfsSZ(to, v);
		res += 2 * min(S[to], n - S[to]) * (LL)w;
		S[v] += S[to];
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	FOR(i, 0, n - 1)
	{
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		g[a].push_back(MP(b, c));
		g[b].push_back(MP(a, c));
	}

	dfsSZ(0, -1);
	//cout << "res=" << res << endl;
	int v = 0;
	int p = -1;

	while (1)
	{
		int w = -1;
		FOR(i, 0, SZ(g[v]))
		{
			int to = g[v][i].first;

			if (S[to] * 2 > n && to != p)
			{
				w = to;
				break;
			}
		}

		if (w == -1) break;
		p = v;
		v = w;
	}

	//cout << v + 1 << endl;
	FOR(i, 0, SZ(g[v]))
	{
		int to = g[v][i].first;
		int w = g[v][i].second;
		if (S[to] * 2 == n)
		{
			cout << res - w << endl;
			return 0;
		}
	}

	LL ans = -LINF;
	FOR(i, 0, SZ(g[v]))
	{
		int w = g[v][i].second;
		ans = max(ans, res - w);
	}

	cout << ans << endl;
}


Measured memory_bytes: 11520
#include<iostream>
#include<vector>

int main(){
	int n, l, left;
	std::vector<int> v;

	std::cin >> n >> l;

	for (int i = 0; i < n; i++)
	{
		int num;

		std::cin >> num;

		v.push_back(num);
	}

	bool isPossible = false;
	for (int i = 1; i < n; i++)
	{
		if (v[i - 1] + v[i] >= l){
			left = i - 1;
			isPossible = true;
		}
	}

	if (!isPossible)
	{
		std::cout << "Impossible" << std::endl;
		return 0;
	}

	std::cout << "Possible" << std::endl;

	// v[left], v[left + 1]のロープを残すようにして他をほどく
	for (int i = 0; i < left; i++)
	{
		std::cout << i + 1 << std::endl;
	}

	for (int i = n - 1; i > left + 1; i--)
	{
		std::cout << i << std::endl;
	}

	std::cout << left + 1 << std::endl;
	return 0;

}

Measured memory_bytes: 1272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>


using namespace std;

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

	bool ans = true;
	int cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		if (cnt % 2 == 0) {
			if (S.at(i) != 'h') {
				ans = false;
				break;
			}
		}
		else {
			if (S.at(i) != 'i') {
				ans = false;
				break;
			}
		}
		cnt++;
	}

	if (cnt % 2 != 0) ans = false;

	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
        int A1,A2,A3;
        A1=A2=A3=0;
        scanf("%d%d%d",&A1,&A2,&A3);
        if((A1+A2+A3)>=22)
          printf("bust\n");
         else
            printf("win\n");
  
  
 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define PQ priority_queue
#define pb push_back
#define fu(i,a,j) for(int i=a;i<j;i++)
#define fd(i,a,j) for(int i=a;i>=j;i--)
#define SYNC ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define MOD 1000000007 
#define MOD2 1000000021
#define MAXN 2000000
#define INF 1e9
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;

//ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll m_pow(ll a, ll b, ll M = MOD) { ll res = 1; for (; b; b >>= 1, a = (a * a) % M)if (b & 1)res = (res * a) % M; return res; }
ll gcd(ll a, ll b) { if (a < b) swap(a, b); for (; b; a %= b, swap(a, b)); return a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };
db dis(pii a, pii b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); }
int dr[] = { 0, 1, 0, -1, 1,1,-1,-1 };
int dc[] = { 1, 0, -1, 0, 1,-1,1,-1 };

int n, m, k, t;

string ansok[2] = { "NO","YES" };
ll a[200001];
int cnt[101];
int main()
{
	SYNC;
	string s;
	cin >> s;
	bool ok = 1;
	string ansok[2] = { "No","Yes" };
	ll sum = 0;
	for (int i = 0; i < s.size(); i++) {
		sum += s[i] - '0';
	}
	if (sum % 9 != 0)
		ok = 0;
	cout << ansok[ok];
	return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define mod (1e9 + 7)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()

typedef long long ll;

void solve1()
{
    int n, k; cin >> n >> k;

    ll ans;
    rep(i,n) {
        if(i == 0) {
            ans = k;
        } else {
            ans *= k - 1;
        }
    }

    cout << ans << endl;
}


int main()
{
    solve1();
}

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

#define int             long long int
#define ff              first
#define ss              second
#define pb              push_back

#define vi              vector <int>
#define pii             pair <int, int>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))

#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl



template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}


void solve()
{
	int n;
	cin >> n;
	int x = n % 10;
	string ans;
	if (x == 2 or x == 4 or x == 5 or x == 7 or x == 9) ans = "hon";
	if (x == 3) ans = "bon";
	if (x == 0 or x == 1 or x == 6 or x == 8) ans = "pon";
	cout << ans << endl;
	return;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


	int t = 1;
	//cin >> t;
	while (t--) solve();

	return 0;
}

Measured memory_bytes: 3656
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
    int n = s.Length;
		long[,] dp = new long[n+1,2];
    dp[1,0] = 1;

    for(int i = 2; i <= n; i++)
    {
      if(s[i-1] != s[i-2]) dp[i,0] = dp[i-1,0]+1;
      dp[i,0] = Math.Max(dp[i,0], dp[i-1,1]+1);

      dp[i,1] = dp[i-2,0]+1;

      //Console.WriteLine(i+" "+dp[i,0]+" "+dp[i,1]);
    }

		Console.WriteLine(Math.Max(dp[n,0], dp[n,1]));
	}
}

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

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

// chmax, chmin
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;
}

const string YES = "Yes";
const string NO = "No";

void solve(std::string S) {
    if( S.size() == count(S.begin(), S.end(), S[0])){
        cout << NO<< endl;
    }else{
        cout << YES << endl;
    }

}

int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


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

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

int ans = 1;
  for (int i = 1; i < s.size(); i++)
  {
    if (s[i-1] != s[i]) {
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        int[] b = new int[n];
        int[] c = new int[n];
        b[0] = a[0];
        c[n-1] = a[n-1];
        for(int i=0; i<n-1; i++){
            b[i+1] = gcd(b[i], a[i+1]);
            c[n-2-i] = gcd(c[n-1-i], a[n-2-i]);
        }
        
        int max = Math.max(c[1], b[n-2]);
        for(int i=0; i<n-2; i++){
            int tmp = gcd(b[i], c[i+2]);
            max = Math.max(tmp, max);
        }
        
        System.out.println(max);
        
    }
    
    public static int gcd(int a,int b){
        return b>0?gcd(b,a%b):a;
    }
}


Measured memory_bytes: 48052
// abc096_a
#include <iostream>
using namespace std;

int main(void) {
	int a, b;
	cin >> a >> b;
	int count = 0;
	//for (int i = 1; i <= a; i++) {
	//	for (int j = 1; j <= b; j++) {
	//		if (i == j) {
	//			count++;
	//		}
	//	}
	//}
	if (a <= b) {
		cout << a << endl;
	}
	else {
		cout << a - 1 << endl;
	}
	//cout << count << endl;
	return 0;


}

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

int main() {
  string s;
  cin >> s;
  
  if(s.at(0) == s.at(1) || s.at(1) == s.at(2) || s.at(0) == s.at(2)){
    cout << "No" << endl;
  }
  
  else{
    cout << "Yes" << endl;
  }
}


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

int main(){
  int n, m, k;
  cin >> n >> m >> k;

  if(k % n == 0 || k % m == 0){
    cout << "Yes" << endl;
    return 0;
  }
  
  for(int i = 1; i < n; i++){
    for(int j = 1; j < m; j++){
      int num = i * j + (n - i) * (m - j);
      if(num == k){
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
  cout << "No" << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {
  ll N, M; cin >> N >> M;
  vi p(M), q(M), c(M);
  for (ll i = 0; i < M; i++) {
    cin >> p[i] >> q[i] >> c[i];
    p[i] -= 1; q[i] -= 1;
  }
  unordered_set<ll> v;
  vvi E;
  auto f = [](ll a, ll b) { return 1000000 * b + a; };
  for (ll i = 0; i < N; i++) {
    v.insert(f(i, -1));
  }
  for (ll i = 0; i < M; i++) {
    v.insert(f(p[i], c[i]));
    v.insert(f(q[i], c[i]));
    v.insert(f(p[i], -1));
    v.insert(f(q[i], -1));
    E.push_back({f(p[i], c[i]), f(q[i], c[i]), 0});
    E.push_back({f(q[i], c[i]), f(p[i], c[i]), 0});
    E.push_back({f(p[i], -1), f(q[i], c[i]), 1});
    E.push_back({f(q[i], c[i]), f(p[i], -1), 0});
    E.push_back({f(q[i], -1), f(p[i], c[i]), 1});
    E.push_back({f(p[i], c[i]), f(q[i], -1), 0});
  }
  ll V = v.size();
  unordered_map<ll, ll> mapping;
  {
    ll idx = 0;
    for (auto i: v) {
      mapping[i] = idx++;
    }
  }
  vector<vpii> G(V);
  for (vi &e: E) {
    ll fr = mapping[e[0]];
    ll to = mapping[e[1]];
    ll cost = e[2];
    G[fr].push_back({to, cost});
  }
  vi dist(V, (1ll << 30));
  dist[mapping[f(0, -1)]] = 0;
  priority_queue<pii, vpii, greater<pii>> pq;
  pq.push({0, mapping[f(0, -1)]});
  while (pq.size()) {
    ll fr; tie(ignore, fr) = pq.top(); pq.pop();
    for (pii e: G[fr]) {
      if (dist[e.first] > dist[fr] + e.second) {
        dist[e.first] = dist[fr] + e.second;
        pq.push({dist[e.first], e.first});
      }
    }
  }
  if (dist[mapping[f(N - 1, - 1)]] == (1ll << 30)) cout << -1 << endl;
  else cout << dist[mapping[f(N - 1, - 1)]] << endl;
}

Measured memory_bytes: 160220
def bubbleSort(a, n):
    flag = True
    c = 0
    while flag:
        flag = False
        for j in reversed(range(1, n)):
            if a[j] < a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]
                c += 1
                flag = True

    return a, c

if __name__ == "__main__":
    n = int(input())
    a_l = [int(a) for a in input().split()]

    as_l, c  = bubbleSort(a_l, n)
    print(' '.join(map(str, as_l)))
    print(c)

Measured memory_bytes: 7768