akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

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

class UnionFind {
public:
    vector <int> par;
    vector <int> siz;

    UnionFind(int sz_): par(sz_), siz(sz_, 1LL) {
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(int sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }

    int root(int x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return siz[root(x)];
    }
};

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

  vector<int> ans(M);

  int ret = N*(N-1)/2;
  UnionFind uf(N);

  vector<int> u(M), v(M);
  REP(i, M){
    cin >> u[i] >> v[i];
    u[i]--; v[i]--;
  }

  RREP(i, M){
    ans[i] = ret;
    if(!uf.same(u[i], v[i])){
      ret -= uf.size(u[i])*uf.size(v[i]);
      uf.unite(u[i], v[i]);
    }
  }

  REP(i, M) cout << ans[i] << endl;

  return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MAX_SIZE 1000001
#define debug(x) cout<<#x<<" "<<x<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);freopen("error.txt","w",stderr);
#define vi(vec,n) vector<ll>vec(n)
#define vio(vec,n,a) vector<ll>vec(n,a)
#define FOR(i,a,b,c) for(ll i=a;(c)?i<(ll)b:i>=(ll)b;(c)?i+=1:i-=1)
#define eb emplace_back
#define mod (ll)(1e9+7)
#define all(a,b) memset(a,b,sizeof a)
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)

vio(isprime,MAX_SIZE,true); 
vector<ll>prime; 
int SPF[MAX_SIZE];
vector<int> cnt(MAX_SIZE);

void manipulated_seive(int N){
    isprime[0] = isprime[1] = false;
    FOR(i,2,N,1){
        if (isprime[i]){
            prime.push_back(i);
            SPF[i] = i; 
        } 
        for(ll j=0;j<prime.size() && i*prime[j]<N && prime[j]<=SPF[i];j++){ 
            isprime[i*prime[j]]=false;
            SPF[i*prime[j]] = prime[j]; 
        } 
    } 
} 

void fact(int x){
    unordered_map<int,bool> mp;
    while (x != 1) 
    { 
        if(!mp[SPF[x]]){
            cnt[(SPF[x])]++; 
            mp[SPF[x]] = 1;
        }
        x = x / SPF[x]; 
    }
}


bool pairWise(){
    for(int i = 0;i < MAX_SIZE;i++){
        if(cnt[i] >= 2) return false;
    }
    return true;
}

bool setWise(int * ar,int n){
    int gcd = ar[0];
    for(int i = 1;i < n;i++) gcd = __gcd(gcd,ar[i]);
    if(gcd == 1) return true;
    return false;
}

int main(){
    //clock_t tStart = clock();
    // file;
    manipulated_seive(MAX_SIZE);
    fast;

    int n;
    cin >> n;
    int ar[n];
    for(int i = 0;i < n;i++){
        cin >> ar[i];
    }
    for(int i = 0;i < n;i++){
        fact(ar[i]);
    }
    if(pairWise()){
        cout<<"pairwise coprime\n";
        return 0;
    }
    if(setWise(ar,n)){
        cout<<"setwise coprime\n";
        return 0;
    }
    cout<<"not coprime\n";

    //printf("Time taken: %.6fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}

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

int main(){
    double n;
    cin>>n;
    double ans;
    for(int i=1;i<=n;i++){
        if(i%2) ans++;
    }
    cout<< setprecision(8) << ans/n<<endl;
}


Measured memory_bytes: 256
n = int(input())
a, b = map(int, input().split())
probs = [int(x) for x in input().split()]
probs.sort()

intervals = [0, 0, 0]
point = 0

for x in probs:
    if point == 0:
        if x <= a:
            intervals[0] += 1
        else:
            point += 1
    if point == 1:
        if x <= b:
            intervals[1] += 1
        else:
            point += 1
    if point == 2:
        intervals[2] += 1

print(min(intervals))


Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	int s=1,bk=0,t,n,i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d",&n);
		if(n==s)
		s++;
		else
		bk++;
	}
	if(bk==t)
	printf("-1");
	else
	printf("%d",bk);
}

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

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [(usize, usize); n]
    }
    let mut t = v[0].0;
    let mut a = v[0].1;
    for i in 1..n {
        let d = max((t - 1) / v[i].0 + 1, (a - 1) / v[i].1 + 1);
        t = v[i].0 * d;
        a = v[i].1 * d;
    }
    println!("{}", t + a);
}


