akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.size()<=k){
        cout<<s;
    }
    else{
        for(int i=0;i<k;i++){
            cout<<s[i];
        }
        cout<<"...";
    }
    cout<<"\n";
    
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,ans = "",tmp = "";
  getline(cin,s);
  rep(i,s.size()){
    if(s[i] != ' ' && s[i] != ',' && s[i] != '.'){
      tmp += s[i];
    }
    else{
      if(2 < tmp.size() && tmp.size() < 7){
        ans += tmp;
        ans += " ";
      }
      tmp.clear();
    }
  }
  if(2 < tmp.size() && tmp.size() < 7){
    ans += tmp;
    ans += " ";
  }
  tmp.clear();
  ans.resize(ans.size()-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

ll N, M, V, P, a;
vector<ll> A;

bool can_clear(ll index){
    //cout<<index<<endl;
    if(N-index<=P) return true;
    ll necess=max((ll)0, V-P-index);
    ll value_maxim=A[index]+M;
    ll count=0;
    ll i=index+1;
    while(true){
        //cout<<i<<endl;
        if(i>N-P) break;
        if(A[i]>value_maxim) return false;
        count+=min(M, value_maxim-A[i]);
        i++;
    }
    //
    if(count>=necess*M) return true;
    else return false;
}

//条件に合致する最小indexを二分探索 O(logN)
//-2...全indexがみたす -1...条件に合致するものがない
ll nibutan_min(ll min, ll max){
  //評価関数can_clear(ll　value) を指定すること
  ll left=min, right=max;
  ll ans;
  while(true){
      //cout<<left<<" " <<right<<endl; //debug用
      if(left+1==right){
        if(can_clear(left)){
          if(left==min) return -2;
          else return left;
        }
        else{
          if(can_clear(right)) return right;
          else return -1;
        }
        break;
      }
      ll nibutan=(left+right)/2;
      bool can_do_it=can_clear(nibutan);
      if(can_do_it) right = nibutan;
      else left = nibutan;
  }
}

int main(void){
    //cout<<"started"<<endl;
    cin>>N>>M>>V>>P;
    rep(i, N){
        cin>>a;
        A.push_back(a);
    }
    sort(all(A));
    ll nibutan_result=nibutan_min(0, N-1);
    if(nibutan_result==-2) cout<<N<<endl;
    else cout<<(N-nibutan_result)<<endl;
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
#define right sefudermano
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int32_t main(){
  fastio;
  int a;
  cin>>a;
  cout << (a + a*a + a*a*a) << endl;

  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
} 

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
typedef vector<int> vi;
typedef pair<int , int> ii;
int mod = 1000 * 1000 * 1000 + 7;
string s;
set<string> q;
vector<pair<int , int> > indices;
int cnt[256];
int main()
{
    //freopen("input.txt" , "r" , stdin);
    cin >> s;
    int n = s.size();
    for(int i = 0; i < s.size(); i++)
        cnt[s[i]]++;
    ll res = 1 + (ll)n * (n - 1) / 2;
    for(int i = 0; i < 256; i++)
        res -= (ll)cnt[i] * (cnt[i] - 1) / 2;
    printf("%lld\n" , res);

}


Measured memory_bytes: 640
s=input()
q=0

if s.find("keyence")!=-1:
    q=1#ok
else:
    if s[:6]== "keyenc" and s[len(s)-1]=="e":
        q=1
    else:
        if s[:5]=="keyen" and s[len(s)-2:]=="ce":
            q=1
        else:
            if s[:4]=="keye" and s[len(s)-3:]=="nce":
                q=1
            else:

                if s[:3]=="key" and s[len(s)-4:]=="ence":
                    q=1
                else:

                    if s[:2]=="ke" and s[len(s)-5:]=="yence":
                        q=1
                    else:

                        if s[0]=="k" and s[len(s)-6:]=="eyence":
                            q=1
if q==1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    string n;
    cin >> n;
    cout << "ABC" + n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;

void solve()
{
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	for(ll i=k;i<=n+1;i++)
	{
		ll frs=(i-1)*i/2;
		ll rrs=(2*n-i+1)*i/2;
		ans+=rrs-frs+1;
		ans%=M;
	}
	cout<<ans;
}
 
int main()
{
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

Measured memory_bytes: 3656
import sys
sys.setrecursionlimit(100000000)

S = input()[::-1]


while len(S) > 0:
    if S[0] == 'r':
        if S[0:6] == 'resare':
            S = S[6:]
        elif S[0:7] == 'remaerd':
            S = S[7:]
        else:
            print('NO')
            exit()
    elif S[0:5] == 'maerd':
        S = S[5:]
    elif S[0:5] == 'esare':
        S = S[5:]
    else:
        print('NO')
        exit()
print('YES')


Measured memory_bytes: 134420
N = int(input())
C = [0] * N
S = [0] * N
F = [0] * (N - 1)
F.append(1)

for i in range(N - 1):
    C[i], S[i], F[i] = map(int, input().split())

for i in range(N):
    time = S[i]
    for j in range(i, N):
        time = max((F[j] - (time - S[j])) % F[j] + time, S[j]) + C[j]
    print(time)

Measured memory_bytes: 3064
/**
* AOJ: 0015
* 4/29/19
**/

import java.util.Scanner;

public class Main {

   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
   
      int n = Integer.parseInt(sc.nextLine());
      String num1;
      String num2;
      String sum;
   
   
      for(int i = 0; i < n; i ++) {
         /*initialize/reset numbers*/
         num1 = sc.nextLine();
         num2 = sc.nextLine();
         sum = "";
               
         /*skip to next loop if num1 OR num2 is too large*/
         if(num1.length() > 80 || num2.length() > 80) {
            System.out.println("overflow");
            continue;
         }
         
         /* Calculate the length of the sum. 
         * Take longer digit and add one to its length to allow carry over
         */
         int digits = num1.length() > num2.length() ? (num1.length() + 1) : (num2.length() + 1);
         
         /*pad each number with 0s (ex. 223 + 5 => 0223 + 0005)*/      
         num1 = pad(num1, digits - num1.length());
         num2 = pad(num2, digits - num2.length());
         sum  = pad(sum, digits);
         
         /*summation*/
         for(int index = digits - 1; index >= 1; index --) {
            sum = add(sum, index, num1.charAt(index), num2.charAt(index));
         }
         
         /*checks if the first character is 0 and omit it if so*/
         sum = sum.charAt(0) == 48 ? sum.substring(1) : sum;
         
         /*checks if sum overflows*/
         if(sum.length() > 80) {
            System.out.println("overflow");
            continue;
         } else {
            System.out.println(sum);
         }      
      }//end of each calculation
   }// end of main method
   
   
   public static String pad(String original, int numZeros) {
      for(int i = 0; i < numZeros; i ++) {
         original = "0" + original;
      }
      return original;
   }
   
   public static String add(String original, int index, char c1, char c2) {
      int num1 = Character.getNumericValue(c1);
      int num2 = Character.getNumericValue(c2);
      int numOrg = Character.getNumericValue(original.charAt(index));
      
      int numericalSum = num1 + num2 + numOrg;
      
      int oneth = numericalSum % 10;
      int tenth = numericalSum / 10;
      
      return original.substring(0, index - 1) + tenth + oneth + original.substring(index + 1);
      
      
   }
}// end of class


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

int main(void){
	string s;
	cin >> s;

	int cnt = 0;
	for(int i=0;i<s.size();i++){
		if(!cnt && s[i] == 'C'){
			cnt++;
		}else if(cnt == 1 && s[i] == 'F'){
			cnt++;
		}
	}
	if(cnt == 2)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    N=int(input())
    S=input()
    ans=S.count('R')*S.count('G')*S.count('B')
    for i in range(N):
        for d in range(N):
            j = i+d
            k = j+d
            if k >= N:
                break
            if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
                ans-=1
    print(ans)
main()

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b;cin>>a>>b;
  if(a==1)a=14;
  if(b==1)b=14;
  string ans="Draw";
  if(a>b)ans="Alice";
  else if(a<b)ans="Bob";
  cout(ans);
  
  return 0;
}

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

using ll=long long; 

void solve(){
	int a,b;
	cin>>a>>b;
	int dif=b-a;
	int h=(dif+1)*dif/2;
	cout<<h-b<<endl;	
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let b = scan!();
    println!(
        "{}",
        match &b[..] {
            "A" => "T",
            "T" => "A",
            "C" => "G",
            "G" => "C",
            _ => "A",
        }
    )
}


Measured memory_bytes: 4352
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, d: "List[int]"):
    ans = 0
    for i in range(N-1):
        for j in range(i+1, N):
            # print(i, j@)
            ans += d[i]*d[j]

    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>

int n, A[20], q, m[200];
int solve(int i, int m)
{
    if (m == 0)
        return 1;
    if (i >= n)
        return 0;
    return solve(i + 1, m) || solve(i + 1, m - A[i]);
}

int main(void)
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {
        scanf("%d", &m[i]);
        if (solve(0, m[i]))
            printf("yes\n");
        else
            printf("no\n");
    }

    return 0;
}


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

