akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	string s;
	cin >> s;
	if (s[0] == s[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  ll h, w;
  cin >> h >> w;
  ll ans;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (h % 2 == 0) {
    ans = h/2 * w;
  }
  else {
    ans = h/2 * w + (w+2-1)/2;
  }
  cout << ans << endl;
  return 0;
}

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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     for(int i=1;i<=5;i++){
       int a;
       cin >> a;
       if(a==0){cout << i;return;}
     }
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pll pair<int ,int >
#define ppll pair < pll , pll >
#define mod 1000000007
unsigned int bp(int n) // built_in_pop_count // 
{ 
    unsigned int count = 0; 
    while (n) { 
        n &= (n - 1); 
        count++; 
    } 
    return count; 
} 
int countDivisors(int n) 
{ 
	int cnt = 0; 
	for (int i = 1; i <= sqrt(n); i++) { 
		if (n % i == 0) { 
			if (n / i == i) 
				cnt++; 

			else
				cnt = cnt + 2; 
		} 
	} 
	return cnt; 
}
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        ans += (i * (n/i) * (1 + n/i))/2;
    }
    cout << ans ;
}

Measured memory_bytes: 3648
#include <iostream>
#include <limits.h>
using namespace std;

int main() {
	int n, a[110], min = 1000, max = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
	    cin >> a[i];
	    if (a[i] < min) min = a[i];
	    if (a[i] > max) max = a[i];
	}
	cout << max - min;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define MAX_H 50
#define MAX_W 50

int H, W;

char G[MAX_H + 10][MAX_W + 10];

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

int check(int y, int x) {
    if (y < 0 || y >= H) return 0;
    if (x < 0 || x >= W) return 0;
    return 1;
}

