akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    string s, res;
    cin >> s;
    int num[4];
    for (int i = 0; i < 4; i++) num[i] = s[i] - '0';
    int sum = 0;
    for (int bit = 0; bit < (1 << 3); bit++) {
        sum = num[0];
        res = s[0];
        for (int i = 0; i < 3; i++) {
            if (bit & (1 << i)) {
                sum += num[i+1];
                res = res + '+' + s[i+1];
            } else {
                sum -= num[i+1];
                res = res + '-' + s[i+1];
            }
        }
        if (sum == 7) {
            cout << res << "=7" << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl

int n;

int main()
{
	SPEED;
	cin>>n;
	ll d;
	cin>>d;
	int ans=0;

	for(int i=1;i<=n;i++)
	{
		ll x,y;
		cin>>x>>y;
		if(x*x+y*y<=d*d)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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



int main()
{
    long long int n,sum,i;
    cin>>n;
    long long int a[n],b[n+2];
    for(i=0;i<n-1;i++)
    {
        cin>>b[i];
    }
    sum=b[0]+b[n-2];
    for(i=0;i<n-2;i++)
    {
        sum+=min(b[i],b[i+1]);
    }
    cout<<sum;
    return 0;
}
















Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a[4][3][10]={0},n,x,y,z,temp;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
{
        scanf("%d%d%d%d",&x,&y,&z,&temp);
        a[x-1][y-1][z-1]+=temp;
    }
    for(int i=0;i<4;i++)
{
        for(int j=0;j<3;j++)
{
            for(int k=0;k<10;k++)
{
                printf(" %d",a[i][j][k]);
            }
            printf("\n");
        }
        if(i<3)
{
            for(int j=0;j<20;j++)
{
            printf("#");
            }
            printf("\n");
        }
    }
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n,k; cin >> n >> k;
    vl v(n);
    rep(i,n) cin >> v[i];

    ll ans = 0;
    rep(l,min(n,k)+1){
        rep(r,min(k-l,n-l)+1){
            vi a;
            rep(i,l) a.push_back(v[i]);
            rep(i,r) a.push_back(v[n-1-i]);
            sort(rall(a));
            int x = min(k-l-r, l+r);
            while(x > 0 && a[a.size() - 1] < 0) a.pop_back(), x--;
            ans = max(ans, accumulate(all(a), 0ll));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
using System;

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

            if(s == 7 || s == 5 || s == 3){
                Console.WriteLine("YES");
            }else{
                Console.WriteLine("NO");
            }
        }
    }
}


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

int a,b=0,c=0;

int main(){
	for(int i=0;i<3;i++){
		cin>>a;
		if(a==5) b++;
		if(a==7) c++;
	}
	if(b==2&&c==1) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

void printVec(vector <int> v){
    for(int i = 0; i < v.size(); i++){
        cout << v[i] << " ";
    }
    cout << endl;
}

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

    vector<int> x(m);
    for(int i = 0; i < m; i++){
        cin >> x[i];
    }

    if(n >= m){
        cout << "0" << endl;
        return 0;
    }


    sort(x.begin(), x.end());
    vector<int> diff(m-1);
    for(int i = 0; i < m-1; i++){
        diff[i] = x[i+1] - x[i];
    }

    sort(diff.begin(), diff.end());
    for(int i = 0; i < n - 1; i++){
        diff[diff.size() - 1 - i] = 0;
    }


    cout << accumulate(diff.begin(), diff.end() , 0) << endl;

    return 0;

}



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

using namespace std;
vector<pair<int,int>>v;
int x[10];
int y[10];
int mem[3003][3003];
int n,t;
vector<pair<int,int>>ans;
int solve(int indx,int time){
    if(time<=0||indx>=n)
        return 0;
    int &ret = mem[indx][time];
    if(ret!=-1)
        return ret;
    int ans1 = solve(indx+1,time);
    int ans2 = solve(indx+1,time-ans[indx].first)+ans[indx].second;
    ret = max(ans1,ans2);
    return ret;
}
int main()
{
//    string s;
//
//    int n;
//    scanf("%d",&n);
//    cin>>s;
//    int start = 0,end=s.size()/2;
//    if(s.size()%2==1)puts("No");
//    else{
//        bool flag = true;
//        while(start!=s.size()/2){
//            if(s[start++]!=s[end++]){
//                flag=false;
//                break;
//            }
//        }
//        if(!flag)puts("No");
//        else puts("Yes");
//    }
//int n;
//    scanf("%d",&n);
//    int a,b;
//    for(int i=0;i<n;i++){
//        scanf("%d %d",&x[i],&y[i]);
//    }
//    vector<int>pos;
//    for(int i=0;i<n;i++){
//        pos.push_back(i);
//    }
//    double ans = 0;
//    int cnt=0;
//    do{
//        cnt++;
//        for(int i=0;i<n-1;i++){
//            ans+=(double)sqrt(((x[pos[i]]-x[pos[i+1]])*(x[pos[i]]-x[pos[i+1]]))+((y[pos[i]]-y[pos[i+1]])*(y[pos[i]]-y[pos[i+1]])));
//        }
//    }while(next_permutation(pos.begin(),pos.end()));
//    printf("%.10lf",ans/(double)cnt);

    int happy,tt;
    long long sum=0;
    scanf("%d%d",&n,&t);
    memset(mem,-1,sizeof(mem));
    for(int i=0;i<n;i++){
        scanf("%d%d",&tt,&happy);
        ans.push_back(make_pair(tt,happy));
    }
    sort(ans.begin(),ans.end());
    printf("%d",solve(0,t));
    return 0;
}


Measured memory_bytes: 35712
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (ll)(n); i++)
#define All(obj) (obj).begin(),(obj).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;


int main() {
	speed;
	string s;
	cin >> s;
	if (s[0] == s[1] || s[0] == s[2] || s[1] == s[2])cout << "No";
	else cout << "Yes";
	ed;
	return 0; 
}


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

int main(){

    
    int n,T;
    cin >> n >> T;

    int c[n];
    int t[n];
    int r[n];

    for(int i=0; i<n; i++){
        cin >> c[i] >> t[i];
        if(t[i] <= T){
            r[i] = c[i];
        } else {
            r[i] = 1001;
        }
    }

    int min = 1001;

    for(int i=0; i<n; i++){
        if(min > r[i]){
            min = r[i];
        }
    }

    if(min != 1001){
        cout << min << endl;
    } else {
        cout << "TLE" << endl;
    }
    

   

}

Measured memory_bytes: 256
// ABC_139_D

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

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

	ll sum = 0;
	for(ll i = 0; i < n; ++i) sum += i;

	cout << sum << "\n";

	return 0;
}

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

int main(){
    long long n;
    cin >> n;
    long long ans = 0;
    for (long long i = 1; i <= n; i++){
        if (i%5 != 0 && i%3 != 0){
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pib = pair<int,bool>;
using ll = long long;
using ld = long double;
#define all(x) (x).begin(),(x).end()
#ifdef fread_unlocked
#define fread fread_unlocked
#define fwrite fwrite_unlocked
#endif
#define mp make_pair
#define lc ind<<1
#define rc ind<<1|1
const int MN = 2e5+5, MOD = 1e9+7, BASE = 31, MASK = (1 << 10) - 1;
struct State {
	int x,y,dir;
};
pii d[4] = {{0,1},{0,-1},{1,0},{-1,0}};
deque<State> q;
int main () {
	int h,w,k;
	scanf ("%d %d %d",&h,&w,&k);
	vector<vector<vector<pii>>> dist(h+1, vector<vector<pii>>(w+1,vector<pii>(4,{1e9,-1})));
	vector<vector<char>> grid(h+1, vector<char>(w+1));
	int sx,sy,ex,ey;
	scanf ("%d %d %d %d",&sx,&sy,&ex,&ey);
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			scanf (" %c",&grid[i][j]);
		}
	}
	for (int i = 0; i < 4; i++) q.push_back({sx,sy,i}), dist[sx][sy][i] = {0,k};
	while (!q.empty()) {
		State cur = q.front(); q.pop_front();
		for (int j = 0; j < 4; j++) {
			int nx = cur.x + d[j].first, ny = cur.y + d[j].second;
			if (nx < 1 || nx > h || ny < 1 || ny > w || grid[nx][ny] == '@') continue;
			if (j == cur.dir) {
				pii ndist = dist[cur.x][cur.y][j];
				if (++ndist.second > k) ++ndist.first, ndist.second = 1; 
				if (ndist < dist[nx][ny][j]) {
					dist[nx][ny][j] = ndist;
					if (ndist.second == 1) q.push_back({nx,ny,j}); 
					else q.push_front({nx,ny,j});
				}
			} else {
				pii ndist = {dist[cur.x][cur.y][cur.dir].first + 1, 1};
				if (ndist < dist[nx][ny][j]) {
					dist[nx][ny][j] = ndist;
					q.push_back({nx,ny,j});
				}
			}
		}
	}
	int ret = INT_MAX;
	for (int i = 0; i < 4; i++) ret = min(ret,dist[ex][ey][i].first);
	printf ("%d\n",ret > 1e8 ? -1 : ret);
	return 0;
}


Measured memory_bytes: 214232
#include<bits/stdc++.h>
using namespace std;
typedef vector<int>VI;
#define rep(i,n) for(int i=0;i<(n);i++)
int N,M;
VI a;
VI ans;
int main(){
    cin>>N>>M;
    a.resize(M);
    rep(i,M)cin>>a[i],a[i]--;

    ans.resize(N);rep(i,N)ans[i]=i;
    rep(i,M)swap(ans[a[i]],ans[a[i]+1]);



    sort(a.begin(),a.end());
    int mi=M;
    do{
        bool used[10]={0};
        int h=1;
        rep(i,M){
            if((a[i]&&used[a[i]-1])||used[a[i]]||used[a[i]+1]){
                fill_n(used,10,false);
                h++;
            }
            used[a[i]]=true;
        }

        VI _ans(N);
        rep(i,N)_ans[i]=i;
        rep(i,M)swap(_ans[a[i]],_ans[a[i]+1]);
        if(ans==_ans){
            mi=min(mi,h);
        }
    }while(next_permutation(a.begin(),a.end()));

    cout<<mi<<endl;
    return 0;
}

Measured memory_bytes: 1216
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	final boolean DEBUG = false;
	final int INF = Integer.MAX_VALUE;

	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] w = new int[n];
		int[] sortedW = new int[n];
		int[] transDestIdx = new int[n];
		int[] rank = new int[n];

		for (int i = 0; i < n; i++)
			rank[i] = INF;
		for (int i = 0; i < n; i++)
			sortedW[i] = w[i] = scan.nextInt();
		Arrays.sort(sortedW);
		for (int i = 0; i < n; i++)
			transDestIdx[i] = Arrays.binarySearch(sortedW, w[i]);

		if (DEBUG) {
			System.out.println(Arrays.toString(w));
			System.out.println(Arrays.toString(transDestIdx));
			System.out.println(Arrays.toString(sortedW));
		}

		int r = 0;
		for (int i = 0; i < n; i++) {
			int idx = i;
			if (rank[i] != INF)
				continue;
			while (rank[i] == INF) {
				rank[transDestIdx[idx]] = r;
				idx = transDestIdx[idx];
			}
			r++;
		}
		if (DEBUG)
			System.out.println(Arrays.toString(rank));

		HashMap<Integer, LinkedList<Integer>> map = new HashMap<Integer, LinkedList<Integer>>();
		for (int i = 0; i < n; i++) {
			LinkedList<Integer> list = map.get(rank[i]);
			if (list == null) {
				LinkedList<Integer> l = new LinkedList<Integer>();
				l.add(w[i]);
				map.put(rank[i], l);
			} else {
				list.add(w[i]);
				map.put(rank[i], list);
			}
		}

		if (DEBUG) {
			System.out.println(map.size());
			for (int i = 0; i < map.size(); i++) {
				LinkedList<Integer> list = map.get(i);
				System.out.println("map " + i + ": " + list.toString());
			}
		}

		int ans = 0;
		for (int i = 0; i < map.size(); i++) {
			LinkedList<Integer> list = map.get(i);
			if (list.size() == 1)
				continue;
			int sum = 0;
			int min = INF;
			int length = list.size();
			for (int j = 0; j < length; j++) {
				int num = list.get(j);
				sum += num;
				min = Math.min(min, num);
			}
			if (DEBUG)
				System.out.println(sum + " " + min + " " + length);
			ans += Math.min(sum + (length - 2) * min, sum + min + (length + 1) * sortedW[0]);
		}
		System.out.println(ans);
	}

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



