akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint X;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> X;
	lint N = 360;
	REP(i, 361) {
		if (N % X == 0) {
			cout << N / X << endl;
			return 0;
		}
		N += 360;
	}
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;

int main(void){
    
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    
    long long ans = LLONG_MAX;
    
    // ハーフの2枚買ったときの繰り返し（残りはAとBの買ったときを考える）
    for(int i = 0; i <= 100000; i++){
        
        // ０枚からMAX枚のハーフピザを買ったときの値段の繰く返し
        // X - i , Y -i がマイナスの場合は０枚買ったこと
        long long price = (2 * i * C) + max( X - i, 0) * A + max( Y - i, 0) * B;
        ans = min(ans, price);
    }
    
    cout << ans << endl;
}


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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> X(M);
  for(int i=0;i<M;++i){
    cin>>X.at(i);
  }
  sort(X.begin(),X.end());

  if(M==1){
    cout<<0<<endl;
  }
  else{
  vector<int> distance(M-1);
  int X_width=X.at(M-1)-X.at(0);

  for(int i=0;i<M-1;++i){
    distance.at(i)=X.at(i+1)-X.at(i);
  }

  sort(distance.begin(),distance.end(),greater<int>());
  for(int i=0;i<min(N-1,M-1);++i){
    X_width=X_width-distance.at(i);
  }
    cout<<X_width<<endl;
}
}

Measured memory_bytes: 1024
def f(n):
  if n % 2 == 0:
    return n//2
  else:
    return 3 * n + 1

s = int(input())
a = [s]
B = True
i = 0
while B:
  a.append(f(a[i]))
  if a.count(f(a[i])) > 1:
    print(i+2)
    break
  i += 1
  

Measured memory_bytes: 9064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main() {
	char A,B;
	cin>>A>>B;
	if(A<B)
		cout<<"<"<<endl;
	else if(A==B)
		cout<<"="<<endl;
	else
		cout<<">"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#define N (1000000000+7)
typedef long long ll;
using namespace std;

int main(void){
    int n;
    cin>>n;
    int b[5]={5,12,17,24,31};
    while(n!=0){
        string s;
        vector<int>a(n),sum(n+1);
        for(int i=0;i<n;i++){
            cin>>s;
            a[i]=s.length();
        }
        sum[0]=0;
        int num=0;
        for(int i=1;i<=n;i++){
            sum[i]=sum[i-1]+a[i-1];
        }
        for(int i=1;i<n;i++){
            num=0;
            for(int j=i;j<=n;j++){
                if(sum[j]==b[num]){
                    num++;
                    //cout<<sum[j]<<endl;
                }
                if(num==5)break;
            }
            if(num==5){
                cout<<i<<endl;
                break;
            }
            //cout<<"ks"<<endl;
            for(int k=1;k<=n;k++)sum[k]-=a[i-1];
        }
        cin>>n;
    }
    return 0;
}


Measured memory_bytes: 3228
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] array = br.readLine().split(" ");
        int W = Integer.parseInt(array[0]);
        int H = Integer.parseInt(array[1]);
        int x = Integer.parseInt(array[2]);
        int y = Integer.parseInt(array[3]);
        int r = Integer.parseInt(array[4]);
        if(r<=x&&x<=W-r&&r<=y&&y<=H-r){
    		System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
	}
}

Measured memory_bytes: 17040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string S;
    int Q;
    cin >> S >> Q;
    deque<char> q;
    rep(i, S.size()){
        q.pb(S[i]);
    }
    int now = 0;
    rep(i, Q){
        int x;
        cin >> x;
        if(x == 1){
            now++;
        }
        else{
            int F;
            char c;
            cin >> F >> c;
            if((F+now)%2) q.push_front(c);
            else q.pb(c);
        }
    }
    if(now%2){
        while(!q.empty()){
            cout << q.back();
            q.pop_back();
        }
    }
    else{
        while(!q.empty()){
            cout << q.front();
            q.pop_front();
        }
    }
    cout << endl;
}

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

int main(){
	int n;
  	cin >> n;
  
  	int x = (n + 1000 - 1) / 1000; //n/1000の切り上げ計算
  	int ans = x * 1000 - n;
	cout << ans << endl;
}

Measured memory_bytes: 3624
N=int(input())
A=[int(i) for i in input().split()]
S1,S2=[],[]
if A[0]>0:
  S1.append(A[0])
  S2.append(-1)
  a1,a2=0,A[0]+1
elif A[0]==0:
  S1.append(1)
  S2.append(-1)
  a1,a2=1,1
else:
  S1.append(1)
  S2.append(A[0])
  a1,a2=-A[0]+1,0