int main() {

    scanf("%d %d", &H, &W);
    for (int y = 0; y < H; y++) {
        scanf("%s", G[y]);
    }

    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; x++) {
            if (G[y][x] == '.') {
                int res = 0;
                for (int i = 0; i < 8; i++) {
                    if (!check(y + dy[i], x + dx[i])) continue;
                    if (G[y + dy[i]][x + dx[i]] == '#') res++;
                }
                G[y][x] = '0' + res;
            }
        }
    }

    for (int y = 0; y < H; y++) {
        printf("%s\n", G[y]);
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define VL vector < ll >
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
#define cu cout<<
#define en endl
#define sp " "
#include<cstdio>
#include<cstring>
void bug()
{
    cout << "here\n";
}
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 100000009
bool prime[N];
vector<ll> prm;
void seive ()
{
    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {

        if (prime[i] == true)
        {
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
    for (ll i=2; i<=N; i++)
    {
        if(prime[i]) prm.pb(i);
    }
}*/
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
bool isprime(ll n)
{
    if(n<2) return 0;
    if(n==2) return 1;
    else
    {
        for(int i=2; i*i<=n; i++)
            if(n%i==0) return 0;
    }
    return 1;

}
ll countSum(ll x)
{
    ll res = 0;
    while (x != 0)
    {
        res += (x % 10);
        x /= 10;
    }
    return res;
}
ll power(ll a,ll b)
{
    if(b==0) return 1;
    if(b==1) return a;
    else
    {
        ll  res = power(a,b/2);
        if(b%2)
            return res * a*res;
        else
            return res*res;
    }
}
ll p [20005];
int main()
{
    fast;
    ll n;
    cin >> n;
    ll ans = n-1;
    ll x = n/2;
    if(x )
    for (ll i=2;i<n;i++)
    {
        if(n%i==0)
        {
            ans+=(n/i - 1);
        }
        else
        ans+=(n/i);
    }
   cout << ans <<endl;
}





Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int n = a - b;

    if (n == 0) {
        cout << "a == b" << endl;
    } else if (n > 0) {
        cout << "a > b" << endl;
    } else {
        cout << "a < b" << endl;
    }
}



Measured memory_bytes: 3088
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AChangingACharacter solver = new AChangingACharacter();
        solver.solve(1, in, out);
        out.close();
    }

    static class AChangingACharacter {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            StringBuilder s = new StringBuilder(sc.nextLine());
            s.setCharAt(k - 1, Character.toLowerCase(s.charAt(k - 1)));
            out.println(s);

        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}



Measured memory_bytes: 22996
N = input()
A = list(map(int, input().split()))

a = [i for i in A if i % 2 == 0]

flag = True

for i in a:
    if i % 3 != 0 and i % 5 != 0:
        flag = False

if flag:
    print('APPROVED')
else:
    print('DENIED')

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n+1, 0);
    rep(i, n) cin >> a[i];
    
    ll sum = 0;
    ll lsum = 0;
    ll rsum = 0;
    rep(i, k) sum += a[i];
    for(int i = k; i < n; i++) rsum += max(0, a[i]);
    ll maxx = sum;
    rep(i, n-k+1){
        maxx = max(maxx, max(0ll, sum)+lsum+rsum);
        sum -= a[i];
        sum += a[i+k];
        lsum += max(0, a[i]);
        rsum -= max(0, a[i+k]);
    }

    cout << maxx << endl;

    return 0;
}



Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};
//約数の列挙O(√n)
vector<ll>divisor(ll n){
  vector<ll>res;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(n/i);
    }
  }
  return res;
}
int main(){
  ll n,m;cin>>n>>m;
  vl vec=divisor(m);
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  rep(i,vec.size()){
    if(vec[i]*n<=m){
      cout<<vec[i]<<endl;
      return 0;
    }
    
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,sum=0;
	for(int i=0;i<4;i++)
	{
		cin>>n;
		sum+=n;	
	}
	cout<<sum/60<<endl<<sum%60<<endl;
	return 0;
}


Measured memory_bytes: 3096
import sys
input = sys.stdin.buffer.readline
 
 
def main():
    K = int(input())
    A, B = map(int, input().split())
    for i in range(A, B + 1):
        if i % K == 0:
            print('OK')
            sys.exit()
    print('NG')
 
 
if __name__ == '__main__':
    main()


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

using ll = long long;
// #define int long long

using P = pair<int, char>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n, m;
  cin >> n >> m;
  vector<P> v(m);
  REP(i,m) {
    int first;
    char second;
    cin >> first >> second;
    --first;
    v[i] = P(first, second);
  }
  int ans = pow(10, n-1);
  if(n == 1) ans = 0;
  SORT(v);
  string s = to_string(ans);
  int prev = -1;
  char prev_char = 'a';
  REP(i,v.size()) {
    P tmp = v[i];
    if(tmp.first == 0 && tmp.second == '0' && n != 1) {
      cout << -1 << endl;
      return 0;
    }
    if(prev == tmp.first && prev_char != tmp.second) {
      cout << -1 << endl;
      return 0;
    }
    s[tmp.first] = tmp.second;
    prev = tmp.first;
    prev_char = tmp.second;
  }
  cout << s;
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		int ans = 102;
		int re = 0;
		List<Integer> p = new ArrayList<Integer>();
		
		for(int i =0; i<n; i++) {
		    p.add(sc.nextInt());
		}
		
		
		for(int i=101;i>=0;i--) {
		    if(!p.contains(i)) {
		        if(ans>=Math.abs(x-i)) {
		            ans=Math.abs(x-i);
		            re = i;
		        }
		    }
		}
		System.out.println(re);
    }
}

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


int h,w;
int table[81][81], t; // 0-indexed

bitset<26000> dp[81][81]; // 1-indexed

signed main(){
    cin >> h >> w;
    REP(i,h) REP(j,w) cin >> table[i][j];
    REP(i,h) REP(j,w){
        cin >> t;
        table[i][j] = abs(table[i][j] - t);
    }
    dp[0][1][13000] = 1;
    REP(i,h){
        REP(j,w){
            dp[i+1][j+1] |= (dp[i+1][j] << table[i][j]);
            dp[i+1][j+1] |= (dp[i+1][j] >> table[i][j]);
            dp[i+1][j+1] |= (dp[i][j+1] >> table[i][j]);
            dp[i+1][j+1] |= (dp[i][j+1] << table[i][j]);
        }
    }
    int ret = 20000;
    REP(ind,26000) if(dp[h][w][ind]) ret = min(ret, abs(13000-ind));
    cout << ret << endl;
}

