akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define cel(n, k) ((n-1)/k+1)
#define sets(a) memset(a, -1, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))
 
 
#define fr(i, n) for(int i=0; i<n;i++)
#define fr1(i, n) for(int i=1; i<=n;i++) 
 
#define readf(f) freopen(f, "r", stdin)
#define writef(f) freopen(f, "w", stdout)
 
#define fastio() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file() readf("in.txt"),writef("out.txt")
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define nl "\n"
#define sp " "
 
template< class T > T sq(T x) { return x * x; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
typedef long long ll;
typedef pair<int,int> pii;
 

int main()
{
	
	//file();
    
    fastio();
 
    int n;

    ll sum = 0;

    cin>>n;

    for(int i = 1; i <= n; i++){
    	if(i%3==0 or i%5==0)
    		continue;
    	else
    		sum += i;
    }

    cout<<sum<<nl;
 
   
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
#define pll pair<ll, ll>
#define vpl vector<pll>
#define vb vector<bool>
#define PB push_back
#define MP make_pair
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=s; i>=e; i--)
#define vasort(v) sort(v.begin(), v.end())
#define vdsort(v) sort(v.begin(), v.end(),greater<ll>())
#define F first
#define S second

#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6

#define mz(a)   memset(a,0,sizeof(a))
#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

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

int main() {
    zoom;
    ll a,b,c,d;
    in4(a,b,c,d);
    ll x1=a*c;
    ll x2=a*d;
    ll x3=b*c;
    ll x4=b*d;
    out1(max(x1,max(x2,max(x3,x4))));
    return 0;
}


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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

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

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int n;

vec<int> g[Sz];

int depth[Sz];

void calc (int v) {
  for (int to :  g[v]) {
    calc(to);  
  }    
  sort (g[v].begin(), g[v].end(), [] (int a, int b) { return depth[a] < depth[b]; });
                         
  for (int to : g[v]) {
    depth[v] = max (depth[v], depth[to]) + 1;
  }    
}
   
int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  int n; cin >> n;
  for (int i = 2; i <= n; i++) {
    int pr; cin >> pr;
    g[pr].pb (i);
  }
  calc (1);

  cout << depth[1];

  return 0;
}






// Coded by Z..



Measured memory_bytes: 36352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=305;
int n,a[N<<1][N<<1];
void hf(int x,int de){
	int t=0;
	while(x%4==0){x/=4; t++;}
	if(x%4==2){
		For(i,0,2*n-1){
			For(j,0,2*n-1)if(i>>t&1)a[i][j]|=de;
		}
	}else {
		For(i,0,2*n-1){
			For(j,0,2*n-1)if(((i>>t)+(j>>t))&1)a[i][j]|=de;
		}
	}
}
vector<PI> v[4];
int main(){
	n=read(); int d1=read(),d2=read();
	hf(d1,1);
	hf(d2,2);
	For(i,0,2*n-1)For(j,0,2*n-1)v[a[i][j]].pb(mp(i,j));
	For(i,0,3)if(v[i].size()>=n*n){
		For(j,0,n*n-1)wri(v[i][j].fi),writeln(v[i][j].se); return 0;
	}
}

Measured memory_bytes: 5992
class Stack(object):
    def __init__(self):
        self.container = []

    def __len__(self):
        return len(self.container)

    def push(self, elem):
        self.container.append(elem)

    def pop(self):
        index = len(self.container) - 1
        if index < 0:
            return None
        ret = self.container[index]
        del self.container[-1]
        return ret

    def compare(self, val):
        return self.container[-1] == val

if __name__ == '__main__':
    N = int(input())
    S = input()
    stack = Stack()
    stack.push(S[0])
    for s in S[1:]:
        if not stack.compare(s):
            stack.push(s)
    print(stack.__len__())

Measured memory_bytes: 4060
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

//うるう年判定
bool isLeap(int y) {
	bool flag = false;
	if (y % 4 == 0)flag = true;
	if (y % 100 == 0)flag = false;
	if (y % 400 == 0)flag = true;
	return flag;
}

int main() {
	bool first = true;

	while (true) {
		int a, b; cin >> a >> b;
		if (a == 0 && b == 0)break;

		if (!first)puts("");

		bool flag = false;
		FOR(i, a, b + 1)if (isLeap(i)) {
			flag = true;
			Cout(i);
		}
		if (!flag)puts("NA");

		first = false;
	}
}


Measured memory_bytes: 3072
n = gets().to_i
a = gets().split(" ")

check = Array.new(n)