for i in range(1,N):
  if S1[i-1]>0:
    if S1[i-1]+A[i]<0:
      S1.append(S1[i-1]+A[i])
    elif S1[i-1]+A[i]>=0:
      S1.append(-1)
      a1+=S1[i-1]+A[i]+1
  elif S1[i-1]<0:
    if S1[i-1]+A[i]>0:
      S1.append(S1[i-1]+A[i])
    elif S1[i-1]+A[i]<=0:
      S1.append(1)
      a1+=-S1[i-1]-A[i]+1
  if S2[i-1]>0:
    if S2[i-1]+A[i]<0:
      S2.append(S2[i-1]+A[i])
    elif S2[i-1]+A[i]>=0:
      S2.append(-1)
      a2+=S2[i-1]+A[i]+1
  elif S2[i-1]<0:
    if S2[i-1]+A[i]>0:
      S2.append(S2[i-1]+A[i])
    elif S2[i-1]+A[i]<=0:
      S2.append(1)
      a2+=-S2[i-1]-A[i]+1
print(min(a1,a2))

Measured memory_bytes: 72788
using System;

public class Test
{
	public static void Main()
	{
		int a = int.Parse(Console.ReadLine());
		int b = int.Parse(Console.ReadLine());
		int c = int.Parse(Console.ReadLine());
		int d = int.Parse(Console.ReadLine());
		int ans = 0;
		for(int i =1;i<=a;i++){
			if(i<=b){
				ans = ans + c;
			}else{
				ans = ans +d;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 2776
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#define ll long long

using namespace std;

int n;
vector< vector< vector<int> > > t;
vector<int> ho(20,0);
int check( int num ){
    //if( num == 3 )
      //cout << num << endl;
    for( int i = 0 ; i < n ; i++ ){
        if( num & (1 << i)  ){
            ho[i] = 1;
        }
    }
    for( int i = 0 ; i < n ; i++ ){
        if( ho[i] == 1 ){
            for( int j = 0 ; j < t[i].size() ; j++ ){
                if( t[i][j][1] == 1 && ho[t[i][j][0]] == 0 ) return 0;
                if( t[i][j][1] == 0 && ho[t[i][j][0]] == 1 ) return 0;
            }
        }
    }
    return 1;
}
int calc1( int num ){
    int cnt = 0;
    while( num > 0 ){
        if( num % 2 ) cnt++;
        num = num / 2;
    }
    return cnt;
}
int main(){
    cin >> n;
    for( int i = 0 ; i < n ; i++ ){
        int cntai;
        cin >> cntai;
        vector<vector<int>> ai( cntai , vector<int>(2,0));
        for( int j = 0 ; j < cntai ; j++ ){
            int x,y;
            cin >> x >> y;
            ai[j][0] = x-1;
            ai[j][1] = y;
        }
        t.push_back( ai );
    }
    /*
    for( int i = 0 ; i < n ; i++ ){
        for( int j = 0 ; j < t[i].size() ; j++ ){
            cout << t[i][j][0] << " " << t[i][j][1] << ",";
        }
        cout <<  endl;
    }
     */
    int ret = 0;
    for( int st = (1 << n) - 1 ; st >= 0 ; st-- ){
        for( int k = 0 ; k < n ; k++ ) ho[k] = 0;
        if( check(st) == 1 ){
            
            ret = max( ret , calc1(st));
        }
    }
    cout << ret << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        x: usize
    }
    let mut ans = n;
    let mut b = min(x, n - x);
    let mut a = n - b;
    loop {
        let c = a / b;
        let d = a % b;
        if d == 0 {
            ans += (2 * c - 1) * b;
            break;
        }
        ans += 2 * c * b;
        a = b;
        b = d;
    }
    println!("{}", ans);
}


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

using namespace std;

int main()
{
    long long int a,i,j=1;

    cin>> a;

    long long int A[a];

    for(i=0;i<a;i++)
    {
        cin>> A[i];

        if(i>0)
        {
            if(A[i-1] >= A[i]) j++;

            else A[i]= A[i-1];
        }
    }

    cout<< j<< endl;

    return 0;
}


Measured memory_bytes: 5128
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
using namespace std;

int main(){
	while(1){
		int n, m, atari, d;
		int a[10]; //amida
		string s[30];
		
		scanf(" %d", &n);
		if(n==0) break;
		
		for(int i=0; i<n; ++i) a[i]=i+1;
			
		scanf(" %d %d %d", &m, &atari, &d);
		for(int i=0; i<d; ++i) cin >> s[i];
			
		for(int i=0; i<d; ++i){
			for(int j=0; j<s[i].size(); ++j){
				if(s[i][j]=='1') swap(a[j], a[j+1]);	
			}
		}
		if(m == a[atari-1]){ // 線を引く必要がない
			printf("0\n");
			continue;	
		}
		
		bool flag=true;
		//横線を1つだけ足す
		for(int i=0; i<d; ++i){
			for(int j=0; j<s[i].size(); ++j){
				if(s[i][j]=='1') continue;
				
				int l=j-1, r=j+1;
				if(l>=0 && s[i][l]=='1') continue;
				if(r<n && s[i][r]=='1') continue; 
				
				for(int k=0; k<n; ++k) a[k]=k+1;
				string t[30];
				for(int x=0; x<d; ++x) t[x]=s[x];
				
				t[i][j]='1';
				
				/*
				printf("\n");	
				printf("%d %d\n",i+1 ,j+1);
				for(int x=0; x<d; ++x) cout<<t[x]<<endl;
				printf("\n");
				*/
				
				for(int x=0; x<d; ++x){
					for(int y=0; y<t[x].size(); ++y){
						if(t[x][y]=='1') swap(a[y], a[y+1]);	
					}
				}
				
				/*
				for(int k=0; k<n; ++k) printf("%d ", a[k]);
				printf("\n");
				*/
				
				if(m == a[atari-1]){ // 線を引いたらうまくいった
					printf("%d %d\n",i+1 ,j+1);
					flag=false;
				}	

				if(!flag) break;			
			}
			if(!flag) break;
		}
		
		if(flag) printf("1\n");
	}
}

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

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

    int a;
    cin >> a;

    cout << a+a*a + a*a*a << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

const int N=1<<20 ;

int a[N] ;
int n , m , k ;

int main ()
{
	int i , j , l , x=0 ;
	scanf("%d%d",&m,&k),n=(1<<m);
	if ( m==0 )
	{
		if ( k==0 ) puts("0 0");
		else puts("-1");
		return 0 ;
	}
	for ( i=0 ; i<n ; i++ ) x^=i; x^=k;
	if ( k>=n || (k>0&&k!=x) ) return puts("-1")*0;
	if ( m==1 )
	{
		if ( k==0 ) puts("0 0 1 1");
		return 0 ;
	}
	for ( x=0 ; x<n ; x++ ) 
		if ( x^k ) break;
	a[2]=k,a[1]=a[3]=x;
	for ( i=1,j=4,l=n*2 ; i<n ; i++ ) 
		if ( i^k && i^x ) a[j]=a[l]=i,j++,l--;
	a[j]=k;
	for ( i=1 ; i<=2*n ; i++ ) printf("%d ",a[i]);
	return 0 ;
}

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	ll A,B,N; cin >> A >> B >> N;
	corner(B==1,0);
	corner(B>N,ll(A*N/B) - A * (ll)(N/B) );
	ll M = N / B;
	ll K = M*B + B-1;
	while(K>N) K -= B;
	ll X = (A*K)/B;
	ll Y = K/B;
	cout << X-A*Y << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for(int i=1;i<=505050;i++){
        int res = i * 1.08;
        if(res == N){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=2005;
int a[3*maxn],maxx[maxn][maxn],maxval[maxn],nxtval[maxn];
void chmax(int &x,int y)
{
    x=max(x,y);
    return;
}
void upd(int val,int t,int x,int y)
{
    if(val==-1) return;
    int nxt=max(maxx[x][y],val+t);
    maxx[x][y]=maxx[y][x]=nxt;
    chmax(nxtval[x],nxt);
    chmax(nxtval[y],nxt);
    return;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=3*n;i++)
        scanf("%d",&a[i]);
    memset(maxx,-1,sizeof(maxx));
    memset(maxval,-1,sizeof(maxval));
    maxx[a[1]][a[2]]=maxx[a[2]][a[1]]=0;
    maxval[a[1]]=maxval[a[2]]=0;
    int add=0;
    for(int i=1;i<n;i++)
    {
        memset(nxtval,-1,sizeof(nxtval));
        int u=a[i*3],v=a[i*3+1],w=a[i*3+2];
        if(u==v&&v==w) {add++; continue;}
        else if(u==v||v==w||w==u)
        {
            int p=max(min(u,max(v,w)),min(v,w)),q=u+v+w-2*p;
            for(int nxt=1;nxt<=n;nxt++)
            {
                if(nxt==p||nxt==q) continue;
                upd(maxx[p][nxt],1,q,nxt);
            }
            int tmp=maxx[q][q];
            upd(maxx[p][q],1,q,q);
            upd(maxx[p][p],1,p,q);
            upd(tmp,1,p,p);
        }
        else
        {
            upd(maxx[u][u],1,v,w);
            upd(maxx[v][v],1,u,w);
            upd(maxx[w][w],1,u,v);
        }
        for(int nxt=1;nxt<=n;nxt++)
        {
            upd(maxval[nxt],0,u,nxt);
            upd(maxval[nxt],0,v,nxt);
            upd(maxval[nxt],0,w,nxt);
        }
        int allmax=-1;
        for(int j=1;j<=n;j++)
            chmax(allmax,maxval[j]);
        upd(allmax,0,u,v);
        upd(allmax,0,u,w);
        upd(allmax,0,v,w);
        for(int j=1;j<=n;j++)
            maxval[j]=max(maxval[j],nxtval[j]);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        for(int j=i;j<=n;j++)
            if(~maxx[i][j])
                chmax(ans,maxx[i][j]+(i==a[3*n]&&j==a[3*n]));
    printf("%d\n",ans+add);
    return 0;
}
/*
2
1 2 1 2 2 1
 
2
 
 
3
1 1 2 2 3 3 3 2 1
 
1
 
 
3
1 1 2 2 2 3 3 3 1
 
3
 
 
3
1 2 3 2 3 1 2 3 1
 
1
 
 
4
1 1 3 3 3 2 3 3 2 3 3 2
 
3
 
 
 (p,q)->(q,q)
 (p,p)->(p,q)
 (q,q)->(p,p)
  */


Measured memory_bytes: 19508
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================
 
vi g[N];
char f(string s){
	char x = s[0];
	return x-'a'+'A';
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,n,k,j;
	string a,b,c;
	cin >> a >> b >> c;
	cout<<f(a)<<f(b)<<f(c);
 
	return 0;
} 

Measured memory_bytes: 7296
N,W = map(int,input().split())
w = [0]*N
v = [0]*N
for i in range(N):
    w[i], v[i] = map(int,input().split())

dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j >= w[i]:
            dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[N][W])

Measured memory_bytes: 120044
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}

void main()
{
  int r; readV(r);
  int g; readV(g);
  writeln(2*g-r);
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt(), W = sc.nextInt();
		int h = sc.nextInt(), w = sc.nextInt();
		int a = H-h, b = W-w;
		System.out.println(a*b);
	}

}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	vector<int> vec(3);
	cin >> vec[0] >> vec[1]>> vec[2];

	sort(begin(vec), end(vec));
	cout << vec[2] * 10 + vec[0] + vec[1] << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	H := sc.nextInt()
	count := 1
	num := 1
	for H != 1 {
		H /= 2
		num *= 2
		count += num
	}

	fmt.Fprintln(wtr, count)
	wtr.Flush()
}


Measured memory_bytes: 640
// author @hello_hell
#include <stdio.h>
#include <climits>
using namespace std;
int main(void){
    int n;scanf("%d",&n);
    int *arr = new int[n];
    for(int i=0;i<n;++i){
        scanf("%d",&arr[i]);
    }
    int counter{};
    int min_ = INT_MAX;
    for(int i=0;i<n;++i){
        if(min_>=arr[i]){
            counter++;
            min_ = arr[i];
        }
    }
    printf("%d",counter);
    return 0;
}

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

int main(void){
  string s;
  int i;

  cin >> s;
  bool isgood = true;
  for(i=0;i<s.length()-1;i++){
    if(s[i] == s[i+1]){
      isgood = false;
    }
  }
  if(isgood){
    cout << "Good" <<endl;
  } else {
    cout << "Bad" <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

vector<int> col[100010];

int main() {
	int N, A, am = 0;
	ll ans = 1;
	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> A;
		am = max(A, am);
		col[A].push_back(i);
	}
	int osz = col[0].size(), sz, cnt = 0;
	if (osz == 1) {
		ans = 3;
	}
	else {
		ans = 6;
	}
	if (osz > 3) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1;i <= am;i++) {
		cnt = 0;
		sz = col[i].size();
		if (sz > osz) {
			cout << 0 << endl;
			return 0;
		}
		if (sz == 1) {
			for (int j = 0;j < osz;j++) {
				if (col[i][0] > col[i - 1][j])
					cnt++;
			}
		}
		else if (sz == 2) {
			for (int j = 0;j < osz;j++) {
				for (int k = 0;k < osz;k++) {
					if (j == k)continue;
					if (col[i][0] > col[i - 1][j] && col[i][1] > col[i - 1][k]) {
						cnt++;
					}
				}
			}
		}
		else if (sz == 3) {
			for (int j = 0;j < osz;j++) {
				for (int k = 0;k < osz;k++) {
					for (int l = 0;l < osz;l++) {
						if (j == k)continue;
						if (j == l)continue;
						if (k == l)continue;
						if (col[i][0] > col[i - 1][j] && col[i][1] > col[i - 1][k] && col[i][2] > col[i - 1][l]) {
							cnt++;
						}
					}
				}
			}
		}
		else {
			cout << 0 << endl;
			return 0;
		}
		ans *= cnt;
		ans %= MOD;
		osz = sz;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5760
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < sz(s); i++) {
    if (i % 2 == 0 && s[i] == 'p') {
      ans--;
    } else if (i % 2 == 1 && s[i] == 'g') {
      ans++;
    }
  }
  cout << ans << "\n";
}



Measured memory_bytes: 512
import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint

sys.setrecursionlimit(1000000)
# MOD = 10 ** 9 + 7
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]

