akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

static const ll MOD = 1000000007LL;

ll n;
ll dp[100005][13];

int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string s;
    cin >> s;
    n = 1LL * s.size();

    dp[0][0] = 1;
    rep(i,n){
      int c;
      if(s[i] == '?') c = -1;
      else c = s[i] - '0';

      rep(j,10){
        if(c != -1 && c != j) continue;
        rep(ki,13){
          dp[i+1][(ki * 10 + j) % 13] += dp[i][ki];
        }
      }
      rep(j,13) dp[i+1][j] %= MOD;
    }
    print(dp[n][5]);
}

Measured memory_bytes: 10704
#include <bits/stdc++.h>
#define INF 1000000
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int p[2001];
int x[2001];
int sum[2001];
int mini[2001];
int maxi[2001];
vector<int> G[1001];
int dp[1001][5001][2];

int dfs(int v){
	int res=x[v];
	for(int j=0;j<=5000;j++){
		for(int k=0;k<2;k++){
			dp[v][j][k]=INF;
		}
	}
	for(int i=0;i<G[v].size();i++){
		res+=dfs(G[v][i]);
	}
	sum[v]=res;
	return res;
}

bool dfs2(int v){
	if(G[v].size()==0){
		mini[v]=0;
		maxi[v]=0;
		return true;
	}
	int now=1,prev=0;
	dp[v][0][0]=0;
	for(int i=0;i<G[v].size();i++){
		if(!dfs2(G[v][i]))return false;
		for(int j=0;j<=x[v];j++){
			if(j+x[G[v][i]]<=x[v]){
				dp[v][j+x[G[v][i]]][now]=min(dp[v][j+x[G[v][i]]][now],dp[v][j][prev]+mini[G[v][i]]);
			}
			if(j+mini[G[v][i]]<=x[v])dp[v][j+mini[G[v][i]]][now]=min(dp[v][j+mini[G[v][i]]][now],dp[v][j][prev]+x[G[v][i]]);
		}
		swap(now,prev);
		for(int j=0;j<=5000;j++){
			dp[v][j][now]=INF;
		}
	}
	mini[v]=114514;
	for(int i=0;i<=x[v];i++){
		mini[v]=min(mini[v],dp[v][i][prev]);
		if(dp[v][i][prev]<=x[v]){
			mini[v]=min(mini[v],i);
		}
	}
	if(mini[v]==114514)return false;
	return true;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		scanf("%d",&p[i]);
		p[i]--;
		G[p[i]].push_back(i+1);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&x[i]);
	}
	dfs(0);
	printf("%s\n",dfs2(0)?"POSSIBLE":"IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 39424
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

string to_s = "w*kstnhmyrw";
char to_b[256]={0};

int main(){
	to_b['T'] = 'a';
	to_b['L'] = 'i';
	to_b['U'] = 'u';
	to_b['R'] = 'e';
	to_b['D'] = 'o';
	
	string s, ans;
	cin >> s;
	for(int i=1 ; i < s.size() ; i += 2 ){
		if( s[i-1] == '0' && s[i] == 'U' ){
			ans += "nn";
		}else{
			if( s[i-1] != '1' ){
				ans.push_back( to_s[s[i-1]-'0']);
			}
			ans.push_back( to_b[s[i]] );
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  VI P(N);
  rep(i,N) cin>>P[i];
  VI Q(N);
  rep(i,N) Q[P[i]-1]=i;
  int ans=0;
  int X=1;
  rep(i,N){
    if(i<N-1){
      if(Q[i+1]>Q[i]) X++;
      else{
        ans=max(ans,X);
        X=1;
      }
    }else ans=max(ans,X);
  }
  cout<<N-ans<<endl;
}





Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	vector<int> a(4);
	rep(i, 4)cin >> a[i];
	sort(all(a));
	if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9)cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

using namespace std;

#define M 300001

int main(){
  int N,Q,q,in,c[M]={0};
  cin >> N >> Q;
  for(int i = 0 ; i < N ; i++){
    scanf("%d",&in);
    c[in] = in;
  }
  for(int i = 1 ; i < M ; i++){
    c[i] = max(c[i],c[i-1]);
  }
  while(Q--){
    cin >> q;
    int r = 0;
    for(int i = q-1 ; i < M ; i += q){
      r = max(r,c[i]%q);
    }
    printf("%d\n",r);
  }
  return 0;
}

Measured memory_bytes: 2408
#![allow(unused_imports)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{min, max};
use std::collections::{HashMap, HashSet, VecDeque, BinaryHeap};

fn main() {
    input!{
        a: usize,
        b: f64
    }
    println!("{}", a * ((b * 100.0).round() as usize) / 100);
}


Measured memory_bytes: 2632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

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

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

bool ok(int n){
    int a = n%10;
    while(n){
        if(n%10!=a)return false;
        n/=10;
    }
    return true;
}

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

    while(true){
        if(ok(n)){
            cout<<n<<endl;
            return 0;
        }
        n++;
    }

    return 0;
}

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

template<typename T, T(*append)(T,T), T empty>
struct Segtree {
  struct Node {
    int lp, rp; // [l, r)
    T v;
    Node *lc, *rc;
    Node(T v_, int lp_, int rp_) : v(v_), lp(lp_), rp(rp_) {}
  };
  Node* root;
  
  T minv(Node* x, Node* y) {
    if (!x) return (!y)?empty:y->v;
    if (!y) return x->v;
    return append(x->v, y->v);
  }
  
  void update(Node* t, int k, T a) {
    if (t->rp - t->lp == 1 and t->lp == k) {
      t->v = a;
      return;
    } 
    int mid = (t->lp + t->rp) / 2;
    if (k < mid) {
      if (!(t->lc)) t->lc = new Node(empty, t->lp, mid);
      update(t->lc, k, a);
    } else {
      if (!(t->rc)) t->rc = new Node(empty, mid, t->rp);
      update(t->rc, k, a);
    }
    t->v = minv(t->lc, t->rc);
    return;
  }
  void update(int k, T a) { update(root, k, a); }
  
  // min([a,b))
  T query(Node* t, int a, int b) {
    if (!t) return empty;
    if (t->rp <= a || b <= t->lp) return empty;
    else if (a <= t->lp && t->rp <= b) return t->v;
    else {
      T vl = query(t->lc, a, b), vr = query(t->rc, a, b);
      return append(vl, vr);
    }
  }
  int query(int a, int b) { return query(root, a, b); }

  Segtree(int n_) {
    int n = 1;
    while (n < n_) n*=2;
    root = new Node(empty, 0, n);
  }
};

int getmin(int a, int b) {
  return (a > b ? b : a);
}

int main() {
  int n, q;
  cin >> n >> q;
  Segtree<int,getmin,2147483647> t(n);
  for (int i = 0; i < q; ++i) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 1) {
      cout << t.query(x, y+1) << endl;
    } else {
      t.update(x, y);
    }
  }
}