class MyClass
{
    public static void Main(string[] args)
    {
        var str = "";
        while ((str = Console.ReadLine()) != null)
        {
            var a = str.Split();
            str = Console.ReadLine();
            var b = str.Split();
            var hit = 0;
            var blow = 0;
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (a[i] == b[j])
                    {
                        if (i == j)
                        {
                            hit++;
                        }
                        else
                        {
                            blow++;
                        }
                    }
                }
            }
            Console.WriteLine("{0} {1}", hit, blow);
        }
    }
}


Measured memory_bytes: 15832
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef vector<vi> vii;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
const int MAXN = 1e5 +5;
const LL m = 1e9 + 7;
void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}


LL po(LL a, LL n){
	if(n==0) return 1;
	LL an = po(a,n/2);
	an = (an*an)%m;
	if(n&1) return (an*a)%m;
	return an;
}


int main(){
  fio();
  LL n; cin>>n;
  LL an = po(10, n);
  an = (an - po(9, n) + m)%m;
  an = (an - po(9, n) + m)%m;
  an = (an + po(8, n))%m;
  cout<<an<<endl;
  return 0;
}

Measured memory_bytes: 3648
n, m = gets.split.map(&:to_i)
s, c = m.times.map { gets.split.map(&:to_i) }.transpose