Measured memory_bytes: 20864
#ITP1_4_C
while True:
  a, op, b = input().split()
  a, b = int(a), int(b)
  if op == "?":
    break
  elif op == "+":
    print(a + b)
  elif op == "*":
    print(a * b)
  elif op == "/":
    print(a // b)
  elif op == "-":
    print(a - b)


Measured memory_bytes: 5600
N = int(input())
l = list(map(int, input().split()))
for i in range(N):
    t = l[i]
    j = i-1
    while j >= 0 and l[j] > t:
        l[j+1], l[j] = l[j], l[j+1]
        j -= 1
    print(*l)

Measured memory_bytes: 8028
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>

using namespace std;
int ans;
char s[100];
int main()
{
	scanf("%s",s);
	for(int i=0;i<strlen(s);i++)
	{
		if(s[i]=='o') ans+=100;
	}
	ans+=700;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
typedef pair<ll, ll> P;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int dp[2020];

int f(int n){
    if(dp[n]!=-1)return dp[n];
    ll ans=0;
    for(int i=3;i<=n+1;i++){
      ans+=f(n-i);
      ans%=MOD;
    }
    dp[n]=ans;
    return ans;
}
int main(){
    int n;
    cin>>n;
    rep(i,2020)dp[i]=-1;
    dp[0]=1;
    ll ans=f(n);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3584
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_A() {}


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int N; cin >> N;

    string ans = "No";
    if (N / 10 == 9 || N % 10 == 9) ans = "Yes";

    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef pair<int,ii> iii;
typedef vector<iii> viii;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

const int MOD = 1e9 + 7;
const ll INF = ll(1e18);
const ld eps = ld(1e-8);

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	vi a;
	int x, y, z;
	cin>>x>>y>>z;
	a.pb(x); a.pb(y); a.pb(z);
	sort(a.begin(),a.end());
	if(a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES\n";
	else cout<<"NO\n";
	
}

Measured memory_bytes: 256
n=int(input())
Ac=0
Wa=0
Tle=0
Re=0
for _ in range(n):
    s=input()
    if s=='AC':
        Ac+=1
    elif s=='WA':
        Wa+=1
    elif s=='TLE':
        Tle+=1
    elif s=='RE':
        Re+=1
print('AC x {}'.format(Ac))
print('WA x {}'.format(Wa))
print('TLE x {}'.format(Tle))
print('RE x {}'.format(Re))

Measured memory_bytes: 9208
N = int(input())
result=0
for i in range(1,N+1,2):
    j= i+1
    cnt=0

    for k in range(1,j):
        if i % k==0:

            cnt+=1

            if cnt>8:
                break
    
    if cnt == 8:
        result+=1
    
print(result)


Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N ;
  cin>>N;
  vector<int>data(110); //余裕を持たせるために100以上にしておく。
 for(int i=0;i<N;i++){
  cin>>data.at(i);
 }
 sort(data.begin(),data.end());
 reverse(data.begin(),data.end()); //reverseとsortで大きい順にする
  int alice;
  int bob;
  
  for(int i=0;i<N;i++){
   if(i%2==0){
   alice+=data.at(i); //aliceは偶数の枚数をとる
   }else{
   		 bob+=data.at(i);
    	}
	}
  cout<<alice-bob<<endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()
counter = {'R':0, 'G':0, 'B':0}
for s in S:
    counter[s] += 1

ans = counter['R'] * counter['G'] * counter['B']
for i in range(N):
    for j in range(i + 1, N):
        if S[i] != S[j] and 2 * j - i < N and S[i] != S[2 * j - i] and S[j] != S[2 * j - i]:
            ans -= 1
print(ans)

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

int main(void) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a > b) {
		a = b;
	}
	if (c > d) {
		c = d;
	}
	cout << a + c << endl;
	return 0;
}

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

int main(void){
    ll n;
    cin >> n;
    
    vector<ll> a(n), a_abs(n);
    ll res = 0, c = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a_abs[i] = abs(a[i]);
        res += a_abs[i];
        if (a[i] < 0) c++;
    }
    

    if (c % 2 == 1) {
        res -= 2 * *min_element(a_abs.begin(), a_abs.end());
    }
  
    cout << res << endl;
    
}


Measured memory_bytes: 1792
import numpy as np
N, P = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(A)
A = A % 2
A = list(A)
count0 = A.count(0)
count1 = A.count(1)

#print(count0, count1, P)

if P == 0 and count1 % 2 == 0:
    tmp = max(1, 2**(count1-1)) * 2**count0

elif P == 0 and count1 % 2 == 1:
    tmp = max(1, 2**(count1-1)) * 2**count0

elif P == 1 and count1 % 2 == 0:
    tmp = max(1, 2**(count1-1))* 2**count0

elif P == 1 and count1 % 2 == 1:
    tmp = max(1, 2**(count1-1)) * 2**count0 

if count1 == 0 and P ==1:
    tmp = 0

print(round(tmp))

