akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

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

	//string s; cin >> s;
	ll h1, m1, h2,m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;

	int ans = (h2-h1)*60 + m2 - m1 - k;

	cout << ans << endl;
}


Measured memory_bytes: 3640
using System;

namespace _111_A
{
    class Program
    {
        static void Main(string[] args)
        {
           int N = int.Parse(Console.ReadLine());
            int answer = 0;
            while (N > 0)
            {
                N -= 111;
                answer += 111;
            }
            Console.WriteLine(answer);
       

          
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int>A(N);
  rep(i,N){
    cin >> A[i];
  }
  rep(i,N){
    if(A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0){
      cout << "DENIED";
      return 0;
    }
  }
  cout << "APPROVED";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    public static void main(String args[]){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            String order;
            while((order=br.readLine())!=null){
                String[] splited = order.split(" ");
                int a4[] = new int[4];
                for(int i=0;i<4;i++)a4[i]=Integer.parseInt(splited[i]);
                splited = br.readLine().split(" ");
                int b4[] = new int[4];
                for(int i=0;i<4;i++)b4[i]=Integer.parseInt(splited[i]);
                int hit=0,blow=0;
                for(int i=0; i<4;i++){
                    int a = a4[i];
                    for(int j=0;j<4;j++){
                        if(a==b4[j]) {if(i==j) hit++; else blow++; break;}
                    }
                }
                System.out.println(hit+" "+blow);

            }
            
        }catch(Exception e){e.printStackTrace();}
    }
}

Measured memory_bytes: 16916
while 1:
    try:
        s = input()
    except:
        break
    sz = len(s)
    joi,ioi = 0,0
    for i in range(sz - 2):
        t = s[i : i + 3]
        if t == "JOI":
            joi += 1
        elif t == "IOI":
            ioi += 1
    print(joi)
    print(ioi)


Measured memory_bytes: 5568
#include <bits/stdc++.h>
typedef unsigned long long lli;
using namespace std;

int main()
{
    lli n, a=0;
    string s, t;
    cin >> s >> t;
    for(lli i=0; i<s.length(); i++)
    {
      if(s[i]!=t[i]) a++;
    }
    cout << a << endl;
    return 0;
}


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

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 0 ; i < a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1
#define M 1000000007

long long binpow(long long a, long long b) {
	long long res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % M;
		a = (a * a) % M;
		b >>= 1;
	}
	return res;
}