ans = Array.new(n, 0)

m.times do |i|
  if n >= 2 && s[i] == 1 && c[i] == 0
    ans[0] = -1
  elsif ans[s[i] - 1] != 0 && ans[s[i] - 1] != c[i]
    ans[s[i] - 1] = -1
  else
    ans[s[i] - 1] = c[i]
  end
end

ans[0] = 1 if n >= 2 && ans[0] == 0

puts ans.any? { |v| v == -1 } ? -1 : ans.join

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  rep(i,s.size()) {
    rep(j,s.size()) {
      if(i+j>s.size()) break;
      string t=s.substr(0,i)+s.substr(i+j);
      if(t=="keyence") {
        pr("YES");
        return;
      }
    }
  }
  pr("NO");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
/*@authored by: Subham Pratap*/

/* ************************************************************************************************************************** */

#include <bits/stdc++.h>
using namespace std;
#define PKMKB ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define lli long long int
#define ull unsigned long long
#define INT_MAX 2147483647
#define all(a) begin(a),end(a)
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define MOD 1000000007
#define MAXN 10000005

  int main()
  {
    PKMKB;
    lli t;
    cin >> t;
    lli a[t+10];
    lli count = 0;
    for(lli i=0;i<t;i++)
    {
        cin >> a[i];
    }
    sort(a,a+t);
    if(t%2!=0)
        cout << 0 << endl;
    else
    {
        lli val = (t-1)/2 +1;
//        cout <<val << endl;
//        cout << a[val] << " " << a[t/2] << endl;
        cout << a[val]-a[(t-1)/2] << endl;
    }
	return 0;
}


Measured memory_bytes: 1152
/*Shivam Bhalla */
  /* f2016941@pilani.bits-pilani.ac.in */



  #include <iostream>
  #include <cstdio>
  #include <cstring>
  #include <cstdlib>
  #include <cctype>
  #include <algorithm>
  #include <map>
  #include <vector>
  #include <list>
  #include <set>
  #include <queue>
  #include <deque>
  #include <stack>
  #include <iostream>
  #include <string>
  #include <cmath>
  #include <cassert>
  #include <bits/stdc++.h>
  #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
  using namespace std;
  long long maxv = 1e9;


  int main()
  {
    fast_cin();
    int N;
    cin>>N;
    vector<long long>arr(N);
    for(int i=0;i<N;i++)
      cin>>arr[i];
    long long X1=0;
    for(int i=0;i<N;i++)
      X1+=pow(-1,i)*arr[i];
    cout<<X1<<" ";
    for(int i=0;i<N-1;i++){
      X1=(2*arr[i])-X1;
      cout<<X1<<" ";
    }  
    return 0;
  }


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