Measured memory_bytes: 31544
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
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")
    };
}

#[allow(dead_code)]
const MOD: u64 = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        N: isize, K: isize,
    }

    let mut ans = K;
    for _ in 1..N {
        ans *= K - 1;
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	char c;
	cin >> c;
	cout << (char)(c + 1) << endl;
}

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

using namespace std;

int main()
{
	int a,b,n;

	while(cin >> a >> b >> n && n)
	{
		int count=0,flag=0;
		for(int i=a;i<=1000000;i+=b)
		{
			for(int j=2;j<=sqrt(i);j++)
			{
				if(i%j==0 && i!=j)
				{
					flag++;
					break;
				}
			}
			if(!flag && i>=2)count++;
			if(count==n)
			{
				cout << i << endl;
				break;
			}
			flag=0;
		}
	}
}

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

using namespace std;
typedef char TElemType;
#define OK 1
typedef int Status;
typedef struct BiNode {
    TElemType data;
    struct BiNode *lchild, *rchild;
} BiNode, *BiTree;
const int MAXN = 200005;
const int INF = 0x3f3f3f3f;

void CreateBiTree(BiTree &T) {
    if (T == NULL) {
        T = new BiNode;
        T->data = 'c';
    } else {
        CreateBiTree(T->rchild);
        CreateBiTree(T->lchild);
    }
}