Measured memory_bytes: 12488
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
 
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        ArrayDeque<Integer> left = new ArrayDeque<Integer>();
        ArrayDeque<Integer> areaLeft = new ArrayDeque<Integer>();
        ArrayDeque<Integer> area = new ArrayDeque<Integer>();
         
        for(int i = 0; i < s.length(); ++i) {
            char c = s.charAt(i);
            if(c == '\\'){
                left.addFirst(i);
            }else if(c == '/'){
                if(!left.isEmpty()) {
                    int l = left.removeFirst();
                    areaLeft.addFirst(l);
                    area.addFirst(i-l);
                }
            }
        }
         
        int lastl = s.length();
        while(!areaLeft.isEmpty()){
            int l = areaLeft.removeFirst();
            if(l > lastl){
                area.addLast(area.removeFirst() + area.removeLast());
            }else{
                area.addLast(area.removeFirst());
                lastl = l;
            }
        }
         
        StringBuilder sb = new StringBuilder();
        int sum = 0;
        for(Integer i : area){
            sum += i;
            sb.insert(0, " " + i);
        }
        sb.insert(0, area.size());
         
        System.out.println(sum);
        System.out.println(sb);
    }
     
}

Measured memory_bytes: 26036
n = int(input())
c = [[i for i in input().split()] for _ in range(n)]
a, b = 0, 0
for v in c:
    a, b = (a + 3, b + 0) if v[0] > v[1] else (a + 1, b + 1) if v[0] == v[1] else (a + 0, b + 3)
print(a, b)


Measured memory_bytes: 5712
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];
    let line = read_as_vec::<i64>();
    let (t, a) = (line[0]*1000, line[1]*1000);
    let h = read_as_vec::<i64>();
    let mut ans = std::i64::MAX;
    let mut ansi = 0;
    for i in 0..h.len(){
        if ans > (t-6*h[i]-a).abs(){
            ans = (t-6*h[i]-a).abs();
            ansi = i;
        }
    }

    println!("{}", ansi+1);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string.h>
#include <stack>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    int n,t,a;
    cin >> n >> t >> a;
    int minN = 100000001;
    int p = 0;
    rep(i, 0, n){
        int x;
        cin >> x;
        int tmp = (t*1000 - x*6) - a*1000;
        if(tmp < 0) tmp = -tmp;
        if(minN > tmp){minN = tmp; p=i+1;}
    }
    cout << p << endl;
}


Measured memory_bytes: 3620
N = int(input())
X = list(map(int, input().split()))

x_max = 100
ans_min = 1000000
for p in range(x_max):
    sum_ = 0
    for x in X:
        sum_ += (x - p) ** 2
    ans_min = min(sum_, ans_min)
print(ans_min)

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