typedef long long ll;

using namespace std;

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

int main(){
    int kakunin[40000];
    int n,q;
    cin >> n;
    int A[n];
    rep(i,n) cin >> A[i];
    cin >> q;
    int M[q];
    rep(i,q) cin >> M[i];
    for(int bit = 0 ; bit < (1 << n);bit++){
        int sum=0;
        for(int j=0;j<n;j++){
            if(bit & (1<<j)) sum += A[j]; 
        }
        kakunin[sum] = 1;
    }
    for(int i=0;i<q;i++){
        if(kakunin[M[i]]) cout << "yes" << endl;
        else cout << "no" << endl; 
    }
    return 0;
}



Measured memory_bytes: 3100
from sys import stdin


def main():
    _ = int(stdin.readline().rstrip())
    Pn = [int(x) for x in stdin.readline().rstrip().split()]
    min_ = 200001
    count = 0
    for x in Pn:
        if x <= min_:
            min_ = x
            count += 1
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25768
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  map<string, int> mp;
  int sum=0;
  rep(i, n){
  	string s;int t;cin>>s>>t;
    sum+=t;
    mp[s]=sum;
  }
  string u;cin>>u;
  cout<<sum-mp[u]<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); //freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);
using namespace std;


signed main()
{
    FLASH


    int x, y;
    cin>>x>>y;
    if((y&1) or y < 2*x or y > 4*x) cout<<"No\n";
    else cout<<"Yes\n"; 
}

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

int main()
{
    int n;
    cin >> n;
    switch (n % 10)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    case 3:
        cout << "bon" << endl;
        break;
    }
}


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


H.insert(N,10**9)

ans='Yes'

for i in range(N):
    if H[i]<H[i+1]:
        H[i+1]=H[i+1]-1

    elif H[i]>H[i+1]:
        ans='No'
        break

print(ans)




Measured memory_bytes: 14252
n = int(input())
def get_divisor(x):
  divisor = set()
  for i in range(1, int(x**(1/2))+1):
    if x%i==0:
      divisor.add(i)
      divisor.add(x//i)
  return divisor
ans = 0
for i in range(1, n+1, 2):
  if len(get_divisor(i))==8:
    ans += 1
print(ans)

Measured memory_bytes: 3188
//============================================================================
// Name        : b
// Date        : Sat Apr 20 20:07:32 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include "bits/stdc++.h"
using namespace std;

#define x first
#define y second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fore(i, a, b) for (int i = a; i < b; ++i)
#define prt(x, i, n) { cout << x[i] << (i == n - 1 ? "\n" : " "); }
#define par(x, s, n, v) if(v) cout << #x << ": "; fore(i, s, n) prt(x, i, n)
template<class T> inline void amin(T &x, const T &y) { if (y < x) x = y; }
template<class T> inline void amax(T &x, const T &y) { if (x < y) x = y; }
template <typename T> void output(T t) { cout << t << "\n"; }
template <typename T, typename U, typename... Args>
void output(T t, U u, Args... args) { cout << t << " "; output(u, args...); }

#ifndef _has_trace
#define trace(...)
#define dbstream ostream
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int k;
  cin >> k;
  char c = s[k - 1];
  for (int i = 0; i < n; ++i) {
    if (s[i] != c) {
      s[i] = '*';
    }
  }
  output(s);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	int a[2][n];
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin >> a[i-1][j-1];
		}
	}
	
	int ans=0;

	for(int i=1;i<=n;i++)
	{
		int x=0;
		for(int j=1;j<=i;j++)
			x+=a[0][j-1];
		for(int j=i;j<=n;j++)
			x+=a[1][j-1];

		ans=max(ans,x);
	}

	cout << ans << endl;
}

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