int pr(BiTree T) {
    if (T == NULL) return OK;
    else {
        pr(T->lchild);
        cout << T->data;
        pr(T->rchild);
    }
}

int main() {
# ifdef ONLINE_JUDGE
# else
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
# endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    long A;
    double B;
    cin>>A>>B;
    cout<<A*(long)(round(B*100.00))/100<<endl;
    return 0;

}

Measured memory_bytes: 3752
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll a[1010];
ll sum[1010];
ll bit[1010][50];
vector<ll> V;
int main()
{
	int N;
	ll K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = 0; i < N; i++) {
		sum[i + 1] = sum[i] + a[i];
	}
	for (int i = N; i > 0; i--) {
		for (int j = 0; j < i; j++) {
			V.push_back(sum[i] - sum[j]);
		}
	}
	ll ans = 0;
	for (ll i = 50; i >= 0; i--) {
		ll sum = (1ll << i);
		vector<ll> nv;

		for (int j = 0; j < V.size(); j++) {
			if ((sum & V[j]) == (1ll << i)) {
				nv.push_back(V[j]);
			}
		}
		if (nv.size() >= K) {
			V = nv;
			ans += sum;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6384
import java.util.*;

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

	void doIt() {
		int n = sc.nextInt();
		int[] a = new int[n];
		long sum = 0;
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}
		int[] b = new int[n];
		for(int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
			sum -= b[i];
		}
		if(sum < 0) {
			System.out.println(-1);
			return;
		}
		int d[] = new int[n];
		for(int i = 0; i < n; i++) {
			d[i] = a[i] - b[i];
		}
		Arrays.sort(d);
		int i, ii;
		long diff = 0;
		for(i = 0; i < n; i++) {
			if(d[i] >= 0) break;
			diff += d[i];
		}
		for(ii = n - 1; ii >= 0; ii--) {
			if(diff >= 0) break;
			diff += d[ii];
		}
		System.out.println(i + (n - 1 - ii));
		
	}


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


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

const int MAX = 50;
const int BIG = 400000000;
int dist(pair<int, int> p, pair<int, int> q) { // 点Pと点Qの距離
	return abs(p.first - q.first) + abs(p.second - q.second);
}
int main() {
	int N, M, a, b, c, d;
	pair<int, int> people[MAX], checkpoint[MAX];
	cin >> N >> M;
	for (int i = 0;i < N;i ++) {
		cin >> a >> b;
		people[i] = make_pair(a, b);
	}
	for (int i = 0;i < M;i ++) {
		cin >> c >> d;
		checkpoint[i] = make_pair(c, d);
	}
	int distance, go;
	for (int i = 0;i < N;i ++) { // i+1番目の学生はどのチェックポイントに向かったか
		distance = BIG; // 絶対に到達しない大きな数を入れることで、うっかりnullを行先にすることを防ぐ
		for (int j = 0;j < M;j ++) {
			if (distance > dist(people[i], checkpoint[j])) { // もしより近いチェックポイントが見つかったら
				distance = dist(people[i], checkpoint[j]); // そこまでの距離
				go = j + 1; // 行先
			}
		}
		cout << go;
		if (i < N - 1) cout << endl;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

各人は一番近いチェックポイントに向かうので、チェックポイントの番号が小さい順にチェックポイントの距離を見ていく
そして、今まで見たチェックポイントより距離が小さくなればそこを新しい候補にする
そうやって全てのチェックポイントを確認したら、最後に最も小さかった距離のチェックポイントに向かえば良い
この処理だと距離が同値なら大きい番号の奴は無視されるからもう一つの条件も満たすよね
O(NM)
*/

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Main bst = new Main();
		int ops = in.nextInt();
		while (in.hasNextLine()) {
			String[] holder;
			holder = in.nextLine().split(" ");
			
			if (holder[0].equals("insert")) {
				bst.insert(bst, new Node(Integer.parseInt(holder[1])));
			}
			else if (holder[0].equals("print")) {
				bst.print();
			}
			else if (holder[0].equals("find")) {
				if (bst.find(bst, Integer.parseInt(holder[1]))) {
					System.out.println("yes");
				}
				else {
					System.out.println("no");
				}
			}
		}
		
	}
	
	Node root;
	
	public Main() {
		root = null;
	}
	
	public boolean find(Main T , int k) {
		boolean result = false;
		Node curr = T.root;
		while (curr != null) {
			if (k == curr.key) {
				return true;
			} 			
			else if (k < curr.key) {
				curr = curr.left;
			} else {
				curr = curr.right;
			}
		}
		return result;
	}
	
	public void insert(Main T, Node z) {
		Node y = null;
		Node x = T.root;
		
		while (x != null) {
			y = x;
			if (z.key < x.key) {
				x = x.left;
			}
			else {
				x = x.right;
			}
		}
		z.p = y;
		
		if (y == null) {
			T.root = z;
		}
		else if (z.key < y.key) {
			y.left = z;
		}
		else {
			y.right = z;
		}
	}
	
	public String inOrder(Node z) {
		String result = "";
		if (z == null) {
			return result;
		}
		else {
			return inOrder(z.left) + " " + z.key + inOrder(z.right); 
		}
	}
	
	public String preOrder(Node z) {
		String result = "";
		if (z == null) {
			return result;
		}
		else {
			return " " + z.key + preOrder(z.left) + preOrder(z.right); 
		}
	}
	
	public void print() {
		System.out.println(this.inOrder(root));
		System.out.println(this.preOrder(root));
	}
}
class Node {
	int key; // Key of the node
	Node p; // Parent of the node
	Node left; // Left child
	Node right; // Right child
	
	public Node(int val) {
		key = val;
		p = null;
		left = null;
		right = null;
	}
	
	public String toString() {
		return key + "";
	}
}




Measured memory_bytes: 582148
from collections import deque

k = int(input())

num0 =[i for i in range(1,10)]
num = deque()
num = deque(num0)

if k < 10:
    print(k)
    
else:
    while True:
        x = num.popleft()
        if x % 10 != 0:
            num.append(10*x +(x % 10)-1)
            num0.append(10*x +(x % 10)-1)
            if len(num0) == k:
                break
        num.append(10*x +(x % 10))
        num0.append(10*x +(x % 10))
        if len(num0) == k:
            break
        if x % 10 != 9:
            num.append(10*x +(x % 10)+1)
            num0.append(10*x +(x % 10)+1)
            if len(num0)==k:
                break
    print(num0[-1])

Measured memory_bytes: 16180
#include <bits/stdc++.h>
#define vec vector
#define sz(c) int(c.size())
#define FOR(i, a, b) for (int i = a; i < (b); ++i)
#define DOWN(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define cerr2 cerr << __func__ << ":" << __LINE__ << ": "
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vec<int> vi;
const char eol = '\n';
#define y1 y123
#define fmax fmax123

int const MAXCOORD = (int) 1e8;
int const MAXN = (int) 2e5 + 10;

int x1, y1, x2, y2;
int n;
int x[MAXN];
int y[MAXN];
int fmax[MAXN];
map<int,int> posx;

void update(int pos, int val) {
  for (int i = pos; i < MAXN; i |= i + 1) {
    fmax[i] = max(fmax[i], val);
  }
}

int getmax(int pos = MAXN - 1) {
  int res = 0;
  for (int i = pos; i >= 0; i &= i + 1, --i) {
    res = max(res, fmax[i]);
  }
  return res;
}

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

  cin >> x1 >> y1 >> x2 >> y2;
  bool flip_x = x1 > x2;
  bool flip_y = y1 > y2;

  if (flip_x) {
    x1 = MAXCOORD - x1;
    x2 = MAXCOORD - x2;
  }
  if (flip_y) {
    y1 = MAXCOORD - y1;
    y2 = MAXCOORD - y2;
  }

  cin >> n;
  FOR(i, 0, n) {
    cin >> x[i] >> y[i];
    if (flip_x) {
      x[i] = MAXCOORD - x[i];
    }
    if (flip_y) {
      y[i] = MAXCOORD - y[i];
    }
  }

  vec<int> xs(x, x + n);
  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  FOR(i, 0, sz(xs)) {
    posx[xs[i]] = i;
  }

  vec<pii> pts;
  pts.reserve(n);
  FOR(i, 0, n) {
    if (x[i] >= x1 && x[i] <= x2 && y[i] >= y1 && y[i] <= y2) {
      pts.emplace_back(y[i], x[i]);
    }
  }
  sort(pts.begin(), pts.end());

  for (pii pt : pts) {
    int i = posx[pt.second];
    update(i, getmax(i) + 1);
  }
  
  int count = getmax();
  
  double res = 100.0 * (x2 - x1 + y2 - y1) - count * (20 - 5 * M_PI);
  if (min(x2 - x1, y2 - y1) + 1 == count) {
    res += 5 * M_PI;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 14336
#include<iostream>
#define I(i,n)for(int i=0;i<n;i++)
long long M=1e9+7,n,a[2],s[100000],w[2][100001],e[2],l[2][100000],p,v[2];
int main(){
	std::cin>>n>>a[0]>>a[1];
	I(i,n)std::cin>>s[i];
	I(k,2){
		p=0;
		I(i,n){
			while(s[i]-s[p]>=a[k]&&p<i-1)p++;
			l[k][i]=p;
		}
	}
	I(k,2){e[k]=-1;w[k][0]=1;}
	I(i,n){if(i){
		I(k,2)v[k]=(e[1-k]<l[k][i]?w[1-k][l[k][i]]:0);
		I(k,2)if(s[i]-s[i-1]<a[k]){e[k]=i-1;}else{(v[k]+=w[k][i-1])%=M;}
		I(k,2)w[k][i]=v[k];
	}
	}
	std::cout<<(w[0][--n]+w[1][n])%M;
	return 0;
}

Measured memory_bytes: 4224
fun main(args: Array<String>) {
    val (n, k) = readLine()
        ?.split(" ")
        ?.map(String::toInt)
        ?: return
    val pList = readLine()
        ?.split(" ")
        ?.map(String::toInt)
        ?: return

    var max = 0
    var total = 0
    for (i in 0 until pList.size - k + 1) {
        if (total == 0) {
            for (j in i until i + k) {
                total += pList[j]
            }
        } else {
            total -= pList[i - 1]
            total += pList[i + k - 1]
        }
        if (max < total) {
            max = total
        }
    }
    println((max + k).toDouble() / 2)
}


Measured memory_bytes: 60080
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))
s=0