for i in 0..n-1
	a[i] = a[i].to_i
	if a[i] %2 == 0
		check[i] = 2
	elsif a[i] %2 == 1
		check[i] = 1
	end
end

seki = 1
all = 1

for j in 0..n-1
	seki = seki * check[j]
	all = all * 3
end

ans = all - seki

puts(ans)


Measured memory_bytes: 1788
n = int(input())
abs_ = [tuple(map(int, input().split())) for _ in range(n)]
cds = [tuple(map(int, input().split())) for _ in range(n)]

ab_to = [set() for _ in range(len(abs_))]
cd_from = [set() for _ in range(len(cds))]

ab_pair = [-1 for _ in range(len(abs_))]
cd_pair = [-1 for _ in range(len(cds))]

def dfs(j, visited):
    i = cd_pair[j]
    if i == -1:
        return [j]
    visited.add(j)
    for k in ab_to[i]:
        if k in visited:
            continue
        #visited.add(k)
        r = dfs(k, visited)
        if r is not None:
            r.append(j)
            return r

for i, (a, b) in enumerate(abs_):
    for j, (c, d) in enumerate(cds):
        if a < c and b < d:
            ab_to[i].add(j)
            cd_from[j].add(i)
            """
            if ab_pair[i] == -1 and cd_pair[j] == -1:
                ab_pair[i] = j
                cd_pair[j] = i
            """

# print(ab_pair)
# print(cd_pair)

continue_ = True
while continue_:
    continue_ = False
    for i, (a, b) in enumerate(abs_):
        if ab_pair[i] == -1:
            visited = set()
            for cand in ab_to[i]:
                route = dfs(cand, visited)
                #print(route)
                if route is not None:
                    continue_ = True
                    for k in range(len(route)-1):
                        a = cd_pair[route[k+1]]
                        ab_pair[a], cd_pair[route[k]] = route[k], a
                    ab_pair[i], cd_pair[route[-1]] = route[-1], i
                    break