Measured memory_bytes: 6696
#include <iostream>
using namespace std;
int main(){
    int n, l = 1000, m, i;
    cin >> n;
    m = l - n;
    for (i = 1; l <= 10000; i++){
        if (m >= 0){
            cout << m << endl;
            break;
        }
        else{
            l += 1000;
            m = l - n;
        }
    }
    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> t(n);
	vector<int> x(n);
	vector<int> y(n);
	for(int i = 0; i < n; i++)
	{
		cin >> t[i] >> x[i] >> y[i];
	}
	
	int now_x = 0;
	int now_y = 0;
	int time = 0;
	for(int i = 0; i < n; i++)
	{
		bool flag = false;
		for(int j = 0; j < t[i] - time; j++)
		{	
			if(((t[i] - (time + j)) % 2) == 0 && now_x == x[i] && now_y == y[i])
			{
				flag = true;
				break;
			}
			else if(((t[i] - (time + j)) % 2) != 0 && now_x == x[i] && now_y == y[i])
			{
				break;
			}
			
			if(x[i] - now_x > 0)
			{
				now_x++;
			}
			else if(x[i] - now_x < 0)
			{
				now_x--;
			}
			else if(y[i] - now_y > 0)
			{
				now_y++;
			}
			else if(y[i] - now_y < 0)
			{
				now_y--;
			}
			if(j == t[i] - time - 1 && now_x == x[i] && now_y == y[i])
			{
				flag = true;
				break;
			}
		}
		
		if(flag == false)
		{
			cout << "No" << endl;
			return 0;
		}
		if(i == 0)
		{
			time += t[i];
		}
		else
		{
			time += t[i] - t[i - 1];
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}
		

Measured memory_bytes: 1408
using System;

namespace Rectangle
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);

            Console.WriteLine( a * b  + " " + (2*a + 2*b)); 
        }
    }
}

Measured memory_bytes: 9100
/*  Name: Abu Hurayra
    Handle: HurayraIIT
    Institute: IIT_JU   */

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