for i in range(N):
    t=A[i]
    s+=B[t-1]
    if i==0:
        pass
    elif A[i]==A[i-1]+1:
        s+=C[t-2]
print(s)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
 
int main()
{
  double x1,y1;
  double x2,y2;
  double dist;

  cin >> x1 >> y1 >> x2 >> y2;

  dist = sqrt(pow((x1 - x2), 2.0) + pow((y1 - y2), 2.0));

  cout << fixed
       << setprecision(5)
       << dist
       << endl;

  return(0);
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <unordered_map>
#define maxn 100005
#define mod 998244353
using namespace std;
typedef long long LL;
int main()
{

    int n;
    scanf("%d",&n);
    int a[maxn*2];
    LL num[maxn*2]={0},ans=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        num[a[i]]+=1;
    }
    for(int i=1;i<=n;i++)
    {
        if(num[i]>=2)
            ans+=(num[i]-1)*num[i]/2;
    }
    for(int i=1;i<=n;i++)
        printf("%lld\n",ans-num[a[i]]+1);
    return 0;
}


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

int main()
{
string S;
cin>>S;
if(S=="SSS")cout <<0;
else if(S=="SSR")cout <<1;
else if(S=="SRS")cout <<1;
else if(S=="RSS")cout <<1;
else if(S=="SRR")cout <<2;
else if(S=="RSR")cout <<1;
else if(S=="RRS")cout <<2;
else if(S=="RRR")cout <<3;



}

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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

 
/*CODE START HERE*/
int main() {
  int a,b;
  cin >> a >> b;
  int sum = 1 ;
  int count = 0 ;
    while ( sum < b){
      sum += a-1 ;
      count ++ ;
    }
  cout << count << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=100;
ll dp[MAX_N+1][MAX_N*3+1];
int N;
ll W,w[MAX_N],v[MAX_N];
int main(){
	cin>>N>>W;
	REP(i,N){
		cin>>w[i]>>v[i];
	}
	REP(i,N){
		for(int n=i+1;n>=1;n--){
			REP(j,3*N+1){
				if (j-(w[i]-w[0])>=0){
					dp[n][j]=max(dp[n][j],dp[n-1][j-(w[i]-w[0])]+v[i]);
				}
			}
		}
	}
	ll ans=0;
	REP(i,N){
		REP(j,3*N+1){
			if ((i+1)*w[0]+j<=W){
				ans=max(ans,dp[i+1][j]);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define pb push_back
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	cout << n / 500 * 1000 + n % 500 / 5 * 5 << endl;
	return 0;
}

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

#define LL long long
#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define MID(l, r) (((l)+(r))>>1)
#define fi first
#define se second

typedef pair<int, int> pii;

const int maxn = (int) 5e5 + 20;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const double eps = 1e-8;


template < typename T > inline void read(T &x)
{
    static bool f;
    static char ch;

    f = 0;
    x = 0;
    ch = getchar();

    while(ch < '0' || '9' < ch) {if(ch == '-') f = 1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = (x << 3) + (x << 1) + (ch & 15); ch = getchar();}

    if(f) x = -x;
}

LL gcd(LL a, LL b) {if(!b) return a; return gcd(b, a % b);}
LL fp(LL a, LL n, LL m = MOD) {LL res; for(res = 1; n; a = a * a % m, n >>= 1) if(n & 1) res = res * a % m; return res;}

template <typename T> inline T minx(T a, T b) {if(a < b) return a; return b;}
template <typename T> inline T maxx(T a, T b) {if(a < b) return b; return a;}

int n;
char s[maxn];
int val[maxn];

void dfs(int d)
{
    if(d > n) return ;

    if(s[d] == '>' && s[d + 1] == '<')
        val[d] = 0;

    if(s[d] == '<') val[d] = max(val[d], val[d - 1] + 1);
    dfs(d + 1);
    if(s[d + 1] == '>') val[d] = max(val[d], val[d + 1] + 1);
}

void work()
{
    cin >>(s + 1);
    n = strlen(s + 1) + 1;
    s[0] = '>';
    s[n + 1] = '<';

    for(int i = 0; i < n; i++) val[i] = 0;

    dfs(0);

    LL ans = 0;
    for(int i = 0; i < n; i++) ans += val[i];

    cout <<ans <<endl;
}


int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
#endif // yukihana0416

    int tc = 1;
//    read(tc);

    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 18304
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
void solve()
{
    int n;
    cin>>n;
    long long sum=0,ans=0;
    rep(i,n)
    {
        int a;
        cin>>a;
        sum+=a;
        if(a==0)
        {
            ans+=sum/2;
            sum=0;
        }
    }
    ans+=sum/2;
    cout<<ans<<endl;
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    solve();
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

// type alias
using ll = long long;
using ull = unsigned long long;

// constant value
const ll mod = 1000000007ll;

template<class ll>
inline ll getCeilExponent(ll a)
{
	if (a <= 0)
	{
		throw invalid_argument("vaule equal to or less than 0 should not be valid");
	}

	ll index = 0;
	--a;
	for (; a != 0; a >>= 1)
	{
		++index;
	}
	return index;
}

template<class ll>
inline ll getFloorExponent(ll a)
{
	if (a <= 0)
	{
		throw invalid_argument("vaule equal to or less than 0 should not be valid");
	}

	ll index = 0;
	a >>= 1;
	for (; a != 0; a >>= 1)
	{
		++index;
	}
	return index;
}

// computational complexity: o(log(max(a, b))) 
template<class ll>
inline ll getGcd(ll a, ll b)
{
	if (b == 0)
	{
		return a;
	}
	return getGcd(b, a % b);
}

// computational complexity: o(log(max(a, b))) 
template<class ll>
inline pair<ll, ll> getBezoutsIdentitySolution(ll a, ll b)
{
	if (b == 0)
	{
		return { 1, 0 };
	}
	auto sol = getBezoutsIdentitySolution(b, a % b);
	return { sol.second, sol.first - (a / b) * sol.second };
}

inline ll getModValue(ll a, ll m)
{
	return (a % m + m) % m;
}

// computational complexity: o(log(max(a, n))) 
inline ll getModInverse(ll a, ll m)
{
	auto sol = getBezoutsIdentitySolution(a, m);
	if (a * sol.first + m * sol.second != 1)
	{
		return -1;
	}
	return getModValue(sol.first, m);
}

ll getModCombinatorialNumber(ll n, ll r, ll m)
{
	ll res = 1;
	for (; n > 0; --n, --r)
	{
		res = (((res * n) % m) * getModInverse(n, m)) % m;
	}
	return getModValue(res, m);
}

ll getModPower(ll base, unsigned t, ll m)
{
	if (t == 0)
	{
		return 1ll;
	}

	auto res = getModPower(base, t >> 1, m);
	res = getModValue(res * res, m);
	if (t % 2 == 1)
	{
		res = getModValue(res * base, m);
	}
	return res;
}

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

	ll N;
	string S;
	cin >> N >> S;

	bool haveSeenBlack = false;
	ll res = 0LL;
	for (ll i = 0; i < N; ++i)
	{
		if (S[i] == '#')
		{
			haveSeenBlack = true;
		}
		else if (haveSeenBlack)
		{
			++res;
		}
	}

	haveSeenBlack = false;
	ll new_res = res;
	for (ll i = 0; i < N; ++i)
	{
		if (S[i] == '#')
		{
			haveSeenBlack = true;
			++res;
		}
		else if (haveSeenBlack)
		{
			--res;
			new_res = min(res, new_res);
		}
	}

	cout << new_res << endl;

	return 0;
}

Measured memory_bytes: 720
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a; string s; cin >> a >> s;
	if(a >= 3200) println(s);
	else println("red");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string.h>
#include <cassert>
#include <string.h>
#include <tuple>

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--)///n-1番目からn回
#define  REP(i,a,b) for(int i=a;i<=b;i++) ///a番目からb回
#define  RREP(i,a,b) for(int i=a;i<b;i--)
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pair_t;
#define MOD 1000000007

//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///*min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();
///(10-(n%10))%10  10-(1桁目)取得 12->8 20->0

#define Ru(n)  ( ((n)+9)/10*10  ) //切りあげ
#define Rd(n)  ( ((n)-10)/10*10 +10 )	切り捨て


int gcd(int a,int b);
size_t length(const std::string& str) {
	return str.length();
}
bool comp(const pair_t &a, const pair_t &b) {
	return a.first < b.first;
}

int main() {
	string s,ans;

	cin>>s;
	if(s=="T")
		ans="A";
	else if(s=="A")
		ans="T";
	else if(s=="C")
		ans="G";
	else
		ans="C";
	cout<<ans<<endl;
	return 0;

}


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


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N, K = map(int, input().split())
    ans = K
    for i in range(N - 1):
        ans *= K - 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4584
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int a, b, c, d, e, f, g;
	cin >> a >> b >> c >> d >> e >> f >> g;
	long long int ans = 0;
	ans += b;
	ans += a - a % 2;
	ans += d - d % 2;
	ans += e - e % 2;
	if (a && d && e) {
		a--;
		d--;
		e--;
		ans = max(ans, 3 + a - (a % 2) + d - (d % 2) + e - (e % 2) + b);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	x := getNextInt(scanner)
	ans := x
	if x > 2 {
		l := 0
		r := x
		for l < r {
			m := (l + r) >> 1
			if m*(m+1) < x*2 {
				l = m + 1
				continue
			}
			r = m
		}
		ans = l
	}
	fmt.Fprintln(writer, ans)

	writer.Flush()
}


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

using namespace std;

vector<vector<int>> adjlist;
vector<int> pairs;
vector<bool> visited;
int a[100], b[100], c[100], d[100];

bool dfs(int v) {
  if (visited[v]) return false;
  visited[v] = true;
  for (auto w : adjlist[v]) if (pairs[w] < 0 || dfs(pairs[w])) {
    pairs[w] = v; pairs[v] = w; return true;
  }
  return false;
}

int kuhn(int n) {
  pairs.assign(adjlist.size(), -1);
  int ans = 0;
  for (int i = 0; i < n; i++) for (auto w : adjlist[i])
    if (pairs[w] == -1) { pairs[i] = w; pairs[w] = i; ans++; break; }
  for (int i = 0; i < n; i++) if (pairs[i] == -1) {
    visited.assign(n, false);
    ans += dfs(i);
  }
  return ans;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i], &b[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &c[i], &d[i]);
  }

  adjlist.resize(2 * n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i] < c[j] && b[i] < d[j]) {
        adjlist[i].push_back(j + n);
      }
    }
  }

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


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

