akhauriyash/Code-Regression huggingface dataset:
#include<iostream>


using namespace std;

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

	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (a % 2 == 0) {
			//偶数
			if (a % 3 == 0 || a % 5 == 0) {
				//cout << "APPROVED" << endl;
			}
			else {
				cout << "DENIED" << endl;
				return 0;
			}
		}
		else {
			//奇数
			//cout << "DENIED" << endl;
		}
	}

	cout << "APPROVED" << endl;

}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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; }

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	string s; cin >> s;

	int n = s.length();
	for(int i = n - 2; i > 0; i -= 2){
		string ss = s.substr(0, i);
		bool ans = true;
		rep(i, ss.size() / 2){
			if(ss[i] != ss[i + ss.size() / 2]){
				ans = false;
			}
		}
		if(ans){
			cout << ss.length() << endl;
			break;
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    int arr[101];
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> arr[i];
    sort(arr, arr+n);
    
    int ans = 0;
    for(int i=0; i<n; i++)
        for(int j=i+1; j<n; j++)
            for(int k=j+1; k<n; k++){
                if(arr[i] != arr[j] && arr[j] != arr[k] && arr[i] != arr[k] 
                && arr[i] + arr[j] > arr[k])
                    ans++;
            }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3624
#include"bits/stdc++.h"
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i!=s.size();++i){
		if(s[i]=='9')
			s[i]='1';
		else if(s[i]=='1')
			s[i]='9';
	}
	cout<<s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);



int main() {
    ios_base::sync_with_stdio(false); 

    int t;
    cin >> t;
    rep(u,t){
        int n;
        cin >> n;
        vector<vector<pair<int,int>>> p(n),q(n);
        ll ans=0;
        rep(i,n) {
            ll k,l,r;
            cin >> k >> l >> r;
            if (l>=r) p[k-1].push_back({l,r});
            else q[k-1].push_back({l,r}); 
            ans+=(l<r)?l:r;
        }
        priority_queue<ll> pq;
        rep(i,n) {
            rep(j,p[i].size()) pq.push(p[i][j].second-p[i][j].first);
            while (pq.size()>i+1) {
                pq.pop();
            }
        }
        while (!pq.empty()) {
            ans+=-pq.top();
            pq.pop();
        }
        invrep(i,n) {
            rep(j,q[i].size()) pq.push(q[i][j].first-q[i][j].second);
            while (pq.size()>n-1-i) {
                pq.pop();
            }
        }
        while (!pq.empty()) {
            ans+=-pq.top();
            pq.pop();
        }
    
        cout << ans << endl;
    }


    return 0;
}


Measured memory_bytes: 18388
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll mark[10000005];
int main()
{
    ll n;
    cin>>n;
    memset(mark,0,sizeof mark);
    ll p=n/2;
    for(int i=1;i<=p;i++)
        for(int j=i;j<=n;j+=i)
            mark[j]++;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        if(i==1)
            sum+=i;
        else if(mark[i]==1)
            sum+=(i*2);
        else if(i<=p)
            sum+=(i*mark[i]);
        else
            sum+=(i*(mark[i]+1));
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 81720
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 998244353;
const ll INF = 1 << 30;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
int main() {
	ll n;
	cin >> n;
	cout << (n > 999 ? "ABD" : "ABC") << endl;
	return 0;
}

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

int main(){   
    int c,d,n,x,a;
    cin >> n >> d >> x;
    for(int i=0;i<n;i++){
        cin >> a;
        int co=0;
        for(int l=0;l<d;l+=a,co++){}
        x+=co;
    }   
    cout << x << endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;

int a, b, c, d, e, f;

int main() {
  while (1) {
    if (scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f) != 6) break;

    double x = double(c*e-b*f)/(a*e-b*d);
    double y = double(c*d-a*f)/(b*d-a*e);

    x = int(x*1000)/1000.0;
    y = int(y*1000)/1000.0;

    printf("%.3f %.3f\n", x, y);
  }
}

Measured memory_bytes: 2672
object Main {
  case class Line(string: String) {
    def strings: Seq[String] = string.split(' ')
    def ints: Seq[Int] = strings.map(_.toInt)
    def i(n: Int): Int = ints(n)
  }

  def readLine: Line = Line(io.StdIn.readLine())
  def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))

  def yesNo(b: Boolean): String = if (b) "Yes" else "No"

  def main(args: Array[String]) {
    def read(i: Int): Unit = {
      val a: Int = readLine.i(0)
      if (a > 0) {
        println(s"Case $i: $a")
        read(i + 1)
      }
    }
    read(1)
  }
}

Measured memory_bytes: 55940
a = list(input().split())

b = int(a[0])
c = int(a[1])
d = int(a[2])
e = int(a[3])