typedef long long LL;
typedef string S;
typedef double D;
typedef vector<int> vi;
typedef queue<int> qi;
typedef stack<int> si;

#define pi acos(-1.0)
#define endl '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define Fin freopen("input.txt","r",stdin)
#define Fout freopen("output.txt","w",stdout)

int main()
{
	off;
    
    int n,i,j,k;
    cin >> n >> k;
    int a[n],cost[n];
    for(i=0;i<n;i++)
    {
    	cin >> a[i];
    	cost[i] = 1000000000 ;
    }
    cost[0] = 0;

    for(i=1;i<n;i++)
    {
    	int t = max(0,i-k);
    	for(j=t;j<i;j++)
    	{
    		cost[i] = min(cost[i],cost[j]+abs(a[i]-a[j]));
    	}
    }
    
    cout << cost[n-1] << endl;



	return 0;

}



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

typedef long long ll;

int main() {
    string s;
    cin >> s;
    rep(i, (s.size() + 1) / 2) {
        cout << s[i * 2];
    }
    cout << "\n";
}

Measured memory_bytes: 3656
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int arr[31][31];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);

    int N;
    cin >> N;

    int ans;
    cin >> ans;

    for (int i = 1; i < N; ++i)
    {
        int a;
        cin >> a;
        ans = gcd(ans, a);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n,m,k;
  int id,val;
  string gl;
  int skill[2][110][110];
  bool use[110];

  cin >> m >> n;
  for(int i=0;i<m;i++){
    use[i] = false;
    for(int j=0;j<n;j++)skill[0][i][j] = skill[1][i][j] = -1;
  }

  for(int i=0;i<m;i++){
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> id >> gl >> val; id--;
      if(gl == ">="){
	if(skill[0][i][id]<0 || skill[0][i][id]<val)skill[0][i][id] = val;
      }else{
	if(skill[1][i][id]<0 || skill[1][i][id]>val)skill[1][i][id] = val;
      }
    }
  }
  
  int low[110];
  for(int cnt = 0;cnt<m;cnt++){
    for(int i=0;i<n;i++)low[i] = 10000;

    for(int i=0;i<m;i++){
      if(use[i])continue;
      for(int j=0;j<n;j++){
	if(skill[1][i][j]>=0)low[j] = min(low[j],skill[1][i][j]);
      }
    }

    int num = -1;
    for(int i=0;i<m;i++){
      if(use[i])continue;
      bool f = true;
      for(int j=0;j<n;j++){
	if(low[j] < skill[0][i][j]){
	  f = false; break;
	}
      }
      if(f){num = i; break;}
    }
    if(num<0){
      cout << "No\n"; return 0;
    }
    use[num] = true;
  }
  cout << "Yes\n";
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 55;
int a[11];
int use[11];
int n, m, q;
long long maxans = 0;
struct node
{
	int a, b, c, d;
}nd[maxn];
void check()
{
	long long sum = 0;
	for (int i = 1; i <= q; i++)
	{
		if (a[nd[i].b] - a[nd[i].a] == nd[i].c)
		{
			sum += nd[i].d * 1LL;
		}
	}
	maxans = max(maxans, sum);
	return;
}
void dfs(int startx)
{
	if (startx == n + 1)
	{
		check();
		return;
	}
	for (int i = a[startx - 1]; i <= m; i++)
	{
		if (i == 0)
			continue;
		a[startx] = i;
		dfs(startx + 1);
	}
}
int main()
{
	cin >> n >> m >> q;
	for (int i = 1; i <= q; i++)
	{
		cin >> nd[i].a >> nd[i].b >> nd[i].c >> nd[i].d;
	}
	dfs(1);
	cout << maxans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(int argc, const char *argv[])
{
  int a, b;
  cin >> a >> b;
  if (a > b) {
    swap(a, b);
  }

  if ((b - a) % 2 == 1) {
    cout << "IMPOSSIBLE\n";
  } else {
    cout << (b - (b - a) / 2) << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI 3.141592653589793238
int main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("F:/cpp/input.txt", "r", stdin);
    // freopen("F:/cpp/output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll a[n], i, x = 0;
    for (i=0;i<n;i++)
    {
        cin >> a[i];
        x = x^a[i];
    }
    for (i=0;i<n;i++)
    {
        cout << (x^a[i]) << " ";
    }
    return 0;
}

Measured memory_bytes: 5116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;

ll dp[105][2][5];
int main() {
    string s;
    int k;
    cin >> s >> k;
    int n = s.length();
    dp[0][1][0] = 1;
    for(int i = 0; i < n; i++) {
        for(int k = 0; k <= 3; k++) {
            for(int j = 0; j < 10; j++) {
                int e = (j != 0);
                int aa = s[i] - '0';
                if(j == aa) {
                    dp[i+1][1][k+e] += dp[i][1][k];
                } else if(j < aa) {
                    dp[i+1][0][k+e] += dp[i][1][k];
                }
                dp[i+1][0][k+e] += dp[i][0][k];
            }
        }
        // for(int j = 0; j < 2; j++) {
        //     for(int k = 0; k < 3; k++) {
        //         printf("dp[%d][%d][%d]:%lld\n", i+1, j, k, dp[i+1][j][k]);
        //     }
        // }
    }
    cout << dp[n][0][k] + dp[n][1][k] << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


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

	int n; bool chk = false;
	cin >> n;
	rep(i, 100) {
		rep(j, 100) {
			if (4 * i + 7 * j == n) {
				chk = true;
			}
		}
	}
	if (chk) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

    vector<pii> AB(n);
    rep(i, 0, n)
        cin >> AB[i].first >> AB[i].second;
    sort(AB.begin(), AB.end());

    vector<vector<int>> dp(n+1, vector<int>(t+1, 0));
    rep(i, 0, n)
        rrep(j, t, 0)
        {
            int k = min(t, j+AB[i].first);

            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + AB[i].second);
            dp[i+1][k] = max(dp[i+1][k], dp[i][k]);
        }
    
    int ans = 0;
    rep(j, 0, t+1)
        ans = max(ans, dp[n][j]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;



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

	int N; cin >> N;
	P a[110000];
	for (int i = 0; i < N; i++) {
		cin >> a[i].first;
		a[i].second = i + 1;
	}
	sort(a, a + N);
	for (int i = 0; i < N; i++) {
		cout << a[i].second << " ";
	}
}

Measured memory_bytes: 1664
import itertools

N, M = map(int, input().split())

S = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))