N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse=True)
a = sum(A[0::2])
b = sum(A[1::2])

print(a - b)


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
# define LL          long long
# define pr          pair
# define mkp         make_pair
# define lowbit(x)   ((x)&(-x))
# define PI          acos(-1.0)
# define INF         0x3f3f3f3f3f3f3f3f
# define eps         1e-8
# define MOD         1000000007
# define MX          300

int h,w;
int sp[MX][MX];
int mp[MX][MX];

int main()
{
    scanf("%d%d",&h,&w);
    for (int i=0;i<10;i++)
        for (int j=0;j<10;j++)
            scanf("%d",&sp[i][j]);
    for (int i=0;i<10;i++)
    {
        for (int j=0;j<10;j++)
        {
            for (int k=0;k<10;k++)
            {
                sp[j][k] = min(sp[j][k],sp[j][i]+sp[i][k]);
            }
        }
    }

    for (int i=0;i<h;i++)
        for (int j=0;j<w;j++)
        scanf("%d",&mp[i][j]);

    LL all=0;
    for (int i=0;i<h;i++)
        for (int j=0;j<w;j++)
            if (mp[i][j]!=-1)
                all+=sp[mp[i][j]][1];
    printf("%lld\n",all);

    return 0;
}


Measured memory_bytes: 512
import re
from collections import Counter
s = input()
res = re.finditer(r"(<+>+)|(^>+)|(<+$)", s)