int main(void){
    int n; 
    int r; 
    int p; 
    int c; 

    while(cin >> n >> r){
        if(n==0 && r==0)break;
        int card[n]; 
        int tmp[n]; 

        for (int i=n-1,number=1; i>=0; i--,number++){ 
            card[i] = number;
        }

        for (int i=0;i<n;i++){
            tmp[i] = 0;
        }

        for (int i=0;i<r;i++){
            cin >> p >> c;
            for(int j=0;j<p-1;j++){
                tmp[j] = card[j];
            }
            for(int j=0;j<c;j++){
                card[j] = card[j+p-1];
            }
            for(int j=0;j<p-1;j++){
                card[c+j]=tmp[j];
            }
        }
        cout << card[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
#include <fstream>
#include <string>
#include <cmath>
#include <algorithm>
#include <time.h>
#include <stack>
#include <vector>
using namespace std;



int main()
{
	int D, T, S;
	cin >> D >> T >> S;
	if (T*S >= D)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}

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

A.sort()
if A[-1]-A[0]>1:
    print('No')
else:
    if A[-1]-A[0]==1:
        n=A.count(A[0])
        m=A.count(A[-1])
        kind=A[-1]-n
        if m>=2*kind and kind>0:
            print('Yes')
        else:
            print('No')
    else:
        if A[0]==N-1:
            print('Yes')
        else:
            if N>=2*A[0]:
                print('Yes')
            else:
                print('No')

Measured memory_bytes: 52292
n, m = list(map(int, input().split()))

a, b = [], []

for i in range(n):
  a.append(list(map(int, input().split())))

for i in range(m):
  b.append(int(input()))

for i in range(n):
  e = 0
  for j in range(m):
    e += a[i][j] * b[j]
  print(e)


Measured memory_bytes: 6008
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
			int N=sc.nextInt();
			int D=sc.nextInt();
			
			int v[][]=new int[N][D]; 
			
			for(int i=0;i<N;i++) {
				for(int b=0;b<D;b++) {
					v[i][b]=sc.nextInt();
				}
			}
			int sum;
			int ans=0;
			for(int i=0;i<N;i++) {
				for(int b=i+1;b<N;b++) {
					
					sum=0;
					for(int a=0;a<D;a++) {
						sum+=(v[i][a]-v[b][a])*(v[i][a]-v[b][a]);
					}
					
					for(int t=1;t<=sum;t++) {
						if(t*t==sum) {
							ans++;
							break;
						}else if(t*t>sum)break;
					}
					//p(i+"    "+b+"   "+sum);
					
				}
			}p(ans);
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
//Optimizations
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
//save time
#define endl '\n'
#define db(x) cerr << "> " << #x << ": " << x << endl
typedef long long ll;
 
//for sorting
#define all(a) a.begin(),a.end()
 
//Constants
#define PI   3.141592653593
#define MOD  1000000007LL
#define EPS  0.000000001
#define INF  0X3f3f3f3f
 
//loops
#define REP(i,n) 	    for(int i=0;i<(n);++i)
#define FOR(i,a,b)      for(int i=(a);i<(b);++i)
#define DFOR(i,a,b)     for(int i=(a);i>=(b);--i)
 
//vectors
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int,int>>
#define vlll vector<pair<ll,ll>>
#define pb 	push_back
 
//pairs
#define pi pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define F first
#define S second
 
//fast I/O
#ifndef _WIN32
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
#define gc getchar
#define pc putchar
 
//If using cin and cout
#define IOS ios::sync_with_stdio(false)
#define TIE cin.tie(NULL);cout.tie(NULL)
 
//queue
#define di deque<int>
#define dll deque<ll>
#define qi queue<int>
#define PQ priority_queue
 
//general
#define E empty()
 
//Declare all variables and methods needed between this comment and the next one(OCD lol)
const int MAXN=0;
int main(){
    IOS;
    TIE;
    ll n ; cin >> n ; 
    //stack<int> s;
    ll x=1, y=1, z=1;
    ll curr = x*x + y*y+ z*z +x*y + y*z+z*x;
    vll res(n+1, 0);
    for(int i = 1 ; i*i <= n ; ++i){
        for(int j = 1 ; j *j < n ; ++j){
            for(int k = 1 ; k*k < n ; ++k){
            curr = i*i+ j*j + k*k +i*j+ j*k + k*i;
            if(curr >n) continue;
                    
                    res[curr] +=1;
            
            }
        }
    }
        /*
        if(x==y && y == z && z == x){
        if(curr <=n)  
        res[curr] +=1;
        x = 1, y = 1, z++;
        }
        else {
     //   cout << x << " " << y << " s " << z << endl;
        if(x<= z &&x <= y)x++;
        else if (y <= z && y <= x)y++;
        else z++;
        if(curr <= n)
        res[curr] +=3;
        }
        curr = x*x + y*y+ z*z +x*y + y*z+z*x;   /
    }*/
    REP(i, n){
        cout << res[i+1] << endl;
    }

}

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

int H,W,K;
vector<vector<int>> p;
int imos(int a,int b,int c,int d){
  return p[c][d]-p[c][b]-p[a][d]+p[a][b];
}

int main() {
  cin>>H>>W>>K;
  p.resize(H+1,vector<int>(W+1));
  int Z=100000;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      char a;
      cin>>a;
      p[i][j]=a-'0';
    }
  }
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      p[i][j]+=p[i-1][j];
    }
  }
  for(int j=1;j<=W;j++){
    for(int i=1;i<=H;i++){
      p[i][j]+=p[i][j-1];
    }
  }
  for(int l=0;l<(1<<(H-1));l++){
    vector<int> q={0};
    for(int i=1;i<H;i++){
      if(l&(1<<(i-1))){
        q.push_back(i);
      }
    }
    q.push_back(H);
    int N=q.size();
    int A=0,B=0,J;
    for(int i=1;i<=W;i++){
      J=0;
      for(int j=1;j<N;j++){
        if(K<imos(q[j],i,q[j-1],B)){
          J=1;
          break;
        }
      } 
      if(J){
        B=i-1;
        A++;
        for(int j=0;j<N;j++){
          if(K<imos(q[j],i,q[j-1],i-1)){
            J++;
            break;
          }
        }
      }
      if(J==2){
        A=10000;
        break;
      }
    }
    Z=min(Z,A+N-2);
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#define ll long long
using namespace std;
int n,k,tot,pre[400005],nxt[400005],a[400005],l[400005],r[400005],sl[400005],sr[400005];
ll ans;
bool flag[400005];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >q;
int main()
{
	scanf("%d%d",&n,&k);
	tot=n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		pre[i]=i-1,nxt[i]=i+1;
		q.push(make_pair(a[i],i));
		l[i]=r[i]=1;
	}
	nxt[n]=0;
	while(!q.empty())
	{
		int node=q.top().second;
		q.pop();
		if(flag[node])continue;
		int L=node,R=node,len=1;
		while(a[pre[L]]==a[node])L=pre[L],len++;
		while(a[nxt[R]]==a[node])R=nxt[R],len++;
		int last=0;
		for(int i=L,j=1;i!=nxt[R];i=nxt[i],j++)
		{
			sl[j]=sl[j-1]+l[i];
			sr[j]=sr[j-1]+r[i];
			if(i<=n)last=j;
			if(last&&j>=k)ans+=1ll*sl[min(j-k+1,last)]*r[i];
			flag[i]=1;
		}
		if(len<k)
		{
			nxt[pre[L]]=pre[nxt[R]]=0;
			continue;
		}
		for(int i=1;i<=len/k;i++)
		{
			r[tot+i]=sr[min(len,(i+1)*k-1)]-sr[i*k-1];
			l[tot+i]=sl[len-(len/k-i+1)*k+1]-sl[max(0,len-(len/k-i+2)*k+1)];
		}
		nxt[pre[L]]=tot+1,pre[tot+1]=pre[L];
		pre[nxt[R]]=tot+len/k,nxt[tot+len/k]=nxt[R];
		for(int i=1;i<len/k;i++)
		{
			nxt[tot+i]=tot+i+1;
			pre[tot+i+1]=tot+i;
		}
		for(int i=1;i<=len/k;i++)a[tot+i]=a[L]+1;
		q.push(make_pair(a[tot+1],tot+1));
		tot+=len/k;
	}
	printf("%lld\n",ans+n);
	return 0;
}