void solve()
{
	int k;
	cin >> k;

	string s;
	cin >> s;

	if (s.size() <= k )
	{
		cout << s << "\n";
		return;
	}

	for (int i = 0 ; i < k ; i++)
		cout << s[i];
	cout << "...";
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

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

	return 0;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
main(){
    int m,d;cin>>m>>d;
    int ans=0;
    for(int i=1;i<=m;i++){
        for(int j=10;j<=d;j++){
            if(j%10>=2&&j/10>=2)
                ans+=(i==((j%10)*(j/10)));
           // cout<<i<<" "<<j%10<<" "<<j/10<<endl;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;
/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

ll h, w, k;
ll const MAX = 808;
ll grid[MAX][MAX];
ll dist[MAX][MAX];
struct point {
	ll x; ll y;
};

ll f(point p) {
	ll x = p.x, y = p.y;
	ll x1, x2, y1, y2;
	x1 = (x - 1) / k + (0 < (x - 1) % k);
	x2 = (h - x) / k + (0 < (h - x) % k);
	y1 = (y - 1) / k + (0 < (y - 1) % k);
	y2 = (w - y) / k + (0 < (w - y) % k);
	ll ans = min({ x1,x2,y1,y2 });
	return ans;
}

int main() {
	cin >> h >> w >> k;
	REP(i, 0, MAX - 1) {
		REP(j, 0, MAX - 1) {
			dist[i][j] = -1;
		}
	}
	point start;
	REP(i, 0, h+1) {
		REP(j, 0, w+1) {
			if (i == 0 || i == h + 1 || j == 0 || j == w + 1) {
				grid[i][j] = 1;
			}
			else {
				char c;
				cin >> c;
				if (c == '.') {
					grid[i][j] = 0;
				}
				else if (c == '#') {
					grid[i][j] = 1;
				}
				else {
					grid[i][j] = 0;
					start = { i,j };
					dist[i][j] = 0;
				}
			}
		}
	}
	ll dx[4] = { 1,0,-1,0 };
	ll dy[4] = { 0,1,0,-1 };
	queue<point> qu;
	qu.push(start);
	ll ans = f(start);
	while (!qu.empty()) {
		point cur = qu.front();
		ll cur_dist = dist[cur.x][cur.y];
		qu.pop();
		REP(dir, 0, 3) {
			point next = { cur.x + dx[dir], cur.y + dy[dir] };
			if (grid[next.x][next.y] == 0 && dist[next.x][next.y] == -1 && cur_dist <= k-1) {
				dist[next.x][next.y] = cur_dist + 1;
				qu.push(next);
				ans = min(ans, f(next));
			}
		}
	}
	cout << ans+1 << endl;

}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define mod 1000000007
#define ll unsigned long long
using namespace std;
int pa[200005],ra[200005],n,m,ma=0,x,y;
void initialise(){
    for(int i=0;i<n;i++)
    pa[i]=i,ra[i]=0;
}
int find(int x){
    if(x==pa[x])
    return x;
    pa[x]=find(pa[x]);
    return pa[x];
}
void unio(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)return;
    if(ra[a]<ra[b])pa[a]=b;
    else if(ra[a]>ra[b])pa[b]=a;
    else{
        pa[b]=a;
        ra[a]++;
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    initialise();
    while(m--){
        cin>>x>>y;
        x--;y--;
        unio(x,y);
    }
    unordered_map<int,int> m;
    for(int i=0;i<n;i++){
        m[find(i)]++;
    }
    for(auto i:m){
        ma=max(ma,i.second);
    }
    cout<<ma;
    
}

Measured memory_bytes: 12920
#include <bits/stdc++.h>
using namespace std;
int n,x,y,a[10005][10005],b[10000005];
int main()
{
	int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
            a[i][j]=min(j-i,abs(x-i)+1+abs(y-j));
	}
    for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
			b[a[i][j]]++;
	}
    for(int i=1;i<n;i++)
		cout<<b[i]<<endl;

	return 0;
}

Measured memory_bytes: 80128
#include <stdio.h>

void swap(int* a,int* b)
{
    int tmp=*b; *b=*a; *a=tmp;
}

#define MAX_W 30

int main(void)
{
    FILE *fpin;
//#define DEBUG
#ifdef DEBUG
    fpin=fopen("input.txt","r");
#else
    fpin=stdin;
#endif
    int w,n;
    fscanf(fpin,"%d\n",&w); // num of vertical lines
    fscanf(fpin,"%d\n",&n); // num of horizontal lines
    // init data
    // warning: a[0]=1,a[1]=2...
    int i;
    int data[MAX_W];
    for(i=0;i<w;i++){ data[i]=i+1; }
    // for all horizontal lines
    for(i=0;i<n;i++){
        int a,b;
        fscanf(fpin,"%d,%d\n",&a,&b);        
        swap(data+a-1,data+b-1); // note that a,b start from '1' (not zero!!)        
    }
    // result
    for(i=0;i<w;i++){ printf("%d\n",data[i]); }            
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
    string s;   cin>>s;
    if(s[0]!=s[1]&&s[0]!=s[2]&&s[1]!=s[2])  cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;
}

Measured memory_bytes: 256
/* Simplicity and Goodness */

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

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n;
    scn(n);

    string s;
    cin >> s;

    int opened = 0;
    int open_needed = 0;

    rep(i, 0, n) {
        if(s[i] == ')') {
            if(opened == 0)
                open_needed ++;
            else
                opened --;
        } else {
            opened ++;
        }
    }

    int close_needed = opened;

    s = string(open_needed, '(') + s + string(close_needed, ')');

    cout << s << '\n';
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3680
/*
Author: Rishabh Agarwal
Nationality: Indian
*/
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define MOD 1000000007
#define vpi vector<pair<int, int>>
#define ll long long int
#define inf 1000000000
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Cases int testCases; cin>>testCases; while(testCases--) 
#define MOD 1000000007
#define pb push_back
//---------------------------------------------------
int main() {
    FIO
    ll N, M; cin>>N>>M;
    ll array[M];
    for(int i=0; i<M; ++i) cin>>array[i];
    ll sum = 0;
    for(int i=0; i<M; ++i) sum+= array[i];
    N = N - sum;
    if(N<0) cout<<"-1"<<endl;
    else cout<<N<<endl;
}



Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
 
int N,S;
int dfs(int n,int t,int sum){
    if(n>10)return 0;
    if(t==N){
          if(sum==S)return 1;
          else return 0;
    }
    return dfs(n+1,t,sum)+dfs(n+1,t+1,sum+n);
}
int main(){
    while(cin>>N>>S,N||S)cout<<dfs(0,0,0)<<endl;
    return 0;
}

Measured memory_bytes: 3068
import java.io.*;
import java.math.BigDecimal;
import java.util.Objects;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    int n = Integer.parseInt(br.readLine());
    int[] an = new int[n];
    String[] data = br.readLine().split(" ");
    
    for (int i=0; i<n; i++){
      an[i] = Integer.parseInt(data[i]);
    }
    BigDecimal temp = new BigDecimal(0);
    BigDecimal sum = new BigDecimal(0);
    for (int i=0; i<n; i++){
      sum = sum.add(new BigDecimal(an[i]));
    }
    BigDecimal min = null;
    BigDecimal temp2;
    for (int i=0; i<n-1; i++){
      temp = temp.add(new BigDecimal(an[i]));
      temp2 = sum.subtract(temp.multiply(new BigDecimal(2))).abs();
      if (min == null){
        min = temp2;
      }
      if (min.compareTo(temp2)>0){
        min = temp2;
      }
    }
    System.out.println(Objects.requireNonNull(min).toPlainString());
  }
}