ans = 0
for p in itertools.product([True, False], repeat=N):
    for i in range(M):
        ok = True if P[i] == 0 else False
        for s in S[i]:
            ok ^= p[s - 1]
        if not ok:
            break
    if ok:
        ans += 1

print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
  int q;
  cin>>q;
  for(int i=0; i<q; i++)
  {
      ll a,b,c,mem;
      cin>>a>>b;
      c=ll(a*b);
      mem=sqrt(c);
      if(mem*mem==a*b)
      {
         if(a==b) cout<<(mem-1)*2<<endl;
         else if(a!=b) cout<<(mem-1)*2-1<<endl;
      }
      else if(mem*mem!=a*b)
      {
         if(mem*(mem+1)>=a*b) cout<<(mem-1)*2+1-1<<endl;
		 else if(mem*(mem+1)<a*b) cout<<mem*2-1<<endl;
      }
  }
  return 0;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
/* func */
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;
 
 
/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
 
//#define int long long
 
signed main()
{
  int a; cin >> a;
  int n;
  int cnt;
  bool flag = false;
  vector<int> v1(0);
  while(cin >> n)
  v1.PB(n);
  
  while(!flag){
   for(const auto& i: v1){
    if(i%2 != 0)
     flag = true;
   }
  
   if(flag != true){
    for(auto& i: v1)
      i = i / 2;
    ++cnt; 
   }
  }
  
  cout << cnt;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> v(N);
  for(int i=0; i < N; i++){
    cin >> v.at(i);
  }
  
  sort(v.begin() , v.end());
  reverse(v.begin() , v.end());
  
  /*for(int i =0; i < N; i++){
  cout << v.at(i) <<endl;
  }*/
  
  int alice = 0;
  int bob = 0;
  
  for(int i = 0; i < N; i += 2){
    alice += v.at(i);
  }
  
  for(int i = 1; i < N; i += 2){
      bob += v.at(i);
  }
  
  cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 100000000;
typedef pair<int, int> P;
const int MAX_N = 1000000;

string S;

int main() {
	cin >> S;
	int tmp = 0;
	rep(i, S.size()) {
		if (i % 2 == 0)
		{
			if (S.at(i) == '0')tmp++;
		}
		else {
			if (S.at(i) == '1')tmp++;

		}
	}
	if (tmp > S.size() - tmp)cout << S.size() - tmp << endl;
	else cout << tmp << endl;
	
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    ll t1, t2, a1, a2, b1, b2;
    while(cin>>t1>>t2>>a1>>a2>>b1>>b2){
        ll ans=0;
        ll tmp1=t1*a1;
        ll tmp2=t2*a2;
        ll tmp3=t1*b1;
        ll tmp4=t2*b2;
        // cout<<tmp1<<" "<<tmp2<<" "<<tmp3<<" "<<tmp4<<endl;
        // cout<<tmp1-tmp3<<" "<<tmp2-tmp4<<endl;
        if((tmp1>tmp3&&tmp2>tmp4)||(tmp1<tmp3&&tmp2<tmp4)){
            ans=0;
        }
        else if(tmp1+tmp2==tmp3+tmp4){
            ans=-1;
        }
        else{
            if(tmp1>tmp3){
                if(tmp4-tmp2<tmp1-tmp3){
                    ans=0;
                }
                else{
                    ll tmp= tmp4-tmp2-(tmp1-tmp3);
                    ans=(tmp1-tmp3)/tmp+(tmp1-tmp3+tmp-1)/tmp;
                }
            }
            else{ // tmp1 <= tmp3
                if(tmp2-tmp4 < tmp3-tmp1){
                    ans=0;
                }
                else{
                    ll tmp=tmp2-tmp4-(tmp3-tmp1);
                    ans=(tmp3-tmp1)/tmp+(tmp3-tmp1+tmp-1)/tmp;
                }
            }
        }
        if(ans==-1){
            cout<<"infinity"<<endl;
        }
        else{
            cout<<ans<<endl;
        }
    }
  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n=0;
  int ans=0;
  int t=0;
  for(int i=0;i<3;i++){
    if(s[i]=='R'){
      t++;
    }
  }
  if(t==3){
    ans=3;
  }
  if(t==0){
    ans=0;
  }
  if(t==1){
    ans=1;
  }
  if(t==2){
    if(s[1]=='R'){
      ans=2;
    }
    else{
      ans=1;
    }
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        ans += a[i]/2;
        a[i] %= 2;
        if(i != n-1 && a[i+1] > 0 && a[i] != 0){
            a[i+1]--;
            ans++;
        }
        //cout << ans << " " << i << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4000
N = int(input())
S= input()
sub = 0
R,G,B = [],[],[]
r = S.count('R')
g = S.count('G')
b = S.count('B') 
for i in range(N):
    for j in range(i+1,N):
        if 2*j-i > N-1:
            break
        if S[i] != S[j] and S[2*j-i] != S[i] and S[2*j-i] != S[j]:
            sub += 1
ans = r*g*b -sub
print(ans)
       

Measured memory_bytes: 68156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		long a = Long.parseLong(str[1]);
		long b = Long.parseLong(str[2]);

		long x[] = new long[n];

		str = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			x[i] = Long.parseLong(str[i]);
		}

		long ans = 0;
		for (int i = 0; i < n - 1; i++) {
			long dist = x[i + 1] - x[i];
			if (dist * a < b) {
				ans += dist * a;
			} else {
				ans += b;
			}
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 46432
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int main(int, const char**)
{
    struct Data
    {
        ll n;
        bool f3;
        bool f5;
        bool f7;
    };
    set<ll> nums;
    queue<Data> q;
    q.push({3, true, false, false});
    q.push({5, false, true, false});
    q.push({7, false, false, true});
    while(!q.empty())
    {
        auto d = q.front();
        q.pop();

        if(d.n * 10 < 1000000000)
        {
            q.push({d.n * 10 + 3, true, d.f5, d.f7});
            q.push({d.n * 10 + 5, d.f3, true, d.f7});
            q.push({d.n * 10 + 7, d.f3, d.f5, true});
        }

        if(d.f3 && d.f5 && d.f7)
        {
            nums.insert(d.n);
        }
    }
    int n;
    cin >> n;
    auto f = upper_bound(nums.begin(), nums.end(), n);
    cout << distance(nums.begin(), f) << endl;
    return 0;
}


Measured memory_bytes: 4892
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    g1 = [1,3,5,7,8,10,12]
    g2 = [4,6,9,11]
    g3 = [2]

    a1=0
    a2=0

    if a[0] in g1:
        a1 =1
    elif a[0] in g2:
        a1 =2
    else:
        a1=3

    if a[1] in g1:
        a2 =1
    elif a[1] in g2:
        a2 =2
    else:
        a2=3

    if a1 ==a2:
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 3828
n,k=map(int,input().split())
s=input()

def renzoku(s):
    n=len(s)
    lis=[]
    c=1
    if len(s)==1:
        return [1]
    for i in range(n-1):
        if s[i+1]==s[i]:
            c+=1
        else:
            lis.append(c)
            c=1
        if i==n-2:
            lis.append(c)
    return lis


r=renzoku(s)
i=0
if s[0]=="0":
    r=[0]+r
if s[-1]=="0":
    r=r+[0]

cand = sum(r[:min(2*k+1,len(r))])
ans=cand
while 2*k+3 + 2*i<=len(r):
    cand += r[2*k+1+2*i]+r[2*k+2+2*i]-r[2*i]-r[2*i+1]
    if cand>ans:
        ans=cand
    i+=1
print(ans)


Measured memory_bytes: 47984
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstring>
#include<cstdio>
using namespace std; void File(){ freopen("C.in","r",stdin); freopen("C.out","w",stdout); }

#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
#define ll long long
const int maxn=2e5+10; int n; ll a[maxn],sum[maxn]; int main(){ 
	cin>>n; REP(i,1,n)scanf("%lld",&a[i]); REP(i,1,n+1)sum[i]=sum[i-1]+abs(a[i]-a[i-1]); REP(i,1,n){ printf("%lld\n",sum[n+1]-abs(a[i+1]-a[i])-abs(a[i]-a[i-1])+abs(a[i+1]-a[i-1])); } return 0; }


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

#define rep(i,s,t) for(int i = s; i <= t; ++ i)
const int MaxN = 30;

int h, w, r, c;
char str[MaxN];

int main()
{
    scanf("%d%d",&r,&c);
    rep(i,1,r) rep(j,1,c)
    {
        scanf("%s",str);
        if(strcmp(str,"snuke") == 0)
            h = i, w = j;
    }
    printf("%c%d",(char)('A'+w-1),h);
    return 0;
}

Measured memory_bytes: 384
import itertools
n,m,x = map(int,input().split())
c=[]
for i in range(n):
  c.append(list(map(int,input().split())))
#print(c)

ans = 9999999999

for el in itertools.product([0,1],repeat=n):
  # 達成可能性の判定
  cav = [0]*(m+1)
  for i in range(n):
    if el[i] == 1:
      for j in range(m+1):
        cav[j] += c[i][j]

  if x > min(cav[1:m+1]):
    pass
  else:
    ans = min(cav[0],ans)

if ans ==  9999999999:
  print(-1)
else:
  print(ans)


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

bool s[13]={},h[13]={},c[13]={},d[13]={};

int main(){
	int a,b;
	char c1;
	cin>>a;
	for (int i=0;i<a;i++){
		cin>>c1>>b;
		if (c1=='S')s[b-1]=1;
		if (c1=='H')h[b-1]=1;
		if (c1=='C')c[b-1]=1;
		if (c1=='D')d[b-1]=1;
	}
		for (int i=0;i<13;i++){
			if (s[i]==0)cout<<"S "<<i+1<<endl;
		}
		for (int i=0;i<13;i++){
			if (h[i]==0)cout<<"H "<<i+1<<endl;
		}
		for (int i=0;i<13;i++){
			if (c[i]==0)cout<<"C "<<i+1<<endl;
		}
		for (int i=0;i<13;i++){
			if (d[i]==0)cout<<"D "<<i+1<<endl;
		}
		//cout<<endl;
}


Measured memory_bytes: 3100
package main

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

func scan(scanner *bufio.Scanner) uint64 {

	scanner.Scan()
	n, err := strconv.ParseUint(scanner.Text(), 10, 64)

	if err != nil {
		panic(err)
	}

	return n
}

type (
	PY         [2]uint64
	Years      []uint64
	YearsOrder map[uint64]uint64
)

func (ys Years) Len() int { return len(ys) }
func (ys Years) Less(i, j int) bool {
	return ys[i] < ys[j]
}
func (ys Years) Swap(i, j int) {
	y := ys[i]
	ys[i] = ys[j]
	ys[j] = y
}

func makeSort(unsorted []Years) []YearsOrder {

	ret := make([]YearsOrder, len(unsorted))

	for p, ys := range unsorted {
		sort.Sort(ys)

		ret[p] = make(YearsOrder, len(ys))
		for i, y := range ys {
			ret[p][y] = uint64(i) + 1
		}
	}

	return ret
}

func main() {

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	n := scan(scanner)
	m := scan(scanner)

	city_order := make([]PY, m)
	pref_years := make([]Years, n)

	for i := uint64(0); i < m; i++ {
		p := scan(scanner) - 1
		y := scan(scanner)

		city_order[i] = PY{p, y}
		pref_years[p] = append(pref_years[p], y)
	}

	sorted := makeSort(pref_years)

	for _, py := range city_order {
		p := py[0]
		y := py[1]
		fmt.Printf("%06d%06d\n", p+1, sorted[p][y])
	}
}


Measured memory_bytes: 31232
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
char a;
cin>>a;
if('a'<=a&& a<='z'){
cout<<"a"<<endl;}
else
cout<<"A"<<endl;}

Measured memory_bytes: 3616
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int H, W;
int K;
char map[400][400];
int res[400][400];

template<typename T>void imos2d(int32_t x, int32_t y, int32_t x2, int32_t y2, T& arr)
{
	++arr[x][y];
	--arr[x][y2];
	--arr[x2][y];
	++arr[x2][y2];
}


int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> H >> W >> K;
	for (size_t i = 0; i < H; i++)
	{
		in >> map[i];
	}

	int count = 1;
	int lasth = -1;
	for (int i = 0; i < H; i++)
	{
		int lastw = -1;
		bool updated = false;
		for (int j = 0; j < W; j++)
		{
			if (map[i][j] == '#') {
				
				updated = true;

				res[lasth + 1][lastw + 1] += count;
				res[lasth + 1][j+1] -= count;
				res[i + 1][lastw + 1] -= count;
				res[i + 1][j + 1] += count;

				lastw = j;
				++count;
			}
		}
		if (updated) {
			res[lasth + 1][lastw + 1] += count-1;
			res[lasth + 1][W] -= count - 1;
			res[i + 1][lastw + 1] -= count - 1;
			res[i + 1][W] += count - 1;

			lasth = i;
		}
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 1; j < W; j++)
		{
			res[i][j] += res[i][j - 1];
		}
	}
	for (int i = 1; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			res[i][j] += res[i - 1][j];
		}
	}

	for (int i = lasth+1; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			assert(res[i][j]==0);
			res[i][j] += res[i - 1][j];
		}
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W-1; j++)
		{
			out << res[i][j] << ' ';
		}
		out << res[i][W - 1] << '\n';
	}




	return 0;
}
#endif


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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const long long int MOD = 1e9 + 7;