# print(ab_pair)
print(sum(1 for p in ab_pair if p != -1))


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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,k;
    cin >> n >> k;
    int a[n];
    vector<bool> dp(k+1,false);
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = 1;i <= k;++i) {
        bool f = false;
        for (int j = 0;j < n;++j) {
            if (i-a[j] < 0) break;
            if (!dp[i-a[j]]) f = true;
        }
        if (f) dp[i] = true;
    }
    cout << (dp[k] ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

string R, T;

int main() {
	cin >> R >> T;

	//Tの方が長かったら無条件で詰み
	int lr = (int)R.length();
	int lt = (int)T.length();
	if (lr<lt) cout << "UNRESTORABLE";
	else {
		//Tが適合するか下から検索
		bool match = false;
		for (int i = lr - lt;i >= 0;i--) {
			bool ptmatch = true;
			rep(j, lt)if (T[j] != R[i + j] && R[i + j] != '?')ptmatch = false;
			if (ptmatch) {
				match = true;
				rep(j, lt)R[i + j] = T[j];
				rep(j, lr) {
					if (R[j] == '?') R[j] = 'a';
					cout << R[j];
					}
					break;
				}
		}
		if (!match)cout << "UNRESTORABLE";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
  int a, b;
  cin >> a >> b;
  if((a>0) || (b<0 && (b-a)%2!=0))cout << "Positive" << endl;
  else if((b<0) && ((b-a)%2==0)) cout << "Negative" << endl;
  else cout << "Zero"<<endl;
}

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

public class Main{

 Scanner sc=new Scanner(System.in);;

 int INF=1<<28;
 double EPS=1e-9;

 int[][] a;
 int w, h;
 boolean[][] visited;

 void run(){
  for(;;){
   h=sc.nextInt();
   w=sc.nextInt();
   if((h|w)==0){
    break;
   }
   a=new int[h][w];
   visited=new boolean[h][w];
   for(int j=0; j<h; j++){
    String s=sc.next();
    for(int i=0; i<w; i++){
     switch(s.charAt(i)){
     case '@':
      a[j][i]=0;
      break;
     case '#':
      a[j][i]=1;
      break;
     case '*':
      a[j][i]=2;
      break;
     }
    }
   }
   solve();
  }
 }

 void solve(){
  int ans=0;
  for(int j=0; j<h; j++){
   for(int i=0; i<w; i++){
    if(!visited[j][i]){
     ans++;
     bfs(i, j);
    }
   }
  }
  println(ans+"");
 }

 void bfs(int x, int y){
  LinkedList<P> que=new LinkedList<P>();
  que.offer(new P(x, y));
  visited[y][x]=true;
  int[] dx={0, 0, -1, 1};
  int[] dy={-1, 1, 0, 0};
  for(; !que.isEmpty();){
   P p=que.poll();
   for(int i=0; i<4; i++){
    P q=new P(p.x+dx[i], p.y+dy[i]);
    if(q.x>=0&&q.x<w&&q.y>=0&&q.y<h&&!visited[q.y][q.x]
      &&a[p.y][p.x]==a[q.y][q.x]){
     que.offer(q);
     visited[q.y][q.x]=true;
    }
   }
  }
 }

 class P{
  int x, y;

  P(int x, int y){
   this.x=x;
   this.y=y;
  }
 }

 void debug(Object... os){
  System.err.println(Arrays.deepToString(os));
 }

 void print(String s){
  System.out.print(s);
 }

 void println(String s){
  System.out.println(s);
 }

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



Measured memory_bytes: 32028
N = int(input())
A = list(map(int, input().split()))
total = sum(A)
mid = total // 2
sum_left, sum_left2 = 0, 0
sep_i = 0
for i, a in enumerate(A):
  sum_left += a
  if sum_left >= mid:
    sep_i = i
    sum_left2 = sum_left - a
    break
sum_right, sum_right2 = sum(A[sep_i + 1:]), sum(A[sep_i:])
print(min(abs(sum_right - sum_left), abs(sum_right2 - sum_left2)))

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


void solve(std::string S){
  string ans = (S == "ABC") ? "ARC" : "ABC";
  cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3628
N,M = gets.split.map(&:to_i)
G = Array.new(N + 1){ [] }
E = M.times.map{ gets.split.map(&:to_i) }
E.each do |from,to|
  G[from] << to
end

ACTIVE = Array.new(N + 1)
USED = Array.new(N + 1)
SUBGRAPH = Array.new(N + 1)

def active?(v); ACTIVE[v]; end
def activate!(v);  ACTIVE[v] = true; end
def inactivate!(v); ACTIVE[v] = false; end
def used?(v); USED[v]; end
def use!(v); USED[v] = true; end
def subgraph_include?(v); SUBGRAPH[v]; end
def subgraph_init!(vset)
  ACTIVE.fill(false)
  USED.fill(true)
  SUBGRAPH.fill(false)
  vset.each{|v| USED[v] = false; SUBGRAPH[v] = true }
end
  
def cycle_exists?
  (1 .. N).each do |s|
    next if used?(s)
    
    stack = [s]; use!(s)
    cycle = find_cycle(stack)
    return cycle if cycle
  end
  return false
end

def smaller_cycle?(cycle)
  subgraph_init!(cycle)
  
  stack = nil
  smaller_not_found = cycle.each_with_index.none? do |from, i|
    to = (i + 1 == cycle.size ? cycle[0] : cycle[i + 1])
    to_ = G[from].find{|to_| subgraph_include?(to_) && to_ != to }
    stack = [from, to_] if to_
  end
  return false if smaller_not_found

  use!(stack[0])
  use!(stack[1])
  activate!(stack[0])

  find_cycle(stack)
end

def find_cycle(stack)
  until stack.empty?
    u = stack.pop
    
    if active?(u)
      inactivate!(u)
      next
    else
      activate!(u)
      stack << u
    end
    
    G[u].each do |v|
      return stack.select{|r| active?(r) }.drop_while{|r| r != v } if active?(v)
      next if used?(v)
      use!(v)
      stack << v
    end
  end
  false
end

cycle = cycle_exists?
if !cycle
  puts -1
else
  loop do
    smaller = smaller_cycle?(cycle)
    if smaller  
      cycle = smaller
    else
      break
    end
  end
  puts cycle.size
  puts cycle
end


Measured memory_bytes: 2172
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int K = sc.nextInt();
    /*
    int[] A = new int[M];
    int[] B = new int[M];
    for (int i = 0; i < M; i++) {
      A[i] = sc.nextInt();
      B[i] = sc.nextInt();
    }
    int[] C = new int[K];
    int[] D = new int[K];
    for (int i = 0; i < K; i++) {
      C[i] = sc.nextInt();
      D[i] = sc.nextInt();
    }
    sc.close();
    */

    @SuppressWarnings("unchecked")
    Set<Integer>[] g = new Set[N + 1];
    int[] fc = new int[N + 1];
    for (int i = 0; i < M; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      if (g[a] == null && g[b] == null) {
        Set<Integer> set = new HashSet<>();
        set.add(a);
        set.add(b);
        g[a] = set;
        g[b] = set;
      } else if (g[a] == null) {
        Set<Integer> set = g[b];
        set.add(a);
        g[a] = set;
      } else if (g[b] == null) {
        Set<Integer> set = g[a];
        set.add(b);
        g[b] = set;
      } else if (g[a] != g[b]) {
        Set<Integer> setL = g[a];
        Set<Integer> setS = g[b];
        if (setL.size() < setS.size()) {
          Set<Integer> temp = setL;
          setL = setS;
          setS = temp;
        }
        setL.addAll(setS);
        for (int c : setS) g[c] = setL;
      }
      fc[a]++;
      fc[b]++;
    }

    int[] bc = new int[N + 1];
    for (int i = 0; i < K; i++) {
      int c = sc.nextInt();
      int d = sc.nextInt();
      if (g[c] == g[d]) {
        bc[c]++;
        bc[d]++;
      }
    }
    sc.close();

    int[] ans = new int[N + 1];
    for (int i = 1; i < N + 1; i++)
      if (g[i] != null)
        ans[i] = g[i].size() - 1 - fc[i] - bc[i];

    for (int i = 1; i < N + 1; i++)
      System.out.print(ans[i] + " ");
    System.out.println();
  }
}

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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

const int inf = 1e9 + 7;
const int mod = 1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  if (a < 0) a += mod;
}

inline int mul(int a, int b) {
  return (a * (ll) b) % mod;
}

inline int pw(int x, int n) {
  int res = 1;
  while (n > 0) {
    if (n % 2) {
      res = mul(res, x);
      n--; 
    } else {
      x = mul(x, x);
      n /= 2;
    }
  }
  return res;
}

const int N = 22;

int a[N][N];
int go[1 << 21];
int dp[1 << 21];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  }
  dp[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int msk = 0; msk < (1 << n); msk++) {
      int cnt = __builtin_popcount(msk);
      if (cnt != i) {
        continue;
      }
      for (int j = 0; j < n; j++) {
        if ((msk >> j) & 1 && a[i][j + 1]) {
          add(go[msk], dp[msk ^ (1 << j)]);
        }
      }
    }
    swap(dp, go);
  }
  cout << dp[(1 << n) - 1] << '\n';
  return 0;
}

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

