akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

void solve()
{
  ll A, B, C, K;
  std::cin >> A >> B >> C >> K;

  ll ans = 0LL;
  if (A >= K) {
    print(K);
    return;
  }
  ans += A;
  K -= A;

  if (B >= K) {
    print(ans);
    return;
  }
  K -= B;

  ans -= K;

  print(ans);
  return;
}

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



Measured memory_bytes: 3600
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc  = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		
		for(int i=0;i<n;i++){
			String[] s = sc.nextLine().split("[\\s]+");
			int[] data = new int[3];
			
			for(int k=0;k<3;k++){
				data[k] = Integer.parseInt(s[k]);
			}
			Arrays.sort(data);
			
			if(data[0]*data[0]+data[1]*data[1] == data[2]*data[2]) System.out.println("YES");
			else{System.out.println("NO");}
		}
		
	}
}

Measured memory_bytes: 25260
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

ll n, a[111111], hoge, huga, nyaa = 0, nyan = 0;

main(){
    scanf("%lld", &n);
    for(int i=0; i<n; i++){
        scanf("%lld", &a[i]);
    }
    /*
    if(!a[0]){
        hoge = 1;
        huga = -1;
        nyaa = nyan = 1;
    }else {
        hoge = max(a[0], -a[0]);
        huga = min(a[0], -a[0]);
        nyaa += abs(a[0] - hoge);
        nyan += abs(a[0] - huga);
    }
    */
    int p = 0;
    //printf("%lld %lld %lld %lld\n", hoge, huga, nyaa, nyan);
    for(int i=0; i<n; i++){
        hoge += a[i];
        if(p){
            if(hoge >= 0){
                nyaa += hoge + 1;
                hoge = -1;
            }
        }else {
            if(hoge <= 0){
                nyaa += 1 - hoge;
                hoge = 1;
            }
        }
        huga += a[i];
        if(p){
            if(huga <= 0){
                nyan += 1 - huga;
                huga = 1;
            }
        }else {
            if(huga >= 0){
                nyan += huga + 1;
                huga = -1;
            }
        }
        p ^= 1;
        //printf("%lld %lld %lld %lld\n", hoge, huga, nyaa, nyan);
    }
    printf("%lld\n", min(nyaa, nyan));
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define t(a,b) t[a][b]
string s,t[]={"..rr....","..rr....","ggyybbww","ggyybbww","..oo....","..oo...."};
char c,d,e;
int i,j;

void r(int y,int x){
  e=t(y,x),t(y,x)=t(y+1,x),t(y+1,x)=t(y+1,x+1),t(y+1,x+1)=t(y,x+1),t(y,x+1)=e;
}
int main(){
  cin>>s;
  for(;i<s.size();++i){
    if(s[i]=='U'){
      c=t(2,0),d=t(2,1),t(2,0)=t(2,2),t(2,1)=t(2,3),t(2,2)=t(2,4),t(2,3)=t(2,5),t(2,4)=t(2,6),t(2,5)=t(2,7),t(2,6)=c,t(2,7)=d;
      r(0,2);
    }else if(s[i]=='F'){
      c=t(1,2),d=t(1,3),t(1,2)=t(3,1),t(1,3)=t(2,1),t(2,1)=t(4,2),t(3,1)=t(4,3),t(4,2)=t(3,4),t(4,3)=t(2,4),t(2,4)=c,t(3,4)=d;
      r(2,2);
    }else if(s[i]=='R'){
      c=t(0,3),d=t(1,3),t(0,3)=t(2,3),t(1,3)=t(3,3),t(2,3)=t(4,3),t(3,3)=t(5,3),t(4,3)=t(3,6),t(5,3)=t(2,6),t(3,6)=c,t(2,6)=d;
      r(2,4);
    }else if(s[i]=='D'){
      c=t(3,0),d=t(3,1),t(3,0)=t(3,6),t(3,1)=t(3,7),t(3,6)=t(3,4),t(3,7)=t(3,5),t(3,4)=t(3,2),t(3,5)=t(3,3),t(3,2)=c,t(3,3)=d;
      r(4,2);
    }else if(s[i]=='B'){
      c=t(0,3),d=t(0,2),t(0,2)=t(2,5),t(0,3)=t(3,5),t(2,5)=t(5,3),t(3,5)=t(5,2),t(5,3)=t(3,0),t(5,2)=t(2,0),t(2,0)=c,t(3,0)=d;
      r(2,6);
    }else if(s[i]=='L'){
      c=t(0,2),d=t(1,2),t(1,2)=t(2,7),t(0,2)=t(3,7),t(3,7)=t(4,2),t(2,7)=t(5,2),t(4,2)=t(2,2),t(5,2)=t(3,2),t(2,2)=c,t(3,2)=d;
      r(2,0);
    }
  }
  for(;j<6;++j)cout<<t[j]<<endl;
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  long long int ans = 0;
  long long int count = 0;
  for(int i = 0; i < s.size()-1; i++){
  //  cout << count << endl;
    if(s[i] == 'A'){
      count++;
    }
    else if(s[i] == 'B' && s[i+1] == 'C'){
      ans += count;
      i++;
    }
    else{
      count = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if ((a == b) & (b == c)){
        cout << a << " " << b << " " << c << endl;
    } else if ((a == b) & (b > c)){
        cout << c << " " << a << " " << b << endl;
    } else if ((c == a) & (a > b)){
        cout << b << " " << c << " " << a << endl;
    } else if ((b == c) & (c > a)){
        cout << a << " " << b << " " << c << endl;
    } else if ((a == b) & (b < c)){
        cout << a << " " << b << " " << c << endl;
    } else if ((c == a) & (a < b)){
        cout << a << " " << c << " " << b << endl;
    } else if ((b == c) & (c < a)){
        cout << b << " " << c << " " << a << endl;
    } else if ((a > b) & (b > c)){
        cout << c << " " << b << " " << a << endl;
    } else if ((c > a) & (a > b)) {
        cout << b << " " << a << " " << c << endl;
    } else if ((b > c) & (c > a)) {
        cout << a << " " << c << " " << b << endl;
    } else if ((a < b) & (b < c)){
        cout << a << " " << b << " " << c << endl;
    } else if ((c < a) & (a < b)) {
        cout << c << " " << a << " " << b << endl;
    } else if ((b < c) & (c < a)) {
        cout << b << " " << c << " " << a << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int N, M;
	cin >> N >> M;

	vector<vector<int64_t>> v(3, vector<int64_t>(0));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			int64_t n;
			cin >> n;
			v.at(j).push_back(n);
		}
	}

	int64_t ans = 0;
	for (int bit = 0; bit < (1 << 3); bit++) {
		bitset<3> bs(bit);

		vector<int64_t> vec(N);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 3; j++) {
				if (bs[j]) vec.at(i) += v.at(j).at(i);
				else vec.at(i) += -v.at(j).at(i);
			}
		}

		sort(vec.begin(), vec.end());
		reverse(vec.begin(), vec.end());

		int64_t sum = 0;
		for (int i = 0; i < M; i++) sum += vec.at(i);
		ans = max(ans, sum);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3640
#ifdef LOCAL
  #define debug_echo(expr) cout << expr;
#else
  #define debug_echo(expr)
#endif

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

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#include <vector>
template<class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o<<"{";
    bool f = false;
    for (const T &a: v)
        o<<(f?", ":"")<<a,
        f = true;
    o<<"}";
    return o;
}

int main() {
    int N;
    cin >> N;
    int div2 = 1;
    while (true) {
        div2 *= 2;
        if (N < div2) {
            div2 /= 2;
            break;
        }
    }
    cout << div2 << endl;
}


Measured memory_bytes: 256
//              _      _                 
//             (_)    | |                
//    _ __ ___  _  ___| |__   __ _  ___  
//   | '_ ` _ \| |/ __| '_ \ / _` |/ _ \ 
//   | | | | | | | (__| | | | (_| | (_) |
//   |_| |_| |_|_|\___|_| |_|\__,_|\___/ 
//                                       
// 
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int MAX=1<<18;
int S[4*MAX],D[4*MAX];
vi event[MAX];
void lazy(int u,int lo,int hi)
{
  D[2*u+1]+=D[u];
  D[2*u]+=D[u];
  S[u]+=(hi-lo)*D[u];
  D[u]=0;
}

void update(int a,int b,int u,int lo,int hi,int c)
{
   if (a>=b) return;
   if (a==lo && b==hi)
   {
     D[u]+=c;
     return;
   }
   S[u]+=c*(b-a);
   int mid=(lo+hi)/2;
   update(a,min(b,mid),2*u,lo,mid,c);
   update(max(a,mid),b,2*u+1,mid,hi,c);
}

int query(int a,int b,int u,int lo,int hi)
{
   if (a>=b)return 0;
   lazy(u,lo,hi);
   if (a==lo && b==hi)
   {
     return S[u];
   }
   int mid=(lo+hi)>>1;
   int L=query(a,min(b,mid),2*u,lo,mid);
   int R=query(max(a,mid),b,2*u+1,mid,hi);
   return L+R;
}

int32_t main()
{
  BOOST;
  int ans=0;
  int n;
  cin>>n;
  for (int i=1;i<=n-1;i++)
  {
  	int a,b;
  	cin>>a>>b;
  	if (a>b)swap(a,b);
  	event[a].pb(b);
  }
  
  for (int i=n;i>=1;i--)
  {
  	update(i,n+1,1,1,MAX+1,1);
  	for (auto it:event[i])
  	update(it,n+1,1,1,MAX+1,-1);
  	ans+=query(i,n+1,1,1,MAX+1);
  	//cout<<"TERAZ "<<ans<<" "<<i<<"\n";
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 25356
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <map>
#include <sstream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    double l[10], v1, v2;
    string s;
    while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", 
        &l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v1,&v2)
        != EOF) {
        double sum = 0, per;
        REP(i, 10)
            sum += l[i];
        per = sum * (v1 / (v1 + v2));
        sum = 0;
        REP(i, 10){
            sum += l[i];
            if (sum >= per) {
                cout << i+1 << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 3148
using System;

namespace ReversingNumbers 
{
	class MainClass
	{
		static char[] suit = {'S', 'H', 'C', 'D'};
		public static void Main (string[] args)
		{
			int n = int.Parse (Console.ReadLine ());
			bool[,] data = new bool[4,13];
			for (int i = 0; i <data.GetLength (0); i++)
				for (int j = 0; j<data.GetLength (1); j++)
					data [i, j] = false;

			for (int i = 0; i < n; i++) {
				string[] tmp = Console.ReadLine ().Split (" ".ToCharArray ());
				int type = getSuitNum (tmp[0][0]);
				data[type, int.Parse(tmp[1])-1] = true;
			}

			for (int i = 0; i<data.GetLength (0); i++)
				for (int j = 0; j<data.GetLength (1); j++)
					if (!data [i, j]) {
						Console.WriteLine ("{0} {1}", suit [i], j+1);
					}
		}

		static int getSuitNum(char suitdata){
			for (int i = 0; i < suit.Length; i++)
				if (suitdata == suit [i])
					return i;

			return -1;
		}
	}
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef pair<int, int> pii ;
typedef tree< pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 300005

/*
     *os.find_by_order(k) -> returns the k'th smallest element (indexing starts from 0)
      os.order_of_key(v)  -> returns how many elements are strictly smaller than v
*/

char s[505] ;

int main()
{
    scanf("%s",s) ;
    i64 k ;
    scanf("%lld",&k) ;

    vector < pair<i64,i64> > vp ;

    int n = strlen(s) ;

    for(int i=0 ; i<n ; i++)
    {
        int l = i , r = i ;
        while( r+1 < n && s[r+1]==s[r] ) r++ ;

        i = r ;
        vp.push_back( mp(1,r-l+1) ) ;
    }

    if( vp.size() == 1 ) vp[0].yy *= k ;
    else if( k!=1 ){

        int m = (int)vp.size() ;

        for(int i=1 ; i<m-1 ; i++) vp[i].xx *= k ;

        if( s[0]==s[n-1] )
        {
            pair<char,int> temp = vp[m-1] ;
            vp[m-1] = mp( k-1 , (vp[m-1].yy+vp[0].yy) ) ;
            vp.pb(temp) ;
        }
        else{
            vp[0].xx *= k ;
            vp[m-1].xx *= k;
        }
    }

    i64 ans = 0 ;

    for(int i=0 ; i<vp.size() ; i++)
    {
        ans += ((vp[i].yy)/2)*vp[i].xx ;
    }

    printf("%lld\n",ans) ;

    return 0 ;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////


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

    vector<set<string>> dic(N);
    dic[0].emplace("a");

    for (int i = 1; i < N; ++i) {
        for (auto j : dic[i-1]) {
            int K = j.size();
            int MAX = 0;
            rep(k,K) {
                int p = j[k] - 'a';
                chmax(MAX,p);
            }
            rep(k,MAX+2) {
                string T = j;
                char c = char(k + 'a');
                T += c;
                dic[i].emplace(T);
            }
        }
    }

    for (auto i : dic[N-1]) {
        cout << i << ln;
    }
}


Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAX = 250000 + 5;
const int M = 3e5;
const int mod = 1e9 + 7;
const int MOD = 1e9 + 7;
const int INF = 0;
const int LG = 21;

void solve()
{
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
}
 
int32_t 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: 3652
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	public static void main(String[] args) {
		int N=sc.nextInt();
		int M=sc.nextInt();
		
		long a[]=new long[N];
		long b[]=new long[N];
		
		long c[]=new long[M];
		long d[]=new long[M];
		
		
		for(int i=0;i<N;i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
		}
		for(int i=0;i<M;i++) {
			c[i]=sc.nextInt();
			d[i]=sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			long ans=mod;
			int answer=0;
			for(int x=0;x<M;x++) {
				long tmp=Math.abs(a[i]-c[x])+Math.abs(b[i]-d[x]);
				if(tmp<ans) {
					answer=x;
					ans=tmp;
				}
			}
			p(answer+1);
		}
		
		
		
		
		
		
		
	}
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,K;
    cin >> N >> K;
    
    int x[N];
    for (int i=0; i<N; i++) {
        cin >> x[i];
    }
    
    int ans=0;
    for (int i=0; i<N; i++) {
        ans += min(x[i], K-x[i]);
    }
    
    cout << ans*2 << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll b,c=0,k=1,n,h,w,m,min=100000000000,ans=1,max=0;
    string s,s2;
    cin >> n;
    VI a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(ALL(a));

    cout << a[n-1]-a[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
   
using namespace std;

int w, h;
string s[21];

string solve()
{
    vector<string> result;
    int cnt = 0, wcnt = 0, hcnt = 0;
    int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
    int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            // ???????????????s[i][j]
            for(int k = 0; k < 8; k++){
                string tmp = "";
                int sx = i, sy = j;
                while(!(sx == i && sy == j) || tmp.length() == 0){
                    tmp += s[sx][sy];
                    // cout << tmp << endl;
                    sx += dx[k];
                    sy += dy[k];
                    if(sx >= h) sx = 0;
                    if(sy >= w) sy = 0;
                    if(sx < 0) sx = h - 1;
                    if(sy < 0) sy = w - 1;
                }
                result.push_back(tmp);
            }
        }
    }
    sort(result.begin(), result.end());
    string ans = "";
    for(int i = 0; i < result.size() - 1; i++){
        // cout << result[i] << endl;
        if(result[i].length() < ans.length()) continue;
        int cnt = 0;
        string nowans = "";
        while(cnt < min(result[i].length(), result[i + 1].length())){
            if(result[i][cnt] == result[i + 1][cnt]){
                nowans += result[i][cnt];
                cnt++;
            } else {
                break;
            }
        }
        if(nowans.length() > ans.length()) ans = nowans;
    }
    if(ans.length() < 2) return "0";
    else return ans;
}

int main()
{
    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        for(int i = 0; i < h; i++){
            cin >> s[i];
        }
        cout << solve() << endl;
    }
    return 0;
}

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

template <typename T>
class BinaryIndexedTree
{
public:
    vector<T> arr;
    long long size;
    T initial_value;

    BinaryIndexedTree(long long N)
    {
        setSize(N);
    }

    BinaryIndexedTree(long long N, T init)
    {
        setSize(N);
        setInitialValue(init);
        initializeArr();
    }

    void setSize(long long N)
    {
        size = N + 1;
    }

    void setInitialValue(T init)
    {
        initial_value = init;
    }

    void initializeArr()
    {
        arr = vector<T>(size, initial_value);
    }

    void initializeArr(T init)
    {
        setInitialValue(init);
        initializeArr();
    }

    T func(T x, T y);

    void update(long long idx, T value)
    {
        while (idx <= size)
        {
            arr[idx] = func(arr[idx], value);
            idx += (idx & -idx);
        }
    }

    T query(long long idx)
    {
        T ret = initial_value;
        while (idx > 0)
        {
            ret = func(ret, arr[idx]);
            idx -= (idx & -idx);
        }
        return ret;
    }
};

template <typename T>
T BinaryIndexedTree<T>::func(T x, T y)
{
    return max(x, y);
}

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

    int h;
    vector<int> h_idx(N + 1, 0);
    for (int i = 1; i <= N; i++)
    {
        cin >> h;
        h_idx[h] = i;
    }

    vector<long long> a(N + 1, 0);
    for (int i = 1; i <= N; i++)
    {
        cin >> a[i];
    }

    BinaryIndexedTree<long long> bit(N, 0);
    for (int i = 1; i <= N; i++)
    {
        int idx = h_idx[i];
        bit.update(idx, bit.query(idx - 1) + a[idx]);
    }

    cout << bit.query(N) << endl;
}


Measured memory_bytes: 4224
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
C = 0

for key in T:
    left = 0
    right = n
    while left < right:
        mid = (left + right) // 2
        if S[mid] == key:
            C += 1
            break
        elif key < S[mid]:
            right = mid
        else:
            left = mid + 1

print(C)



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int N, K; string S; cin >> N >> S >> K;
  K--;
  char c = S[K];
  string ans = "";
  for(int i = 0; i < S.size(); ++i) {
    if(S[i] == c) ans.push_back(c);
    else ans.push_back('*');
  }
  cout << ans << endl;

  return 0;
}


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

int n, k;

int main()
{
  cin >> n >> k;
  
  ll res = 0;
  for(int i = k + 1; i <= n; i++)
  {
    res += (n / i) * (i - k);
    if(k == 0)
    {
      res += n % i;
    }
    else if(n % i >= k)
    {
      res += n % i - k + 1;
    }
  }
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 256
import numpy as np
 
N, P = map(int, input().split())
A = list(map(int, input().split()))
odd = len([i for i in A if i%2!=0])
if odd==0 and P==0:
    ans = 2**N
elif odd==0 and P==1:
    ans = 0
else:
    ans = 2**(N-1)
print(ans)

Measured memory_bytes: 20544
import java.util.*;
  
public class Main{

     public static void main(String []args){
        Scanner sc = new Scanner(System.in);
     
        int[] alph = new int[26];
        int tmp;
        boolean answer = false;
        for(int i = 0; i<26; i++)
            alph[i] = 0;
            
        String S = sc.next();
        
        for(int i = 0; i<S.length(); i++){
            if(S.charAt(i) == 'a')
                alph[0]++;
            else{
                tmp = (int) S.charAt(i) - 'a';
                alph[tmp]++;
            }
        }
        
        for(int i =0; i<alph.length; i++){
            if(alph[i] > 1)
                answer = true;
        }
        if(answer == false)
            System.out.println("yes");
        else
            System.out.println("no");
    }
}

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

int main(){

    size_t n;
    std::cin >> n;

    std::vector<size_t> p(n);
    for(auto&& e : p){
        std::cin >> e;
    }

    size_t ans = 0;
    for(size_t i = 0; i < n; i++){
        if(i + 1 == p.at(i)){
            if(i == n - 1){
                std::swap(p.at(i), p.at(i - 1));
            }else{
                std::swap(p.at(i), p.at(i + 1));
            }
            ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 1024
import itertools,bisect

num_list = []
def toInt(arr):
    num = int(''.join(arr))
for i in range(3,10):
    num_list += list(itertools.product('753',repeat=i) )
num = []
for nm in num_list:
    if '3' in nm and '5' in nm and '7' in nm:
        num.append(int(''.join(nm)))
num.sort()

print(bisect.bisect_right(num,int(input())))


Measured memory_bytes: 13704
#pragma warning(disable:4996)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;

#define INF 0x3fffffff
typedef long long ll;

#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define pb push_back

const int maxn = 5e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }

int len, k;
char x[maxn];
int pos[maxn], ans[maxn];

void kmp()
{
	k = 0;
	memset(pos, 0, sizeof(pos));
	for (int i = 2; i <= len; i++)
	{
		while (k && x[k + 1] != x[i])
		{
			k = pos[k];
		}
		if (x[k + 1] == x[i])
		{
			k++;
		}
		pos[i] = k;
	}
}

void solve()
{
	scanf("%s", x + 1);
	len = strlen(x + 1);
	kmp();
	int L = 0;
	if (k&&len % (len - k) == 0)
	{
		L = (len - k);
	}
	if (L == 0)
	{
		printf("1\n1\n");
		return;
	}
	if (L == 1)
	{
		printf("%d\n1\n", len);
		return;
	}
	for (int i = 1; i <= len; i++)
	{
		ans[i] = (pos[i] == 0 || (i % (i - pos[i]) != 0));
	}
	reverse(x + 1, x + len + 1);
	kmp();
	int res = 0;
	for (int i = 1; i <= len; i++)
	{
		ans[len - i] &= (pos[i] == 0 || (i % (i - pos[i]) != 0));
		res += ans[len - i + 1];
	}
	printf("2\n%d\n", res);
}

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


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

#define _USE_MATH_DEFINES

const double PI = M_PI;
const double EXP = M_E;

using namespace std;

mt19937 mrand(random_device{} ());

int random(int a, int b) {
	return mrand() % (b - a + 1) + a;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;        
	vector<long long> s(n + 1);
	s[0] = 0LL;
	for (int i = 1; i <= n; i++) {
		long long t;
		cin >> t;
		s[i] = s[i - 1] + t;
	}			
	sort(s.begin(), s.end());
	long long ans = 0LL;
	int start = 0;
	int t = 0;
	while (start <= n) {
		while (start + t <= n && s[start] == s[start + t]) {
			t++;
		} 
		ans += (long long) t * (t - 1) / 2;
		start += t;
		t = 0;
	}
	cout << ans << endl;
	return 0;
}




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

int main(){
    string s;
    cin >> s;
    int N = s.size();
    string answer;
    for (int i = 0; i < N; ++i)
    {
        if (i % 2 == 0){
            answer += s[i];
        }
    }
    cout << answer << endl;
}

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

const int N = 2010;

struct edge {
    int to, next;
} e[N * 2];

int head[N], ecnt;

inline void adde(int from, int to) {
    e[++ecnt] = (edge){to, head[from]}, head[from] = ecnt;
    e[++ecnt] = (edge){from, head[to]}, head[to] = ecnt;
}

// sum: 子树内棋子个数 dp: 子树内最少操作步数
int sum[N], dp[N];

int val[N];

void dfs(int u, int f) {
    sum[u] = val[u], dp[u] = 0;
    for (int i = head[u]; i; i = e[i].next)
        if (e[i].to != f) {
            dfs(e[i].to, u);
            sum[u] += sum[e[i].to], dp[u] += dp[e[i].to] + sum[e[i].to];
        }
}

// 子树的最小剩余深度
int dfs2(int u, int f) {
    int mx = 0;
    for (int i = head[u]; i; i = e[i].next)
        if (e[i].to != f) 
            if (dp[e[i].to] >= dp[mx]) 
                mx = e[i].to;
    if (!mx) return 0;
    int tmp = dfs2(mx, u) + sum[mx];
    if (dp[u] - dp[mx] - sum[mx] >= tmp) return dp[u] & 1;
    return tmp - (dp[u] - dp[mx] - sum[mx]);
}

char s[N];

int main() {
    int n; scanf("%d%s", &n, s + 1);
    for (int i = 1; i <= n; i++) val[i] = s[i] == '1';
    for (int i = 1, a, b; i < n; i++) scanf("%d%d", &a, &b), adde(a, b);
    int res = 1e9;
    for (int i = 1; i <= n; i++) {
        dfs(i, 0);
        if (!dfs2(i, 0)) res = min(res, dp[i] / 2);
    }
    if (res < 1e8) printf("%d\n", res);
    else puts("-1");
    return 0;
}

Measured memory_bytes: 384
N = int(input())
S = input()
ans = 0
for i in range(10):
  l = 0
  while(True):
    if(i == int(S[l])):
      for j in range(10):
        m = l + 1
        while(True):
          if(j == int(S[m])):
            for k in range(10):
              for n in range(m+1, N):
                if(k == int(S[n])):
                  ans += 1
                  break
          m += 1
          if(m >= N - 1 or j == int(S[m - 1])):
             break
    l += 1
    if(l >= N - 2 or i == int(S[l - 1])):
      break
print(ans)

Measured memory_bytes: 43356
aI, aO, aT, aJ, aL, aS, aZ = map(int, input().split())
ans = aO
p = [aI, aJ, aL]
for i in range(3):
    if p[i] >= 2:
        if p[i] % 2 == 0:
            ans += (p[i] - 2) // 2 * 2
            p[i] = 2
        else:
            ans += p[i] // 2 * 2
            p[i] = 1
p.sort()
if sum(p) >= 5:
    ans += sum(p) // 2 * 2
elif sum(p) == 4:
    if p == [1, 1, 2]:
        ans += 3
    elif p == [0, 2, 2]:
        ans += 4
    else:
        assert(False)
elif sum(p) == 3:
    if p == [0, 1, 2]:
        ans += 2
    elif p == [1, 1, 1]:
        ans += 3
    else:
        assert(False)
elif sum(p) == 2:
    if p == [0, 0, 2]:
        ans += 2
    elif p == [0, 1, 1]:
        pass
    else:
        assert(False)
else:
    assert(sum(p) <= 1)
print(ans)


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i , n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    ll t = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    for(int i = n; i--;) {
        a[i] += t;
        t += (b[i] - a[i] % b[i]) % b[i];
    }
    cout << t << endl;
}


Measured memory_bytes: 4796
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int M = sc.nextInt();
			
			HashMap<Integer, HashSet<Integer>> speaks = new HashMap<Integer, HashSet<Integer>>();
			for(int i = 0; i < N; i++){
				final int K = sc.nextInt();
				
				for(int j = 0; j < K; j++){
					final int L = sc.nextInt();
					
					if(!speaks.containsKey(L)){
						speaks.put(L, new HashSet<Integer>());
					}
					
					speaks.get(L).add(i);
				}
			}
			
			UnionFind uf = new UnionFind(N);
			for(final Entry<Integer, HashSet<Integer>> entry : speaks.entrySet()){
				int prev_person = -1;
				for(final int person : entry.getValue()){
					if(prev_person < 0){
						prev_person = person;
					}else{
						uf.union(prev_person, person);
					}
				}
			}
			
			System.out.println(uf.size(0) == N ? "YES" : "NO");
		}
	}
	
	public static class UnionFind{
		int[] par; //
		
		public UnionFind(int n){
			par = new int[n];
			for(int i = 0; i < n; i++){ par[i] = -1; }
		}
		
		public int find(int x){
			if(par[x] < 0){
				return x;
			}else{
				return par[x] = find(par[x]);
			}
		}
		
		public boolean union(int x, int y){
			x = find(x);
			y = find(y);
			
			if(x != y){
				if(par[y] < par[x]) {  // 多い方が根になるようにスワップする.
					int tmp = x; x = y; y = tmp;
				}
				par[x] += par[y];
				par[y] = x;
				return true;
			}else{
				return false;
			}
		}
		
		public boolean same(int x, int y){
			return find(x) == find(y);
		}
		
		public int size(int x){
			return -par[find(x)];
		}
	}
	
	public static class Scanner implements AutoCloseable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() {
			try {
				while (!hasNext()) {tok = new StringTokenizer(br.readLine());}
			} catch(IOException e){ /* ignore */ }
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() {
			getLine(); return tok.nextToken();
		}

		public int nextInt(){
			return Integer.parseInt(next());
		}
		// 他のnextXXXもXXX.parseXXX()メソッドを使って作れるので省略

		public void close() {
			try{ br.close(); } catch (IOException e){ /*ignore*/ }
		}
	}
}