def calc(string):
    ct = Counter(string)
    cnt_d = ct[">"]
    cnt_s = ct["<"]
    if cnt_s > cnt_d:
        return (cnt_s * (cnt_s + 1) + (cnt_d - 1) * cnt_d) // 2
    elif cnt_s == cnt_d:
        return cnt_s * cnt_s
    else:
        return ((cnt_d + 1) * cnt_d + (cnt_s - 1) * cnt_s) // 2
score = 0
for r in res:
    score += calc(r.group())
print(score)

Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second
#define MP make_pair
#define PB push_back

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
  int count = 0 ;
  int n ;
  cin >> n ;
  vector<int> a(n) ;
  REP(i,n){
    cin >> a.at(i) ;
  }
  
  int i = 0 ;
  while(i<n){
    if(a.at(i)%2==0){
      count++ ;
      a.at(i) = a.at(i)/2 ;
    }
    else{
      i++ ;
    }
  }
  
  cout << count <<endl ;
  

  return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int n = Integer.parseInt(sc.next());

		long ans = ((long) (n - 1) * (long) n / 2);

		System.out.println(ans);

		sc.close();
	}
}

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

int main(){
  ll A,B,N;
  cin >> A >> B >> N;
  
  ll x = min(N,B);
  if (B == x) x -= 1LL;
  cout << (A*x/B) - A*(x/B) << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a>>b>>c;
  cout<<max(0LL,c-(a-b))<<endl;
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int MAX = 100005;
/* global variables */
/* function */
bool isPrime(int x) {
    if (x <= 1) return false;
    if (x == 2) return true;
    if (x % 2 == 0) return false;
    for (int i = 3; i * i <= x; i += 2) {
        if (x % i == 0) return false;
    }
    return true;
}
/* main */
int main() {
    vector<bool> p(MAX);
    for (int i = 1; i < MAX; i++) p[i] = isPrime(i);
    vector<int> a(MAX);
    for (int i = 1; i <= 100000; i += 2) if (p[i] && p[(i + 1) / 2]) a[i] = 1;
    vector<int> sum(MAX);
    for (int i = 1; i <= 100000; i++) sum[i+1] = sum[i] + a[i];
    int Q, l, r;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        cin >> l >> r;
        cout << sum[r + 1] - sum[l] << '\n';
    }
}