int main() {
  int x, y, r;
  cin >> x >> y;

  while (r != 0) {
    r = x % y;

    if (r == 0) {
      cout << y << endl;
      break;
    } else {
      x = y;
      y = r;
    }
  }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  cout << a.at(N-1) - a.at(0);
}

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

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

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

const int B = 27397, MOD = 1e9 + 7;
const int B1 = 33941, MOD1 = 1e9 + 9;

int a, b, c;

int main(void) {
  scanf("%d%d%d", &a, &b, &c);
  if (b - a == c - b)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}

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

int main(){
	int N, M;
	cin >> N >> M;
	dsu d(N);
	rep(i,M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		d.merge(a,b);
	}
	set<int> ld;
	rep(i,N) {
		ld.insert(d.leader(i));
	}
	cout << ld.size()-1 << endl;

	return 0;
}


Measured memory_bytes: 7444
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long int ld;
typedef unsigned long long int lu;
typedef vector< int > vi;
typedef vector < ld > vd;
typedef set <ld> sd;
typedef vector< vi > vvi;
typedef vector< vd > vvd;
typedef pair< int,int > ii;
typedef pair< ld,ld > id;
#define sz(a) ld((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

#define rep(i,a,b) for(i=a;i<b;i++)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define reprev(i,a,b) for(i=a;i>=b;i--)


#define Vi vector
#define pr pair
#define isnum(a) (a>=48 && a<=57)
#define isS(a) (a>='a' && a<='z')
#define isU(a) (a>='A' && a<='Z')
#define toS(a) (isU(a)?a+32:a)
#define toU(a) (isS(a)?a-32:a)
#define toC(a) a&15

vector<char> prime (10000000+1, true);
void sieve(ld n)
{	
	//O(nloglogn) time
	prime[0] = prime[1] = false;
	for (ld i=2; i<=n; ++i)
		if (prime[i])
			if (i * 1ll * i <= n)
				for (ld j=i*i; j<=n; j+=i)
					prime[j] = false;
}


vd v1;
vector <bool> visit;
vvd g;
vvd g1;
vd ar;
vvd final;
//ld mind = 1000000006;
vd mind;
ld c;

//for topological sort of a graph
void dfs(ld i,ld n)
{
	visit[i] = true;
	ld j,k;
	for(j=0;j<g[i].size();j++)
	{
		if(!visit[g[i][j]])
		{
			dfs(g[i][j],n);
		}
	}
	v1.pb(i);
}
//next step
//from transposed graph g1,get strongly connected components
void dfs1(ld i,ld n,ld len)
{
	visit[i] = true;
	ld j,k;
	final[len].pb(i);
	mind[len] = min(mind[len],ar[i]);
	rep(j,0,g1[i].size())
	{
		if(!visit[g1[i][j]])
		{
			dfs1(g1[i][j],n,len);
		}
	}
}