int main(){
				string a,b;
				cin >> a >> b;
				string c = a + b;
				int n  = stoi(c);
				for(int i = 0; i < 1000; i++)
								if(i*i == n){
											 	cout << "Yes" << endl;
												return 0;
								}
				cout << "No" << endl;
				return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
A = [input() for i in range(H)]
low = [False]*H
col= [False]*W
for l in range(H):
    for c in range(W):
        if A[l][c] == "#":
            low[l] = True
            col[c] = True
for l in range(H):
    if low[l] ==True:
        for c in range(W):
            if col[c]==True:
                print(A[l][c],end="")
        print()


Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
int main(){
long long int A,B,C;
  cin >> A >> B >> C;
  long long int D=max(abs(A-B),max(abs(B-C),abs(C-A)));
 long long int count=0;
  bool K=true;
  if (D==0 && A%2==0)cout << -1 <<endl;
  else {
    while(K){
  	if (A%2==1 || B%2==1 || C%2==1){cout << count <<endl;K=false;}
    else {
      count++;
      long long int D,E,F;
      D=(B+C)/2;
      E=(C+A)/2;
      F=(A+B)/2;
      A=D;
      B=E;
      C=F;
    }
    }
  }
}


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

int int_sort(const void* a, const void* b) {
	if (*(int*)a < *(int*)b) {
		return -1;
	}
	else if (*(int*)a == *(int*)b) {
		return 0;
	}
	else {
		return 1;
	}
}

int main()
{
	int x[3];
	cin >> x[0] >> x[1] >> x[2];
	
	size_t data_cnt, i;

	data_cnt = sizeof(x) / sizeof(x[0]);
	qsort((void*)x, data_cnt, sizeof(x[0]), int_sort);

	int a = 0;
	for (i = 1; i < data_cnt; i++) {
		a += x[i] - x[i - 1];
	}
	cout << a;
    return 0;
}



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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr int INF = 1'000'000'000;
int N, M;
int A[1100], B[1100], C[1100];
int dp[1100][1<<12];

int rec(int i, int s){
    if(s + 1 == (1 << N)){
        return 0;
    }

    if(i == M){
        return INF;
    }

    if(dp[i][s] != -1){
        return dp[i][s];
    }

    int res = std::min(rec(i + 1, s), rec(i + 1, s | C[i]) + A[i]);
    return dp[i][s] = res;
}

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

  std::cin >> N >> M;

  for(int i=0;i<M;++i){
      std::cin >> A[i] >> B[i];

      for(int j=0;j<B[i];++j){
          int c;
          std::cin >> c;

          c -= 1;

          C[i] |= (1 << c);
      }
  }

  memset(dp, -1, sizeof(dp));

  int res = rec(0, 0);

  if(res >= INF){
      res = -1;
  }

  std::cout << res << std::endl;
}