Measured memory_bytes: 4352
N, X = map(int, input().split()) # 横に2個
L = list(map(int, input().split())) # １行に別れてるとき
L.append(0)

count = 0
D = 0
for i in range(N+1):
    if D <= X:
        count += 1
    D += L[i]


print(count)

Measured memory_bytes: 3060
/*#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
*/
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define rrep()
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int v[3]={1,0,0};
    char a,b,c;
    while(cin>>a>>c>>b){
        swap(v[a-'A'],v[b-'A']);
    }
    
    rep(i,0,3){
        if(v[i]==1){
            cout<<char('A'+i)<<endl;
            return 0;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3076
a = [[0,0],[0,0],[0,0],[0,0],[0,0]]
for i in range(5):
    a[i][0] = int(input())


time = 0

for j in range(5):
    if a[j][0]%10 == 0:
      a[j][1] = 0
    else:
      a[j][1] = 10-(a[j][0]%10)

for k in range(5):
    a.sort(key=lambda x:x[0])
    a.sort(key=lambda x:x[1])


for l in range(4):
  if a[l][1] == 0:
    time += a[l][0]
  else:
    time += (a[l][0]+(10-(a[l][0]%10)))
time += a[4][0]
print(time)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
    ll n,k,s;
    cin >> n >> k >> s;
    ll che = n;
    for(int i=0;i<k;i++){
        if(che==1){cout<<s<<endl;return 0;}
        cout<<s<<" ";
        che--;
    }
    ll next = s+1;
    if(s==1e9){
        next =1;
    }
    for(int i=k;i<n;i++){
        if(che==1){cout<<next<<endl;return 0;}
        cout<<next<<" ";
        che--;
    }
}



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

using namespace std;


int main()
{
    int n,Acount=0,Wcount=0,Tcount=0,Rcount=0;
    string s;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        if(s[0]=='A')
            Acount++;
        if(s[0]=='W')
            Wcount++;
        if(s[0]=='T')
            Tcount++;
        if(s[0]=='R')
            Rcount++;

    }
    cout<<"AC x "<<Acount<<endl<<"WA x "<<Wcount<<endl<<"TLE x "<<Tcount<<endl<<"RE x "<<Rcount<<endl;

    return 0;
}


Measured memory_bytes: 3616
while True:
	string = input()
	if string == 'END OF INPUT':
		break
	ans = []
	temp = 0
	space = 0
	for i in range(len(string)):
		if string[i] == ' ' and space == 0:
			ans.append(temp)
			temp = 0
			space = 1
			continue
		elif space > 0 and string[i] == ' ':
			ans.append(0)
			continue
		space = 0
		temp += 1
	ans.append(temp)
	print(''.join([str(x) for x in ans]))


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