Measured memory_bytes: 64944
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll sum(ll n) {
	ll res = 0;
	while (n > 0) {
		res += n % 10;
		n  /= 10;
	}
	return res;
}

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

	int N;
	cin >> N;
	ll ans = inf;
	for (int a = 1; a < N; a++)ans = min(ans, sum(a) + sum(N-a));
	puts(ans);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
 
int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)    cin >> a[i];

    sort(all(a));
    reverse(all(a));

    ll ans = 0;
    for(int i = 1;i<n;i++) {
        ans += a[i/2];
    }

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

Measured memory_bytes: 4040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,k,i,j,a,B[41] = {},c = (1LL<<40);scanf("%lld%lld",&n,&k);bool flag = 0;
  for(i=0;i<n;i++){
    scanf("%lld",&a);
    for(j=0;a;j++,a/=2) B[j] += a%2;
  }
  ll dp[42][2] = {};
  for(i=40;i>=0;i--){
    dp[i][0] = dp[i+1][0]+((k&c) ? n-B[i]:B[i])*c;
    if(k&c){
      if(B[i]>n-B[i]) flag = 1;
      dp[i][1] = max(dp[i+1][0]+B[i]*c,dp[i+1][1]+max(B[i],n-B[i])*c);
    }
    else if(flag) dp[i][1] = dp[i+1][1]+max(B[i],n-B[i])*c;
    c >>= 1;
  }
  printf("%lld\n",max(dp[0][0],dp[0][1]));
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <cstdio>
using namespace std;
typedef long long ll;

int gcd(int a,int b){
    int t;
    while(b>0){
        t=b;
        b=a%b;
        a=t;
    }
    return a;
}

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

int main(){
    ll a,b,c,d,e,k,l,m,n,o=1,o1=9,o2=10,p,q,x,y,z,max1=0,ans=0,n1;
    string s,t,u;
    cin>>n;
    ll h[n];
    for(ll i=0;i<n;i++){
        cin>>h[i];
        
    }
    for(ll i=0;i<n-1;i++){
        if(h[i]>h[i+1]){
            cout<<"No"<<endl;
            return 0;
        }
        if(h[i]<h[i+1]){
            h[i+1]--;   
        }
    }
    cout<<"Yes"<<endl;
}





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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> 
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
const int dr[]={0,1,0,-1,0};

int main(){
	int a,b,k;
	cin >>a >>b >>k;
	
	rep(i, k){
		if(i%2==0){
			if(a%2==1) a--;
			b += a/2; a /=2;
		}else{
			if(b%2==1) b--;
			a += b/2; b /=2;
		}
		//dbg(i,a,b);
	
	}
	cout << a <<" "<<b  <<"\n";
}



Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        S : String,
    );

//    let S: String = "a".to_string();
    let s = S.chars().collect::<Vec<_>>();
    let bit = 1 << s.len() - 1;
    let mut ans = 0;
    // pattern inserting plus
    for i in 0..bit {
        let mut temp: i64 = 0;
        // calc
        for j in 0..s.len() {
            let sj = s[j] as i64 - 48;

            if i >> j & 1 == 1 {
//                print!("{}+", sj);
                temp = temp*10+sj;
                ans += temp;
                temp = 0;
            } else {
//                print!("{}", sj);
                temp = temp * 10 + sj;
            }
        }
        ans += temp;
//        print!(" {}",ans);
//        println!();
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    int[][] a = new int[][](n, n);
    for (int i = 0; i < n; i++) {
        auto l = readln.chomp.split.map!(to!int);
        if (l[1] != 0) {
            foreach (e; l[2..l.length]) {
                a[l[0] - 1][e - 1] = 1;
            }
        }
    }

    foreach (r; a) {
        r.map!(to!string).join(" ").writeln;
    }
}