Measured memory_bytes: 17920
# A - Cookie Exchanges

A, B, C = map(int, input().split())

ans = 0
while True:
    if A%2 or B%2 or C%2:
        break
    if A == B == C:
        ans = -1
        break
    nA = B//2 + C//2
    nB = A//2 + C//2
    nC = A//2 + B//2
    A = nA
    B = nB
    C = nC
    ans += 1

print(ans)

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

int main(){
  int arr[5], k;
  
  for(int i = 0; i < 5; i++){
    cin >> arr[i];
  } 
  cin >> k;
  bool wrong = true;
  
  for(int i = 0; i < 5; i++){
    for(int j = i + 1; j < 5; j++){
      if(abs(arr[i] - arr[j]) > k){ 
        wrong = false;
      }
    }
  } 
  if(wrong == false){
    cout << ":(" << endl;
  } 
  else{ 
    cout << "Yay!" << endl;
  }
  return 0;
} 

Measured memory_bytes: 256
<>;$x=$==-1,s/( \d+)\1*\b/$x*=$&**($a=$&=~y! !!%3);$=*=$&**(-$a%3)/ge,++$$x,$t{$x}=$=for`factor`;$\+=$_>-2||$$_,$$_=${$t{$_}}=0for sort{$$b-$$a}keys%t;print

Measured memory_bytes: 75992
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
ll n;
ll a[114514];
signed main() {
	ll ans = 0;
	cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	ll cnt[114514];
	cnt[0] = a[0];
	rep(i, n - 1) {
		cnt[i + 1] = cnt[i] + a[i + 1];
	}
	ll memo = 0;
	for (int i = n - 2; i >= 0; i--) {
		if (cnt[i] * 2 < a[i + 1]) {
			memo = i + 1;
			break;
		}
	}
	cout << n - memo << endl;
	ggr
}

Measured memory_bytes: 1792