vvd dp;

int main(){
	ld N,i,j,k;
	ld W;
	cin >> N >> W;
	ld w[N],v[N];
	ld sum=0;
	rep(i,0,N)
	{
		cin >> w[i] >> v[i];
		sum+=v[i];
	}
	dp = vvd(N+1,vd(sum+1,1000000000));
	dp[0][0]=0;
	REP(i,1,N)
	{
		dp[i][0]=0;
	}
	REP(i,1,N)
	{
		REP(j,1,sum)
		{
			if(j<v[i-1])dp[i][j] = dp[i-1][j];
			else dp[i][j] = min(dp[i-1][j],w[i-1]+dp[i-1][j-v[i-1]]);
		}
	}
	ld maxs=0;
	reprev(i,sum,0)
	{
		if(dp[N][i]<=W)
		{
			maxs = i;
			break;
		}
		//cout << endl;
	}
	cout << maxs << endl;
	return 0;
}	

Measured memory_bytes: 89984
// AOJ 2939 Othello
// 2019.4.6 bal4u

#include <stdio.h>
#include <stdlib.h>

//// 高速入力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
//	while (isspace(c)) c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int main()
{
	int a, b, c, d, Q, r, ans;

	Q = in();
	while (Q--) {
		a = in(), b = in(), c = in(), d = in();
		ans = (c - a + 1) * (d - b + 1);
		for (r = 1 + a - (a & 1); r <= c; r += 2) {
			ans -= 1 + ((d - (b + (b & 1))) >> 1);
		}
		printf("%d\n", ans);
	}
	return 0;
}


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

int main() {
  ll a,b;
  cin >> a >> b;
  ll c = min(a,b);
  vector<ll> v(1,1);
  int i = 2;
  while(i<=c){
    if (a%i==0 && b%i==0){
      v.push_back(i);
      a=a/i;
      b=b/i;
    }
    else{
      i++;
    }
  }
  ll sum= 1;
  for(ll i = 0;i<v.size();i++){
    sum *= v.at(i);
  }
  cout << a*b*sum << endl;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll k,x;
  cin >> k >> x;
  ll mi = -1000000;
  ll ma = 1000000;
  mi = max(mi,x-k+1);
  ma = min(ma,x+k-1);
  FOR(i,mi,ma+1) cout << i << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) (cout << "#x = " << (x) << '\n')

using namespace std;
typedef long long ll;

inline char gc() {
	static char buf[100000], *p1 = buf, *p2 = buf;
	return (p1 == p2) && (p2 = (p1 = buf) +
		fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
}

#define dd ch = getchar()
template <class T>
inline void read(T &x) {
	x = 0;
	int f = 0; char dd;
	for (; !isdigit(ch); dd) f ^= (ch == '-');
	for (; isdigit(ch); dd)  x = (x << 1) + (x << 3) + (ch ^ 48);
	x = f? -x: x;
}
#undef dd

template <class T>
inline void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 | 48);
}

template <class T>
inline void wrn(T x) {
	write(x), putchar(' ');
}

template <class T>
inline void wln(T x) {
	write(x), putchar('\n');
}

template <class T>
inline void wlnn(T x, T y) {
	wrn(x), wln(y);
}

const ll P = 1e9 + 7;

ll n, a, b;

inline ll power(ll a, ll b, ll res = 1) {
	for (; b; b >>= 1, a = a * a % P) 
		res = (b & 1)? res * a % P: res;
	return res;
}

int main()
{
	read(n), read(a), read(b);
	ll X1 = 1, X2 = 1, Ans = power(2, n);
	for (ll i = n; i >= n - a + 1; --i) X1 = X1 * i % P;
	for (ll i = n; i >= n - b + 1; --i) X2 = X2 * i % P;
	for (int i = 1; i <= a; ++i) X1 = X1 * power(i, P - 2) % P;
	for (int i = 1; i <= b; ++i) X2 = X2 * power(i, P - 2) % P;
	Ans = ((Ans - X1) % P + P) % P, Ans = ((Ans - X2) % P + P) % P;
	return wln((Ans - 1 + P) % P), 0;
}

/*

*/




Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define endl '\n'

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7;
const int MAXN = static_cast<int>(1e6) + 17;

int n;
int a[MAXN];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