int main() {
    int k, x;
    cin >> k >> x;
    string ans;
    if (k * 500 >= x) {
        ans = "Yes";
    } else {
        ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 1000000
#define SQRTMAX 1000
void seive_prime(bool seive[])
{
	for(int i=2;i<=SQRTMAX;i++) {
		if(seive[i] == false) {
			for(int j=i*2;j<=MAX;j+=i) {
				seive[j]=true;
			}
		}
	}
}
int main() {
	int n;
	bool sieve[MAX+1] = {false};
	// エラトステネスの篩
	seive_prime(sieve);
	
	while(cin >> n) {
		int cnt = 0;
		for(int i=2;i<=n;i++) {
			if(sieve[i] == false)
				cnt++;
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a[7]={1,3,5,7,8,10,12};
	int b[4]={4,6,9,11};
	int x,y;
	cin>>x>>y;
	for(int i=0;i<7;i++){
		for(int j=0;j<7;j++){
			if(x==a[i]&&y==a[j]){
				cout<<"Yes"<<endl;
				goto age;
			}
			else if(i<4&&j<4&&b[i]==x&&b[j]==y){
				cout<<"Yes"<<endl;
				goto age;
			}
		}
	}
	cout<<"No"<<endl;
	age:;
}


Measured memory_bytes: 256
a,b = map(int,input().split())
ans = ""
if a == b:
    ans = "Draw"
elif a == 1 or b == 1:
    if a < b:
        ans = "Alice"
    else:
        ans = "Bob"
else:
    if a > b:
        ans = "Alice"
    else:
        ans = "Bob"
print(ans)

Measured memory_bytes: 3060
n, m = map(int, input().split())
if n % 2 == 1:
    for i in range(1, m + 1):
        print(i, n + 1 - i)
else:
    turning_point = (m + 1) // 2
    for i in range(1, turning_point + 1):
        print(i, n + 1 - i)
    for i in range(turning_point + 1, m + 1):
        print(i, n - i)


Measured memory_bytes: 9272
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main() {
  long double W, H, x, y;
  cin >> W >> H >> x >> y;
  long double result = W * H * 0.5;
  cout.precision(12);
  cout << result << " ";
  if (x * 2 == W && y * 2 == H) {
    cout << 1;
  } else {
    cout << 0;
  }
}

Measured memory_bytes: 256
K = int(input())
A = list(map(int, input().split()))

def ng():
  print(-1)
  exit()

A = A[::-1]
if A[0] != 2:
  ng()
mim = 2
mox = 3

for i in range(1, K):
  a = A[i]
  n = -(-mim // a) * a
  if n > mox:
    ng()
  mim = n
  mox = mox // a * a + a - 1

print(mim, mox)

Measured memory_bytes: 85096
N, M = gets.split.map &:to_i
A = gets.split.map &:to_i
BC = $<.map{|s|
  b, c = s.split.map &:to_i
}
A.sort!
BC.sort_by!{|b, c| -c }
idx = 0
BC.each{|b, c|
  while idx < N && A[idx] < c && b > 0
    A[idx] = c
    idx += 1
    b -= 1
  end
}
p A.inject:+

Measured memory_bytes: 21368
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

public class Program
{
    public static void Main(string[] args)
    {
        new Program().Solve(new ConsoleInput(Console.In, ' '));
    }

    public void Solve(ConsoleInput cin)
    {
        var n = cin.ReadInt;
        string[] index = ReadLine().Split(' ');
        var ans = new string[n];
        var a = "";
        for (var i = 0; i < n; i++)
        {
            ans[int.Parse(index[i])-1] = (i+1).ToString();
        }
        for (var i = 0; i < n; i++)
        {
            Write(ans[i] + " ");
        }
        ReadKey();
    }
}

public class ConsoleInput
{
    private readonly System.IO.TextReader _stream;
    private char _separator = ' ';
    private Queue<string> inputStream;
    public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
    {
        this._separator = separator;
        this._stream = stream;
        inputStream = new Queue<string>();
    }
    public string Read
    {
        get
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(_separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
    }
    public string ReadLine { get { return _stream.ReadLine(); } }
    public int ReadInt { get { return int.Parse(Read); } }
    public long ReadLong { get { return long.Parse(Read); } }
    public double ReadDouble { get { return double.Parse(Read); } }
    public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
    public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
    public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
}


Measured memory_bytes: 29144
#include <iostream>
#include <algorithm>
using namespace std;
void dice(){
    int d1,d2,d3,d4,d5,d6;
    cin>>d1>>d2>>d3>>d4>>d5>>d6;
    
    char dir;
    int tmp;
    while(true){
        cin>>dir;
        if(cin.eof()) break;
        if(dir=='E'){
            tmp=d1;d1=d4;d4=d6;d6=d3;d3=tmp;
        }else if(dir=='N'){
            tmp=d1;d1=d2;d2=d6;d6=d5;d5=tmp;
        }else if(dir=='S'){
            tmp=d1;d1=d5;d5=d6;d6=d2;d2=tmp;
        }else if(dir=='W'){
            tmp=d1;d1=d3;d3=d6;d6=d4;d4=tmp;
        }
    }
    cout<<d1<<endl;
}
int main(){
    dice();
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#define size(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
int main(void){
    string a,b;
    cin >> a >> b;
  if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]){
    cout << "YES";
  }else{
    cout << "NO";
  }
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            String str1= br.readLine();
            Double r= Double.parseDouble(str1);
            double S,C;
            S=r*r*Math.PI;
            C=2*r*Math.PI;
            System.out.printf("%f"+" "+"%f", S,C);
        } catch (IOException e) {
            System.out.println(e);
        } catch (NumberFormatException e) {
            System.out.println("The input age was not correct.");
       }
    }
}


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

using namespace std;

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

// 46786 - 106

vector<int> fin;
vector<int> fup;
vector<vector<int>> edges;

int br = 0;
int tt = 0;

void dfs(int node, int parent = -1) {
    fin[node] = tt;
    fup[node] = tt;
    ++tt;
    for (auto out : edges[node]) {
        if (out == parent) {
            continue;
        }
        if (fin[out] == -1) {
            dfs(out, node);
        }
        fup[node] = min(fup[node], fup[out]);
        if (fup[out] > fin[node]) {
            ++br;
        }
    }
}


void oneCase() {
   int n, m;
   cin >> n >> m;
   edges.resize(n);
   for (int i = 0; i < m; ++i) {
       int a, b;
       cin >> a >> b;
       --a;
       --b;
       edges[a].pb(b);
       edges[b].pb(a);
   }
   fin.assign(n, -1);
   fup.assign(n, -1);
   dfs(0);

   cout << br << "\n";


}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
int n,a[N][4];
void No(){
	puts("No");
	exit(0);
}
int c[N];
void add(int x,int d){
	for (;x<=n;x+=x&-x)
		c[x]^=d;
}
int ask(int x){
	int ans=0;
	for (;x;x-=x&-x)
		ans^=c[x];
	return ans;
}
int main(){
	n=read();
	for (int i=1;i<=3;i++)
		for (int j=1;j<=n;j++)
			a[j][i]=read();
	for (int i=1;i<=n;i++){
		int t=(a[i][2]-1)/3;
		for (int j=1;j<=3;j++)
			if ((a[i][j]-1)/3!=t)
				No();
		if (a[i][2]!=t*3+2)
			No();
		if ((t&1)==(i&1))
			No();
	}
	int a1=0,a2=0,c1=0,c2=0;
	for (int i=n;i>=1;i-=2)
		if (a[i][1]>a[i][3])
			a1^=1;
	for (int i=n-1;i>=1;i-=2)
		if (a[i][1]>a[i][3])
			a2^=1;
	memset(c,0,sizeof c);
	for (int i=n;i>=1;i-=2){
		int t=a[i][2]/3+1;
		c1^=ask(t);
		add(t,1);
	}
	memset(c,0,sizeof c);
	for (int i=n-1;i>=1;i-=2){
		int t=a[i][2]/3+1;
		c2^=ask(t);
		add(t,1);
	}
	puts(a1==c2&&a2==c1?"Yes":"No");
	return 0;
}

Measured memory_bytes: 2176
res = []
while True:
    n,k = map(int,input().split())
    if n == 0 and k == 0:
        break
    card = [i for i in range(n,0,-1)]
    for i in range(k):
        p,c = map(int,input().split())
        card = card[p-1:p-1+c]+card[:p-1]+card[p+c-1:]
    res.append(card[0])
for i in range(len(res)):
    print(res[i]) 


Measured memory_bytes: 5636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
    int x,a,b;
    cin>>x>>a>>b;
    cout<<((abs(x-a)<abs(x-b))?"A":"B")<<endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int mx = 0;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int cnt = 0;
        int tmp = i;
        while(tmp%2 == 0){
            tmp /= 2;
            cnt++;
        }
        if(mx <= cnt){
            mx = cnt;
            ans = i;
        }
    }    
    cout << ans << endl;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; ++i)
    cin >> S[i];
  sort(S.begin(), S.end());
  for (int i = 0; i < N; ++i)
    cout << S[i];
  cout << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <stack>

long long int INF = 1e18;
using namespace std;

typedef pair<string, int> P;

int main(){
	
	int n, q;
	cin >> n >> q;
	
	queue<P> que;
	P p;
	for(int i = 0; i < n; i++){
		cin >> p.first >> p.second;
		que.push(p);
	}
	
	int ans = 0;
	while(!que.empty()){
		p = que.front();
		que.pop();
		ans += min(p.second, q);
		if(p.second <= q){
			cout << p.first << " " << ans << endl;
		}else{
			p.second -= q;
			que.push(p);
		}
	}
	
	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<vector<ll>> adj;
vector<ll> to_p;
vector<ll> A;

bool dfs(int n, int p=-1) {
  ll tmp = 0, mtmp = 0;
  for (auto x: adj[n]) {
    if (x==p) continue;
    if (!dfs(x,n)) return false;
    tmp += to_p[x];
    mtmp = max(mtmp, to_p[x]);
  }
  if (tmp!=0&&A[n]>tmp) return false;
  if (mtmp>A[n]) return false;
  to_p[n] = (adj[n].size()==1) ? A[n]-tmp : A[n]*2-tmp;
  // cout << n << " " << p << " " << to_p[n] << " " << mtmp << endl;
  return to_p[n]>=0;
}

int main() {
  int N; cin >> N;
  A.resize(N); rep(i,N) cin >> A[i];
  adj.resize(N); to_p.resize(N);
  rep(i,N-1) {
    ll a, b; cin >> a >> b; a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  string result = (dfs(0)&&to_p[0]==0) ? "YES" : "NO";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 15232
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sn = new Scanner(System.in);
        
        int price = sn.nextInt();
        int cnt = 0;
        
        if((price / 500) != 0) {
            cnt += 1000 * (price / 500);
            price %= 500;
        } 
        
        if((price / 5) != 0) {
            cnt += 5 * (price / 5);
        }
        
        System.out.print(cnt);
        
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 	    make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod        1000000007
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll power(ll a , ll b,ll modi)
{
    a%=modi;
    ll res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % modi ;
        }
        b/=2 ;
        a = (a*a) % modi ;
    }
    return res ;
}
//ll a[100001];
ll a[200001];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
	//cin>>t;
	while(t--)
	{
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
        cin>>a[i];
    ll x=0;
    for(ll i=0;i<n;i++)
        x^=a[i];
    for(ll i=0;i<n;i++)
        a[i]=a[i]^x;
    for(ll i=0;i<n;i++)
        cout<<a[i]<<" ";
	}
return 0;
}


Measured memory_bytes: 5132
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
    int N; cin >> N;
    vector<int> targets(N);
    for (int i = 0; i < N; i++) {
        cin >> targets[i];
    }

    int decrease = 0;
    int prev_idx, next_idx;
    for (int i = 1; i < N; i++) {
        if (targets[i] < targets[i - 1]) {
            decrease += 1;
            if (1 == decrease) {
                prev_idx = i - 1;
            } else if (2 == decrease) {
                next_idx = i;
                swap(targets[prev_idx], targets[next_idx]);
            } else {
                continue;
            }
        }
    }

    vector<int> sorted_targets;
    sorted_targets = targets;
    sort(sorted_targets.begin(), sorted_targets.end());
    if (sorted_targets == targets && decrease < 3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())

l = []

for i in range(h):
    l.append(input())


ans = 0
c = 0
for i in range(2**h):
    for j in range(2**w):
        c = 0
        for ii in range(h):
            
            for jj in range(w):
                # print(ii, jj)
                if ( ((i >> ii) & 1) and ( (j >> jj) & 1) )  and l[ii][jj] == '#'   :
        
                    c += 1
        if c == k:
            ans += 1

print(ans)

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

typedef long long ll;
typedef pair<int, int> P;
int const MAX_V = 20001;
int const MAX_E = 100001;
int const INF = 1<<29;

vector<int> G[MAX_V];
int ord[MAX_V], low[MAX_V];

int V,E;
void init();
vector<int> ans;

int rec(int pos,int prev,int& k){
  // cout<<pos<<endl;

  low[pos]=ord[pos]=k++;
  int res=0,cnt=0,flg=0,child=0;
  
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    if(ord[to]==-1){
      child++;
      int x=rec(to,pos,k);
      cnt+=res*x;
      res+=x;  
      low[pos]=min(low[pos],low[to]);
      if(low[to]>=ord[pos]&&prev!=-1)flg=true;
    }else low[pos]=min(low[pos],ord[to]);
  }
  
  cnt+=(V-res-1)*res;
  if(prev==-1&&child>=2)flg=true;
  if(flg){
    ans.push_back(pos);
  }
  return res+1;
}