if max(b,d) < min(c,e):
    print(min(c,e)-max(b,d))       

elif max(b,d)>=min(c,e):
        print(0)
          

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 




int main() {


  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int AS = A * B;
  int BS = C * D;

  if(AS >= BS) print(AS);
  else print (BS);


}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }




int main() {
	int N, L;
	char S[100][101];
	char tmp[101];
	scanf("%d %d", &N, &L);
	for (int i = 0; i < N; i++) {
		scanf("%s", S[i]);
		//printf("%s\n", S[i]);
	}
	for (int j = 0; j < N; j++) {
		for (int i = 0; i < N - 1; i++) {
			if (strcmp(S[i], S[i + 1]) >= 0) {
				strcpy(tmp, S[i]);
				strcpy(S[i], S[i + 1]);
				strcpy(S[i + 1], tmp);
			}
		}
	}
	//for (int i = 0; i < N; i++) {
	//	printf("S[%d] = %s\n", i, S[i]);
	//}

	for (int i = 0; i < N; i++) {
		printf("%s", S[i]);
	}
	printf("\n");


#ifdef DEBUGF
	getch();
#endif
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

int n,d;

int main()
{
    cin >> d >> n;
    if (d==0)
    {
        if (n==100)cout << 101 << endl;
        else
        cout << n << endl;
    }
    else if (d==1)
    {
        if (n!=100)
        cout << n*100 << endl;
        else cout << 10100 << endl;
    }
    else
    {
        if (n!=100)
        cout << n*10000 << endl;
        else cout << 1010000 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
int_switch_repr = 2**N
light_bulbs_switches = []
for i in range(M):
  k_s = [int(x) for x in input().split()]
  k_i = k_s[0]
  light_bulbs_switches.append(k_s[1:]) # i-th light bulb
P = [int(x) for x in input().split()]  # p_i

ans = 0
for itg in range(int_switch_repr):
  binary_switch_repr = "{w:{fill}{width}b}".format(w=itg, fill='0', width=N)
  all_on = True
  for lbs_i, p_i in zip(light_bulbs_switches, P):
    is_light_on = sum([1 for sw in lbs_i if binary_switch_repr[int(sw)-1]=='1'])%2 == p_i
    if not is_light_on:
      all_on = False
      break
  if all_on:
    ans+=1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include <cstdio>
#include<cstring>
#include<cmath>
#include<functional>
#include<numeric>
#include<random>
 
using namespace std;

int partition(vector<int>::iterator b, vector<int>::iterator e) {
	int i{ 1 };
	int j{ e - b - 1 };
	int x = *b;
	while (true) {
		while (b[i] <= x && i<j) i++;
		while (b[j] > x) j--;
		if (j <= i) break;
		swap(b[i], b[j]);
	}
	swap(b[0], b[j]);
	return j;
}


int select(vector<int>::iterator b, vector<int>::iterator e,int i) {
	sort(b, e);
	return b[i];
/*
    int mine = *min_element(b, e);
	int maxe = *max_element(b, e);
	if (i == 0||mine== maxe) return mine;
	if (i == e - b - 1) return maxe;
	int j = partition(b, e);
	if (i == j) return b[j];
	if (i < j) return select(b, b + j, i);
	else return select(b + j + 1, e, i - j - 1);
	*/
}




int main() { 
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a;
	int k;
	for (int i = 1; i <= n; i++) {
		//cin >> k;
		scanf("%d", &k);
		a.push_back(k - i);
	}
	mt19937 get_rand_mt;
    shuffle( a.begin(), a.end(), get_rand_mt );
	int med = select(a.begin(), a.end(), n / 2);
	long long ans{ 0 };
	for (auto e : a) {
		ans += abs(e - med);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>

int main(void){
	int H, W,i,j;

	while (1) {
		
		scanf("%d %d", &H, &W);
		
		if (H == 0 && W == 0)break;
		
		for ( i = 0; i < H; i++) {
			for ( j = 0; j < W; j++)	printf("#");
			printf("\n");
			j = 0;
		}
		printf("\n");
	}

	return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> A(3);
  REP(i, 3) cin >> A[i];
  sort(A.begin(), A.end());
  cout << A[0] + A[1] + A[2] * 10 << endl;

  return 0;
}

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


int main(){
	string number;
	int sum;
	
	while(1){
		cin >> number;
		
		if(number == "0"){
			break;
		}
		
		sum = 0;
		for(int i = 0; i < number .size(); i++){
			sum += number[i] - '0' ;
		}
		cout << sum << endl;
	}
		
		
			
		    return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int k;
  cin >> k;
  vector<vector<int>> queen(k,vector<int>(2));
  vector<int> tmp(8);
  vector<vector<bool>> board(8, vector<bool>(8, false));
  rep(i, k) {
    int r, c;
    cin >> r >> c;
    board[r][c] = true;
    queen[i][0] = r;
    queen[i][1] = c;
  }
  vector<int> slant1(8);
  vector<int> slant2(8);
  vector<int> order(8);
  rep(i, 8) {
    order[i] = i;
  }
  do {
    bool can = true;
    rep(i, 8) {
      tmp[i] = order[i];
    }
    rep(i, k) {
      if(tmp[queen[i][0]] != queen[i][1]) {
        can = false;
        break;
      }
    }
    rep(i, 8) {
      slant1[i] = i + tmp[i];
      slant2[i] = i - tmp[i];
    }
    sort(slant1.begin(), slant1.end());
    sort(slant2.begin(), slant2.end());
    rep(i, 7) {
      if(slant1[i] == slant1[i+1] || slant2[i] == slant2[i+1]) {
        can = false;
        break;
      }
    }
  if(can) {
    rep(i, 8) {
      rep(j, 8) {
        if(j == order[i]) {
          cout << "Q";
        }
        else {
          cout << ".";
        }
      }
      cout << endl;
    }
  }
  }while(next_permutation(order.begin(), order.end()));
}


Measured memory_bytes: 3168
N=gets.to_i
F=[]
P=[]
N.times{
  F << gets.split.map(&:to_i)
}
N.times{
  P << gets.split.map(&:to_i)
}

val = -10e10
1.upto(1023) do |pat|
  c = [0] * N
  10.times{|t|
    next if pat[t] == 0
    N.times{|i|
      if F[i][t] == 1
        c[i] += 1
      end
    }
  }

  v = 0
  N.times{|i|
    v += P[i][c[i]]
  }
  val = [val, v].max
end

p val



Measured memory_bytes: 2556
function Main(input) {
    input = input.split("\n");
  	var K = input[0].split(" ")[0];
  	var N = input[0].split(" ")[1];
  	var list = input[1].split(" ").map(v=>v-0);
  	var max = 0;
  	list.forEach((v,i)=>{
  	    if(i>0) max = Math.max(list[i]-list[i-1],max);
  	    else max = Math.max((K-list[N-1]) + (list[i]),max);
  	});
  	
  	console.log(K-max);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 34420
#include <iostream>
using std::string;
using std::cin;
using std::cout;
using std::endl;
int cmpdic(string a,string b){
  int i= 0;
  while(a[i] == b[i]){
    i++;
    if(a[i] == '\0' && b[i]== '\0'){
      return 0;
    }else if(a[i] == '\0'){
      return -1;
    }else if(b[i] == '\0'){
      return 1;
    }
  }
  return(a[i] - b[i]);
}

int main(void){
  std::string card1;
  std::string card2;
  int n;
  cin >> n;
  int p1 = 0;
  int p2 = 0;

  for(int i = 0;i < n;i++){
    cin >> card1 >> card2;
    if(cmpdic(card1,card2) > 0){
      p1 += 3;
    }else if(cmpdic(card1,card2) < 0){
      p2 += 3;
    }else{
      p1 += 1;
      p2 += 1;
    }
  }
  cout << p1 << " " << p2 << endl;
}

Measured memory_bytes: 3148
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		map<char,char> conv;

		REP( i, 0, n )
		{
			char src, to;
			cin >> src >> to;

			conv[ src ] = to;
		}

		int m;
		cin >> m;

		REP( i, 0, m )
		{
			char c;
			cin >> c;

			if ( EXIST( conv, c ) )
			{
				printf("%c", conv[c] );
			}
			else
			{
				printf("%c", c );
			}
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1180
/******************************************
* AUTHOR : Muhammed Shakir CK *

* INSTITUTION : Government Engineering College Wayanad *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long


int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int a, b,c;
cin >> a >> b>> c;
if ((a+b+c)>=22) cout << "bust";
else cout << "win";

return 0;
}

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



int main(){
  vector<int> s;
  s.push_back(6);
  for(int i=8;i<=300000;i++){
    if(i%7==1 || i%7==6){
      bool j=true;
      for(int t=0;s[t]*s[t]<=i;t++){
	if(t>=s.size()){break;}
	if(i%s[t]==0){j=false; break;}
      }
      if(j){s.push_back(i);}
    }
  }

  while(1){
  int n;
  cin>>n;
  if(n==1){break;}
  vector<int> ns;
  for(int i=0;i<s.size();i++){
    if(n%s[i]==0){ns.push_back(s[i]);}
  }
  cout<<n<<":";
  for(int i=0;i<ns.size();i++){
    cout<<" "<<ns[i];
  }
  cout<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3272
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	int n;
	cin >> n;
	vector<int> t(n);
	for (int i = 0; i < n; i++) cin >> t[i];
	int m;
	cin >> m;
	vector<int> p(m), x(m);
	for (int i = 0; i < m; i++) cin >> p[i] >> x[i];
	for (int i = 0; i < m; i++) {
		int tm = 0;
		for (int j = 0; j < n; j++) {
			if (j + 1 == p[i]) tm += x[i];
			else tm += t[j];
		}
		cout << tm << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

red = [0]*N
red[0] = 1
white = [1]*N
white[0] = 0
ans = 1
for i in range(M):
    a, b = map(int, input().split())
    if red[a-1] == 1:
        if red[b-1] == 0:
            red[b-1] += 1
            ans += 1
        else:
            white[b-1] += 1

        if white[a-1] > 0:
            white[a-1] -= 1
        else:
            red[a-1] -= 1
            ans -= 1
    elif white[a-1] > 0:
        white[a-1] -= 1
        white[b-1] += 1
print(ans)
    
        
        
    


Measured memory_bytes: 10220
n = int(input())
a = list(map(int, input().split()))
lis = [0]*(n+1)
lis[0] = 3
ans = 1
mod = 10**9 + 7
for i in range(n):
    x = lis[a[i]]
    if x == 0:
        print(0)
        exit()
    else:
        ans *= x
        ans %= mod
        lis[a[i]] -= 1
        lis[a[i] + 1] += 1
print(ans)


Measured memory_bytes: 84708
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}

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

    if(n == 0){
        cout << x << endl;
        return 0;
    }
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    int dst = 200, ans = 0;
    for(int i = 0; i <= 101; i++){
        bool flag = false;
        for(int j = 0; j < n; j++){
            if(i == p[j]) flag = true;
        }

        if(flag == false && abs(x-i) < dst){
            dst = min(dst, abs(x-i));
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define INF (INT64_MAX/2)
#define MAX 100
#define MOD (1000000000+7)

int N;
int b[MAX];

int c[MAX];
int ans[MAX];

int main() {
	cin >> N;
	for( int i = 0; i < N; i++ ) {
		cin >> b[i];
	}

	for( int i = 0; i < N; i++ ) {
		c[i] = (i + 1) - b[i];
	}
	for( int i = 0; i < N; i++ ) {
		int flag = 0;
		for( int j = N - 1; j >= 0; j-- ) {
			if( c[j] == 0 ) {
				ans[N - 1 - i] = b[j];
				for( int k = j; k < N; k++ ) {
					c[k]--;
				}
				flag = 1;
				break;
			}
		}
		if( flag == 0 ) {
			cout << -1 << endl;
			return 0;
		}
	}

	for( int i = 0; i < N; i++ ) {
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 10L^^15;

void main() {
    auto s = readln.chomp;
    auto t = readln.chomp;

    auto n = s.length.to!int;
    auto m = t.length.to!int;

    auto dp = new int[][](n + 1, m + 1);

    foreach (i ; 1 .. n + 1) {
        foreach (j ; 1 .. m + 1) {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if (s[i-1] == t[j-1]) {
                dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
            }
        }
    }

    debug {
        writefln("%(%s\n%)", dp);
    }

    int a = n;
    int b = m;
    string ans;

    while (a > 0 && b > 0) {
        if (s[a-1] == t[b-1]) {
            ans ~= s[a-1];
            a--;
            b--;
            continue;
        }
        if (dp[a][b] == dp[a-1][b]) {
            a--;
            continue;
        }
        if (dp[a][b] == dp[a][b-1]) {
            b--;
            continue;
        }
    }

    writeln(ans.retro());
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

int main()
{
	int M;
	cin >> M;
  	cout << 48-M << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
long long A[200000];
int main(){
  int N;
  long long K;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  vector <long long> A_neg;
  vector <long long> A_pos;
  long long zero_num = 0;
  for(int i = 0; i < N; i++){
    if(A[i] < 0){
      A_neg.push_back(A[i]);
    } else if(A[i] > 0){
      A_pos.push_back(A[i]);
    } else {
      zero_num ++;
    }
  }
  sort(A_neg.begin(), A_neg.end());
  sort(A_pos.begin(), A_pos.end());

  long long left = LLONG_MIN / 4;
  long long right = LLONG_MAX / 4;
  while(left + 1 < right){
    long long mid = (left + right) / 2;
    long long less_num = 0;

    if(mid > 0){
      for(int i = 0; i < A_neg.size(); i++){
        long long target;
        if(abs(mid) % abs(A_neg[i]) == 0){
          target = - abs(mid) / abs(A_neg[i]);
        } else {
          target = - abs(mid) / abs(A_neg[i]);
        }
        auto it = lower_bound(A_neg.begin() + i + 1, A_neg.end(), target);
        //cout << A_neg[i] << " " << target << " " << (A_neg.end() - it) << endl;
        less_num += (A_neg.end() - it);
        less_num += A_pos.size() + zero_num;
      }
      for(int i = 0; i < zero_num; i++){
        less_num += (zero_num - i - 1) + A_pos.size();
      }
      for(int i = 0; i < A_pos.size(); i++){
        long long target = mid / A_pos[i];
        auto it = upper_bound(A_pos.begin() + i + 1, A_pos.end(), target);
        less_num += (it - (A_pos.begin() + i + 1));
      }
    } else if(mid < 0){
      for(int i = 0; i < A_neg.size(); i++){
        long long target;
        if(abs(mid) % abs(A_neg[i]) == 0){
          target = abs(mid) / abs(A_neg[i]);
        } else {
          target = abs(mid) / abs(A_neg[i]) + 1;
        }
        auto it = lower_bound(A_pos.begin(), A_pos.end(), target);
        less_num += (A_pos.end() - it);
      }
    } else {
      for(int i = 0; i < A_neg.size(); i++){
        less_num += (zero_num + A_pos.size());
      }
      for(int i = 0; i < zero_num; i++){
        less_num += (zero_num - i - 1) + A_pos.size();
      }
    }
    //cout << left << " " << mid << " " << right  << " " << less_num << endl;
    if(less_num < K){
      left = mid;
    } else {
      right = mid;
    }
  }
  cout << right << endl;
  return 0;
}


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

typedef long long LL;
const int N = 1e5 + 50;

struct NODE {
  int x, y, z;
} arr[N];

inline bool cmp(const NODE &p, const NODE &q) {
  return p.x - p.y > q.x - q.y;
}

int a, b, c, n;
LL tmp[N], ans, sum, Max = - 9e18;

int main() {
  scanf("%d%d%d", &a, &b, &c);
  n = a + b + c;
  for (int i = 1; i <= n; i ++)
    scanf("%d%d%d", &arr[i].x, &arr[i].y, &arr[i].z), ans += arr[i].z;
  sort(arr + 1, arr + n + 1, cmp);
  priority_queue <int, vector <int>, greater <int> > Q;
  for (int i = n; i; i --) {
    sum += arr[i].y - arr[i].z;
    Q.push(arr[i].y - arr[i].z);
    if ((int)Q.size() > b) {
      sum -= Q.top(); Q.pop();
    }
    tmp[i] = sum;
  }
  for (int i = 1; i <= b; i ++) Q.pop();
  sum = 0;
  for (int i = 1; i <= n; i ++) {
    sum += arr[i].x - arr[i].z;
    Q.push(arr[i].x - arr[i].z);
    if ((int)Q.size() > a) {
      sum -= Q.top(); Q.pop();
    }
    if (i >= a && n - i >= b) Max = max(Max, sum + tmp[i + 1]);
  }
  printf("%lld\n", ans + Max);
  return 0;
}


Measured memory_bytes: 2812
//簡易競プロテンプレ
#include<bits/stdc++.h>
using namespace std;
int main(void){
 int n; cin >> n;
 long long ans = 1;
 for(int i=1;i<=n;i++) ans = ans * i % 1000000007;
 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,E,T,t,a[100005],f[100005],M=1LL<<60;int main(){scanf("%lld%lld%lld",&n,&E,&T);for(int i=1;i<=n;i++)scanf("%lld",&a[i]);for(int i=1;i<=n;i++){for (;T<=2*(a[i]-a[t+1]);t++)M=min(M,f[t]-2*a[t+1]);f[i]=min(f[t]+T,M+2*a[i]);}printf("%lld",E+f[n]);}

Measured memory_bytes: 1792
local n=io.read("n")
local a={}
for i=1,n do
    a[i]=io.read("n")
end
table.sort(a)

local suma={a[1]}
for i=2,n do
    suma[i]=suma[i-1]+a[i]
end

local counter=n
for i=n-1,1,-1 do
    if a[i+1]>2*suma[i] then
        counter=counter-i
        break
    end
end
print(counter)

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
	int n; cin>>n;
	int m=n;
	int digit=0,div=10;
	rep(i,10){
		digit+=n%div;
		n=n/div;
	}
	if(m%digit==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <deque>
#include <cmath>
#include <cassert>
#include <memory>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i < n; ++i) cin >> a[i];
    map<int, int> c1, c2;
    for (int i=0; i < n; i+=2) {
        c1[a[i]]++;
        c2[a[i+1]]++;
    }
    vector<pair<int, int> > v1, v2;
    v1.reserve(c1.size());
    v2.reserve(c2.size());
    for (auto& kv : c1) {
        v1.push_back(make_pair(kv.second, kv.first));
    }
    for (auto& kv : c2) {
        v2.push_back(make_pair(kv.second, kv.first));
    }
    sort(v1.rbegin(), v1.rend());
    sort(v2.rbegin(), v2.rend());
    int res;
    if (v1[0].second == v2[0].second) {
        int mx = 0;
        if (v1.size() > 1) {
            mx = max(mx, v1[1].first + v2[0].first);
        }
        if (v2.size() > 1) {
            mx = max(mx, v2[1].first + v1[0].first);
        }
        if (v1.size() == 1 && v2.size() == 1) {
            mx = v1[0].first;
        }
        res = n - mx;
    } else {
        res = n - v1[0].first - v2[0].first;
    }
    cout << res;
    return 0;
}



Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main(){
  int n, k;
  int h[100000];
  cin >> n >> k;
  for(int i = 0;i < n;i++){
    cin >> h[i];
  }
  int dp[100000];
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  for(int i = 2;i < n;i++){
    dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
    for(int j = 2;j <= k;j++){
      if(i >= j){
        dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
      }else{
        break;
      }
    }
  }
  cout << dp[n - 1] << endl;
}

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

int main(){
	int n;
	cin>>n;
	int tag=0;
	while(n){
		if ((n%10)==9) tag=1;
		n/=10;
	}
	if (tag==1) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define INF (1LL << 31)
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "

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

    cout << (a*b) << endl;
    return 0;
}


Measured memory_bytes: 3636
# Submission #1346933 を参考

gets
s = gets.chomp
temp = s.dup

s.chars.each_with_index do |char, index|
  if char == '('
    pair_index = temp[(index + 1)..-1].index(')')

    if pair_index
      temp[index], temp[index + pair_index + 1]  = '_', '_'
    end
  end
end

add_left_num, add_right_num = temp.count(')'), temp.count('(')

puts "#{'(' * add_left_num}#{s}#{')' * add_right_num}"


Measured memory_bytes: 1788
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char a[1010];
	int w=0,e=0,n=0,s=0;
	cin>>a;
	for(int i=0;i<strlen(a);i++){
		switch(a[i]){
			case 'W':
				w++;
				break;
			case 'E':
				e++;
				break;
			case 'N':
				n++;
				break;
			case 'S':
				s++;
				break;
		}
	}
	cout<<(((w&&e)||(!w&&!e))&&((n&&s)||(!n&&!s))?"Yes":"No")<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

ll get_count(ll z, const vector<ll> &a) {
    ll n = (ll)a.size();
    ll ret = 0ll;
    rep(i,n) {
        ll y = z-a[i];
        auto itr = lower_bound(a.begin(), a.end(), y);
        ret += (a.end()-itr);
    }
    return ret;
}

ll get_sum(ll z, ll s, const vector<ll> &a, const vector<ll> &sum) {
    ll ret = 0;
    ll n = a.size();
    rep(i,n) {
        ll y = z-a[i];
        // cout <<"a["<<i<<"] = "<<a[i]<< ", ";
        auto itr = lower_bound(a.begin(), a.end(), y);
        // cout << "y = " << y << ", ";
        ll idx = itr-a.begin();
        // cout << "idx = " << idx << ", ";
        ret += (s-sum[idx]);
        // cout << "up = " << s-sum[idx] << ", ";
        ll cnt = n-idx;
        // cout << "cnt = " << cnt << endl;
        ret += (a[i] * cnt);
    }
    return ret;
}

void test(const vector<ll> &a) {
    int n = a.size();
    vector<ll> ret;
    rep(i,n) {
        rep(j,n) {
            ret.push_back(a[i]+a[j]);
        }
    }
    sort(ret.begin(), ret.end(), greater<>());
    print(ret);
}

int main(int argc, char const *argv[]) {
    ll n,m; cin>>n>>m;
    vector<ll> a(n), sum(n+1,0);
    ll s = 0;
    rep(i,n) cin>>a[i], s+=a[i];
    sort(a.begin(), a.end());
    rep(i,n) sum[i+1] = sum[i]+a[i];
    
    // binary search
    ll ok = 0; ll ng = LINF;
    while (abs(ok-ng)>1) {
        ll mid = (ok+ng)/2;
        ll zc = get_count(mid,a);
        if (zc>=m) ok = mid;
        else ng = mid;
    }

    // cout << "ok = " << ok << endl;

    ll ans = get_sum(ok,s,a,sum);
    ans -= (get_count(ok,a)-m)*ok;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int mbk(long long a,int n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
int inv(int a,int m){return mbk((long long)a,m-2,m);}
int main(){
  long long s=0,a=1,n,m,M=1e9+7,i,i2=inv(2,M);;
  scanf("%lld %lld",&n,&m);
  for(i=m;i<n+2;i++){
    s=(s+(i*(n-i+n+1)%M*i2)%M)%M;//printf("%lld\n",(i*(n-i+n+1)%M*i2)%M);
    s=(s+1+M-((i-1)*(i)%M*i2)%M)%M;
    //printf("!%lld\n",((i-1)*(i)%M*i2)%M);
  }
  printf("%lld\n",s);
  return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <vector>

bool equiv(const std::vector<std::string>& A,
           const std::vector<std::string>& B,
           size_t iu, size_t ju) {

  size_t M = B.size();
  for (size_t i = 0; i < M; ++i)
    for (size_t j = 0; j < M; ++j)
      if (A[i+iu-M][j+ju-M] != B[i][j]) return false;
  return true;
}

int main() {
  size_t N, M;
  std::cin >> N >> M;

  std::vector<std::string> A(N), B(M);
  for (auto& a: A) std::cin >> a;
  for (auto& b: B) std::cin >> b;

  for (size_t i = M; i <= N; ++i)
    for (size_t j = M; j <= N; ++j)
      if (equiv(A, B, i, j)) {
        std::cout << "Yes\n";
        return 0;
      }

  std::cout << "No\n";
}

Measured memory_bytes: 256
N, S = map(int, input().split())
A = list(map(int, input().split()))
MOD = 998244353

def main():
  dp = [0]*(S+1)
  dp[0] = 1
  for i in range(1, N+1):
    p = [0]*(S+1)
    dp, p = p, dp
    for j in range(0, S+1):
      dp[j] += 2*p[j]
      dp[j] %= MOD
      if j-A[i-1] >= 0:
        dp[j] += p[j-A[i-1]]
        dp[j] %= MOD
  print(dp[S])

if __name__ == "__main__":
  main()

Measured memory_bytes: 68932
#include<bits/stdc++.h>
using namespace std;
int h,w,c,dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
vector<int> p(64);

int nu(int x,int y,int cl,int t){
  int res=1;
  p[y*w+x]=cl;
  for(int i=0;i<4;i++){
    int nx=x+dx[i],ny=y+dy[i];
    if(nx<0||w<=nx||ny<0||h<=ny||p[ny*w+nx]!=t||p[ny*w+nx]==cl)continue;
    res+=nu(nx,ny,cl,t);
  }
  return res;
}

int dfs(int d){
  vector<int> tp=p;
  int res=0;
  if(d==4){
    res=nu(0,0,c,p[0]);
    return nu(0,0,7,p[0]);
  }
  for(int j=1;j<7;j++){
    nu(0,0,j,p[0]);
    res=max(res,dfs(d+1)),p=tp;
  }
  return res;
}

int main(){
  while(cin>>h>>w>>c,h){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin>>p[i*w+j];
    cout<<dfs(0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3052
#include<iostream>
#include<map>
#include<string>
#include<cstring>
using namespace std;
#define NIL 0
#define ll long long


map<char,int>ch;
ll getKey(string s)
{

	ll key=0;
	ll p=1;
	for(unsigned int i=0; i<s.length(); i++)
	{
		key+=p*(ch[s[i]]);
		p*=5;//权值为5
	}
	return key;
}

const int M=1046527;
ll T[M];//记得初始化

ll h1(ll key)
{
	return key%M;
}

ll h2(ll key)
{
	return 1+(key%(M-1));
}

ll h(ll key,ll i)
{
	return (h1(key)+i*h2(key))%M;
}

void insert(string s)
{
	ll i=0;
	ll key=getKey(s);
	while(true)
	{
		ll j=h(key,i);
		if(T[j]==NIL)
		{
			T[j]=key;
			return ;
		}
		else
		{
			i++;
		}
	}
}

ll search(string s)
{
	ll i=0;
	ll key=getKey(s);
	while(true)
	{
		ll j=h(key,i);
		if(T[j]==key)
		{
			return 1;
		}
		else if(T[j]==NIL||i>=M)
		{
			return 0;
		}
		else
		{
			i++;
		}
	}
}



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

	ch['A']=1;
	ch['C']=2;
	ch['G']=3;
	ch['T']=4;
	memset(T,0,sizeof(T));
	int T;
	cin>>T;
	string flag,s;
	while(T--)
	{
		cin>>flag>>s;
		if(flag[0]=='i')insert(s);
		else
		{
			if(search(s)==1)cout<<"yes"<<endl;
			else cout<<"no"<<endl;
		}
	}


	return 0;
}



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

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

const LL MOD = 1000000007;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
    
    return 0;
}


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

int main()
{
    int n,i,j,k,flag;
    string a,b,c;
    while(cin >> a >> b >> c)
    {
       cout<< a[0] <<b[1] <<c[2]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3540
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<cmath>
#include<typeinfo>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define REPll(i,m,n) for(ll i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

map<ll, ll>s;
vector<ll>v;

int main() {
	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	REP(i, 0, n) {
		ll a, b;
		cin >> a >> b;
		s[a] += b;
		v.push_back(a);
	}
	sort(all(v));
	v.insert(v.begin(), 0);
	REP(i, 1, v.size()) {
		if (v[i] != v[i - 1]) {
			if (s[v[i]] < m) {
				ans += v[i] * s[v[i]];
				m -= s[v[i]];
			}
			else {
				ans += m * v[i];
				cout << ans << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 7284
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(int i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int r; cin >> r;
    cout << pow(r, 2) << endl;
}

Measured memory_bytes: 256
s=input()
a=len(s)
b=a-4
c=0
mod=2019
num=[0]*mod
num[0] = 1
now=0
ans=0
_10 = 1
for i in range(a-1, -1, -1):
    now=(now+int(s[i])*_10)%mod
    _10*=10
    _10%=mod
    ans+=num[now]
    num[now]+=1
print(ans)

Measured memory_bytes: 9304
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    string s, t;
    cin >> s >> t;
    ll slen = s.size();
    ll tlen = t.size();
    ll ssuma[slen + 1], tsuma[tlen + 1];
    ssuma[0] = 0;
    REP(i, 0, slen) {
        if (s[i] == 'A') {
            ssuma[i + 1] = ssuma[i] + 1;
        } else {
            ssuma[i + 1] = ssuma[i];
        }
    }
    tsuma[0] = 0;
    REP(i, 0, tlen) {
        if (t[i] == 'A') {
            tsuma[i + 1] = tsuma[i] + 1;
        } else {
            tsuma[i + 1] = tsuma[i];
        }
    }
    ll q;
    cin >> q;
    REP(i, 0, q) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        ll snum = 2 * (b - a + 1) - (ssuma[b] - ssuma[a - 1]);
        ll tnum = 2 * (d - c + 1) - (tsuma[d] - tsuma[c - 1]);
        if (abs(snum - tnum) % 3 == 0) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	int n,i,m1,m2;
	cin>>n;
	int a[n+1],b[n+1];
	for(i=1;i<=n;i++)
	{
		cin>>a[i];b[i]=a[i];
	}
	sort(a+1,a+n+1);
	m1=a[n];m2=a[n-1];
	
	for(i=1;i<=n;i++)
	{
		if(b[i]!=m1)
		cout<<m1<<endl;
		else
		cout<<m2<<endl;
	}
	return 0;
}


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

int n,m,a[200005];

int main()
{
    n = 5;
    for(int i=1;i<=n;i++)
    {
        sf(a[i]);
        if(a[i]==0)
        {
            m=i;
        }
    }
    pf("%d\n",m);
}


Measured memory_bytes: 3824
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
    string s;
    cin>>s;
    int a_pos;
    int z_pos;
 
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            a_pos = i;
            break;
        }
    }
    for(int i=0;i<s.size();i++){
        if(s[i]=='Z') z_pos = i;
    }
    printf("%d\n",z_pos-a_pos+1);
    return 0;
}

Measured memory_bytes: 1016
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
      	//System.out.println(n);
      	if(n.equals("AAA") || n.equals("BBB")){
          System.out.print("No");
        }else{
          System.out.print("Yes");
        }
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int flag = 0;
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(n == i * j){
                flag = 1;
                break;
            }else{
                continue;
            }
        }
        if(flag == 1){
            break;
        }
    }
    if(flag == 1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
Public Class Program
  Shared Sub Main()
    Dim n As Integer = Integer.Parse(Console.ReadLine())
    Dim ans As String = "No"
    If n <= 81 Then
      For i As Integer = 9 To 1 Step -1
        Dim m As Integer = n \ i
        If m * i = n AndAlso m < 10 Then 
          ans = "Yes"
          Exit For
        End If
      Next
    End If
    Console.WriteLine(ans)
  End Sub
End Class

Measured memory_bytes: 11092
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=2*1e5+2;
map<int,vector<int>> v;
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      int n,m;
      cin>>n>>m;
      string s;
      cin>>s;
      reverse(all(s));
      vector<int> ans;
      for(int i=0;i<n;i++)
      {
        int cnt=0;
        int j=i+1;
        int an=-1;
        while(cnt<m)
        {
          if(s[j]=='0') an=j;
          j++;
          cnt++;
        }
        if(an==-1){
          cout<<"-1";
          return 0;
        }
        ans.pb(an);
        i=an-1;
      }
      for(int i=(int)ans.size()-1;i>=1;i--)
      {
        cout<<ans[i]-ans[i-1]<<" ";
      }
      cout<<ans[0];
}
// I never lose. I either win or I learn

Measured memory_bytes: 1480