Measured memory_bytes: 1408
K, N = map(int, input().split())
loc = list(map(int, input().split()))
distances = []
total = []

for i in range(N-1):
    distances.append(loc[i+1] - loc[i])

distances.append(loc[0] + K - loc[N-1])

for i in range(N):
    total.append(K - distances[i])

print(min(total))


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

int kind[100100];

int main(){
  ll N,M; cin >> N >> M;
  
  vector<ll> vec(M,0); // vec[i]はMで割ってi余る要素の個数
  vector<ll> same(M,0); // same[i]はMで割ってi余るグループのうち同一なものの個数
  
  
  for(int i = 0; i < N; i++){
    ll X; cin >> X; kind[X]++;
    vec[X%M]++;
  }
  
  for(ll i = 0; i < 100100; i++){
    same[i%M] += (kind[i]/2)*2;
    }
  
  ll cnt = 0;
  
  // == 0 or == M/2は特別扱い
  cnt += vec[0]/2;
  if( M%2 == 0 ){ cnt += vec[(M/2)]/2;}
  
  for(ll x = 1; x <= (M-1)/2; x++){
    // x と M-xについてみる
    ll r1 = vec[x];
    ll r2 = vec[M-x];
    
    ll res = min(r1,r2); //両方の組みからできるペアの数は以下の通り
    
    cnt += res;
    
    same[x] -= max(0LL,res-(vec[x]-same[x])); //ここがおかしい
    same[M-x] -= max(0LL,res-(vec[M-x]-same[M-x]));
    
  }
  
  
  //残りは同じグループ同士で、同じ数をくっつけあう
  if( M % 2 == 0){ same[M/2] = 0;}
  
  for(int x = 1; x <= M-1; x++){
    
    cnt += max(0LL,same[x])/2;
    
  }
  
  cout << cnt << endl;
  
  
  return 0;
}
   

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