Measured memory_bytes: 2024
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
bool sortbysecdesc(const pair<string,ll> &a,const pair<string,ll> &b)
{
       return a.second>b.second;
}
int main() {
	int n;cin>>n;
	int arr[n];
	loop(n,i,0){
		int x;cin>>x;
		arr[x-1]=i+1;
	}
	for(auto x:arr)cout<<x<<' ';
	return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mk make_pair
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define vl vector<long long int>
#define vvl vector<vector<ll> > 
#define fo(i,a,b) for(int i=a;i<b;i++)
#define rof(i,a,b)  for(int i=b;i>=a;i--)
#define mod 1000000007
using namespace std;
ll dp[404][404];ll a[404],pre[404];
ll cnt(ll i,ll j)
{
    if(i>=j)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    ll mini = 1000000000000009;
    for(ll k=i;k<j;k++)
    {
        if(i>0)
            mini = min(mini,cnt(i,k)+cnt(k+1,j)+pre[j]-pre[i-1]);
        else
            mini = min(mini,cnt(i,k)+cnt(k+1,j)+pre[j]);
    }
    return dp[i][j] = mini;
}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    memset(dp,-1,sizeof(dp));
    fo(i,0,n)
        cin>>a[i];
    pre[0]=a[0];
    fo(i,1,n)
        pre[i]=pre[i-1]+a[i];
    cout << cnt(0,n-1);
}



Measured memory_bytes: 4820
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[] yama;
		int work;

		Scanner sc = new Scanner(System.in);

		yama = new int[10];
		for(int i = 0 ;i < 10 ;i++){
			yama[i] = sc.nextInt();
		}
		for(int i = 0 ;i < yama.length ;i++){
			for(int j = i+1 ; j <yama.length ;j++){
				if(yama[i] < yama[j]){
					work = yama[i];
					yama[i] = yama[j];
					yama[j] = work;
				}
			}
		}
		for(int i = 0 ;i < 3 ;i++){
			System.out.println(yama[i]);
		}
	}

}

Measured memory_bytes: 26240
N, M, X, Y = [int(num) for num in input().split()]
if Y <= X:
  result = "War"
else:
  x = [int(num) for num in input().split()]
  y = [int(num) for num in input().split()]
  if max(x) < min(y) and X < min(y) and max(x) < Y:
    result = "No War"
  else: 
    result = "War"
print(result)

Measured memory_bytes: 3064
//بسم الله الرحمن الرحيم
//اللہ کے نام سے شروع جو بڑا مہربان اور نہایت رحم والا ہے
//Allah in the name of The Most Affectionate, the Merciful
//अल्लाह के नाम से जो दयालु और कृपाशील है
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<ctime>

using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0)
#define ll long long
#define ull unsigned ll 
#define pb push_back

#define endl '\n'
#define mod 1000000007

#define FOR(i,k,n) for(int i=k; i<n; i++)
#define ROF(i,k,n) for(int i=k; i>=n; i--)
#define MEMSET(t) memset(t,0,sizeof(t));
#define time clock_t tStart
#define Start clock()
#define Time printf("Time taken: %.3fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC)



ll minC(int ar[], int n, ll dp[]) 
{
  if(n==1) return 0;
  if(dp[n]!=-1) return dp[n];
  if(n==2) return dp[n]=abs(ar[n-1]-ar[n-2]); 

  return dp[n]=min(
                    abs(ar[n-1]-ar[n-2])+minC(ar,n-1,dp),
                    abs(ar[n-1]-ar[n-3])+minC(ar,n-2,dp)  );    
 // return 0;
}

int main()
{
  fastio; 
  int t=1;
  while(t--)
  {
    int n;
    cin>>n;

    int ar[n];
    ll dp[n+1];
    FOR(i,0,n) cin>>ar[i];

   memset(dp,-1,sizeof(dp));
    cout<< minC(ar,n,dp)<<endl;

  }
  return 0;
}   

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

