akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n,0);
	for(int i=0;i<n;i++){
		cin >> a[i];	
	}
	sort(a.begin(),a.end(),greater<int>());
	int alice=0,bob=0;
	for(int i=0;i<n;i++){
		if(i%2==0)alice+=a[i];
		else bob+=a[i];	
	}
	int ans=alice-bob;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}
ll n,m;
bool ok(ll a,ll b){
    return a>=0&&b>=0&&a<n&&b<m;
}
ll dx[8]={1,0,-1,0,1,-1,1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};

int main(){
    IOS;
    make2(ll,n,m);
    vector <array <ll,2> >st(n),chp(m);
    fr(i,n) cin>>st[i][0]>>st[i][1];
    fr(i,m) cin>>chp[i][0]>>chp[i][1];
    vector <ll> ans(n);
    //sort(chp.begin(),chp.end());
    fr(i,n){
        ll mini=INF;
        fr(j,m){
            mini=min(mini,abs(chp[j][0]-st[i][0])+abs(chp[j][1]-st[i][1]));
        }
        fr(j,m){
            if(abs(chp[j][0]-st[i][0])+abs(chp[j][1]-st[i][1])==mini) {ans[i]=j+1; break;}
        }
    }
    for(auto x : ans) cout<<x<<endl;

    return 0;
}


Measured memory_bytes: 3592
#!python3

# input
N = int(input())
A = list(map(int, input().split()))


def p2(x):
    ret = 0
    while x % 2 == 0:
        ret += 1
        x //= 2
    return ret


def main():
    ans = 0
    for a in A:
        ans += p2(a)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4148
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int r = N / 100;
	if(111 * r >= N) cout << 111 * r << endl;
	else {
		int rsl = 111 * (r + 1);
		cout << rsl << endl;
	}
}


Measured memory_bytes: 256
N = int(input())
XYH = [list(map(int, input().split())) for _ in range(N)]

