akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> field(h);
    REP(i, h){
        cin >> field[i];
    }

    ll ans = 0;
    REP(bith, (1<<h)){
        REP(bitw, (1<<w)){
            vector<string> test = field;
            REP(i, h){
                if(bith & (1<<i)){
                    REP(p, w){
                        test[i][p] = 'r';
                    }
                }
                REP(j, w){
                    if(bitw & (1<<j)){
                        REP(q, h){
                            test[q][j] = 'r';
                        }
                    }
                }
            }
            ll cnt = 0;
            REP(i, h){
                REP(j, w){
                    if(test[i][j] == '#'){
                        cnt ++;
                    }
                }
            }
            if(cnt == k){
                ans ++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

vi p(6), q(6);
double win_rate(double x) {
  double win = 0;
  rep (i, 6) {
    double r = p[i] / 100.0 * x, b = q[i] / 100.0 * (1 - x);
    if (r >= b) {
      win += r;
    }
    else {
      win += b;
    }
  }
  return win;
}

int main() {
  rep (i, 6) {
    cin >> p[i];
  }
  rep (i, 6) {
    cin >> q[i];
  }

  double x1 = 0, x2 = 1;
  rep (_, 100) {
    double y1 = (2*x1 + x2) / 3.0, y2 = (x1 + 2*x2) / 3.0;;
    double w1 = win_rate(y1), w2 = win_rate(y2);
    if (w1 >= w2) x1 = y1;
    else x2 = y2;
  }
  Sp(win_rate(x1));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100100],b[100100];
int n,ans,num;

int main(){
	cin>>n;
	ans=0;num=0;
	for (int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	int k=1;
	for (int i=1;i<=n;i++){
		if (a[i]==a[i+1]) b[k]++; 
			else if (a[i+1]==a[i+2]) k++;
	}
	k--;
	int l=1;int r=k;
	if (k==1 && b[k]==0){}else {
	while (l<=r) {
		b[l]--;b[r]--;
		if (b[l]<=0) l++;
		if (b[r]<=0) r--;
		n-=2;
	}
}
	cout<<n;
	return 0;
}
	
	
	
	




Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            int[] one = { 1, 3, 5, 7, 8, 10, 12 };
            int[] two = { 4, 6, 9, 11 };
            string[] s = Console.ReadLine().Split(' ');
            int x = int.Parse(s[0]);
            int y = int.Parse(s[1]);

            string ans = "No";
            if (one.Contains(x) && one.Contains(y))
            {
                ans = "Yes";
            }
            if (two.Contains(x) && two.Contains(y))
            {
                ans = "Yes";
            }
            if(x == y && x == 2)
            {
                ans = "Yes";
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11220
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

fn main() {
  input! {
    n: usize,
    aa: [i64; n]
  }
  let mut dp = vec![vec![1e18 as i64; n+1]; n+1];
  let mut sum = vec![0i64; n+1];
  for (i, &a) in aa.iter().enumerate() {
    sum[i+1] = sum[i] + a;
  }
  for len in 0 .. n + 1 {
    for l in 0 .. n + 1 - len {
      let r = l + len;
      if len <= 1 {
        dp[l][r] = 0;
        continue;
      }
      let size = sum[r] - sum[l];
      for m in l .. r {
        dp[l][r] = cmp::min(dp[l][r], dp[l][m] + dp[m][r] + size);
      }
    }
  }
  println!("{}", dp[0][n]);
}


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

class Main {

	void solve() {
		
		int a = inint(), b = inint(), c = inint();
		if (c-b == b-a || a-b == b-c) out.println("YES");
		else out.println("NO");
		
	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

	public char[][] incharmap(int h, int w) {
		char[][] a = new char[h][w];
		for (int i=0; i<h; i++) {
			String temp = in.next();
			for (int j=0; j<w; j++) {
				a[i][j] = temp.charAt(j);
			}
		}
		return a;
	}

}

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

int main(){
    
    int N;
    cin >> N;
    double a[N];
    double sum = 0;
    for(int i = 0; i < N;i++)cin >> a[i],sum += a[i];
    
    double ave = sum/N;
    
    double mn = INT_MAX;
    double ans = 0;
    for(int i = 0; i < N-1;i++){
        
        if(mn >abs(a[i]-ave)){
            mn = abs(a[i]-ave);
            ans = i;
        }
        
    }
    cout << ans <<endl;
}
    
    



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

using namespace std;

struct Bipartite_Matching
{
  vector< vector< int > > graph;
  vector< int > match, alive, used;
  int timestamp;

  Bipartite_Matching(int n)
  {
    timestamp = 0;
    graph.resize(n);
    alive.assign(n, 1);
    used.assign(n, 0);
    match.assign(n, -1);
  }

  void add_edge(int u, int v)
  {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(int v)
  {
    used[v] = timestamp;
    for(int i = 0; i < graph[v].size(); i++) {
      int u = graph[v][i], w = match[u];
      if(alive[u] == 0) continue;
      if(w == -1 || (used[w] != timestamp && dfs(w))) {
        match[v] = u;
        match[u] = v;
        return (true);
      }
    }
    return (false);
  }

  int bipartite_matching()
  {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return (ret);
  }
};

int dp[3000][3000];

int gcd(int x, int y)
{
  if(x < 3000) {
    if(~dp[x][y]) return (dp[x][y]);
    int r = x % y;
    if(r == 0) return dp[x][y] = y;
    return dp[x][y] = gcd(y, r);
  } else {
    int r = x % y;
    if(r == 0) return y;
    return gcd(y, r);
  }
}

int main()
{
  memset(dp, -1, sizeof(dp));

  int M, N, B[500], R[500];
  while(scanf("%d %d", &M, &N), M) {
    Bipartite_Matching flow(M + N);
    for(int i = 0; i < M; i++) scanf("%d", &B[i]);
    for(int i = 0; i < N; i++) scanf("%d", &R[i]);
    for(int i = 0; i < M; i++) {
      for(int j = 0; j < N; j++) {
        if(__gcd(B[i], R[j]) > 1) flow.add_edge(i, j + M);
      }
    }
    printf("%d\n", flow.bipartite_matching());
  }
}

Measured memory_bytes: 39708
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    if((A + B)%2==0)cout << (A+B)/2 << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define MAX 10100
using namespace std;

int prime[MAX];
bool p[MAX];

void func(){
  p[0] = true;
  p[1] = true;
  

  int cnt = 0;
  for(int i = 2 ; i < MAX ; i++){
    if(p[i])continue;
    prime[cnt++] = i;
    //cout << i << endl; //
    for(int j = i*2 ; j < MAX ; j += i){
      p[j] = true;
    }
  }
  //cout <<"cnt = " << cnt << endl;//
}

int main(){
  func();
  int n;
  while(1){
    cin >> n;
    if(n == 0)break;
    int cnt = 0,s = 0,t = 0;
    int sum = 0;
    while(1){

      if(prime[s] > n)break;

      if(sum == n){
	cnt++;
      	sum -= prime[s];
	s++;
      }
      else if(sum < n)sum += prime[t++];
      else if(sum > n){
	sum -= prime[s];
	s++;
      }
      //  cout << "s = " << s << " t = " << t <<" prime[s] = "<< prime[s]<< " sum = " << sum << endl;     
    }

    cout << cnt << endl;
  }
  return 0;
}

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

int main() {
	string s;
	cin >> s;
	int n = 0;
	for (int i = 0;i < 4;++ i) n += s[i] == '+' ? 1 : -1;
	cout << n;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

やるだけ
*/

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

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = std.nextInt();
        }
        
        int min = Arrays.stream(as).min().getAsInt();
        int max = Arrays.stream(as).max().getAsInt();
        System.out.println(max - min);
    }
}


Measured memory_bytes: 27604
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  long a, v, b, w, t, d; cin >> a >> v >> b >> w >> t;
  d = abs(a-b);
  if(v > w && (v-w)*t >= d) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
  string a;
  cin>>a;
  string b=a.substr(0,4);
  string c=a.substr(5,2);
  if(stoi(b)<=2019&&stoi(c)<=4)
  cout<<"Heisei";
    else
      cout<<"TBD";
  
}

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

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	int k,memo[m]={},a;
	for (int i = 0; i < n; ++i)
	{
		cin>>k;
		for (int j = 0; j < k; ++j)
		{
			cin>>a;--a;
			++memo[a];
		}
	}
	int ans=0;
	for (int i = 0; i < m; ++i)
	{
		if (memo[i]==n)
		{
			++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char str[100];
    int count=0;
    cin>>str;
    for(int i=0;i<=99;i++)
    {
    if(str[i]=='\0')
    break;
    else
    count++;
    }
    int i;
    for(int i=0;i<count;i++)
    printf("%c",'x');
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

/*
   cin.tie(0);
   ios::sync_with_stdio(false);
 */

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int a[2000005];

int main(){
  ll n,ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  ll xsum=0,sum=0;
  
  int r=0;
  for(int l=0;l<n;l++){
    while(r<n){
      if((xsum xor a[r])!=(sum + a[r]))break;
      xsum=(a[r] xor xsum);
      sum+=a[r];
      r++;
    }
    ans+=(r-l);
    xsum^=a[l];
    sum-=a[l];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,X,Y;
    cin>>N>>X>>Y;
    vector<int>A(N-1);
    for(int i=1;i<N;i++){
        for(int j=i+1;j<N+1;j++){
            int NN=min(min((abs(i-X)+abs(j-Y)+1),(abs(Y-i)+abs(j-X)+1)),j-i);
            A.at(NN-1)=A.at(NN-1)+1;
        }
    }
    for(int i=0;i<N-1;i++){
        cout<<A.at(i)<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pk(x) cout<<(x)<<" ";
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c,d,n,m,x[100001],y[100001],z,h,w,k,sum,mi=inf,ma=-inf,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<ll, ll> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;

ll alphasum[26];

int main(void){
    cin>>n>>st;
    rep(i,n){
        alphasum[st[i]-'a']++;
    }
    ans=1;
    rep(i,26){
        ans=ans*(alphasum[i]+1)%mod;
    }
    p((ans-1)%mod);
    return 0;
}


Measured memory_bytes: 1020
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
bool all_same(vector<T> v1,vector<T> v2)
{
    sort(ALL(v1));
    sort(ALL(v2),greater<T>());
    return v1 == v2;
}
   
// g++ -std=c++11 prac.cpp
ll Max=-1e9,Min=1e9+1;

int main(){
    int x,y,z,n,m,l,w,sum=0,sum2=0,ans=0;
    string s,t;
    bool f=false;
    cin >> n >> m;
    VI num(n,1);
    VB red(n,false);
    red[0] = true;

    rep(i,m){
        cin >> x >> y;
        if(red[x-1])
            red[y-1]=true;

        num[x-1] = num[x-1]-1;
        num[y-1] = num[y-1]+1;
        
        if(num[x-1]==0)
            red[x-1]=false;
    }
    rep(i,n){
        if(red[i]==true)
            ans++; 
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

int main()
{
    ll i,j;
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    priority_queue<pair<ll,ll>> pq;
    ll ans = 0;
    for(i = 0;i < a;++i){
        ll tmp;
        cin >> tmp;
        pq.emplace(tmp,2);
    }
    for(i = 0;i < b;++i){
        ll tmp;
        cin >> tmp;
        pq.emplace(tmp,1);
    }
    for(i = 0;i < c;++i){
        ll tmp;
        cin >> tmp;
        pq.emplace(tmp,0);
    }
    ll xf = 0;
    ll yf = 0;
    ll sum = 0;
    while(sum < x+y){
        auto apple = pq.top();
        pq.pop();
        if(apple.second == 2){
            if(xf == x){
                continue;
            }else{
                ans += apple.first;
                ++xf;
                ++sum;
            }
        }else if(apple.second == 1){
            if(yf == y){
                continue;
            }else{
                ans += apple.first;
                ++yf;
                ++sum;
            }
        }else{
            ans += apple.first;
            ++sum;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10604
fun main(vararg args: String) {
    val input = readLine()!!.split(" ")

    val a = input[0].toInt()
    val b = input[1].toInt()

    if((a - b) % 2 != 0) {
        println("IMPOSSIBLE")
    }else{
        val tmp = Math.abs((a - b) / 2) // 等しくなる数
        println(tmp + Math.min(a, b))
    }
}

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

int main() {
  int N, K, X, Y, goukei;
  cin >> N >> K >> X >> Y;

  for(int i = 0;K > i && N > i; i++) {
    goukei += X;
  }
  for(int j = K; j < N; j++) {
    goukei += Y;
  }
  cout << goukei << endl;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> p(N+1);

    for(int i=1;i<=N;i++) {
        cin >> p[i];
    }
    int k = 0;
    for(int i=1;i<=N;i++) {
        if(p[i] != i) k++;
    }
    if(k<=2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++)
    {
        cin>>vec.at(i);
    }
    int cmax,cmin;
    cmin=vec.at(0);
    int64_t money=1000;
    int k=0;
    for (int i = 1; i < n; i++)
    {
        if (vec.at(i)>vec.at(i-1))
        {
            cmax=vec.at(i);
            k=1;
        }else if (vec.at(i)==vec.at(i-1))
        {
        }else        
        {
            if (k==1)
            {
                money=(money/cmin)*cmax+money%cmin;
                cmin=vec.at(i);
                k=0;
            }else
            {
                cmin=vec.at(i);
                k=0;
            }
            
            

        }
        
        
    }
    if (k==1)
    {
        money=(money/cmin)*cmax+money%cmin;
    }
    cout<<money<<endl;
    
    

    
    

    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
 
int main(void)
{
    int n,x,i,j,k,a;
    while(1){
        scanf("%d%d",&n,&x);
        if(!(n||x))break;
        a=0;
        for(i=1;i<n-1;i++)for(j=i+1;j<n;j++)for(k=j+1;k<=n;k++)if(i+j+k==x)a++;
        printf("%d\n",a);
    }
    return 0;
}


Measured memory_bytes: 2072
/******tech_knight18_@7******/
/*I'm_not_the_only_traveller*/
/*who_has_not_repaid_his_debt*/
/*Take_me_back_to_The_Night_We_Met*/
#include<bits/stdc++.h>
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define lexichar(x,y)     lexicographical_compare(x,x+strlen(x),y,y+strlen(y)) //modify the ranges
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()) 
#define MOD               1000000007
#define pi                3.1415926536
#define tod               1
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;
template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}

int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
      lld t=1; //cin>>t;  
      while(t--){
          lld n; cin>>n;
          if(n%1000==0)  cout<<0<<nl;
          else  cout<<(n/1000+1)*1000-n<<nl;
      }
}


Measured memory_bytes: 3684
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define SZ(x) ((int)(x).size())
#define TC(tc) while (tc--)
#define VI vector<int>
#define PII pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;


int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n; cin >> n;
    int c = 0;
    FOR(i, 0, n)
    {
        int a; cin >> a;
        if (i % 2 == 0 && a % 2 == 1) c++;
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 3584
import sys
from operator import itemgetter as ig
input=sys.stdin.readline

m,n=map(int,input().split())
dt=[]
for i in range(n):
    p,y = map(int, input().split())
    dt+=[[i,p,y,0]]
dt.sort(key=ig(1,2))
pi=1
prep=0
for x in dt:
    if prep==x[1]:
        pi+=1
    else:
        pi=1
    x[3]=pi
    prep=x[1]
dt.sort()
for x in dt:
    print(str(x[1]).zfill(6)+str(x[3]).zfill(6))

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

using namespace std;

int main() {
    vector<int> a, b;
    vector<string> op;
    int n, m, i = 0;
    string o;
    
    while(1) {
        cin >> n >> o >> m;
        a.push_back(n);
        op.push_back(o);
        b.push_back(m);
        
        if(op[i] == "?") break;
        
        i++;
    }
    
    for(i = 0; i < a.size(); i++) {
        if(op[i] == "?") break;
        
        if(op[i] == "+") cout << a[i]+b[i] << endl;
    
        if(op[i] == "-") cout << a[i]-b[i] << endl;
    
        if(op[i] == "*") cout << a[i]*b[i] << endl;
    
        if(op[i] == "/") cout << a[i]/b[i] << endl;
    }
    
}

Measured memory_bytes: 1236
while True:
    n = int(input())
    if n == 0:
        exit()
    s = list(map(int,input().split()))
    m = sum(s) / n
    aa = 0
    for si in s:
        aa += (si - m) ** 2
    print(format((aa / n)**0.5,"0.5f"))



Measured memory_bytes: 5668
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ar array
#define db long double
#define pow pw
const db pi = 3.14159265358979323846;
int pw(int a,int b){
    int ans=1;
    while(b){
    if (b%2) ans*=a;
    a*=a;
    b/=2;
    }
    return(ans);
}
const int mxn=3001;
int n;
db a[mxn];
db dp[mxn];
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
    dp[0]=1;
    for (int i=1;i<=n;i++)
    {
        for (int j=i;j>=0;j--)
        dp[j]=(j>0?dp[j-1]*a[i]:0)+dp[j]*(1-a[i]);
    }
    db ans=0;
    for (int i=n;i>=0;i--)
    {
        int j=n-i;
        if (j>i) break;
        ans+=dp[i];
    }
    cout<<fixed<<setprecision(9)<<ans;
    return 0;
}

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

using namespace std;

int evaluate(const string &trump, const string &led, const string &s){
	int score = 0;
	if(isdigit(s[0])){
		score = s[0] - '0';
	}else if(s[0] == 'T'){
		score = 10;
	}else if(s[0] == 'J'){
		score = 11;
	}else if(s[0] == 'Q'){
		score = 12;
	}else if(s[0] == 'K'){
		score = 13;
	}else if(s[0] == 'A'){
		score = 14;
	}
	if(s[1] == led[1]){ score += 15; }
	if(s[1] == trump[0]){ score += 30; }
	return score;
}

int main(){
	while(true){
		string trump;
		cin >> trump;
		if(trump == "#"){ break; }
		vector<string> cards[4];
		for(int i = 0; i < 4; ++i){
			cards[i].resize(13);
			for(int j = 0; j < 13; ++j){ cin >> cards[i][j]; }
		}
		int score[4] = { 0 };
		int dealer = 3;
		for(int i = 0; i < 13; ++i){
			const string p = cards[dealer][i];
			int winner = dealer, highest = 0;
			for(int j = 0; j < 4; ++j){
				const int s = evaluate(trump, p, cards[j][i]);
				if(s > highest){
					highest = s;
					winner = j;
				}
			}
			++score[winner];
			dealer = winner;
		}
		const int ns = score[0] + score[2], ew = score[1] + score[3];
		if(ns > ew){
			cout << "NS " << (ns - 6) << endl;
		}else{
			cout << "EW " << (ew - 6) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << ' ' << x << ' ' << y << '\n';
 	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll T;

vector<ll> ansvec;

int main() {
  cin >> T;
  rep(i, 0, T) {
    ll N;
    cin >> N;
    map<ll, vector<Pll>> red, blue;
    priority_queue<ll, vector<ll>, greater<ll>> red_que, blue_que;
    ll ans = 0;
    rep(j, 0, N) {
      ll k, l, r;
      cin >> k >> l >> r;
      ans += min(l, r);
      if (l >= r) {
        red[k].push_back(Pll(l, r));
      } else {
        blue[N - k].push_back(Pll(r, l));
      }
    }

    repe(i, 1, N) {
      for (auto e : red[i]) {
        red_que.push(e.first - e.second);
      }
      while (red_que.size() > i) {
        red_que.pop();
      }
    }
    while (!red_que.empty()) {
      auto add = red_que.top();
      red_que.pop();
      ans += add;
    }

    repe(i, 1, N) {
      for (auto e : blue[i]) {
        blue_que.push(e.first - e.second);
      }
      while (blue_que.size() > i) {
        blue_que.pop();
      }
    }
    while (!blue_que.empty()) {
      auto add = blue_que.top();
      blue_que.pop();
      ans += add;
    }

    ansvec.push_back(ans);
  }

  for (auto e : ansvec) {
    cout << e << "\n";
  }
}


Measured memory_bytes: 41452
#include <stdio.h>
int main()
{
    int k, a, b; scanf("%d%d%d", &k, &a, &b);
    long res1=k+1, res2=1;
    while (k>1) {
        if (res2<a) {
            ++res2;
            --k;
        }
        else {
            res2-=a;
            res2+=b;
            k-=2;
        }
    }
    res2+=k;
    printf("%lld\n", res1<res2 ? res2 : res1);
}


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

using namespace std;

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

  int sum = 0;
  unordered_set<int> sumSet;
  for (int i = 1; i <= n; i++) {
    sumSet.insert(i);
    sum += i;

    if (sum >= n) {
      break;
    }
  }

  int d = sum - n;
  sumSet.erase(d);

  for (int i : sumSet) {
    cout << i << endl;
  }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end());
#define fill(a,x) memset(a,x,sizeof(a))
#define zero(a) fill(a,0)
#define minus(a) fill(a,-1)
#define dbg(x) cout << #x"=" << x << endl

struct Node{
  Node* l;
  Node* r;
  Node* p;
  int key;
};

vi num_array;
Node *root;
Node *nil;

void ins(int num){
  Node *n_node;
  n_node=(Node*)malloc(sizeof(Node));
  n_node->key=num;
  n_node->l=NULL;
  n_node->r=NULL;
  Node *x=root;
  Node *y=NULL;
  while(x!=NULL){
    y=x;
    if(x->key < num) x=x->r;
    else x=x->l;
  }
  n_node->p=y;
  if(y==NULL) root = n_node;
  else{
    if(num > y->key) y->r = n_node;
    else y->l = n_node;
  }
}

void array_generator(Node *d){
  if(d==NULL) return;
  if(d->r != NULL){
    num_array.pb(d->r->key);
    array_generator(d->r);
  }
  if(d->l != NULL){
    num_array.pb(d->l->key);
    array_generator(d->l);
  }
}

void del(Node *d){
  array_generator(d);
  if(d->p->l->key == d->key) d->p->l = NULL;
  else d->p->r = NULL;
  free(d);
  rep(i,num_array.size()) ins(num_array[i]);
  num_array.clear();
}

Node* find(Node *p,int num){
  if(p==NULL) return nil;
  if(p->key==num) return p;
  if(p->key < num) find(p->r,num);
  else find(p->l,num);
}

void preorder(Node *p){
  if(p==NULL) return;
  cout << " " << p->key;
  preorder(p->l);
  preorder(p->r);
}

void inorder(Node *p){
  if(p==NULL) return;
  inorder(p->l);
  cout << " " << p->key;
  inorder(p->r);
}

int main(){
  int total,num;
  cin >> total;
  string cmd;
  rep(i,total){
    cin >> cmd;
    if(cmd=="insert"){
      cin >> num;
      ins(num);
    }else if(cmd=="print"){
      inorder(root); cout<<endl;
      preorder(root); cout<<endl;
    }else if(cmd=="find"){
      cin >> num;
      Node *t = find(root,num);
      if(t==nil) cout << "no" << endl;
      else cout << "yes" << endl;
    }else if(cmd=="delete"){
      cin>>num;
      del(find(root,num));
    }
  }
}



Measured memory_bytes: 26492
r,g,b,n=map(int,input().split())
ans=0

for i in range(1+n//r):
  red=i*r
  for j in range(1+(n-red)//g):
    green=j*g
    if((n-red-green)%b==0 and (n-red-green)>=0):
      ans+=1
print(ans)

Measured memory_bytes: 3060
S = int(input())

n = S
a = {S}
for i in range(1, 10**6+1):
    if n%2==0:
        n = n//2
    else:
        n = 3*n+1
    
    if n in a:
        print(i+1)
        exit()
    else:
        a.add(n)
    

Measured memory_bytes: 3068
// D - Banned K
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int N;
vl A;

vl solve(){
	vl m(N+1), csum(N+1), del(N+1);

	rp(i,0,N) m[A[i]]++;

	rp(a, 1, N+1){
		ll c = m[a];
		if(c>=2) csum[a] = c*(c-1)/2;//組み合わせ
		c--;
		if(c>=2) del[a] = c*(c-1)/2;//１減の組み合わせ
	}

	rp(i, 1, N+1) csum[i] += csum[i-1];//Cumulative sum: 累積和

	vl ans(N+1, 0);
	rp(k, 1, N+1){
		int ak = A[k-1];
		ll m = del[ak];// k の組み合わせ
		ll f = csum[ak-1];// k より前の組み合わせの和
		ll b = csum[N] - csum[ak];// k より後の組み合わせの和
		ans[k] = f + m + b;
	}

	return ans;
}

int main(){
	cin>>N;
	A.resize(N);
	rp(i, 0, N) cin>>A[i];
	vl ans = solve();
	rp(i, 1, N+1) cout<< ans[i] <<endl;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
const int mo=1e9+7,N=5005;
int n,a,b,i,j,k,l,f1[N],f2[N],g[N][2][2],ans;
inline void add(int&a,const int&b){a+=b-mo;a+=a>>31&mo;}
int main(){
	scanf("%d%d%d",&n,&a,&b);if(a<b)std::swap(a,b);
	for(i=1;i<=n;++i)f1[i]=1;
	for(i=1;i<n;++i)for(j=b+1;i+j<=n;++j)f1[i+j]=(f1[i+j]+1ll*f1[i]*(j-b))%mo;
	for(i=b+1;i<=n;++i)f2[i]=i-b;
	for(i=1;i<n;++i)for(j=b+1;i+j<=n;++j)f2[i+j]=(f2[i+j]+1ll*f2[i]*(j-b))%mo;
	for(i=1;i<=n;++i)add(f2[i],f1[i]);
	g[0][1][0]=1;
	for(i=1;i<=n;++i)g[i][1][i>=a]=f2[i];
	for(i=0;i<=n;++i){
		for(j=1;j<b && i+j<=n;++j)for(k=0;k<2;++k)add(g[i+j][0][k],g[i][1][k]);
		for(j=1;i+j<=n;++j)for(k=0;k<2;++k)add(g[i+j][1][k|(j>=a)],1ll*(i+j==n?f2[j]:f1[j])*g[i][0][k]%mo);
	}
	for(i=b;i<=n;++i)for(j=b;i+j+1<=n;++j)ans=(ans+f1[n-i-j])%mo;
	for(j=b;j+1<=n;++j)ans=(ans+f1[n-j])%mo;
	ans=(1ll*ans+1+g[n][0][1]+g[n][1][1])%mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 3936
#include<iostream>
#include <stdlib.h>
using namespace std;

int main(void) {
	char n[4];
	cin >> n;

	if (n[0] == '7'  || n[1] == '7' || n[2] == '7')cout << "Yes" << endl;
	else cout << "No" << endl;
	 return 0;
	
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

inline int stoii(string s) {
    int ans = 0;
    for (auto x:s)ans = ans * 10 + x - '0';
    return ans;
}

void solve() {
    int a, b;
    cin >> a >> b;

    int z = stoii(to_string(a) + to_string(b));
    int tp = sqrt(z);
    if (tp * tp == z)
        cout << "Yes";
    else
        cout << "No";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string A,B;
	cin >> A >> B;
	int cnt=0;
	for(int i=0;i<A.length();i++){
		if(A[i]!=B[i])
			cnt+=1;
	}
	cout << cnt << endl;
}


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

int main() {
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;

    if(S == U) cout << A-1 << " " << B << endl;
    else cout << A << " " << B-1 << endl;
}

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

#define vl vector<ll>
#define vs vector<string>
#define vll vector< vector<ll> >
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define psl pair<string,ll>
#define tll tuple<ll, ll, ll>
#define vp vector< pair<ll,ll> >
#define vt vector< tuple<ll, ll, ll> >
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
#define NN 2020202

//command
//c++ atcoder.cpp -std=c++14
//./a.out

//cout << setprecision(12) << ans << endl;

int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;

  char ans[s.length()];

  for (int i=0;i<s.length();i++){
    for (int j=0;j<n;j++){
      if (s[i] == 'Z') s[i] = 'A';
      else ++s[i];
      //cout << s[i] << endl;
    }
  }

  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  int N; cin>>N;
  ld a[N];
  ld s = 0;
  REP(i,N){
    cin >> a[i];
    s += a[i];
  }
  ld avr = s/N;
  
  int r_idx = -1;
  ld d_min = 1000;
  REP(i,N){
    ld d = abs(a[i]-avr);
    if(d<d_min){ d_min = d; r_idx = i; }
  }
  cout << r_idx <<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int a,b;
  cin >> a >> b;
  int ans = 0;
  if((b-a)/2 % 2 == 0){
    ans = 0;
  }
  else{
    ans = 1;
  }
  if(a % 2 == 0 && b % 2 == 0){
    if((b-a)/2 % 2 == 0){
    ans = 0;
    }
    else{
      ans = 1;
    }
    ans = ans^b;
    cout << ans << endl;
  }
  else if(a % 2 == 1 && b % 2 == 0){
    if((b-a)/2 % 2 == 0){
    ans = 0;
    }
    else{
      ans = 1;
    }
    ans = ans^a^b;
    cout << ans << endl;
  }
  else if(a % 2 == 1 && b % 2 == 1){
    if((b-a)/2 % 2 == 0){
    ans = 0;
    }
    else{
      ans = 1;
    }
    ans = ans^a;
    cout << ans << endl;
  }
  else{
    if((b-a+1)/2 % 2 == 0){
    ans = 0;
    }
    else{
      ans = 1;
    }
    cout << ans << endl;
  }
}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main()
{
  string S;
  cin >> S;

  reverse(S.begin(), S.end());
  for(int i=0;i<4;++i) reverse(divide[i].begin(), divide[i].end());

  bool can = true;
  for(int i=0;i<(int)S.size();)
  {
    bool can2 = false;
    for(int j=0;j<4;++j)
    {
      string d = divide[j];
      if(S.substr(i, d.size()) == d)
      {
        can2 = true;
        i += d.size();
      }
    }
    if(!can2)
    { 
      can = false;
      break;
    }
  }
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 512
def max(a,b); a < b ? b : a; end
def min(a,b); a < b ? a : b; end

class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)

  def initialize
    @n = gets.to_s.to_i
  end

  def solve
    n >= 30
  end
  
  def show(ans)
    puts ans ? "Yes" : "No"
  end
end

Problem.new.instance_eval do
  show(solve)
end


Measured memory_bytes: 14412
import java.util.Scanner;
	class Main {
	public static void main(String[] args){
        
		Scanner s = new Scanner(System.in);
		int i,j,r,c,n;
        
                  r=s.nextInt();
      			  c=s.nextInt();
        int[][] sam=new int[r+1][c+1];
      
        for(i=0;i<r;i++){
            for(j=0;j<c;j++){
                sam[i][j]=n=s.nextInt();
                sam[i][c]+=sam[i][j];
                sam[r][j]+=sam[i][j];
                sam[r][c]+=sam[i][j];
            }
        }
        for(i=0;i<r+1;i++){
            for(j=0;j<c+1;j++){
               System.out.print(sam[i][j]);
                if(j!=c)System.out.print(" ");
            }
            System.out.println();
        }
	}
}


Measured memory_bytes: 42488
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what

using namespace std;

const int N = (int) 2e5 + 10;
const int M = (int) 2e6 + 10;
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const double EPS = (double) 1e-9;
const double PI =  3.14159265359;

int n, m;
int a[N];
vector<pii> s1, s2;
ll ans[N];
int cnt[N];
ll sum[N], buff[N];

void dudu() {
    ll asd = 0;
    for (auto it : s1) {
        sum[it.f + 1] += it.f + 1;
        sum[it.s + 1] -= it.f + 1;
        cnt[it.f + 1]++;
        cnt[it.s + 1]--;
        asd += it.s - it.f;
    //    for (int i = it.f + 1; i <= it.s; i++)
    //        ans[i] -= i - it.f - 1;
    }
    for (int i = 1; i <= m; i++) {
        sum[i] += sum[i - 1];
        cnt[i] += cnt[i - 1];
        ans[i] += asd - (-sum[i] + cnt[i] * 1ll * i);
    }
    memset(sum, 0, sizeof(sum));
    memset(cnt, 0, sizeof(cnt));
    for (auto it : s2) {
        sum[it.s] += it.s;
        cnt[it.s]++;
    }
    for (int i = m; i >= 1; i--) {
        sum[i] += sum[i + 1];
        cnt[i] += cnt[i + 1];
        ans[i] += sum[i] - cnt[i] * 1ll * (i - 1);
    }
    memset(sum, 0, sizeof(sum));
    memset(cnt, 0, sizeof(cnt));
    for (auto it : s2) {
        sum[it.f + 1] += m + it.s;
        cnt[it.f + 1]++;
    }
    for (int i = 1; i <= m; i++) {
        sum[i] += sum[i - 1];
        cnt[i] += cnt[i - 1];
        ans[i] += sum[i] - (i - 1) * 1ll * cnt[i];
    }
    memset(sum, 0, sizeof(sum));
    for (auto it : s2) {
        sum[it.s + 1] += m - it.f + it.s;
        sum[it.f + 1] -= m - it.f + it.s;
    }
    for (int i = 1; i <= m; i++) {
        sum[i] += sum[i - 1];
        ans[i] += sum[i];
    }
}

int main() {
    #define fn "bst"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        //freopen(fn".in", "r", stdin);
        //freopen(fn".out", "w", stdout);
    #endif
    srand(time(0));
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i < n; i++) {
        if (a[i] <= a[i + 1]) {
            s1.pb(mp(a[i], a[i + 1]));            
        } else {
            s2.pb(mp(a[i], a[i + 1]));
        }
    }
    dudu();
    ll mn = LINF;
    for (int i = 1; i <= m; i++) {
        //cout << i << ' ' << ans[i] << endl;
        mn = min(mn, ans[i]);
    }
    cout << mn;
    return 0;
}

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

int main(){

  long long n,t;
  string f;
  long long sum=0;
  long long temp_n;
  long long temp_t;
  long long k;
  
  cin>>n>>t;
  cin>>f;
  
  for(int i=0;i<f.size();++i){
	if(f[i]=='^'){
	  i++;
	  temp_t=f[i]-'0';
	  k=1;
	  for(int j=0;j<temp_t;++j){
		k*=n;
		if(sum+k>1000000000){
		  cout<<"TLE"<<endl;
		  return 0;
		}
	  }
	  sum+=k;
	}
  }
  
  if((sum*t<=1000000000))
	cout<<sum*t<<endl;
  else
	cout<<"TLE"<<endl;
	
}



Measured memory_bytes: 3172