void init() {
  ans.clear();
  for(int i=0;i<V;i++){
    low[i]=INF;
    ord[i]=-1;
    G[i].clear();
  }
}

int main(){

  cin>>V>>E;
  init();
  for(int i=0;i<E;i++){
    int u, v; 
    scanf("%d %d",&u,&v);
    //   u--,v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  int k=0;
  for(int i=0;i<V;i++)
    if(ord[i]==-1)
      rec(i,-1,k);      
    
  //for(int i=0;i<V;i++)cout<<low[i]<<' '<<ord[i]<<' '<<i<<endl;
  sort(ans.begin(),ans.end());
  for(int i=0;i<(int)ans.size();i++)
    cout<<ans[i]<<endl;
  
  return 0;
}

Measured memory_bytes: 3228
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    double[] x, y;
    int i, j, s;
    double ax, ay, bx, by;

    n = sc.nextInt();
    x = new double[n];
    y = new double[n];

    for(i = 0;i < n;i++){
      x[i] = sc.nextDouble();
      y[i] = sc.nextDouble();
    }
    sc.close();

    s = 1;
    for(i = 0;i < n - 2;i++){
      ax = x[i + 1] - x[i];
      ay = y[i + 1] - y[i];
      bx = x[i + 2] - x[i];
      by = y[i + 2] - y[i];
      if(ax * by - ay * bx < 0){
        s = 0;
        break;
      }
    }
    ax = x[i + 1] - x[i];
    ay = y[i + 1] - y[i];
    bx = x[0] - x[i];
    by = y[0] - y[i];
    if(ax * by - ay * bx < 0)s = 0;


    if(s == 0){
      System.out.println("0");
    }else{
      System.out.println("1");
    }

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

Measured memory_bytes: 20836
#include<stdio.h>
#define maxH 500001


void maxHeapify(int A[],int i,int H){
	int l=i*2;
	int r=l+1;
	int largest;
	
	if(l<=H && A[l]>A[i])largest=l;
	else largest=i;
	
	if(r<=H && A[r]>A[largest])largest=r;
	
	if(largest!=i){
		int temp=A[i];
		A[i]=A[largest];
		A[largest]=temp;
		maxHeapify(A,largest,H);
	}
}

void buildMaxHeap(int A[],int H){
	int i;
	for(i=H/2;i>0;i--)maxHeapify(A,i,H);
}

int main(void){
	int A[maxH];
	int i,H;
	scanf("%d",&H);
	for(i=1;i<=H;i++)scanf("%d",&A[i]);
	buildMaxHeap(A,H);
	for(i=1;i<=H;i++)printf(" %d",A[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 3688
#[allow(dead_code)]
fn main() {
    let (n, x) = i::u2();
    let mut a = i::uv(n);
    let mut ans = 0;
    if a[0] > x {
        ans = a[0] - x;
        a[0] = x;
    }
    for i in 1..n {
        if a[i] + a[i - 1] > x {
            ans += a[i - 1] + a[i] - x;
            a[i] = x - a[i - 1];
        }
    }
    println!("{}", ans);
    //dbg!(a);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
def gcd(x, y):
  if x < y:
    x, y = y, x
  if y == 0:
    return x
  if x%y == 0:
    return y
  else:
    return gcd(y, x%y)
  
n = int(input())
a = [int(i) for i in input().split()]
x = [0 for i in range(n)]
y = [0 for i in range(n)]

for i in range(1, n):
  x[i] = gcd(x[i-1], a[i-1])
for j in range(n-1)[::-1]:
  y[j] = gcd(y[j+1], a[j+1])
z = [gcd(x[i], y[i]) for i in range(n)]
print(max(z))

Measured memory_bytes: 14428
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()

# その位置にボールを入れるかを保持するA2
A2=[0]*N
B=[]
# 後ろから決めていく
for i in range(N-1, -1, -1):
    cur=i+1
    cnt=0
    # curの倍数を全部見に行く
    for j in range(cur*2, N+1, cur):
        cnt^=A2[j-1]
    # ボールを入れるべきかどうか
    if A[i]!=cnt:
        B.append(cur)
        A2[i]=1

print(len(B))
print(*B)


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

  vector<int> A(N);
  rep0(i, N) cin >> A[i];
  sort(A.begin(), A.end());

  int n1 = A[N - 1], n2 = A[0];
  rep0(i, N) {
    if (abs(2 * A[i] - n1) < abs(2 * n2 - n1)) {
      n2 = A[i];
    }
  }

  cout << n1 << SP << n2 << BR;
  return 0;
}

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

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

  vector<int> ans(n); 
  for(int i=0; i<n-1; ++i){
    int a;
    cin >> a;
    ans[a-1]++;
  }
  for(int i=0; i<n; ++i) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define MAXK 1010
#define MOD 1000000007
#define ll long long


int main()
{
	int a,b; string s;
	cin >> a >>  b >> s;
	bool flag = 0;
	if(s.size()==a+b+1 && s[a]=='-')
	{
		int ct=  -1;
		for(char c: s)
		{
			ct++;
			if(ct==a) continue;
			if(c-48>=0 && c-48<=9) continue;
			else flag=1;
//			cout<<c<<" "<<ct<<endl;

		}
		if(!flag) { cout<<"Yes"<<endl; return 0;}
	}
	cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 256
[N,M]=list(map(int,input().split()))
K=[]
for m in range(M):
  K.append(list(map(int,input().split())))
p=list(map(int,input().split()))

ans=0
for i in range(2**N):
  tmp=list(map(int,list(str(format(i, 'b')
                           )
                       )
              )
          )
  tmp=[0,]*(N-len(tmp))+tmp
  
  blist=[sum([tmp[i-1] for i in joken[1:]]
                         )%2==p[n]
         for n,joken in enumerate(K)
        ]

  #print(i,tmp,blist)
  
  if all(blist):
    ans=ans+1
print(ans)

Measured memory_bytes: 3064