int main(){
	int m,nmin,nmax,x,res,resmax;
	vector<int> v;
	while(1){
		cin >> m >> nmin >> nmax;
		if(m == 0)break;
		resmax = 0;
		v.clear();
		for(int i = 0;i < m;i++){
			cin >> x;
			v.push_back(x);
		}
		sort(v.begin(),v.end(),greater<int>());
		for(int i = nmin - 1;i < nmax;i++){
			x = v[i] - v[i+1];
			if(x >= resmax){
				res = i + 1;
				resmax = x;
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
 
using namespace std;
 
 
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d %d", &a, &b)
#define siii(a, b, c) scanf("%d %d %d", &a, &b, &c)
 
#define sl(a) scanf("%I64d", &a)
#define sll(a, b) scanf("%I64d %I64d", &a, &b)
#define slll(a, b, c) scanf("%I64d %I64d %I64d", &a, &b, &c)
 
#define outi(a) printf("%d\n", a)
#define outii(a, b) printf("%d %d\n", a, b)
#define outiii(a, b, c) printf("%d %d %d\n", a, b, c)
 
#define outl(a) printf("%I64d\n", a)
#define outll(a, b) printf("%I64d %I64d\n", a, b)
#define outlll(a, b, c) printf("%I64d %I64d %I64d\n", a, b, c)
 
#define cel(n, k) ((n-1)/k+1)
#define sets(a) memset(a, -1, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))
 
 
#define fr(i, n) for(ll i=0; i<n;i++)
#define fr1(i, n) for(ll i=1; i<=n;i++) 
 
#define readf(f) freopen(f, "r", stdin)
#define writef(f) freopen(f, "w", stdout)
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
 
template< class T > T sq(T x) { return x * x; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
typedef long long ll;
typedef pair<int,int> pii;


int main()
{
	char c;

	cin>>c;

	cout<<(char)(c+1)<<"\n";
 
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
N, M = map(int, input().split())
dp = [-1] * (N+1)
#0段目と1段目に行く方法は1通り
dp[0] = 1
dp[1] = 1

for i in range(M):
    tmp = int(input())
    dp[tmp] = 0
    
for i in range(2, N+1, 1):
    if dp[i] != 0:
        dp[i] = dp[i-1] + dp[i-2]
        #dp[i] %= 1000000007
print(dp[N]%1000000007)

Measured memory_bytes: 460020
### 解答


#入力はじめ

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

#入力終わり


#累積和とる

A_wa = [0]
for i in range(N) :
    A_wa.append(A_wa[i]+A[i])

B_wa = [0]
for i in range(M) :
    B_wa.append(B_wa[i]+B[i])

#累積和計算おわり


ans = 0
for i in range(M+1):#Bを順番に増やしていくよー
    A_use = K-B_wa[i]
    if A_use<0: #Bだけでこえてる
        break
    
    ##Aは最大で何冊よめるかな
    A_MAX = 0
    start = 0
    end = N
    while  end-start>=1 : #調べるのが2個以上
        now = int((start + end+1)/2) #切り上げ
        if A_wa[now]==A_use :  #A[i]がKと一致
            A_MAX = now #ここが最大
            break
        elif A_wa[now]<A_use : #A[i]がKより小さい
            start = now #目的の値はここ以上のとこにある
            A_MAX = now #現時点での最大値
        else : #A[i]がKより大きい
            end = now-1#目的の値はここより小さい
    ##Aの最大探すの終わり
    
    #これ最大？
    if A_MAX+i>ans :
        ans=A_MAX+i

#コンソールにだす
print(ans)

Measured memory_bytes: 47472
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

int fun(int a,int b,int c){
    int d = (max(a,max(b,c)) - min(a,min(b,c))); 
    return  d; 
}

int solve(int w,int h){
    int  ans = min(w,h) ; 
    for (int i=1,j=w-1;i<=j;i++,j--){
        int a = i*h;
        int b = (h/2) * j; 
        int c = (h * w) - a - b ; 
        ans = min(ans,fun(a,b,c));
    }
    return ans ;
}

signed main()
{
    int w,h;
    cin>>w>>h;
    if (w%3==0 or h%3==0) {
      cout << 0 << endl;
      return 0;
    }
    int ans1= solve(w,h);
    int ans2= solve(h,w);
    cout << min(ans1,ans2) << endl; 
    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
 using namespace std;
int main(){
  int a[10];
  int k;
  for (size_t i = 0; i < 5; i++) {
    cin >> a[i];
  }
  cin >> k;
  string res = "Yay!";
  for (int i = 0; i < 4; i++) {
    for (int j = i+1; j < 5; j++) {
      if (a[j] - a[i] > k) {
        res = ":(";
        break;
      }
    }
  }
  cout << res << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int a, b, h;
    cin >> a >> b >> h;
    cout << 1.0 * (a + b) * h / 2 << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 1; i < n; i++) {
            map.put(i, 0);
        }

        for (int i = 1; i < n; i++) {
            for (int j = i + 1; j <= n; j++) {
                int length = calcLength(i, j, x, y);
                map.put(length, map.get(length) + 1);
            }
        }

        for (int i = 1; i < n; i++) {
            System.out.println(map.get(i));
        }
    }

    private static int calcLength(int i, int j, int x, int y) {
        int a = j - i;
        int b = Math.abs(x - i) + 1 + Math.abs(j - y);
        return Math.min(a,b );
    }
}


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

const int N = 3;
const int N2 = 9;
const int dx[4] = { 0,-1, 0, 1};
const int dy[4] = {-1, 0, 1, 0};
const char dir[4] = {'u', 'l', 'd', 'r'};

struct Puzzle {
    int f[N2];
    int space;
    string path;

    bool operator < (const Puzzle &p) const {
        for (int i = 0; i < N2; i++) {
            if (f[i] == p.f[i]) continue;
            return f[i] < p.f[i];
        }
        return false;
    }
};

bool isTarget(Puzzle p) {
    for (int i = 0; i < N2; i++) {
        if (p.f[i] != (i+1)) return false;
    }
    return true;
}

string bfs(Puzzle s) {
    queue<Puzzle> Q;
    map<Puzzle, bool> V;
    Puzzle u, v;
    s.path = "";
    Q.push(s);
    V[s] = true;

    while (!Q.empty()) {
        u = Q.front(); Q.pop();
        if (isTarget(u)) return u.path;

        int sx = u.space % N;
        int sy = u.space / N;
        for (int r = 0; r < 4; r++) {
            int nx = sx + dx[r];
            int ny = sy + dy[r];
            if (nx < 0 || ny < 0 || nx >= N || ny >= N) continue;

            v = u;
            swap(v.f[u.space], v.f[ny*N + nx]);
            v.space = ny*N + nx;
            if (!V[v]) {
                V[v] = true;
                v.path += dir[r];
                Q.push(v);
            }
        }
    }

    return "unsolvable";
}

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

    Puzzle in;
    for (int i = 0; i < N2; i++) {
        cin >> in.f[i];
        if (in.f[i] == 0) {
            in.f[i] = N2;
            in.space = i;
        }
    }

    string ans = bfs(in);
    cout << ans.size() << endl;

    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

// 約数列挙
vector<ll> divisor(ll N) {
    vector<ll> res;
    for (ll i = 1L; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            ll j = N / i;
            if (j != i)  {
                res.push_back(j);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}

ll get_n_digits(ll N){
    ll ans = 0;
    while (true){
        ans++;
        if (N / 10 == 0){
            return ans;
        } else {
            N /= 10;
        }
    }
}

void Main() {
    ll N; cin >> N;
    vector<ll> x = divisor(N);
    auto iter = lower_bound(x.begin(), x.end(), (ll)sqrt(N));
    cout << get_n_digits(x[iter - x.begin()]) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        self.group_count = n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        self.group_count -= 1

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

def int_(num_str):
    return int(num_str) - 1

N, M = map(int, input().split())
ablist = [list(map(int_, input().split())) for _ in range(M)]
ans = 0
for ng in range(M):
    uf = UnionFind(N)
    for i in range(M):
        if i != ng:
            uf.union(*ablist[i])
    if len(uf.roots()) >= 2:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    int a, p;
    cin >> a >> p;

    p += a * 3;

    cout << p / 2 << "\n";
    return 0;
}

Measured memory_bytes: 888
S = input()
A = S
l = len(S)
SS = []
i = 1
j = 0
str = []
count=0
while j<l:
    if i>l:
        break
    str = S[j:i]
    if str == SS:
        i+=1
        continue
    else:
        SS = str
        j=i
        i+=1
        count+=1
print(count)

Measured memory_bytes: 3500
import java.util.*;

public class Main {
  // constant

  static final int MAX_N = 10000;

  // inner classes

  static class Diff {
    int x1, d1, x2, d2;

    Diff(int x1, int d1, int x2, int d2) {
      this.x1 = x1;
      this.d1 = d1;
      this.x2 = x2;
      this.d2 = d2;
    }
  }

  // main
  public static final void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);

    for (;;) {
      int n = sc.nextInt();
      int r = sc.nextInt();
      if ((n | r) == 0) break;

      ArrayList<ArrayList<Diff>> diffs = new ArrayList<ArrayList<Diff>>();
      for (int i = 0; i < MAX_N + 2; i++)
        diffs.add(new ArrayList<Diff>());

      int minx = MAX_N + 1, miny = MAX_N + 1;
      int maxx = 0, maxy = 0;

      for (int i = 0; i < n; i++) {
        int x1 = sc.nextInt() + 1;
        int y1 = sc.nextInt();
        int x2 = sc.nextInt() + 1;
        int y2 = sc.nextInt();

        if (minx > x1) minx = x1;
        if (miny > y1) miny = y1;
        if (maxx < x2) maxx = x2;
        if (maxy < y2) maxy = y2;

        diffs.get(y1).add(new Diff(x1,  1, x2, -1));
        diffs.get(y2).add(new Diff(x1, -1, x2,  1));
      }

      int area = 0;
      int len = 0;

      int[][] ylines = new int[2][MAX_N + 2];
      Arrays.fill(ylines[0], 0);

      int prvy = 0;
      int cury = 1;

      for (int y = miny; y <= maxy; y++) {
        Arrays.fill(ylines[cury], 0);

        for (Diff df: diffs.get(y)) {
          ylines[cury][df.x1] += df.d1;
          ylines[cury][df.x2] += df.d2;
        }

        int sumx = 0;
        for (int x = minx; x <= maxx; x++) {
          sumx += ylines[cury][x];
          ylines[cury][x] = ylines[prvy][x] + sumx;
        }

        for (int x = minx; x <= maxx; x++) {
          if (ylines[cury][x] > 0) {
            area++;
            if (ylines[cury][x - 1] == 0) len++;
            if (ylines[cury][x + 1] == 0) len++;
            if (ylines[prvy][x] == 0) len++;
          }
          else {
            if (ylines[prvy][x] > 0) len++;
          }
        }

        prvy = cury;
        cury = 1 - cury;
      }

      System.out.println(area);
      if (r == 2) System.out.println(len);
    }
  }
}

Measured memory_bytes: 67808
#include<iostream>
#include<math.h>

using namespace std;

int main(){
  int N;
  cin >> N;
  int i = 0;
  int flag = 0;
  int count = 0;
  for(i = 0; i <= 5 ; i++){
    count += (int)(N / (int)pow(10, i))%10;
  }
  if(count == 1 && N % 10 == 0) cout << 10 << endl;
  else cout << count << endl;
}


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

bool compare(vector<int> a, vector<int> b, int n) {
  for (int i = 0; i < n; i++) {
    if (a.at(i) != b.at(i)) {
      return false;
    }
  }
  return true;
}

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

  vector<int> p(n), q(n);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> q.at(i);
  }

  // 大きさNの順列
  //
  // i element
  // ---------
  // 0 1
  // 1 2
  // 2 3
  //
  vector<int> order(n);
  for (int i = 0; i < n; i++) {
    order.at(i) = i+1;
  }

  int cnt = 0;
  int p_number = 0;
  int q_number = 0;

  do {
    if (compare(order, p, n)) {
      p_number = cnt;
    }
    if (compare(order, q, n)) {
      q_number = cnt;
    }
    cnt++;
  } while (next_permutation(order.begin(), order.end()));

  cout << abs(p_number - q_number) << endl;
  return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long int
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define N 100009
#define mod 1000000007
#define med 998244353
#define debug cout<<"There There\n";
#define debug1(x) cout<<"\nValue is "<<x<<endl
#define debug2(x,y) cout<<"\nValue is "<<x<<" "<<y<<endl
#define debug3(x,y,z) cout<<"\nValue is "<<x<<" "<<y<<" "<<z<<endl  
#define pr pair<int,int>
#define mx INT_MAX
#define lmx LONG_MAX
#define err return 0
#define cn continue
#define bre break

int n,k;

double calc(int a,int b)
{
	int ans=0;
	double see = 1;
	while(a<b)
	{
		a*=2;
		ans++;
		see*=0.5;
	}
	return see;
}

int32_t main()
{
	IOS;
	cin>>n>>k;
	if(k==1)
	{
		cout<<"1\n";
		err;
	}
	double ans = 0;
	for(int i=1;((i<k)&&(i<=n));i++)
	{
		double prob = (double)1/(double)n;
		prob = prob*calc(i,k);
		ans+=prob;
	}
	if(n>=k)
	{
		double see = (n-k+1)/(double)(n);
		ans+=see;
	}
	cout<<setprecision(100)<<ans<<endl;
}	


Measured memory_bytes: 256
// OURL: https://atcoder.jp/contests/abc137/tasks/abc137_a
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b;
  cin >>  a >> b;
  int as[4] = {
    a+b,
    a-b,
    a*b
  };
  cout << *max_element(as, as+3) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace::std;
#define all(x) (x).begin(),(x).end()
#define sax(x) cout << #x << '=' << x << endl
#define int long long

template <class T> istream& operator>>(istream &I, pair<T,T>& p) {return I >> p.first >> p.second;}
template <class T> ostream& operator<<(ostream &O, const pair<T,T>& p) {return O << p.first << ' ' << p.second;}
template <class T> istream& operator>>(istream &I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void MAIN() {
        int a, b;
        cin >> a >> b;
        cout << (a <= b ? "unsafe" : "safe");
}


signed main() { /*[J][O][L][S][K][E][Y]*/
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int t = 1;
//        cin >> t;
        while (t--) MAIN();
        return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    vector<ll> h(n);
    ll ans = 1e9;
    for(int i = 0;i < n;i ++){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    for(int i = k-1;i < n;i ++){
        if(h[i]-h[i-k+1]<ans) ans = h[i] - h[i-k+1];
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	// your code goes here
	int N = 0;
	cin>>N;
	vector<vector<double>> dp(N, vector<double>(N, 0));
	vector<double> prob;
	for(int i=0;i<N;i++){
		double val;
		cin>>val;
		prob.push_back(val);
	}
	//dp[i][j] i - number of coins j is the total number of tails till now.
	dp[0][0] = prob[0]; //P0
	dp[0][1] = 1 - prob[0];// P0`
	for(int i=1;i<N;i++){
		double pos = prob[i];
		double neg = 1 - prob[i];
		for(int j=0;j<N;j++){
			dp[i][j] += dp[i-1][j] * pos;
			if(j<N-1)dp[i][j+1] += dp[i-1][j] * neg;
		}
	}
	double result=0;
	for(int i=0;i<=N/2;i++)result+= dp[N-1][i];
	cout<<setprecision(10)<<result;
	return 0;
}

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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> road(n, 0);
    for(int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        road[a]++;
        road[b]++;
    }
    
    for(int i = 0; i < n; i++)
    {
        cout << road[i] << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

int solve(int n, int m, int a) {
    vector<vector<pair<int, int>>> keep(1010);
    int h, p, q;
    for (int i = 0; i < m; i++) {
        cin >> h >> p >> q;
        keep[h].push_back(make_pair(p, q));
    }
    if (m != 0) {
        for (int i = 999; i > 0; i--) {
            if (keep[i].size() != 0) {
                for (int j = 0; j < keep[i].size(); j++) {
                    // cout << keep[i][j].first << " " << keep[i][j].second << endl;
                    if (keep[i][j].first == a) {
                        // cout << "first chenge secondo";
                        a = keep[i][j].second;
                        break;
                    }
                    if (keep[i][j].second == a) {
                        a = keep[i][j].first;
                        // cout << "second";
                        break;
                    }
                }
            }
        }
    }
    return a;
}

int main() {
    int n, m, a;
    vector<int> ans;

    while (1) {
        cin >> n >> m >> a;
        if (!n && !m && !a) break;
        ans.push_back(solve(n, m, a));
    }
    for (int i : ans) cout << i << endl;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
int main(){
    int n,k,s;
    while(cin >> n >> k >> s){
        if(n == 0 && k == 0 && s == 0) break;
        int dp[30][30][200]={};
        for(int i=0; i<=n; i++) dp[i][0][0] = 1;

        for(int i=1;  i<=n; i++){
            for(int j=1; j<=k; j++){
                for(int l=0; l<=s; l++){
                    if(l < i) dp[i][j][l] = dp[i-1][j][l];
                    else dp[i][j][l] = dp[i-1][j][l] + dp[i-1][j-1][l-i];
                }
            }
        }
        cout << dp[n][k][s] << endl;
    }
    return 0;
}



Measured memory_bytes: 3796
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        try {
            String number;
            ArrayList<Integer> list = new ArrayList<>();
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            while (true) {
                number = reader.readLine();
                
                if ( number.equals("0")) {
                    break;
                } else {
                    int sum= 0;
                    int count = 0;
                    for (int i = 0 ; i < number.length() ; i++ ) {
                        count = Character.getNumericValue(number.charAt(i));
                        sum += count;
                    } 
                    if (sum != 0) {
                        list.add(sum);
                    }
                }
            }
            for (int i = 0; i < list.size();i++) {
                System.out.println(list.get(i));
            }
        } catch ( IOException e) {
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 24412
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    
    int c=0;
for(int i=0;i<3;i++)
if(s[i]=='A')
c++;
if(c==1||c==2)
cout<<"Yes";
else
cout<<"No";
    
}

Measured memory_bytes: 256