int main() {
    int N; cin >> N;
    int l = 0, r = 40000;
    while (l + 1 < r) {
        int m = (l + r) / 2;
        if (m * m <= N) l = m; else r = m;
    }
    cout << (l * l) << endl;
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int r = scan.nextInt();
    int c = scan.nextInt();
    int k = scan.nextInt();
    int l = c*r;
    String[][] f = new String[r][c];
    for (int p=0;p<r;p++){
      String dd = scan.next();
      for (int q=0;q<c;q++){
        char gg = dd.charAt(q);
        f[p][q] = Character.toString(gg);
      }
    }
    int g = (int) Math.pow(2,r);
    int m = (int) Math.pow(2,c);
    int count = 0;
    for (int i=0;i<g;i++){
      int[] a = encode(i,r);
      for (int j=0;j<m;j++){
        int [] b = encode(j,c);
        count += check(f,a,b,k);
      }
    }
    System.out.println(count);
  }


  public static int[] encode(int n,int g){
    int [] a = new int[g];
    int count = 0;
    while (n>0){
      int i = n%2;
      a[count] = i;
      n -= i;
      count++;
      n = (int) n/2;
    }
    return a;
  }

  public static int check(String[][]a, int[] b, int[] c ,int g){
    int sum = 0;
    for (int i=0;i<b.length;i++){
      if (b[i] == 0){
        continue;
      }
      for (int j=0;j<c.length;j++){
        if (c[j] == 0){
          continue;
        }
        if (a[i][j].equals("#")){
          sum += 1;
        }
      }
    }

    if (sum == g){
      return 1;
    }
    return 0;
  }
}


Measured memory_bytes: 36384
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {
        public void Calc()
        {

            var p = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

            var A = p[0];
            var B = p[1];
            var N = p[2];
            long ans = 0;
            if (B > N)
            {
                ans = (long)Math.Floor((double)A * N / B) - A * (long)Math.Floor((double)N / B);
            }
            else
            {
                ans = (long)Math.Floor((double)A * (B - 1) / B) - A * (long)Math.Floor((double)(B - 1) / B);
            }

            //var max = 0;
            //for (var x = 1; x <= N; x++)
            //{
            //    var ans = Math.Floor((double)A * x / B) - A * Math.Floor((double)x / B);
            //    max = Math.Max((int)ans, max);
            //}

            Console.WriteLine(ans);

        }


    }
    public static class Combination
    {
        public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition = false)
        {
            if (k == 1)
            {
                foreach (var item in items)
                    yield return new T[] { item };
                yield break;
            }
            foreach (var item in items)
            {
                var leftside = new T[] { item };

                // item よりも前のものを除く （順列と組み合わせの違い)
                // 重複を許さないので、unusedから item そのものも取り除く
                var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).ToList();

                foreach (var rightside in Enumerate(unused, k - 1, withRepetition))
                {
                    yield return leftside.Concat(rightside).ToArray();
                }
            }
        }
    }
}


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

#define tt template<typename T> ostream& operator <<(ostream& os, const
#define tuv template<typename U, typename V> ostream& operator<<(ostream& os, const
tt vector<T>& v)            { os << "["; for(auto & x : v) os << " " << x; os << " ]"; return os; }
tt vector<vector<T> >& m)   { for(auto & x : m) { for(auto & y : x) os << y << " "; os << "\n"; } return os; }
tt set<T>& s)               { os << "{"; for(auto & x : s) os << " " << x; os << " }"; return os; }
tt unordered_set<T>& s)     { os << "{"; for(auto & x : s) os << " " << x; os << " }"; return os; }
tt queue<T>& q)             { queue<T> q2(q); while(!q2.empty()) { os << q2.front() << " "; q2.pop(); } return os; }
tt stack<T>& s)             { stack<T> s2(s); while(!s2.empty()) { os << s2.top() << " "; s2.pop(); } return os; }
tuv pair<U,V>& p)           { os << "(" << p.first << "," << p.second << ")"; return os; }
tuv map<U,V>& m)            { os << "{ "; for(auto & x : m) os << x.first << ":" << x.second << " "; os << "}"; return os; }
tuv unordered_map<U,V>& um) { os << "{ "; for(auto & x : um) os << x.first << ":" << x.second << " "; os << "}"; return os; }


int main(int argc, char * argv[])
{
    std::ios_base::sync_with_stdio(false);    
    std::cin.tie(NULL);

    int n, m;
    std::cin >> n >> m;

    std::vector<int> a(n);
    int total = 0;
    for(int i = 0; i < n; ++i)
    {
	std::cin >> a[i];
	total += a[i];
    }

    int selected = 0;
    for(int i = 0; i < n; ++i)
    {
	if(a[i] >= 1 / ((double) 4*m) * total) selected++;
	if(selected == m) break;
    }

    if(selected == m)
    {
	std::cout << "Yes" << std::endl;
    }
    else
    {
	std::cout << "No" << std::endl;
    }


    return 0;
}