for cx in range(101):
	for cy in range(101):
		ch = None
		for x, y, h in XYH:
			if 0 < h:
				ch = h + abs(x - cx) + abs(y - cy)
				if 0 < ch:
					break
		else:
			continue
		for x, y, h in XYH:
			th = max(0, ch - abs(x - cx) - abs(y - cy))
			if th != h:
				break
		else:
			print(cx, cy, ch)
			exit()


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
using namespace std;
main(){
  string s;
  vector<int> num;
  while(cin >> s){
    bool nf=false;
    int cs;
    for(int i=0;i<s.size();i++){
      if(s[i]>='0' && s[i]<='9'){
	if(!nf){
	  nf=true;
	  cs=i;
	}
      }else if(nf){
	string nums = s.substr(cs,i-cs);
	num.push_back( atoi(nums.c_str()) );
	nf=false;
      }
    }
    if(nf){
      string nums = s.substr(cs);
      num.push_back( atoi(nums.c_str()) );
      nf=false;
    }
  }
  int sum=0;
  for(int i=0;i<num.size();i++){
    // cout << num[i] << endl;
    sum+=num[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 1224
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
        PriorityQueue<Bridge> queue = new PriorityQueue<>();
        for (int i = 0; i < m; i++) {
            queue.add(new Bridge(sc.nextInt(), sc.nextInt()));
        }
        int count = 0;
        while (queue.size() > 0) {
            count++;
            Bridge bridge = queue.poll();
            while (queue.size() > 0 && queue.peek().start < bridge.end) {
                queue.poll();
            }
        }
        System.out.println(count);
	}
	
	static class Bridge implements Comparable<Bridge> {
	    int start;
	    int end;
	    
	    public Bridge(int start, int end) {
	        this.start = start;
	        this.end = end;
	    }
	    
	    public int compareTo(Bridge another) {
	        return end - another.end;
	    }
	}
}


Measured memory_bytes: 89932
N = int(input())
count = 0
success = False

for i in range(N):
  n_list = [int(n) for n in input().split(' ')]
  if n_list[0] == n_list[1]:
    count += 1
    if count == 3:
      success = True
      break
  else:
    count = 0

if success == True:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9184
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T>
struct BIT{
    int n;
    vector<T> d;
    BIT(int n = 0):n(n), d(n+1){}
    void add(int i, T x = 1){
        for(i++; i <= n; i += i&-i){
            d[i] += x;
        }
    }
    T sum(int i){
        T x = 0;
        for(i++; i; i -= i&-i){
            x += d[i];
        }
        return x;
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	vector<int> pi(n+1, -1);
	vector<vector<int>> ps(n);
	rep(i,n){
		int l = pi[a[i]];
		if(l != -1) ps[l].push_back(i);
		pi[a[i]] = i;
	}
	vector<vector<P>> qs(n);
	rep(qi,q){
		int l, r;
		cin >> l >> r;
		--l; --r;
		qs[l].emplace_back(r,qi);
	}
	vector<int> ans(q);
	BIT<int> bit(n);
	for(int x = n-1; x >= 0; --x){
		for(int y : ps[x]) bit.add(y, 1);
		for(P query : qs[x]){
			int r = query.first, i = query.second;
			ans[i] = r - x + 1 - bit.sum(r);
		}
	}
	rep(i,q) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 62964
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string S;
	scan(S);
	int N=S.size();
	int sum1=0,sum2=0;
	rep(i,N){
		if((S[i]-'0')^(i%2)) sum1++;
		if((S[i]-'0')^((i+1)%2)) sum2++;
	}
	prin(min(sum1,sum2));
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<limits.h>
#include<string>
using namespace std;
 
int LCS(string a, string b){
    int m=a.size();
    int n=b.size();
    int T[m+1][n+1];
    int i,j;
    for (i=0;i<m+1;i++) T[i][0]=i;
    for (j=0;j<n+1;j++) T[0][j]=j;
    for (i=1;i<m+1;i++){
        for (j=1;j<n+1;j++){
            int min=T[i-1][j]+1;
            if (min>T[i][j-1]+1){
                min=T[i][j-1]+1;
            }
            if ((a[i-1]==b[j-1])&&(min>T[i-1][j-1]+1)){
                min=T[i-1][j-1]+1;
            }
            T[i][j]=min;
        }
    }
    return m+n-T[m][n];
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m,i;
    cin >> m;
     
    string a,b;
    for (i=0;i<m;i++){
        cin >> a >> b;
        cout << LCS(a,b) << endl;
    }
    return 0;
}
 

Measured memory_bytes: 7092
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    set<string> s;
    for (int i=0; i<n; i++) {
        string si; cin>>si;
        s.insert(si);
    }

    cout << s.size() << endl;
}

Measured memory_bytes: 15696
//b
#include <iostream>

using namespace std;

int main()
{
    int n,x;
    cin>>n;
    bool b=false;
    for(int i=0;i<n;++i){
        cin>>x;
        if(x%2==0)
            if(!(x%3==0||x%5==0))b=true;
    }
    if(b)cout<<"DENIED\n";
    else cout<<"APPROVED\n";

    return 0;
}


Measured memory_bytes: 256
N = int(input())
s = [int(input()) for _ in range(N)]
ns = []
for v in s:
    if v % 10 != 0:
        ns.append(v)
ns.sort()

ans = sum(s)
while ans % 10 == 0 and len(ns) > 0:
    ans -= ns.pop(0)
print(0 if ans % 10 == 0 else ans)


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

const int MAX_N = 100;
const int MAX_S = 100;

int main() {
	int N, s[MAX_N], S = 0;

	std::cin >> N;
	for(int i = 0; i < N; ++i) {
		std::cin >> s[i];
		S += s[i];
	}

	bool dp[MAX_N * MAX_S + 1] = {};
	dp[0] = true;
	for(int i = 0; i < N; ++i) {
		for(int j = S; j >= 0; --j) {
			if(j - s[i] >= 0 and dp[j - s[i]]) {
				dp[j] = true;
			}
		}
	}

	int ans = 0;
	for(int i = 1; i <= S; ++i) {
		if(i % 10 != 0 and dp[i]) ans = i;
	}

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

Measured memory_bytes: 256
/*
 * atcoder/abc093/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * i) a = b = c の場合) 0
 * ii) 2つが等しくどれか1つが1以上足りない場合) それを+2
 * iii) ２つが等しくどれか1つが1つ多い場合) ２つを+1
 * iv) すべて異なる場合) もっとも小さいものを +2
 */
ll x[3];
void solve() {
  cin >> x[0] >> x[1] >> x[2];
  ll count=0;
  while (x[0] != x[1] or x[1] != x[2]) {
    sort(x, x+3);
    // iv)
    if (x[0] < x[1] and x[1] < x[2]) {
      x[0] += 2;
      count++;
      continue;
    }

    // iii)
    if (x[0] != x[1]) {
      x[0] += 2;
      count++;
      continue;
    }

    // ii)
    x[0]++;x[1]++;
    count++;
  }
  cout << count << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 256
#B
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
amin=min(al)
bmin=min(bl)
minp=amin+bmin
for i in range(m):
    num=list(map(int,input().split()))
    price=al[num[0]-1]+bl[num[1]-1]-num[2]
    minp=min(price,minp)
print(minp)

Measured memory_bytes: 18612
#include<bits/stdc++.h>
 
#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define int long long
#define endl '\n'
 
using namespace std;
 
const int N = 2e5 + 77;
priority_queue<int , vector<int> , greater<int>> A;
vector<pair<int,int>> P;
int32_t main(){
    fast;
    int n , m ; cin >> n >> m ;
    for(int i = 0; i < n ; ++i){
        int a ; cin >> a;
        A.push(a);
    }
    for(int q = 0; q < m ; ++q){
        int a , b; cin >> a >> b ;
        P.push_back({b,a});
    }
    sort(P.rbegin(),P.rend());
    for(auto i : P){
        int a = i.first , b = i.second;
        if(A.top() >= a) break;
        for(int j = 0 ; j < b ; ++j){
            A.pop();
            A.push(a);
        }
    }
 
    int ans = 0;
    while(!A.empty()){
        ans += A.top();
        A.pop();
    }
    cout << ans << endl;
    return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;


// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
vll a;
// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	ll flag = 0;
	for(ll i=0;i<n;i++) {
		cin >> x >> y;
		if(x == y) {
			flag++;
		}
		else {
			flag = 0;
		}

		if(flag == 3) {
			cout<<"Yes\n";
			return;
		} 

	}

	cout<<"No\n";
	
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    string s, t;
    cin >> s >> t;
    int q, n = s.length(), m = t.length();
    VI sa(n+1), ta(m+1);
    REP(i,n) sa[i+1] = sa[i] + (s[i] == 'A');
    REP(i,m) ta[i+1] = ta[i] + (t[i] == 'A');
    cin >> q;
    while (q--){
        int a, b, c, d;
        scanf("%d %d %d %d", &a, &b, &c, &d);
        int ls = b-a+1, lt = d-c+1;
        int cs, ct;
        cs = (sa[b]-sa[a-1]) + 2*(ls-sa[b]+sa[a-1]);
        ct = (ta[d]-ta[c-1]) + 2*(lt-ta[d]+ta[c-1]);
        cs %= 3;
        ct %= 3;
        if (cs == ct) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if (A < 10 && B < 10) cout << A * B << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 892
#include<iostream>
using namespace std;
int main(){
  int t;
  cin >> t;
  int n[10];
  int b[10]={0};
  int c[10]={0};
  int bcount=0,ccount=0,h=0;
  for(int i=0;i<t;i++){
    for(int j=0;j<10;j++) cin >> n[j];
    for(int j=0;j<10;j++){
      if(b[0]==0) b[bcount] = n[j];
      else if(b[bcount]>c[ccount]&&b[bcount]<n[j]){
	bcount++;
	b[bcount] = n[j];
      }
      else if(c[ccount]>b[bcount]&&c[ccount]<n[j]){
	if(c[ccount]!=0) ccount++;
	c[ccount] = n[j];
      }
      else if(b[bcount]>c[ccount]&&b[bcount]>n[j]&&c[ccount]<n[j]){
	if(c[ccount]!=0) ccount++;
	c[ccount] = n[j];
      }
      else if(c[ccount]>b[bcount]&&c[ccount]>n[j]&&b[bcount]<n[j]){
	bcount++;
	b[bcount] = n[j];
      }
      else if(b[bcount]>n[j]&&c[ccount]>n[j]){
	cout << "NO" << endl;
	h = 1;
	break;
      }
    }
    if(h==0) cout << "YES" << endl;
    for(int i=0;i<10;i++){
      b[i] = 0;
      c[i] = 0;
    }
      bcount = 0;
      ccount = 0;
      h = 0;
  }
  return 0;
}

Measured memory_bytes: 1156
# -*- coding: utf-8 -*-
import math

###
# main
if(__name__ == '__main__'):
    # input
    k = int(input())

    sum = 0
    for a in range(1,k+1):
        cand_list = []
        for cand in range(int(math.sqrt(a)),0,-1):
            if a % cand == 0:
                cand_list.append(cand)
                cand_list.append(a//cand)
        cand_list.sort()

        for b in range(a,k+1):
            for c in range(b,k+1):

                gcd = 0
                for tgt in cand_list[::-1]:
                    if b % tgt == 0 and c % tgt == 0:
                        gcd = tgt
                        break

                if a != b:
                    if b != c:
                        gcd *= 6
                    else:
                        gcd *= 3
                elif b != c:
                    gcd *= 3

                sum += gcd

    print(sum)

# else:
    # do nothing


Measured memory_bytes: 9212
import fileinput as fi
def gcd_euler(a,b):
    if b == 0: return a
    u = a
    v = b
    r = u % v
    while True:
        if r == 0:return v
        u = v
        v = r
        r = u % v



if __name__ == "__main__":
    for line in fi.input():
        a,b = list(map(int,line.strip().split()))
        if a > b:gcd=gcd_euler(a,b)
        else:gcd=gcd_euler(b,a)
        print(gcd,int((a*b)/gcd))

Measured memory_bytes: 7696
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    static void Main(string[] args){
    int ans=0;
    var n = int.Parse(Console.ReadLine());
    var p = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
    for(int i=1;i<n-1;i++){
        if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i-1]>p[i]&&p[i]>p[i+1])) ans++;
    }
    Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a+b)%24 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <map>

int main() {
  int n;
  std::cin >> n;
  std::map<int64_t, int64_t> sums;
  sums[0] = 1;
  int64_t sum = 0;
  for (int i = 0; i < n; ++i) {
    int64_t a;
    std::cin >> a;
    sum += a;
    ++sums[sum];
  }
  int64_t cnt = 0;
  for (auto v : sums) {
    cnt += v.second * (v.second - 1) / 2;
  }
  std::cout << cnt << std::endl;
}


Measured memory_bytes: 12800
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

A, B, C = MAP()
for i in range(1, B):
	if (A*i - C)%B == 0:
		print("YES")
		break
else:
	print("NO")


Measured memory_bytes: 13584
using System;
 
class Program{
	public static void Main(){
		string s;
		while((s = Console.ReadLine()) != null){
			float[] n = Array.ConvertAll(s.Split(' '), float.Parse), m = new float[3];
			m[0] = (n[4] - n[2]) * (n[7] - n[3]) - (n[5] - n[3]) * (n[6] - n[2]);
			m[1] = (n[0] - n[4]) * (n[7] - n[5]) - (n[1] - n[5]) * (n[6] - n[4]);
			m[2] = (n[2] - n[0]) * (n[7] - n[1]) - (n[3] - n[1]) * (n[6] - n[0]);
			Array.Sort(m);
			Console.WriteLine(m[0] > 0 || m[2] < 0 ? "YES" : "NO");
		}
	}
}

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

int main(){
	int N, K;
	cin >> N >> K;
	K--;

	string s;
	cin >> s;
	
	if(s[K]=='A')		s[K]='a';
	else if(s[K]=='B')	s[K]='b';
	else			s[K]='c';
	
	
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 256
#ifndef _WIN32
#include<iostream>
#endif
#include<string>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<stack>

using namespace std;

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<typename T>
bool chmin(T&l, T r) { bool f = l > r; if (f)l = r; return f; }
template<typename T>
bool chmax(T&l, T r) { bool f = l < r; if (f)l = r; return f; }
typedef long long LL;
typedef vector<LL> V;
typedef vector<V> VV;
#define DCrc(R,C,v) int R=v.size(),C=v[0].size(); 
VV sub(VV x, int t, int b, int l, int r) {
	int R = b - t;
	int C = r - l;
	VV y(R, V(C));
	FOR(i, t, b)FOR(j, l, r)y[i - t][j - l] = x[i][j];
	return y;
}
VV rot(VV x) {
	DCrc(R, C, x);
	VV y(C,V(R));
	REP(i, C)REP(j, R) {
		y[i][j] = x[j][C - i-1];
	}
	return y;
}
VV setsum(VV& x) {
	DCrc(R, C, x);
	VV y(R + 1, V(C + 1, 0));
	REP(i, R)REP(j, C)
		y[i + 1][j + 1] = x[i][j] + y[i + 1][j] + y[i][j + 1] - y[i][j];
	return y;
}
LL getsum(VV &x, int t, int b, int l, int r) {
	return x[b][r] + x[t][l] - x[b][l] - x[t][r];
}
LL f2(VV x) {
	DCrc(R, C, x);
	auto S = setsum(x);
	LL res = 0;
	FOR(i,1, R)chmax(res, min(getsum(S, 0, i, 0, C) ,getsum(S, i, R, 0, C)));
	FOR(i,1, C)chmax(res, min(getsum(S, 0, R, 0, i) ,getsum(S, 0, R, i, C)));
	return res;
}
LL f3(VV x) {
	LL res = 0;
	REP(_, 4) {
		DCrc(R, C, x);
		auto S = setsum(x);
		FOR(i,1, R)FOR(j, i + 1, R)
			chmax(res, min({
			getsum(S, 0, i, 0, C),
			getsum(S, i, j, 0, C),
			getsum(S, j, R, 0, C)
		}));
		FOR(i,1, R)FOR(j,1,C)
			chmax(res, min({
			getsum(S, 0, i, 0, C),
			getsum(S, i, R, 0, j),
			getsum(S, i, R, j, C)
		}));
		x = rot(x);
	}
	return res;
}
LL f4(VV x) {
	LL res = 0;
	REP(_, 4) {
		DCrc(R, C, x);
		auto S = setsum(x);
		FOR(i, 1, R) {
			chmax(res, min(
				getsum(S, 0, i, 0, C),
				f3(sub(x, i, R, 0, C))
				));
		}
		FOR(a, 1, R)FOR(b, 1, C) {
			LL lb = getsum(S, 0, a, 0, b);
			int c = 0;
			int d = 0;

			while (c < C&&getsum(S, a, R, 0, c) < lb)c++;
			while (d < R&&getsum(S, 0, d, b, C) < lb)d++;
			if (c == C || d == R)continue;
			if (d > a&&c > b)continue;
			LL k;
			if (d > a||c > b) {
				k = getsum(S, d, R, c, C);
			}
			else k = max({
				getsum(S, d, R, b, C),
				getsum(S, a, R, c, C)
			});
			chmax(res, min(lb,k));
		}
		x = rot(x);
	}
	return res;
}


int main() {
	int R, C, N;
	cin >> R >> C >> N;
	{
		VV x(R, V(C));
		REP(i, R)REP(j, C)cin >> x[i][j];
		if (N == 2)cout << f2(x) << endl;
		if (N == 3)cout << f3(x) << endl;
		if (N == 4)cout << f4(x) << endl;

	}
	return 0;
}

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

long long int get_val(long long int,long long int);

int main()
{
    long long int a,b,c,d,e,tmp,res;
    
    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    
    e = get_val(c,d);
    //printf("%lld\n",e);
    //res = b - (a - 1) - int($b / $c) + int(($a - 1) / $c) - int($b / $d) + int(($a - 1) / $d) + (int($b / $e) - int(($a - 1) / $e));
    
    res = b - (a - 1);
    tmp = b/c;
    res = res - tmp;
    tmp = (a - 1) / c;
    res = res + tmp;
    tmp = b/d;
    res = res - tmp;
    tmp = (a - 1) / d;
    res = res + tmp;
    tmp = b/e;
    res = res + tmp;
    tmp = (a - 1) / e;
    res = res - tmp;
    
    printf("%lld\n",res);
    
    return 0;
}

long long int get_val(long long int a,long long int b)
{
    
    long long int r, x, tmp,tmp2;
    
    
    x = a * b;
    
    /* 自然数 a > b を確認・入替 */
    if(a<b)
    {
        tmp = a;
        a = b;
        b = tmp;
    }
    
    /* ユークリッドの互除法 */
    r = a % b;
    
    while(r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    
    tmp = x/b;
    
    return tmp;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a; i < n; i++)
#define per(i,n,a) for (int i = n - 1; i >= a; i--)
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    rep(x, 0, n + 1) {
        rep(y, 0, n - x + 1) {
            int z = n - x - y;
            if (k == x * 10000 + y * 5000 + z * 1000) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

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

int N, W;
const int MAX = 1e5+5;
int values[MAX];
int weights[MAX];
long long int dp[100][MAX];

long long int solve(int n, int w){
    if(dp[n][w]!=-1) return dp[n][w];
    if(n<0 || w<=0) return 0;
    if(n==0){
        long long int best = 0;
        if(weights[n]<=w) best = values[n];
        return dp[n][w]=best;
    }
    return dp[n][w]=max(solve(n-1, w),w>=weights[n]?  solve(n-1, w-weights[n])+values[n] : 0);

}



int main(void){
    cin>>N>>W;
    for(int i=0;i<N;i++){
        cin>>weights[i]>>values[i];
    }
    memset(dp, -1, sizeof dp);
    cout<<solve(N-1, W)<<endl;

    return 0;
}


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

using namespace std;
#define ll long long int
ll const mod=3e9;
vector<ll>v1[100001];
vector<ll>v2(100001,0);
//vector<ll>h(100001,0);

void dfs(ll i)
{
    v2[i]=1;
    for(int j=0;j<v1[i].size();j++)
    {
        if(v2[v1[i][j]]==0)
        {
            dfs(v1[i][j]);
        }
    }
}

int main()
{
    ll n;
    cin>>n;
    ll m;
    cin>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        v1[x].push_back(y);
        v1[y].push_back(x);
    }
    int ans=0;
    for(ll i=1;i<=n;i++)
    {
        if(v2[i]==0)
        {
            ans++;
            dfs(i);
        }
    }
    cout<<ans-1;
}


Measured memory_bytes: 10584
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
using ll = long long;
using namespace std;

int main(){
    int n, c, s, t, hoge;
    cin >> n >> c;
    int table[100010];
    bool flag[31][100010];
    REP(i, 31){
        REP(j, 100010){
            flag[i][j] = false;
        }
    }
    REP(i, 100010){
        table[i] = 0;
    }
    REP(i, n){
        cin >> s >> t >> hoge;
        table[s - 1]++;
        table[t]--;
        if(flag[hoge][s]){
            table[s - 1]--;
            table[s]++;
        }
        if(flag[hoge][t]){
            table[t]++;
            table[t - 1]--;
        }
        flag[hoge][s] = flag[hoge][t] = true;
    }
    REP(i, 100010){
        if(i == 0) continue;
        table[i] += table[i - 1];
    }
    int ans = 0;
    REP(i, 100001){
        if(ans < table[i]){
            ans = table[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3712
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
c = Array.new(n+1,0)
num = Array.new(n+1,0)
t = 0
a.each do |e|
   if c[e] == 0
     t += 1
     c[e] += 1
     num[1] += 1
   else
     c[e] += 1
     num[c[e]-1] -= 1
     num[c[e]] += 1
   end
end

i = 1
ans = 0
until t <= k
  if num[i] <= 0
    i += 1
  else
    t -= 1
    ans += i
    num[i] -= 1
  end
end
puts ans


Measured memory_bytes: 18956
#include<stdio.h>

int main(void) {

	char word[101];
	int count=0;
	int flag = 1;
	int length;
	int top;
	int head;

	scanf("%s", word);

	
	head = strlen(word);
	length = head + 1;
	head--;

	for (top = 0;length/2 > top; top++) {
		if (word[top] != word[head]) {
			word[top] = word[head];
			count++;
		}
		head--;
	}

	printf("%d", count);
	

	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s;
int n, x[100000];

int main() {
	cin >> s;
	n = s.size();
	
	bool f = (s.front() == '1' && s.back() == '0');
	inc(i, n - 1) { f &= (s[i] == s[n - 2 - i]); }
	if(! f) {
		cout << -1 << endl;
		return 0;
	}
	
	s.back() = '1';
	int p = -1;
	dec(i, n) {
		x[i] = p;
		if(s[i] == '1') { p = i; }
	}
	
	inc(i, n - 1) {
		cout << i + 1 << " " << x[i] + 1 << "\n";
	}
	
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    for(int i = 0; int(i * 1.08) <= n; i ++){
        if(n == int(i * 1.08)){
            cout << i;
            return 0;
        }
    }
    cout << ":(";
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

LL oddsolve(LL a) {
    return (a + 1) / 2 % 2;
}

LL solve(LL a) {
    if (a % 2 == 1) {
        return oddsolve(a);
    } else {
        return oddsolve(a + 1) ^ (a + 1);
    }
}
int main() {
    LL a, b;
    cin >> a >> b;
    cout << (solve(b) ^ solve(a - 1)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP)
 { return firstP.first < secondP.first; }//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock

ll n;
vi a;

ll euclid(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    return euclid(b,a%b);
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;ll aaa;
    rep(i,n){
        cin>>aaa;
        a.pb(aaa);
    }//input
    ll ans = a[0];
    rep(i,n){
        ans = euclid(ans,a[i]);
        if(ans==1)break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 892
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    n = I()
    ni = 0

    while ni < n:
        ni += 1
        h,w = LI()
        s = [[c for c in S()] for _ in range(h)]
        d = collections.defaultdict(lambda: [inf,-inf,inf,-inf])
        for i in range(h):
            for j in range(w):
                if s[i][j] == '.':
                    continue
                t = d[s[i][j]]
                if t[0] > i:
                    t[0] = i
                if t[1] < i:
                    t[1] = i
                if t[2] > j:
                    t[2] = j
                if t[3] < j:
                    t[3] = j
        f = True
        k = set(d.keys())
        while f:
            f = False
            for t in list(k):
                hi,ha,wi,wa = d[t]
                ff = True
                for i in range(hi,ha+1):
                    for j in range(wi,wa+1):
                        if s[i][j] != t and s[i][j] != '?':
                            ff = False
                            break
                    if not ff:
                        break
                if ff:
                    k.remove(t)
                    f = True
                    for i in range(hi,ha+1):
                        for j in range(wi,wa+1):
                            s[i][j] = '?'
        if not k:
            rr.append('SAFE')
        else:
            rr.append('SUSPICIOUS')

    return '\n'.join(map(str,rr))


print(main())




Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int r;
    cin >> r;

    if (r < 1200) {
        cout << "ABC" << endl;
    }
    else if (r < 2800) {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "AGC" << endl;
    }
    
    
}


Measured memory_bytes: 256
a_list=[int(input()) for i in range(5)]

sum=0
for i in a_list:
    #print(((i+9)//10)*10)
    sum+=((i+9)//10)*10

ans_list=[]
for i in a_list:
    b=((i+9)//10)*10-i
    ans_list.append(sum-b)
    
print(min(ans_list))

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

int main(void) {
    string input;
    cin >> input;
    int a, b, c, d;
    a = input.at(0) - 48;
    b = input.at(1) - 48;
    c = input.at(2) - 48;
    d = input.at(3) - 48;

    // ビット全探索
    // 0 のとき -, 1 のとき +
    int n = 3;
    int op[3] = {b, c, d};
    for (int bit = 0; bit < (1<<n); bit++) {
        int sum = a;
        char ans[3];
        for (int i = 0; i < n; i++) {
            if (bit & (1<<i)) {
                sum += op[i];
                ans[i] = '+';
            } else {
                sum += op[i] * -1;
                ans[i] = '-';
            }
        }
        if (sum == 7) {
            cout << a << ans[0] << b << ans[1] << c << ans[2] << d << "=7" << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
  long int N,a,keta=0,i;
  scanf("%ld",&N);
  for(i=1;i*i<=N;i++){
    if(N%i==0){
      a=N/i;
    }
  }
  while(a>0){
    a=a/10;
    keta++;
  }
  printf("%ld",keta);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9 + 7, INF = 1e18;
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;}



signed main(){
	int N,M;
	cin>>N>>M;
	vector<int>cnt(100010,0);
	vector<int>mod(M,0);
	vector<int>pair(M,0);
	REP(i,N){
		int t;
		cin >> t;
		cnt[t]++;
		mod[t%M]++;
	}
	REP(i,100010)pair[i%M] += cnt[i] / 2 * 2;
	int ans = mod[0] / 2;
	FOR(i,1,M/2+1){
		if(i==M-i){
			ans += mod[i] / 2;
		}else{
			int t = min(mod[i],mod[M-i]);
			ans += t;
			ans += max(0ll,min(mod[i] - t,pair[i]) / 2);
			ans += max(0ll,min(mod[M-i] - t,pair[M-i]) / 2);
		}
	}
	cout << ans << endl;
}


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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const int INF = 1e9 + 5;
const long long MAXN=2e5 + 5;;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool cmp(const string& a, const string& b) {
	return (a + b) < (b + a);
}

vector<int> Reversed(const vector<int>& s){
   vector<int> d = s;
   reverse(all(d));
   return d;
}

void solve(){
    int h, w;
    cin >> h >> w;
    char c[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j];
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << c[i][j];
        }
        cout << endl;
        for(int j = 0; j < w; j++){
            cout << c[i][j];
        }
        cout << endl;
    }
}


int main(){
    //freopen("slalom.in","r",stdin);
    //freopen("slalom.out","w",stdout);
    //faster();
    int n = 1;
    //cin >> n;
    while(n--){
        solve();
        cout << endl;
    }
    //fclose(stdout);
}


Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;

vector<vector<int>> graph;
vector<int> visited;
vector<int> guide;

void bfs(int i) {
    queue<int> que;
    queue<int> guide_que;
    que.push(i);
    guide_que.push(-1);
    while (!que.empty()) {
        int f = que.front();
        que.pop();
        int g = guide_que.front();
        guide_que.pop();
        if (guide[f] == 0) guide[f] = g;
        for (auto&& n : graph[f]) {
            if (visited[n]) continue;
            visited[n] = 1;
            que.push(n);
            guide_que.push(f+1);
        }
    }
}

int main(void) {
    ll N, M;
    cin >> N >> M;
    visited = vector<int>(N, 0);
    graph = vector<vector<int>>(N, vector<int>());
    guide = vector<int>(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    bfs(0);

    // for (int i = 0; i < N; i++) {
    //     if (guide[i] == 0) {
    //         cout << "No" << endl;
    //         return 0;
    //     }
    // }
    cout << "Yes" << endl;
    for (int i = 1; i < N; i++) {
        cout << guide[i] << endl;
    }


    return 0;
}



Measured memory_bytes: 10456
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000;
const int MOD = (int)1e9 + 7;

signed main()
{
    int h, w;
    cin >> h >> w;
    vector<string> g(h);
    for (int i = 0; i < h; i++)
    {
        cin >> g[i];
    }
    vector<vector<int>> v(h, vector<int>());
    vector<vector<int>> u(w, vector<int>());
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (g[i][j] == '#')
            {
                v[i].push_back(j);
                u[j].push_back(i);
            }
        }
    }

    int maxN = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (g[i][j] == '#')
                continue;
            int rn;
            if (v[i].size() == 0)
                rn = w;
            else
            {
                auto rit = upper_bound(v[i].begin(), v[i].end(), j);
                if (rit == v[i].begin())
                    rn = *rit;
                else if(rit == v[i].end())
                    rn = w - *(rit - 1) - 1;
                else
                    rn = *rit - *(rit - 1) - 1;
            }
            int cn;
            if (u[j].size() == 0)
                cn = h;
            else
            {
                auto cit = upper_bound(u[j].begin(), u[j].end(), i);
                if (cit == u[j].begin())
                    cn = *cit;
                else if (cit == u[j].end())
                    cn = h - *(cit - 1);
                else
                    cn = *cit - *(cit - 1) - 1;
            }
            maxN = max(maxN, rn + cn - 1);
        }
    }
    cout << maxN << "\n";
}

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




int main() {
	string str;
	int N;
	string *s;
	int *t;
	string X;
	cin >> N;
	s = new string[N];
	t = new int[N];
	for (int i = 0;i < N;i++) {
		cin >> s[i] >> t[i];
	}
	cin >> X;
	
	int sum = 0;
	bool flag = false;
	for (int i = 0;i < N;i++) {
		if (flag)sum += t[i];
		if (s[i] == X)flag = true;
		
	}
	cout << sum << endl;

}

Measured memory_bytes: 256
import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

import static java.lang.Integer.parseInt;

public class Main {

  final int MIN = Integer.MIN_VALUE;
  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = parseInt(in.readLine());

      Point[] reds  = new Point[n];
      Point[] blues = new Point[n];
      String[] lines;
      for(int i=0, x=0, y=0; i<n; i++) {
        lines = in.readLine().split(" ");
        x = parseInt(lines[0]);
        y = parseInt(lines[1]);
        reds[i] = new Point(x, y); 
      }
      for(int i=0, x=0, y=0; i<n; i++) {
        lines = in.readLine().split(" ");
        x = parseInt(lines[0]);
        y = parseInt(lines[1]);
        blues[i] = new Point(x, y); 
      }

      Arrays.parallelSort(reds, new Comparator<Point>() {
        public int compare(Point a, Point b) {
          if(a.y == b.y) return 0;
          return a.y > b.y ? -1 : 1;  // 降順
        }
      });

      Arrays.parallelSort(blues, new Comparator<Point>() {
        public int compare(Point a, Point b) {
          if(a.x == b.x) return 0;
          return a.x > b.x ? 1 : -1;  // 昇順
        }
      });

      boolean[] isDone = new boolean[n];

      int ans = 0;
      // Point p = new Point(MIN,MIN);
      // int maxJ = MIN;
      for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
          if(!isDone[j] && reds[j].x < blues[i].x && reds[j].y < blues[i].y) {
            ans++;
            isDone[j] = true;
            break;
          }
        }
      }

      System.out.println(ans);
      // for (Point p : reds) {
      //   System.out.println(p.x + " " + p.y);
      // }
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int s=S.size();
  bool ans=true;
  if (S[0]!='A'){
    ans=false;
  }
  int count=0;
  for (int i=2;i<s-1;i++){
    if (S[i]<'a'){
      if (S[i]!='C'){
        ans=false;
        break;
      }
      else {
        count++;
      }
    }
  }
  if (count==0||count>1){
    ans=false;
  }
  if (S[1]<'a'||S[s-1]<'a'){
    ans=false;
  }
  if (ans){
    cout << "AC" << endl;
  }
  else {
    cout << "WA" << endl;
  }
}

Measured memory_bytes: 256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    n=int(input())
    A=sorted(list(map(int,input().split())), reverse=True)

    print(sum(A[::2])-sum(A[1::2]))


resolve()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	while(cin >> n){
		long long ans=0;
		if(n<=36){
			for(int a=0;a<=9;a++){
				for(int b=0;b<=9;b++){
					for(int c=0;c<=9;c++){
						if(n-a-b-c>=0 and n-a-b-c<10){
							ans++;
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3012