int main(){
  string s;
  cin >> s;
  int count = 0;
  for (int i = 0; i < (s.size() - 1); i++){
    if (s.at(i) != s.at(i + 1)) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 512
-- AOJ: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2006
import Data.List.Split
import Control.Monad.Cont
import Control.Applicative

solve :: String -> String
solve s = let ws = splitOn "0" s
              wss = filter (\x -> x /= "") ws
           in map (\x -> keyToChar x) wss

keyToChar :: []Char -> Char
keyToChar all@(x:xs) = toChar x $ length all

toChar :: Char -> Int -> Char
toChar x n = case x of
               '1' -> solveEx (n-1) ".,!? "
               '2' -> solveEx (n-1) "abc"
               '3' -> solveEx (n-1) "def"
               '4' -> solveEx (n-1) "ghi"
               '5' -> solveEx (n-1) "jkl"
               '6' -> solveEx (n-1) "mno"
               '7' -> solveEx (n-1) "pqrs"
               '8' -> solveEx (n-1) "tuv"
               '9' -> solveEx (n-1) "wxyz"

solveEx :: Int -> [Char] -> Char
solveEx n xs = xs !! (n `mod` length xs)

main = do
    ns <- (map read . words) <$> getLine
    let n = ns !! 0
     in forM_ [0..(n-1)] $ \i ->  do
         ss <- getLine
         putStrLn $ solve ss

Measured memory_bytes: 4228
def invert_letter(letter):
    inv_letter=""
    for c in letter:
        inv_letter+=c.upper() if c.islower() else c.lower()
    return inv_letter

def run():
    letter_list=list(input().split())
    
    inv_letter_list=[]
    
    for letter in letter_list:
        inv_letter=invert_letter(letter)
        inv_letter_list.append(inv_letter)
        
    
    line_letter=" ".join(inv_letter_list)
    
    print(line_letter)

run()


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

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

using namespace std;

int main()
{
	ll l; cin>>l;
	string s; cin>>s;
	ll ans=0;
	rep(i, l){
		if (s[i]!='.') continue;
		ll idx=i-1;
		int D=0;
		while(idx>=0){
			if (s[idx]=='B'){D++; break;}
			if (s[idx]=='.') break;
			idx--;
		}
		idx=i+1;
		while(idx<l){
			if (s[idx]=='B'){D++; break;}
			if (s[idx]=='.') break;
			idx++;
		}
		if (D==2) continue;
		ll sum=0;
		idx=i-1;
		ll cnt=0;
		while(idx>=0){
			if (s[idx]=='.') break;
			if (s[idx]=='B') cnt++;
			if (s[idx]=='W'){
				sum+=cnt;
				break;
			}
			idx--;
		}
		cnt = 0;
		idx=i+1;
		while(idx<l){
			if (s[idx]=='.') break;
			if (s[idx]=='B') cnt++;
			if (s[idx]=='W'){
				sum+=cnt;
				break;
			}
			idx++;
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
	return 0;
}


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


int n;
int temp;

int main()
{
    cin >> n;
    bool found = false;

    for(int i = 0; i < n; i++) {
        cin >> temp;
        if(!(temp&1)) {
            if(!(temp%3==0 || temp%5==0))
                found = true;
        }
    }
    if(found)
        cout << "DENIED" << endl;
    else
        cout << "APPROVED" << endl;

    return 0;
        
}


Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
    }

    let mut ans = 0;

    //pair
    let pairb = (n / (a + b)) * a;
    let pairmod = (n % (a + b));
    if pairmod < a {
        ans = pairb + pairmod;
    }else{
        ans = pairb +  a;
    }

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


Measured memory_bytes: 4352
package main

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

var empty = byte('.')

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	rdr := NewReader()

	grid := make([][]byte, h)
	for i := 0; i < h; i++ {
		grid[i] = rdr.Bytes()
	}

	var dp [1001][1001]int
	dp[0][0] = 1

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if i+1 < h && grid[i+1][j] == empty {
				dp[i+1][j] = (dp[i][j] + dp[i+1][j]) % Mod
			}
			if j+1 < w && grid[i][j+1] == empty {
				dp[i][j+1] = (dp[i][j] + dp[i][j+1]) % Mod
			}
		}
	}

	fmt.Println(dp[h-1][w-1])
}