void solve() {
    map<ll, int> cnt;
    ++cnt[0];

    ll cur = 0, ans = 0;

    forn (i, n) {
        cur += a[i];
        ans += cnt[cur]++;
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');

#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


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

using namespace std;

int main() 
{
 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 cout.tie(nullptr);
 int n;
 cin >> n;
 bool ok = false;
 int cnt = 0;
 while (n--) {
  int x, y;
  cin >> x >> y;
  if (x == y) cnt++;
  else cnt = 0;
  if (cnt >= 3) ok = true;
 }
 cout << (ok ? "Yes" : "No") << '\n';
 return 0;
}


Measured memory_bytes: 3632
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 100505
#define M 200005
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define FJ(i,a,b) for(int i=a;i<b;++i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _q fd[rt]
#define _l fd[rt<<1]
#define _r fd[rt<<1|1]
#define MID int mid=((l+r)>>1)
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
#define PB push_back
#define SZ size
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define MP make_pair
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
using namespace std;
const int MOD=1000000007;
const double PI=acos(-1.0);
const double EPS=1e-8;
char s1[N], s2[N];
int a1[N], b1[N], a2[N], b2[N], q, x1, y11, x2, y2;
int main(){
  //  IN;
    SS(s1 + 1);
    SS(s2 + 1);
    int len1 = strlen(s1 + 1);
    int len2 = strlen(s2 + 1);
    FF(i, 1, len1){
        a1[i] = a1[i - 1];
        b1[i] = b1[i - 1];
        if(s1[i] == 'A')++a1[i];
        if(s1[i] == 'B')++b1[i];
    }
    FF(i, 1, len2){
        a2[i] = a2[i - 1];
        b2[i] = b2[i - 1];
        if(s2[i] == 'A')++a2[i];
        if(s2[i] == 'B')++b2[i];
    }
    SC(q);
    FF(i, 1, q){
        SCC(x1, y11);
        SCC(x2, y2);
        int A1 = a1[y11] - a1[x1 - 1];
        int B1 = b1[y11] - b1[x1 - 1];
        int A2 = a2[y2] - a2[x2 - 1];
        int B2 = b2[y2] - b2[x2 - 1];
        if(A1 > A2)B2 += (A1 - A2) % 3;
        else B1 += (A2 - A1) % 3;
        int tt = abs(B1 - B2);
        if(tt % 3)puts("NO");
        else puts("YES");
    }
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;



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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  sort(ALL(A));

  int ok = INF;;
  int ng = -INF;
  while(ok-ng > 1){
    int x = (ok+ng)/2;

    // x以下の個数
    int ret = 0;
    REP(i, N){
      if(A[i]*A[i] <= x) ret--;

      if(A[i] == 0){
        if(x >= 0) ret += N;
      }
      else if(A[i] > 0){
        if(x >= 0){
          ret += upper_bound(ALL(A), x/A[i])-A.begin();
        }else{
          ret += upper_bound(ALL(A), -((-x+A[i]-1)/A[i]))-A.begin();
        }
      }
      else{
        if(x >= 0){
          ret += A.end()-lower_bound(ALL(A), -(x/(-A[i])));
        }else{
          ret += A.end()-lower_bound(ALL(A), ((-x-A[i]-1)/(-A[i])));
        }
      }
    }

    if(ret/2 >= K) ok = x;
    else ng = x;
  }

  cout << ok << "\n";

  return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * ZAKIREN第5章 4-6.データ構造の応用
 * 
 * @author tdi5277
 *
 */
public class Main {
	/** 入力用 */
	private static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
	
	/** 出力用 */
	private static StringBuilder stringBuilder = new StringBuilder();
	
	/**
	 * トラックの積載量をチェック。
	 */
	private static int check(int p, int k, int[] w, int n) {
		int i = 0;
		// truckの数だけループ
		for (int j = 0; j < k; j++) {
			// max積載量になるまで
			int internalCapacity = 0;
			while (internalCapacity + w[i] <= p) {
				// 内容量を増やす
				internalCapacity += w[i];
				i++;
				
				// 全ての積載量を積むことができた場合
				if (i == n) {
					return n;
				}
			}
		}
		return i;
	}
	
	/**
	 * メイン。
	 * 
	 * @param args 未使用
	 */
	public static void main(String[] args) {
		try {
			final String SPACE = " ";
			// 読み込み
			String[] temp = bufferedReader.readLine().split(SPACE);
			int n = Integer.parseInt(temp[0]);
			int k = Integer.parseInt(temp[1]);
						
			// n回ループ
			int[] w = new int[n];
			for (int i = 0; i < n; i++) {
				w[i] = Integer.parseInt(bufferedReader.readLine());
			}
			
			// 読み込み終了
			bufferedReader.close();
			bufferedReader = null;
	
			// 二分探索法でPを求める
			int left = 0;
			int right = n * 10000;
			int mid = 0;
			while (right - left > 1) {
				mid = (left + right) / 2;
				// そのPで積み込みきれるかチェック
				int size = check(mid, k, w, n);
				if (size >= n) {
					right = mid;
				} else {
					left = mid;
				}
			}
			stringBuilder.append(right);
			
			// 結果出力
			System.out.println(stringBuilder.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}



Measured memory_bytes: 35240
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

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

  int N = S.size();
  rep(diff, N) {
    bool yes = true;
    rep(s, N) {
      int t = (s + diff) % N;
      if (S[s] != T[t]) {
        yes = false;
        break;
      }
    }
    if (yes) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;
int a[10001000];
const ll mod = 1e9 + 7;
// 快速幂 (a^b)%mod
// 如果求逆元，则b = mod-2;
ll pow_quick(ll a, ll b) {
  ll r = 1, base = a;
  while (b) {
    if (b & 1) {
      r *= base;
      r %= mod;
    }
    base *= base;
    base %= mod;
    b >>= 1;
  }
  return r;
}
int main() {
  re(a, 0);
  int n = 0;
  s(n);
  int l1, r1, l2, r2;
  for (int i = 0; i < n; i++) {
  s(a[i])}
  sort(a, a + n);
  int flag = 0;
  if (n & 1) {
    if (a[0] != 0) {
      flag = 1;
    }
    for (int i = 1; i < n; i++) {
      if ((i & 1) && a[i] == i + 1) {

      } else if ((!(i & 1)) && a[i] == i) {
      } else {
        flag = 1;
      }
    }
  } else {
    for (int i = 0; i < n; i++) {
      if ((i & 1) && a[i] == i) {

      } else if ((!(i & 1)) && a[i] == i + 1) {
      } else {
        flag = 1;
      }

    }
  }
  if (flag == 1) {
    p(0);
  } else {
      
    pld(pow_quick(2ll, ((long long)n / 2ll)));
  }
  return 0;
}

/* 
   3 10 1 4 5 6 7 10

   3 10 1 4 1 5 7 10



 */


Measured memory_bytes: 39296
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> order_set;
const int MAXN = 1234;
int grid[87][MAXN];
int psum[87][MAXN];
char s[MAXN];

int cal(int r1, int r2, int c1, int c2) {
    int res = psum[r2][c2] - psum[r1 - 1][c2] - psum[r2][c1 - 1] + psum[r1 - 1][c1 - 1];
    return res;
}

int main() {
    int H, W, K;
    scanf("%d %d %d", &H, &W, &K);
    for (int i = 1; i <= H; i++) {
        scanf("%s", s + 1);
        for (int j = 1; j <= W; j++) {
            grid[i][j] = s[j] - '0';
        }
    }

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

    int ans = H + W;
    for (int S = 0; S < (1 << (H - 1)); S++) {
        vector<pii> cand;
        int tmpS = S + (1 << (H - 1));
        int pre = 1;
        int cur_ans = -1;
        tmpS *= 2;
        for (int j = 1; j <= H; j++) {
            if (tmpS & (1 << j)) {
                cand.push_back(make_pair(pre, j));
                pre = j + 1;
                cur_ans++;
            }
        }
        assert(cand.back().second == H);
        pre = 1;
        for (int i = 1; i <= W; i++) {
            bool OK = true;
            for (auto j : cand) {
                if (cal(j.first, j.second, pre, i) > K)
                    OK = false;
            }
            if (!OK) {
                if (pre == i) {
                    cur_ans = H + W;
                    break;
                }
                cur_ans++;
                pre = i;
            }
        }
        ans = min(ans, cur_ans);
    }
    printf("%d\n", ans);
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 384
#include<stdio.h>
int main(){
	int data;
	if(scanf("%d",&data)==1);
	int data1=data/100;
	int data2=data%100;
	if(data2<=12&&data2>0&&data1<=12&&data1>0){
		printf("AMBIGUOUS\n");
	}
	else if(data2<=12&&data2!=0){
		printf("YYMM\n");
	}
	else if(data1<=12&&data1!=0){
		printf("MMYY\n");
	}
	else{
		printf("NA\n");
	}
	return 0;

}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			int P = sc.nextInt();
			if (N == 0 && M == 0 && P == 0)
				break;
			int X[] = new int[N];
			int sum = 0;
			for (int i = 0; i < N; i++) {
				X[i] = sc.nextInt();
				sum += X[i];
			}
			if (X[M - 1] != 0)
				System.out.println(sum * (100 - P) / X[M - 1]);
			else
				System.out.println("0");
		}
	}
}

Measured memory_bytes: 27760
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    cin >> n;
    vector<int> A(n+1, 0);
    for(int i = 1; i <= n; i++) {
        cin >> A[i];
    }
    vector<int> ans(n+1, 0);
    for(int i = n; i >= 1; i--) {
        int cnt = 0;
        for(int j = i; j <= n; j+=i) {
            cnt += ans[j];
        }
        if ((cnt % 2) != A[i])
            ans[i] = 1;
    }
    cout << accumulate(ans.begin(), ans.end(), 0) << endl;
    for(int i = 1; i <= n; i++)
        if (ans[i] != 0)
            cout << i << " ";
    cout << endl;
    return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	char s[4];
	for (int i = 0; i < 4; i++) cin >> s[i];
	sort(s, s + 4);
	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int gys(int a, int b) {
	int t;
	if (a < b) {
		t = a;
		a = b;
		b = t;
	}
	return b == 0 ? a : gys(b, a % b);
}
int gcd(int a, int b, int c) {
	return gys(gys(a, b), c);
}
int main() {
	int a, i, j, k, t = 0;
	cin >> a;
	for (i = 1; i <= a; i++) {
		for (j = 1; j <= a; j++) {
			for (k = 1; k <= a; k++) {
				t += gcd(i, j, k);
			}
		}
	}
	cout << t << endl;
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,k,c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vector<int32> l(k+1,-1),r(k+1,-1);
  int32 cnt = 0;
  REP(i,n){
    if(s[i] == 'o'){
      cnt++;
      if(cnt > k)break;
      l[cnt] = i;
      i += c;
    }
  }
  cnt = 0;
  FORR(i,n-1,0){
    if(s[i] == 'o'){
      cnt++;
      if(cnt > k)break;
      r[cnt] = i;
      i -= c;
    }
  }
  // REP(i,k+1){
  //   cout << l[i] << " " << r[i] << endl;
  // }
  FOR(i,1,k+1){
    if(l[i] == r[k+1-i]){
      ANS(l[i]+1);
    }
  }
  return 0;
}

Measured memory_bytes: 5012
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

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

int n, m;
ll v[60];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }

    ll ans = 0;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            if (i + j > m || i + j > n) break;
            int num = m - (i + j);
            vector<ll> vec;
            ll sum = 0;
            for (int x = 0; x < i; ++x) {
                vec.emplace_back(v[x]);
                //sum += v[x];
            }
            for (int x = 0; x < j; ++x) {
                vec.emplace_back(v[n - 1 - x]);
                //sum += v[n - 1 - x];
            }
            sort(vec.begin(), vec.end());
            for (int k = 0; k < min(num, (int) vec.size()); ++k) {
                if (vec[k] > 0) break;
                //sum -= vec[k];
                //ans = max(ans, sum);
                vec[k] = 0;
            }
            for (int l = 0; l < (int) vec.size(); ++l) {
                sum += vec[l];
            }
            ans = max(ans, sum);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B;
    if (A <= 8 and B <= 8) printf("Yay!\n");
    else printf(":(\n");
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	vector<ll> psum(n, 0LL);
	psum[0] = (a[0] > 0 ? a[0] : 0);
	repn(i, 1, n) psum[i] = psum[i - 1] + (a[i] > 0 ? a[i] : 0);
	vector<ll> sum(n, 0LL);
	sum[0] = a[0];
	repn(i, 1, n) sum[i] = sum[i - 1] + a[i];
	ll ans = 0LL;
	rep(i, n - k + 1){
		ll cur = max(0LL, sum[i + k - 1] - (i ? sum[i - 1] : 0));
		ans = max(ans, cur + (i ? psum[i - 1] : 0) + (psum[n - 1] - psum[i + k - 1]));
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 5576
# coding: utf-8
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if true
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

#dream, dreamer erase eraser

str = inputs[0][0].reverse

pd str

i = 0
while i < str.length
  if str[i..i+4] == "dream".reverse
    pd "dream"
    i += 5
  elsif str[i..i+6] == "dreamer".reverse
    pd "dreamer"    
    i += 7
  elsif str[i..i+4] == "erase".reverse
    pd "erase"        
    i += 5    
  elsif str[i..i+5] == "eraser".reverse
    pd "eraser"
    i += 6    
  else
    puts "NO"
    exit
  end
end

puts "YES"


Measured memory_bytes: 4092