ll REM( ll a )
{
	a %= MOD;
	if ( a < 0 )
	   a += MOD;
	return a;
}

ll ADD( ll a, ll b )
{
	return REM( REM( a ) + REM( b ) );
}

ll SUB( ll a, ll b )
{
	return REM( REM( a ) - REM( b ) );
}

ll MUL( ll a, ll b )
{
	return REM( REM( a ) * REM( b ) );
}

ll POT( ll n, ll k )
{
	if ( k == 0 )
		return 1;

	ll ret = POT( n, k / 2 );
	ret = MUL( ret, ret );

	if ( k % 2 )
		return MUL( ret, n );
	return ret;
}

ll DIV( ll a, ll b )
{
	return MUL( a, POT( b, MOD - 2 ) );
}

bool isPrime( ll x )
{
	for ( ll i = 2;i <= sqrt( x ); i++ )
		if ( x % i == 0 )
			return false;
	return true;
}

string s, t, s1;

int main()
{
	int n;cin >> n >> s >> t;
	int x = 0, y = 0;
	FOR( i, 0, n * 2 )
	{
		if ( i % 2 == 0 )
		{
			s1 += s[ x ];x++;
		}
		else
		{
			s1 += t[ y ];y++;
		}
		
	}
	cout << s1 << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define N 200005
using namespace std;
long long a[N];
int n;
int main()
{
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    long long di=0;
    long long ans=0;
    for(int i=0; i<n; i++)
        if(a[i]<di)ans+=di-a[i];
        else di=a[i];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5176
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if (a.equals("H")) {
			System.out.println(b);
		} else {
			if (b.equals("H")) {
				System.out.println("D");
			} else {
				System.out.println("H");
			}
		}
	}
}

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