Measured memory_bytes: 47256
#include<stdio.h>

int main(void){
    int a,b;
    
    scanf("%d %d",&a,&b);
    
    if(a < b){
        printf("a < b\n");
    }else if(a > b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    return(0);
}


Measured memory_bytes: 2100
#include<iostream>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int yama,top1=0,top2=0,top3=0;
    for(int i=0;i<10;i++){
        cin >> yama;
        if(top1<yama){
            top3 = top2;
            top2 = top1;
            top1 = yama;
        }
        else if(top2<yama){
            top3 = top2;
            top2 = yama;
        }
        else if(top3<yama){
            top3 = yama;
        }
    }
    cout << top1 << "\n" << top2 << "\n" << top3 << "\n";
}

Measured memory_bytes: 3128
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    string s;
    cin >> s;
    int n = s.size() + 1;
    vl num(n, 0);
    ll chain = 1;
    ll ret   = 0;
    for (int i = 1; i < n; ++i) {
        if (s[i - 1] == ('<')) {
            if (i != 1 && s[i - 2] == '>') {
                if (num[i - 1] > 0) {
                    ret -= num[i - 1] * (chain - 1);
                    num[i - 1] = 0;
                }
            }
            num[i] = num[i - 1] + 1;
            ret += num[i];
            chain = 1;
        } else {
            num[i] = num[i - 1] - 1;
            ret += num[i];
            chain++;
            if (num[i] < 0) {
                num[i]++;
                ret += chain;
            }
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 4740
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
string s,t;
int main()
{
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<3;i++)
	{
		ans+=(s[i]==t[i]);
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(){
    string S;
    cin >> S;
    int c[100000];
    int c_max;
    int c_prev;
    for(int i = 0; i < 26; i++){
        //cout << char('a'+i)<< endl;
        if(S[0] - 'a' == i) c[0] = -1;
        else c[0] = 1;
        if(S[1] - 'a' == i) c[1] = c[0]-1;
        else c[1] = c[0]+1;
        if(c[1] < 0){
            cout << 1 << ' ' << 2 << endl;
            return 0;
        }
        c_max = c[0];
        int max_idx = 0;
        c_prev = c[1];
        for(int j = 2; j < S.size(); j++){
            if(S[j] - 'a' == i) c[j] = c[j-1]-1;
            else c[j] = c[j-1]+1;
            if(c[j] < 0) {
                cout << 1 <<  ' ' << j+1 << endl;
                return 0;
            }
            if(c[j] - c_max < 0) {
                cout << max_idx+2 <<  ' ' << j+1 << endl;
                return 0;
            } 
            if(c_max < c_prev){
                c_max = c_prev;
                max_idx = j-1;
            }
            c_prev = c[j];
        }
    }
    cout << -1 <<  ' ' << -1 << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

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

   if(n==m) cout << "Yes" << endl;
   else cout << "No" << endl;




   return 0;
}

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

void max_heapify(int* A, int i, int H)
{
    int l = 2 * i, r = 2 * i + 1;
    if(l > H && r > H) return;
    int maxid = i, x;
    if(l <= H) maxid = (A[l] > A[maxid] ? l : maxid);
    if(r <= H) maxid = (A[r] > A[maxid] ? r : maxid);
    if(maxid == i) return;
    x = A[maxid]; A[maxid] = A[i]; A[i] = x;
    max_heapify(A, maxid, H);
}

int main()
{
    int A[2000001];
    int i, H, key, x;
    char cmd[8];  // string cmd;
    scanf("%d", &H);
    for(i = 1; i <= H; i++) scanf("%d", &A[i]);
    H = 0;

    while(1){
        scanf("%s", cmd);  // cin >> cmd;
        if(cmd[2] == 'd') break;  // end.
        if(cmd[2] == 't'){  // extract.
            if(H == 0) continue;
            printf("%d\n", A[1]);
            A[1] = A[H]; H--;
            if(H > 0) max_heapify(A, 1, H);
        }else{
            cin >> key; H++;   // insert key.
            A[H] = key; i = H;
            while(i > 1){
                if(A[i] <= A[i / 2]) break;
                x = A[i];
                A[i] = A[i / 2];
                A[i / 2] = x;
                i = i / 2;
            };
        }
    };
    return 0;
}

Measured memory_bytes: 5320
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <string>
using namespace std;
int main() {
	int X; cin >> X;
	int N = X / 100;
	int M = N * 105;
	if (X > M) cout << 0 << endl;
	else cout << 1 << endl;
}

Measured memory_bytes: 256
N=int(input())
r_dic={}
for i  in range(N):
    s,p=input().split()
    r_dic.setdefault(s,[]).append((int(p),i+1))
    
for city in  sorted(r_dic.keys()):
    for data in (sorted(r_dic[city], reverse=True)):
        print(data[1])

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

typedef long long ll;
typedef char keytype;

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

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

const int inf = 1012345678;
int main(){
    int n;
    ll l[100];

    scanf("%d", &n);

    int first = n / 1000;
    int second = (n / 100) % 10;
    int third = (n / 10) % 10;
    int forth = n % 10;

    if(first == second && second == third) puts("Yes");
    else if(second == third && third == forth) puts("Yes");
    else puts("No");

    return 0;
}


Measured memory_bytes: 1600
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let taka: usize = it.next().unwrap().parse::<usize>().unwrap() - 1;
    let aoki: usize = it.next().unwrap().parse::<usize>().unwrap() - 1;
    let mut g = vec![vec![]; n];
    for _ in 1..n {
        let a: usize = it.next().unwrap().parse::<usize>().unwrap() - 1;
        let b: usize = it.next().unwrap().parse::<usize>().unwrap() - 1;
        g[a].push(b);
        g[b].push(a);
    }
    let mut parent = vec![aoki; n];
    let mut depth = vec![0; n];
    let mut stack = vec![aoki];
    while let Some(v) = stack.pop() {
        for &u in g[v].iter() {
            if u != parent[v] {
                parent[u] = v;
                depth[u] = depth[v] + 1;
                stack.push(u);
            }
        }
    }
    let mut ans = 0;
    let mut up = 0;
    let mut now = taka;
    while depth[now] >= up + 3 {
        now = parent[now];
        up += 1;
        ans += 1;
    }
    if (up - depth[now]) % 2 == 0 {
        ans += 1;
    }
    let mut stack = vec![(now, parent[now], 0)];
    let mut max = 0;
    while let Some((v, p, d)) = stack.pop() {
        max = std::cmp::max(d, max);
        for &u in g[v].iter() {
            if u != p {
                stack.push((u, v, d + 1));
            }
        }
    }
    ans += max;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 14588
//
// Created by Hideaki Imamura on 2020-03-15.
//
# include <bits/stdc++.h>

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

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

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

# define EPS (1e-7)
//# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;
const ll INF = 1LL << 60;

ll H, N;
vector<ll> A, B;

int main() {
    cin >> H >> N;
    for (int i = 0; i < N; ++i) {
        ll a, b;
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }

    vector<ll> dp(H + 1, INF);
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= H; ++j) {
            chmin(dp[min(j + A[i], H)], dp[j] + B[i]);
        }
    }
    cout << dp[H] << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
  long long int A,B,N;
  cin>>A>>B>>N;
  long long int x=0;
  if(N>=B-1){
    x=B-1;
  }
  else{
    x=N;
  }
  long long int ans=A*x/B-A*(x/B);
  cout<<ans<<endl;
}
  

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
int main(void) {
	// your code goes here
	int a,b;
	char s[1000],t[1000],u[1000];
	scanf("%s%s",&s,&t);
	scanf("%d%d",&a,&b);
	scanf("%s",&u);
	if(strcmp(u,s)==0)
		printf("%d %d",a-1,b);
	else
		printf("%d %d",a,b-1);
	
	return 0;
}


Measured memory_bytes: 128