// generated by https://github.com/murosan/gollect

const Mod = 1000000007

type Reader struct {
	r    *bufio.Reader
	size int
	sep  string
}

func NewReader() *Reader {
	size := 4096
	return &Reader{
		r:    bufio.NewReaderSize(os.Stdin, size),
		size: size,
		sep:  " ",
	}
}

func (rdr *Reader) Bytes() []byte {
	buf := make([]byte, 0, rdr.size)
	for {
		line, isPrefix, err := rdr.r.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return buf
}


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

int N;
vector<int> B;

int main(void) {
	cin >> N;
	B.resize(N + 1);
	for (int i = 1; i <= N; ++i)
		cin >> B[i];

	int btn = 1;
	int cnt = 1;
	for (int i = 1; i <= N + 1; ++i) {
		if (B[btn] == 2)
			break;
		if (B[btn] == -1) {
			cnt = -1;
			break;
		}
		int use = btn;
		btn = B[btn];
		B[use] = -1;
		++cnt;
	}

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


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int cou = 0;
    for(int i=1; i<=b; i++) {
    	if(k*i>=a && k*i<=b) {
    		cou++;
    		}
    }
    if(cou != 0){
    	System.out.println("OK");
    }else{
    	System.out.println("NG");
      }
}
}

Measured memory_bytes: 35740
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n, a[201];

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

    int res = 100000;

    for (int i = 0; i < n; i++)
    {
        int cnt = 0;
        while (a[i] % 2 == 0)
        {
            a[i] /= 2;
            cnt++;
        }

        res = min(res, cnt);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Mod = (ll) (1e9) + 7;
//bitでの掛け算。1がたっている場合掛ける。
//掛けた後自乗して次の掛け算に備えビット下げる。0になるまで繰り返し
//Mod-2=11 1011 1001 1010 1100 1010 0000 0101
ll cpow(ll a, ll b) {
  ll res = 1;
  while(b){
    if(b & 1) res = (res*a) % Mod;
    a = (a*a) % Mod;
    b >>= 1;
  }
  return res % Mod;
}
ll combination(ll n, ll r) {
  if (r * 2 > n)
    r = n - r;
  ll nd = 1;
  ll rd = 1;
  //n!/r!(n-r)!なので(n!から(n-r)!で割った数/r!)となるためrだけかければいい
  for (ll i = 1; i <= r; ++i) {
    nd *= (n - i + 1);
    nd %= Mod;
    rd *= i;
    rd %= Mod;
  }
  //フェルマーの小定理a^(p-1)≡1 mod p
  //a^(p-2)≡1/a mod p
  //aで割ることはa^(p-2)を掛けることに等しい pはMod
  return nd * cpow(rd, Mod - 2);
}
int main() {
  ll x, y;
  cin >> x >> y;
  //(+2,+1)or(+1,+2)なので3で割れない場合その座標にはいきつかない
  if ((x + y) % 3 != 0) {
    cout << 0;
    return 0;
  }
  //n+2m=x,2n+m=y
  //n+2(y-2n)=x 2y-x=3n
  //2(x-2m)+m=y 2x-y=3m
  //nとmは交換可
  ll n = (2 * y - x) / 3; //(+2,+1)する回数
  ll m = (2 * x - y) / 3; //(+1,+2)する回数

  //0未満の場合片方の座標が2倍以上なのでその座標には行きつかない
  if (n < 0 || m < 0) {
    cout << 0;
    return 0;
  }
  //n+m中いつmの移動するかを求めるのでn+mCm
  //nCr=nCr-1なのでn+mCnでも可
  cout << combination(n + m, m) % Mod;
}


Measured memory_bytes: 256
N = input()

# N の 1 の位が 2 , 4 , 5 , 7 , 9 のとき hon 
# N の 1 の位が 0 , 1 , 6 , 8 のとき pon 
# N の 1 の位が 3 のとき bon

if N[-1] in ["2" , "4" , "5" , "7" , "9"]:
    print("hon")

elif N[-1] in ["0" , "1" , "6" , "8"]:
    print("pon")

elif N[-1] in ["3"]:
    print("bon")


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

int main(){
    
    string X;
    cin>>X;
    int N=X.size();
    stack<pair<int,char>> S;
    int cnt=0;
    for(int i=N-1;i>=0;i--){
        if(i==N-1) cnt++;
        else if(X[i]==X[i+1]) cnt++;
        else{
            S.push(make_pair(cnt,X[i+1]));
            cnt=1;
    }
    }
    S.push(make_pair(cnt,X[0]));
    int sum=0;
    pair<int,char> a,b;
    while(S.size()>1){
        a=S.top();
        if(a.second=='T'){
            sum+=a.first;
            S.pop();
        }
        else{
            S.pop();
            b=S.top();
            S.pop();
            if(b.second=='S'){
                S.push(make_pair(a.first+b.first,'S'));
            }
            else{
                if(a.first>b.first){
                    S.push(make_pair(a.first-b.first,'S'));
                }
                else if(a.first<b.first){
                    sum+=(b.first-a.first);
                }
            }
        }
    }
    if(S.size()){
        sum+=S.top().first;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 1284
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var arr = []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}

	fmt.Println(arr[n - 1])
}


Measured memory_bytes: 512
#include <iostream>
#include <map>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <string>
#include <set>
#include <valarray>
#include <iomanip>
#include <bitset>
#include <random>
#include <complex>
#include <random>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define pb push_back
#define ll long long
#define mp make_pair
#define fdeg firdeg
#define snd second
#define ld long double
#define mt make_tuple
#define fst firs
const double PI = acos(-1);
const int N = 5e6 + 17;
ll MOD = 1e9 + 7;
const int INF = 1e9 + 9;
const int MAXN = 26;
const int maxlog = 18;
ld eps = 1e-8;
random_device rd;
mt19937 rnd(rd());
uniform_int_distribution<ll> nextRand(0,(ll)1e9);
template<class A, class B>
void sum(A &a, B b)
{
    a += b;
    if (a < 0LL) a += MOD;
    if (a >= MOD) a -= MOD;
}
ll add(ll a, ll b)
{
    a += b;
    if (a < 0) a += MOD;
    if (a >= MOD) a -= MOD;
    return a;
}
int to_i(char c)
{
    return c - 'a';
}
ll mult(ll a, ll b)
{
    ll res = a * b - (ll) ((ld) a * b / MOD) * MOD;
    if (res < 0)
    {
        res += MOD;
    }
    if (res >= MOD)
    {
        res -= MOD;
    }
    return res;
}
ll gcd (ll a, ll b, ll & x, ll & y)
{
    if (a == 0)
    {
        x = 0LL; y = 1LL;
        return b;
    }
    ll x1, y1;
    ll d = gcd (b%a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
long long poww(long long a, long long b)
{
    long long res = 1;
    a %= MOD;
    while (b > 0)
    {
        if (b % 2) res = mult(a, res);
        a = mult(a, a);
        b >>= 1;
    }
    return res % MOD;
}
ll inv(ll a)
{
    return poww(a , MOD - 2);
}
int ans = 1e9;
int sm(int x)
{
    string s = to_string(x);
    int res = 0;
    for(auto c : s)
    {
        res += c - '0';
    }
    return  res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(time(0));
    int n;
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int x = n - i;
        ans = min(sm(x) + sm(i) , ans);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
def horizontal_input(T=str):
    return list(map(T,input().split()))

def vertical_input(n,T=str,sep=False,septype=tuple):
    data=[]
    if sep:
        for i in range(n):
            data.append(septype(map(T,input().split())))
    else:
        for i in range(n):
            data.append(T(input()))
    return data

a,b,c=horizontal_input(int)
count=0
time=0
f=True
past=0
alltime=0
while count<70:
    if f:
        time=(time+a)%60
    else:
        time=(time+b)%60
    if f and (past<=c<=time or (past>=time and (0<c<=time or past<=c<60))):
        print(alltime+(c-past if past<=c<60 else 60-past+c))
        break
    elif f:
        alltime+=a
    else:
        alltime+=b
    if past>=time:
        count+=1
    past=time
    f=not f
else:
    print(-1)


Measured memory_bytes: 5612