Measured memory_bytes: 12400
import numpy as np
N,M =list(map(int, input().split()))
X = input().split()
for i in range(len(X)):
    X[i] = int(X[i])
X = np.array(X)
X.sort()

y = []
for i in range(len(X)-1):
    y.append(X[i+1]-X[i])

Y = np.array(y)
Y.sort()

if N ==1:
    print(sum(Y))
else:
    print(sum(Y[:1-N]))

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

int main(void){
   string s;
   cin>>s;
   int N=s.size();
   for(int i=N/2-1;i>=1;i--){
      if(s.substr(0,i)==s.substr(i,i)){
         cout<<i*2<<endl;
         return 0;
      } 
   }
   return 0;
}



Measured memory_bytes: 3632
while True:
  n, x = map(int, input().split())

  if n == 0 and x == 0:
    break

  ans = 0

  for i in range(1,n+1):
    for j in range(i+1,n+1):
      k = x-(i+j)
      if k >= 1 and k <= n and k > j:
        ans += 1

  print(ans)



Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n, k;
   cin >> n >> k;
   vector<int> a(n);
   rep(i, 0, n) cin >> a[i];
   rep(i, 0, n - k) {
      if (a[i] < a[k + i])
         cout << "Yes" << endl;
      else
         cout << "No" << endl;
   }
   return 0;
}