#define lli long long int
#define pb push_back
#define in insert
#define pi pair<int, int>
#define pii pair<int, pi>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 101
#define MAXS 901
#define INF 1000000000
#define mod 1000000007

signed main()
{
  int n;
  cin >> n;
  set<string> sett;
  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    sett.insert(s);
  }
  cout << sett.size() << endl;
  return 0;
}

Measured memory_bytes: 19148
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a,a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ll x, ll y, ll a, ll b){ return sqrt((x - a)*(x - a) + (y - b)*(y - b)); }
void debug(ll* a, ll n) { for ( int k = 0; k < n; k++ ){ cout << a[k] << " ";} cerr << "\n"; }

int main(){
	FASTIO;
	ll n; cin >> n;
	ll a[n]; parseArray(a, n);
	ll ans = 1e12;
	for ( int k = 1; k <= 100; k++ ){
		ll tmp = 0;
		for ( int j = 0; j < n; j++ )
			tmp += (k - a[j]) * (k - a[j]);
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h> 
const int N = 10000;
int main()
{
	int a[N] = {0}, n, maxn = -1000001, minn = 1000001;
	long long sum = 0;
	scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
    	scanf("%d", &a[i]);
    	if(a[i] > maxn)
    	{
    		maxn = a[i];
		}
		if(a[i] < minn)
		{
			minn = a[i];
		}
		sum += a[i];
	}
	printf("%d %d %lld\n", minn, maxn, sum);    
	return 0;
}


Measured memory_bytes: 2800
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main()
{
    scanf("%d %d %d %d",&a,&b,&c,&d);
    int tem1=min(a,b);
    int tem2=min(c,d);
    printf("%d",tem1+tem2);
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

vector<ll> divisors(ll n) {
    vector<ll> res;
    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i);
        if(n/i == i) continue; // 上の行で追加済み。
        res.push_back(n/i);
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    ll ans = 0;
    VLL yakusuu = divisors(n);
    sort(all(yakusuu));
    // rep(i,yakusuu.size()) cout << yakusuu[i] << ' ';
    // cout << endl;
    rep(i,yakusuu.size()){
      if(yakusuu[i] == 1) continue;
      if(n/(yakusuu[i]-1) == n%(yakusuu[i]-1))
        ans += yakusuu[i]-1;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int w[n];
    int diff = 0;
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        diff += w[i];
    }
    int ans = diff;
    for (int i = 0; i < n; i++) {
        diff -= 2 * w[i];
        ans = min(ans, abs(diff));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
const LL MOD = (LL)1e9 + 7;
char s1[87], s2[87];

int main() {
    int N;
    scanf("%d", &N);
    scanf("%s", s1);
    scanf("%s", s2);
    int cur = 0, md = 0;
    LL ans = 0;
    if (s1[0] == s2[0]) {
       ans = 3;
       cur = 1;
       md = 1;
    } else {
       ans = 6;
       cur = 2;
       md = 2;
    }
    while (cur < N) {
          if (s1[cur] == s2[cur]) {
             if (md == 1) ans = (ans * 2) % MOD;
             cur += 1;
             md = 1;
          } else {
             if (md == 2) ans = (ans * 3) % MOD;
             else ans = (ans * 2) % MOD;
             cur += 2;
             md = 2;
          }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main(){
    let mut po: Vec<i64> = (0..3).map(|_| read::<i64>()).collect();
    po.sort();
    println!("{}", 
        if po[0] % 2 == 0 || po[1] % 2 == 0 || po[2] % 2 == 0 {
            0
        } else {
            po[0] * po[1]
        }
    );
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

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

typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<ll> b(n);
    for(int i=0;i<n;i++) cin >> a[i] >> b[i];

    ll ans = 0;
    for(int i=0;i<n;i++){
        if((k|a[i]) == k){
            ans += b[i];
        }
    }
    for(int i=1;i<31;i++){
        if((k>>i)&1){
            int S = (k^(1<<i)) | ((1<<i)-1);
            ll sum = 0;
            for(int j=0;j<n;j++){
                if((S|a[j]) == S){
                    sum += b[j];
                }
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1532
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string S;
    cin >> S;
    char c = S.at(0);
    for (int i = 1; i < S.size(); i++) {
        if (c == S.at(i)) {
            cout << "Bad" << endl;
            return 0;
        }
        c = S.at(i);
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> M;
	vector< pii > Q(M);
	rep(i, M) cin >> Q[i].first >> Q[i].second;
	vector< int > A(N, 1);
	vector< bool > R(N, false);

	R[0] = true;

	rep(i, M) {
		int x = Q[i].first, y = Q[i].second;
		--x;
		--y;
		if (R[x]) {
			R[y] = true;
		}
		A[y]++;
		A[x]--;
		if (A[x] == 0)
			R[x] = false;
	}
	int ans = 0;
	rep(i, N) if (R[i]) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long int ll;
int main()
{
  int A, B; cin >> A >> B;

  int a = A + B;
  int b = A - B;
  int c = A * B;

  int ans = max(max(a, b), c);
  cout << ans << endl;
}

Measured memory_bytes: 256