Measured memory_bytes: 3624
n,a,b=map(int,input().split())
m=10**9+7

def cmb(x,y):

    r=1

    for i in range(1,y+1):

        r=(r*(x-i+1)*pow(i,m-2,m))%m
        
    return r
print((pow(2,n,m)-1-cmb(n,a)-cmb(n,b))%m)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  bool yes = true;
  for(int i=0;i<n;i++) {
    cin >> a[i];
    if(i == 0 && a[i] != 0) yes = false;
    if(i != 0 && a[i] > a[i-1] + 1) yes = false;
  }
  if(!yes) cout << -1 << endl;
  else {
    long long ans = 0;
    for(int i=0;i<n;i++) {
      if(i == 0) continue;
      if(a[i] == a[i-1] + 1) continue;
      else ans += a[i-1];
    }
    ans += a.back();
    cout << ans << endl;
  }
  return 0;
}


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

int dp[3001][3001] = {0};

int main(){
	int N, T, S;
	cin >> N >> T >> S;

	int A[3000], B[3000];
	for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

	for (int n = 1; n <= N; n++){
		for (int t = 1; t <= T; t++){
			dp[n][t] = max(dp[n-1][t], dp[n][t-1]);
			if(t - B[n-1] < 0) continue;
			if(S <= t - B[n-1] || t <= S) dp[n][t] = max(dp[n][t], dp[n-1][t-B[n-1]] + A[n-1]);
		}
	}
	cout << dp[N][T] << endl;
	return 0;
}

Measured memory_bytes: 36360
l = input()

if l == 'SSS':
	print(0)

elif l == 'SSR' or l == 'RSS' or l == 'SRS' or l == 'RSR':
	print(1)

elif l == 'SRR' or l == 'RRS':
	print(2)
  
elif l == 'RRR':
	print(3)

Measured memory_bytes: 9040
#include <cstdio>
#include <utility>
#include <cctype>
#include <array>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

template<typename T>
using A = array<T, 9>;

int main() {
	for (int n: range((int) in)) {
		if (n)
			outl();
		A<A<bool>> b {};
		A<A<int>>  p;
		range r9(9), r3(0, 9, 3);
		for (auto &i: p)
			for (auto &j: i)
				j = (int) in - 1;
		for (int i: r9) {
			A<int> t {}, s {};
			for (int j: r9) {
				t[p[i][j]]++;
				s[p[j][i]]++;
			}
			for (int j: r9) {
				b[i][j] |= t[p[i][j]] != 1;
				b[j][i] |= s[p[j][i]] != 1;
			}
		}
		for (int i: r3)
			for (int j: r3) {
				A<int> t {};
				for (int k: r9)
					t[p[i + k / 3][j + k % 3]]++;
				for (int k: r9)
					b[i + k / 3][j + k % 3] |= t[p[i + k / 3][j + k % 3]] != 1;
			}
		for (int i: r9) {
			for (int j: r9)
				out(b[i][j] ? '*' : ' ', p[i][j] + 1);
			outl();
		}
	}
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
    ll res = 1LL; 
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1LL)  
            res = (res*x) % p;
        y = y>>1LL; 
        x = (x*x) % p;  
    }  
    return res;  
}  

int n, W;
ll **dp;
ll solve(int arr[][2], int idx, int weight){
	if(weight <= 0 || idx >= n)
		return 0;
	if(dp[idx][weight]!=-1) return dp[idx][weight];
	
	ll ch1 = weight - arr[idx][0] >= 0 ? arr[idx][1] + solve(arr, idx + 1, weight - arr[idx][0]) : -1;
	ll ch2 = solve(arr, idx+1, weight);

	return dp[idx][weight] = max(ch1, ch2);
}