Measured memory_bytes: 3988
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int ll

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 1e5 + 20 ;
int n , a[N] ;
vector <int> g[N] ;

inline void err () {
	cout << "NO\n" ;
	exit(0) ;
}

int dfs (int v , int par = -1) {
	if (_sz(g[v]) == 1) return a[v] ;

	int sum = 0 , mx = 0 ;
	for (int u : g[v])
		if (u != par) {
			int val = dfs(u , v) ;
			sum += val ;
			mx = max(mx , val) ;
		}

	if (a[v] > sum || (sum - a[v]) > min(sum / 2 , sum - mx)) err() ;

	return 2 * a[v] - sum ; 
}

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> n ;
	for (int i = 0 ; i < n ; i ++) cin >> a[i] ;

	for (int i = 0 , u , v ; i < n - 1 ; i ++) {
		cin >> u >> v ;
		u -- , v -- ;
		g[u].push_back(v) ;
		g[v].push_back(u) ;
	}

	if (n == 2) {
		return cout << (a[0] == a[1] ? "YES" : "NO") << '\n' , 0 ;
	}

	int root = -1 ;
	for (int i = 0 ; i < n ; i ++) 
		if (_sz(g[i]) > 1) root = i ;

	if (dfs(root)) err() ;

	cout << "YES\n" ;
}


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

typedef pair<int,int> P;

int main(){
  int h,w,n = 0;
  cin >> h >> w;
  int a[h+1][w+1];
  for(int i = 1;i <= h;i++){
    for(int j = 1;j <= w;j++){
      cin >> a[i][j];
    }
  }
  vector<P> ans1,ans2;
  bool havecoin = false;
  for(int i = 1;i <= h;i++){
    if(i % 2 != 0){
      for(int j = 1;j <= w;j++){
        if(a[i][j] % 2 != 0){
          if(havecoin == false){
            havecoin = true;
          }
          else{
            havecoin = false;
          }
        }
        if(j == w && havecoin == true && i != h){
          ans1.push_back({i,j});
          ans2.push_back({i+1,j});
          n++;
        }
        else if(havecoin == true && j != w){
          ans1.push_back({i,j});
          ans2.push_back({i,j+1});
          n++;
        }
      }
    }
    else{
      for(int j = w;j >= 1;j--){
        if(a[i][j] % 2 != 0){
          if(havecoin == false){
            havecoin = true;
          }
          else{
            havecoin = false;
          }
        }
        if(j == 1 && havecoin == true && i != h){
          ans1.push_back({i,j});
          ans2.push_back({i+1,j});
          n++;
        }
        else if(havecoin == true && j != 1){
          ans1.push_back({i,j});
          ans2.push_back({i,j-1});
          n++;
        }
      }
    }
  }
  cout << n << endl;
  for(int i = 0;i < ans1.size();i++){
    cout << ans1.at(i).first << ' ' << ans1.at(i).second << ' ' << ans2.at(i).first << ' ' << ans2.at(i).second << endl;
  }
}

Measured memory_bytes: 5228
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(N);
    CIN(K);
    CIN(X);CIN(Y);
    if(N <= K){
        COUT(X * N);

    }else{
        COUT(X * K + Y *(N - K));

    }
    return 0;
}




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

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

    let mut b: Vec<i64> = vec![0; n];

    let mut cnt = 0;
    let mut ans = 0;
    for i in 0..n {
        b[i] = a[i].abs();
        ans += b[i];
        if a[i] < 0 {
            cnt += 1;
        }
    }
    b.sort();
    if cnt % 2 > 0 {
        ans -= b[0] * 2;
    }
    println!("{}", ans);
}

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