int main(){
	IO
	cin >> n >> W;
	dp = new ll*[n];
	rep(i, 0, n){
		dp[i] = new ll[W+1];
		rep(j, 0, W + 1) dp[i][j] = -1;
	}
	int arr[n][2], a, b;
	rep(i, 0, n){
		cin >> a >> b;
		arr[i][0] = a;
		arr[i][1] = b;
	}
	cout << solve(arr, 0, W) << endl;
	return 0;
}

Measured memory_bytes: 81992
#include<bits/stdc++.h>
using namespace std;
const int maxn= 100010;
int N,M;
long long K;
long long ans;

vector<int> mul(const vector<int> &a, const vector<int> &b){
	int n=(int)a.size();
	vector<int> c(n);
	for (int i=0;i<n;i++) c[i] = b[a[i]];
	return c;
}

vector<int> Pow(vector<int> x,long long k){
	int n=(int)x.size();
	vector<int> c(n);
	for (int i=0;i<n;i++)  c[i]=i;
	for (;k>0;k/=2){
		if (k&1){
			c = mul(c, x);
		}
		x = mul(x,x);
	}
	return c;	
}
int main(){
	scanf("%d",&N);
	vector<int> a(N);
	vector<int> b(N-1);
	vector<int> P(N-1);
	for (int i = 0;i<N;i++) cin >> a[i];
	scanf("%d%lld",&M,&K);
	int st = a[0];
	int x;
	for (int i = 0 ; i<(N-1); i++) a[i]=a[i+1]-a[i];
	for (int i = 0 ; i<(N-1); i++) P[i]=i;
	while (M--){
		scanf("%d",&x);
		swap(P[x-2],P[x-1]);
	}
	P = Pow(P,K);
	for (int i = 0 ; i< (N-1); i++) b[i]=a[P[i]];
	ans=st;
	printf("%d.0\n",st);
	for (int i=1;i<N;i++){
		ans+=b[i-1];
		printf("%lld.0\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2896
#create date: 2020-05-03 21:05

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, m = na()
    h = na()
    g = [[] for i in range(n)]
    for i in range(m):
        a, b = na()
        a -= 1
        b -= 1
        g[a].append(b)
        g[b].append(a)
    ans = 0
    for i in range(n):
        if len(g[i]) > 0:
            if max(h[gi] for gi in g[i]) < h[i]:
                ans += 1
        else:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

typedef long long ll;

ll a[200005], b[200005];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    ll sum = 0, ans = (ll) 1e9 + 1;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i] >> b[i];
        sum += a[i];
        if (a[i] > b[i]) ans = min(ans, b[i]);
    }
    if (ans == (ll) 1e9 + 1) cout << 0;
    else cout << sum - ans;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	cout << n * (n - 1) / 2 + m * (m - 1) / 2;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll n, k, q;
    cin >>n >>k >>q;
    
    vll a(q);
    vll p(n, 0);
    
    rep(i, q) {
        cin >>a[i];
        p[a[i]-1] ++;
    }
    
    rep(i, n) {
        if ((k - q + p[i]) <= 0) {
            mes("No");
            continue;
        }
        mes("Yes");
    }
    
    
    
    
    

}


Measured memory_bytes: 4808
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] iArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long N = iArray[0];
            long D = iArray[1];
            long[,] point = new long[N, D];
            int cnt = 0;
            for (int p = 0; p < N; p++)
            {
                long[] tmpArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
                for(int t = 0; t < D; t++)
                {
                    point[p, t] = tmpArray[t];
                }
            }
            
            for (int i = 0;i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    long sum = 0;
                    for (int z = 0; z < D; z++)
                    {
                         sum += (long)Math.Pow(point[i, z] - point[j, z], 2);
                    }
                    for(long y = 1; y <= sum; y++)
                    {
                        if (y * y == sum)
                        {
                            cnt++;
                        }
                    }
                    //long sqr = (long)Math.Sqrt(sum);
                    //if (sum % sqr == 0)
                    //{
                    //    cnt++;
                    //}
                }
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<char> vch;
typedef vector<long long> vll;
typedef vector<string> vstr;