Measured memory_bytes: 6396
#include <stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==5 and b== 7 and c==5 || a==7 and b==5 and c==5 || a==5 and b==5 and c==7)
        printf("YES\n");
    else printf("NO\n");

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;


int main() {
	int N;
	char s[100], t[100];
	cin >> N >> s >> t;
	for (int i = 0; i < N; i++) {
		bool flag = true;
		for (int k = 0; k < N - i; k++) {
			if (s[k + i] != t[k]) {
				flag = false;
				break;
			}
		}
		if (flag) {
			cout << N + i;
			return 0;
		}
	}
	cout << N * 2;
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

solver :: Int -> Int -> Int
solver 1 c = c
solver n c =
  if even n then
    solver (n `div` 2) (c + 1)
    else
      solver (3 * n + 1) (c + 1)

main :: IO()
main = do
  n <- (read :: String -> Int) <$> getLine
  unless (n == 0) $ do
    print $ solver n 0
    main

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

class Program
{
    static void Main()
    {
        Solve();
    }

    static bool Solve()
    {
        long n = long.Parse(Console.ReadLine());

        long ans = long.MaxValue;
        for (long i = 1; i <= Math.Sqrt(n) + 1; i++)
        {
            if (n % i != 0) continue;
            long c = i + n / i - 2;
            if (ans > c)
            {
                ans = c;
            }
        }

        Console.WriteLine(ans);
                

        return true;
        
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<set>
#include<iomanip>
using namespace std;


int main() {

	int n;
	cin >> n;
	int a[110000];
	long long int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}

	if (sum % 2 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;

	}

	return 0;
}

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

int main(){
    int x1, x2, x3, x4, x5;

    cin >> x1 >> x2 >> x3 >> x4 >> x5;

    if(x1 == 0){
        cout << "1" << endl;
    } else if(x2 == 0){
        cout << "2" << endl;
    } else if(x3 == 0){
        cout << "3" << endl;
    } else if(x4 == 0){
        cout << "4" << endl;
    } else{
        cout << "5" << endl;
    }

    return 0;
}

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

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl

#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define REVERSE(x) reverse( (x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define PW(x) (1LL<<(x))

using namespace std;
using ll = int64_t;
using P = pair<int, int>;

template<class T,class U>
ostream& operator<<(ostream &os, const pair<T, U> &p) {
    os << get_variable_name(p) << " = (" << p.first <<", " << p.second << ")";
    return os;
}

template<class T>
ostream& operator <<(ostream& os, const vector<T> &v){
    cout << get_variable_name(v) << " = [";
    for(auto i : v) 
        os << " " << v[i];
    os << " ]";
    return os;
}


const int INF = 1e8;

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

    string s;
    cin >> s;
    bool turn = true;
    
    while(s.size() > 2) {
        bool ok = false;
        for(int i = 1; i+1 < s.size(); i++) {
            if(s[i-1] != s[i+1]) {
                s.erase(i,1);
                ok = true;
                break;
            }
        }

//        cout << ok << ' ' << s << endl;
       
        if(ok) {
            turn ^= 1;
        }

        if(!ok) {
            break;
        }

    }

    if(turn) {
        cout << "Second" << endl;
    } else {
        cout << "First" << endl;
    }
}



Measured memory_bytes: 592
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

constexpr long mod = 1000000000 + 7;

long solve(long n)
{
  if (n == 1) return 0;
  long result = 0;
  long ten = 1;
  long eig = 1;
  for (long i = 2; i <= n; ++i) {
    ten = ten * 10 % mod;
    eig = eig * 8 % mod;

    auto diff = (ten - eig) % mod;
    if (diff < 0) diff += mod;
    diff = (diff - result) % mod;
    if (diff < 0) diff += mod;
    result = ((result * 10) % mod + diff) % mod;
  }

  return result;
}

int main()
{
  long n;
  std::cin >> n;

  std::cout << std::setprecision(20);
  std::cout << solve(n) << std::endl;
}


Measured memory_bytes: 3592