int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b){ll ans=1; rep(i, b){ans=ans*a%MOD;} return ans;}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}

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




template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

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

    ll n, m, cnt=0;
    cin >> n >> m;

    if(m >= 2 && m >= 2*n){ // Scc
        cnt += n;
        m -= 2*n;

    }

    else if(m >= 2 && m < 2*n){ // Scc
        cnt += m/2;
        m = 0;
    }

    if(m >= 4){ // cc cc
        cnt += m/4;
    }


    ppp(cnt);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 1e2+2;
ll X, K, D, ans;

int main(int argc, char * * argv) {
	cin >> X >> K >> D; X = abs(X);
	if(X/D < K) {
	    K -= X/D;
	    X = X - (X/D)*D;
	    if(!(K&1)) ans = X;
	    else ans = abs(X-D);
	} else
	    ans = X - K*D;
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3632
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

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


    int N;

    cin >> N;

    vector<int> d(N);

    int count = 0;

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

    for(int i = 0; i < N - 1; i++) {
        for(int j = i + 1; j < N; j++) {
            count += d[i] * d[j];
        }
    }

    cout << count << endl;
}

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

#define INF 1LL << 30
typedef long long ll; 

int main() {
  int N;
  double T, A, H;
  double mi = 10000;
  int ans;
  cin >> N;
  cin >> T >> A;
  for (int i=0;i<N;i++){
    cin >> H;
    double tmp = abs(A - T + H*0.006);
    if (mi > tmp) {
      mi = tmp;
      ans = i + 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int zs,ctw,n,q,nt,nv,nfx=1,nzl,xyz,fzt[N],fw1[N],fw2[N];
void mchange()
{
    int kbl=fzt[ctw+1]-fzt[ctw];
    if(nfx==1)
    {
        fw1[ctw+1]=max(0,fw1[ctw]-kbl);
        fw2[ctw+1]=max(0,fw2[ctw]-kbl);
        nzl-=kbl; 
    }
    else
    {
        fw1[ctw+1]=min(zs,fw1[ctw]+kbl);
        fw2[ctw+1]=min(zs,fw2[ctw]+kbl);
        nzl+=kbl;
    }
    nfx=nfx*(-1); 
}
int main()
{
    //freopen("c4.in","r",stdin);
    //freopen("test.out","w",stdout);
    int i,j;
    scanf("%d",&zs);
    scanf("%d",&n);
    for(i=1;i<=n;++i)
    {
        scanf("%d",&fzt[i]);
    }
    scanf("%d",&q);
    fw2[0]=zs; 
    for(i=1;i<=q;++i)
    {
        scanf("%d%d",&nt,&nv);
        while(ctw<n&&fzt[ctw+1]<nt) 
        {
           mchange();
           ctw++;
        }
        if(nv+nzl>=fw1[ctw]&&nv+nzl<=fw2[ctw])	xyz=nv+nzl;
        if(nv+nzl<fw1[ctw]) xyz=fw1[ctw];
        if(nv+nzl>fw2[ctw]) xyz=fw2[ctw];
        int kbl=nt-fzt[ctw];
        if(nfx==1) xyz=max(0,xyz-kbl);
        else xyz=min(zs,xyz+kbl);
        printf("%d\n",xyz);
    }
    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
	int K,T;
	vector<int> a;
	int max=0, ret;

	cin >> K >> T;
	a = vector<int>(T);
	for(int i=0;i<T;i++){
		cin >> a[i];
		if(a[i]>max) max=a[i];
	}
	// maxの間max-1までは連続なし
	ret = 2*max - 1 - K;
	cout << (ret>0 ? ret : 0) << endl; 

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int A, B;
    scanf("%d%d", &A, &B);

    if (A%3==0 || B%3==0 || (A+B)%3==0) {
        printf("Possible\n");
    } else {
        printf("Impossible\n");
    }
    return 0;
}

Measured memory_bytes: 128
#define s(X,Y,Z)(t=X,X=Y,Y=t,p=Z?&X:&Y,*p^=7,a)
a,b,c,t,m,r,*p;main(n){for(;r=a=scanf("%d",&n),n;printf("%d\n",r))for(b=2,c=3;n--;m=t-76,r+=m%6==0?s(c,b,m):1<m&m<8?s(b,a,m^7):s(c,a,m>0))scanf(" %c%*s",&t);}

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

int main()
{
  // 標準入力
  string AP = "APPROVED";
  string DE = "DENIED";
  string ans=AP;
  int N;
  cin >> N;
  int A=0;
  for (int i = 0; i < N; i++) {
    cin >> A;
    if (A % 2 == 0) {
      if (A % 3 != 0 && A % 5 != 0) {
        ans = DE;
        break;
      }
    }
  }
  
  cout << ans;

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL               long long int
#define PB               push_back
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int n;cin>>n;
    vector <pair<int,int>> v(n);
    int c=0;
    bool ans=0;
    for (int i=0;i<n;i++){
        cin>>v[i].first>>v[i].second;
        if (v[i].first== v[i].second) c++;
        else c=0;
        if (c>=3) ans=1;
    }
    if (ans) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3644
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ld = long double;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll A, B, C, K;
  cin >> A >> B >> C >> K;

  if (A < B && B < C) {
    cout << "Yes" << endl;
    return 0;
  }

  while (K > 0) {
    if (A >= B) {
      B *= 2;
    } else if (B >= C) {
      C *= 2;
    }

    if (A < B && B < C) {
      cout << "Yes" << endl;
      return 0;
    }
    K--;
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3608
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll k;
    cin >> k;

    ll div = k / 50;
    ll rim = k % 50;

    ll ans[50];

    rep(i, 50){
        ans[i] = 50;
    }

    rep(i, 50 - rim){
        ans[i] -= 50;
        rep(j, 50){
            if(i == j) continue;
            ans[j]++;
        }
    }

    cout << 50 << endl;

    rep(i, 50){
        cout << ans[i] + div << " " << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

# x = range(1,n+1)

cnt = 0
for i in range(1,n+1) :
  if p[i-1] == i :
    continue
  else :
    cnt += 1

if cnt == 2 or cnt == 0 :
  print('YES')
else : 
  print('NO')

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
ll mod = 998244353LL ;
ll dp[4][300006] ;
int main() {
   string s ;
   cin >> s ;
   for(int i = 0 ;i<s.size();i++)
    cout << 'x'  ;
    cout  << endl ;
    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

#define FOR(var,start,end) for(int var=start; var<end; var++)
#define REP(var,cnt) FOR(var,0,cnt)


int A[2][200100];

int M[200100];

int main(void) {
	
		
	//int test[] = {0,10,20,30,40,50};
	//cout << std::lower_bound(test, test+6, -5) - test << endl;
	//return 0;
	
	
	int N;
	cin >> N;
	
	REP(xxx, 2) {
		REP(i, N) {
			int a;
			cin >> A[xxx][i];
		}
	}
	
	int ret = 0;
	
	REP(k, 30) {
		
		REP(i, N) {
			M[i] = A[1][i] % (1 << (k+1));
		}
		sort(M, M+N);
		
		/*
		cout << "test " ;
		REP(i, N) {
			cout << M[i] << " ";
		}
		cout << endl;
		*/
		
 		long cnt = 0;
		
		REP(i, N) {
			int moto = A[0][i] % (1 << (k+1));
			
			
			//cout << "A " << A[0][i] << endl;
			//cout << "moto " << moto << endl;
			
			
			int upper = (1 << (k+1)) - moto;
			int lower = 0;
			if ( ! (moto & (1 << k)) ) {
				lower = (1 << k) - moto;
			}
			
			//cout << "finding [" << lower << ", " << upper << ")" << endl;
			int *lp = std::lower_bound(M, M+N, lower);
			int *up = std::lower_bound(M, M+N, upper);
			//cout << "found " << (up-lp) << endl;
			
			cnt += max(up-lp, 0L);
			
			if ( moto & (1 << k) ) {
				int lower2 = ((1 << k) | (1 << k+1)) - moto;
				//cout << "refindg [" << lower2 << "... " << endl;
				int *l2 = std::lower_bound(M, M+N, lower2);
				//cout << "found " << (M+N-l2) << endl;
				
				cnt += M+N-l2;
			}
		}
		
		//cout << k << " cnt " << cnt << endl;
		ret = (ret) | ( (cnt % 2L) << k);
	}
	
	cout << ret << endl;
	
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int a,b,c;
int k;

void solve(){
    cin >> a >> b >> c;
    cin >> k;
    if(k<=a){
        cout << k << endl;
    }
    else if(k<=b){
        cout << a << endl;
    }
    else{
        cout << a-(k-a-b) << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3652
import sys

N, M = map(int, sys.stdin.readline().split())

cond = {}
flag = True
for _ in range(M):
    s, c = map(int, sys.stdin.readline().split())
    if s not in cond:
        if N > 1 and s == 1 and c == 0:
            flag = False
            break
        else:
            cond[s] = c
    else:
        if cond[s] != c:
           flag = False
           break

if flag == False:
    print(-1)
else:
    ans = ""
    for i in range(1, N+1):
        if i in cond:
            ans += str(cond[i])
        else:
            if i == 1 and N > 1:
                ans += "1"
            else:
                ans += "0"
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define ALL(x) x.begin(), x.end()

/* clang-format off */
template <class T> inline void chmin(T& a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T& a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {

  ll X, A;
  cin >> X >> A;
  if (X < A) cout << 0 << endl;
  else cout << 10 << endl;

  return 0;
}


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

public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null; }
        String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try { tokenizer = new StringTokenizer(reader.readLine()); } 
                catch (IOException e) { throw new RuntimeException(e);} }
            return tokenizer.nextToken(); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
    }

    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        
        int n = r.nextInt();
        int[] b = new int[n-1];
        int[] a = new int[n];

        for(int i = 0; i < n-1; i++){
            b[i] = r.nextInt();
        }

        a[n-1] = b[n-2];
        for(int i = n-2; i > 0; i--){
            a[i] = Math.min(b[i], b[i-1]);
        }
        a[0] = b[0];

        int sum = 0;
        for(int i = 0; i < n; i++){
            sum += a[i];
        }
        pw.println(sum);

        pw.close();
    }
}

/**
                _        _                 _                                                
               | |      | |               | |                                               
   ___ ___   __| | ___  | |__  _   _    __| | __ _ _ __ _ __ ___ _ __     _   _  __ _  ___  
  / __/ _ \ / _` |/ _ \ | '_ \| | | |  / _` |/ _` | '__| '__/ _ \ '_ \   | | | |/ _` |/ _ \ 
 | (_| (_) | (_| |  __/ | |_) | |_| | | (_| | (_| | |  | | |  __/ | | |  | |_| | (_| | (_) |
  \___\___/ \__,_|\___| |_.__/ \__, |  \__,_|\__,_|_|  |_|  \___|_| |_|   \__, |\__,_|\___/ 
                                __/ |                               ______ __/ |            
                               |___/                               |______|___/             
 */

Measured memory_bytes: 21204
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

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

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n = read::<usize>();
    let mut d:Vec<u32> = (0..n).map(|_| read()).collect();

    d.sort();

    println!("{}", d[n/2]-d[n/2-1]);

}


Measured memory_bytes: 4352