akhauriyash/Code-Regression huggingface dataset:
/*
???,O(n^4)?KM??????,??O(n^3)????????KM?????
???O(1)??????????,????????????
*/
#include <cstring>
#include <cstdio>
#include <algorithm>
#define fr first
#define sc second
#define mp make_pair
using namespace std;
const int maxl=55,maxn = 105,maxt=2505;
const int INF = 0x3f3f3f3f;
int match[maxt],lx[maxt],ly[maxt],slack[maxt];
int G[maxn][maxt];
bool visx[maxt],visy[maxt];
int n,m,nx,ny,ans,cnt;
char pic[maxl][maxl];

bool findpath(int x)
{
    int tempDelta;

    visx[x] = true;
    for(int y = 0 ; y < ny ; ++y){
        if(visy[y]) continue;
        tempDelta = lx[x] + ly[y] - G[x][y];
        if(tempDelta ==  0){//(x,y)??????
            visy[y] = true;
            if(match[y] == -1 || findpath(match[y])){
                match[y] = x;
                return true;
            }
        }
        else if(slack[y] > tempDelta)
            slack[y] = tempDelta;//(x,y)????????y??????
    }
    return false;
}
void KM()
{

    for(int x = 0 ; x < nx ; ++x){
        for(int j = 0 ; j < ny ; ++j) slack[j] = INF;//??????,?????x???????slack
        while(true){
            memset(visx,false,sizeof(visx));
            memset(visy,false,sizeof(visy));//????????????,????findpath()????
            if(findpath(x)) break;
            else{
                int delta = INF;
                for(int j = 0 ; j < ny ; ++j)//??dfs(x)?????x???????,y??????,????
                    if(!visy[j] && delta > slack[j])
                        delta = slack[j];
                for(int i = 0 ; i < nx ; ++i)
                    if(visx[i]) lx[i] -= delta;
                for(int j = 0 ; j < ny ; ++j){
                    if(visy[j])
                        ly[j] += delta;
                    else
                        slack[j] -= delta;
                    //?????,?????slack????delta
                    //????lx[i] ???delta
                    //slack[j] = min(lx[i] + ly[j] -w[i][j]) --j??????--?????delta,????
                }
            }
        }
    }
}
void solve()
{

   memset(match,-1,sizeof(match));
   memset(ly,0,sizeof(ly));
   for(int i = 0 ; i < nx ; ++i){
        lx[i] = -INF;
        for(int j = 0 ; j < ny ; ++j)
            if(lx[i] < G[i][j])
                lx[i] = G[i][j];
   }
   KM();
}
int Head,Tail,ti,vis[maxl][maxl];pair<int,int> que[maxt];
void BFS(int X,int Y){
	Head=0;Tail=0;que[++Tail]=mp(X,Y);vis[X][Y]=++ti;
	while (Head!=Tail){
		Head++;int x=que[Head].fr,y=que[Head].sc;
		if (y<m && vis[x][y+1]<ti && pic[x][y+1]!='#') que[++Tail]=mp(x,y+1),vis[x][y+1]=ti;
		if (x<n && vis[x+1][y]<ti && pic[x+1][y]!='#') que[++Tail]=mp(x+1,y),vis[x+1][y]=ti;
	}
	for (int i=1,x,y;i<=Tail;i++){
		x=que[i].fr;y=que[i].sc;
		if (pic[x][y]!='o') G[cnt][(x-1)*m+y-1]=x-X+y-Y;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",pic[i]+1);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			if (pic[i][j]=='o') BFS(i,j),cnt++;
    nx = cnt;ny = n*m;
    solve();
    int ans = 0;
    for(int i = 0 ; i < ny ; ++i)
        if(match[i] != -1)
            ans += G[match[i]][i];
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2572
//1-11-19
#include<bits/stdc++.h>

#define Pi acos(-1.0)
#define ll long long
#define uu first
#define vv second
#define scl(n) scanf("%d",&n)
#define scll(n) scanf("%lld",&n)
#define pb push_back
#define eb emplace_back

#define For(i,n)  for(int i=0;i<n;i++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOOR(a,b) for(ll i=a;i<=b;i++)
#define all(c) (c).begin(),(c).end()
#define open  freopen("input.txt","r",stdin)
#define close freopen ("output.txt","w",stdout)
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define print(v)   for(auto x : v)  {cout<<x<<" ";}  cout<<endl;
#define PRINT(v)   for(auto x: v) {cout<<x.uu<<" "<<x.vv<<endl;}cout<<endl;
using namespace std;

int main()
{
    // open;
    // close;
    // fastio
    
    map<int,int>mp;
    int n;
    scl(n);
    For(i,n){
        
        int x;
        scl(x);
        mp[x]++;
    }
    
    //PRINT(mp);
    
    int kk=n;
    
    for(auto x: mp){
        
        if(x.first>x.second){
            
            kk-=x.second;
           // cout<<x.second<<" "<<kk<<endl;
        }
        else{
            
            kk-=(x.second-x.first);
            //cout<<x.first<<" "<<x.second<<" "<<kk<<endl;
        }
    }
    
    cout<<n-kk<<endl;
    return 0;
}



Measured memory_bytes: 4736
#include<iostream>
#include<cstdio>
#define MN 100000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int f[11][11][MN+5],c[MN+5],n,m,q,head[MN+5],cnt=0,res[MN+5];
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
	e[++cnt]=(edge){t,head[f]};head[f]=cnt;
	e[++cnt]=(edge){f,head[t]};head[t]=cnt;	
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;++i) ins(read(),read());
	q=read();
	for(int i=1;i<=q;++i)
	{
		int x=read(),d=read();c[i]=read();
		f[d][0][x]=i;
	}
	for(int i=0;i<=10;++i)
	{
		for(int j=1;j<=i;++j)
			for(int k=1;k<=n;++k)
			{
				f[i][j][k]=f[i][j-1][k];
				for(int s=head[k];s;s=e[s].next)
					f[i][j][k]=max(f[i][j][k],f[i][j-1][e[s].to]);
			}
		for(int k=1;k<=n;++k) res[k]=max(res[k],f[i][i][k]);
	}
	for(int i=1;i<=n;++i) printf("%d\n",c[res[i]]);
	return 0;
}

Measured memory_bytes: 46592
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  string s;
  cin>>s;
  cout << s[0] << s.size()-2 << s[s.size()-1] << endl;

  return 0;
}


Measured memory_bytes: 256
while true
    n = gets.to_i
    break if n == 0
    a = []
    for i in 0..n-1
        a<<gets.to_i
    end
    max_ending_here = max_so_far = a[0]
    for i in 1..a.length-1
        max_ending_here = [a[i],max_ending_here+a[i]].max
        max_so_far = [max_so_far, max_ending_here].max
    end
    puts(max_so_far)
end

Measured memory_bytes: 8772
import math


def solve_d(a, b, x):
    if 2 * x == a * a * b:
        return math.atan(b / a) * 180 / math.pi
    elif 2 * x > a * a * b:
        return math.atan((b - x / (a ** 2)) * 2 / a) * 180 / math.pi
    else:
        return 90 - math.atan((x / (a * b)) * 2 / b) * 180 / math.pi


def main():
    # input
    a, b, x = map(int, input().split())
    res = solve_d(a, b, x)
    print(res)


def test():
    assert abs(solve_d(2, 2, 4) - 45.0000000) <= 0.000001
    assert abs(solve_d(12, 21, 10) - 89.7834636934) <= 0.000001
    assert abs(solve_d(3, 1, 8) - 4.2363947991) <= 0.000001


if __name__ == "__main__":
    test()
    main()


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

int main() {
  int H, N, T;
  cin >> H;
  cin >> N;
  T = 0;
  vector<int> A(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    T = T + A.at(i);
  }
  
  if (T >= H) {
  	cout << "Yes";
  }
  else {
  	cout << "No";
  }
  
}

Measured memory_bytes: 640
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        BigInteger x = new BigInteger(sc.next());
        BigInteger y = new BigInteger(sc.next());
        if(x.compareTo(y)>0){
            System.out.println("GREATER");
        }else if(x.compareTo(y)<0){
            System.out.println("LESS");
        }else{
            System.out.println("EQUAL");
        }
    }

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


Measured memory_bytes: 23760
/*input
1079
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

void solve(){
  	int x;cin >> x;
  	RE(i,50000){
  		if(i+((8*i)/100) == x){
  			cout << i;
  			return;
  		}
  	}
  	cout << ":(";
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    
    if (a < b) {
        printf("a < b\n");
    } else if (a > b) {
        printf("a > b\n");
    } else {
        printf("a == b\n");
    }
    
    return 0;
}


Measured memory_bytes: 2592
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define do(x) for(int i = 1; i <= x; i++){ solve(); }

using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e5+2;
const ll mod = 1e9+7;
int n,m,k,a,b,c;
vector<vector<double>> v;

double getres(int i, int j){
	double sum = 0;
	for(int ii = 1; ii <= m; ii++){
		double cur = v[i][ii]-v[j][ii];
		sum += cur*cur;
	}
	return sqrt(sum);
}

void solve(){
	cin >> n >> m;
	v.resize(n+1,vector<double>(m+1,0));
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			double x; cin >> x;
			v[i][j] = x;
		}
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i != j){
				if(getres(i,j) == round(getres(i,j)))
				cnt++;
			}
		}
	}
	cout << cnt/2 << endl;
}


int main(){ 
	speedhack()
	// cin >> n;
	do(1);
	return 0;
}


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

using namespace std;

int main(){
        long long int a,b;
        cin >> a >> b;

        if (a % 2 != b %2){
                cout << "IMPOSSIBLE" << endl;

        }
        else {
                cout << (a + b) / 2 << endl;
        }
        return 0;
}

Measured memory_bytes: 3604
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

// MyScanner is myscanner
type MyScanner struct {
	sc *bufio.Scanner
}

// NewScanner returns MyScanner
func NewScanner(rd io.Reader) *MyScanner {
	s := new(MyScanner)
	s.sc = bufio.NewScanner(rd)
	s.sc.Split(bufio.ScanWords)
	return s
}

func (s *MyScanner) nextString() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *MyScanner) nextInt() int {
	i, e := strconv.Atoi(s.nextString())
	if e != nil {
		panic(e)
	}
	return i
}

func solve(w io.Writer, r io.Reader) {
	sc := NewScanner(r)
	N := sc.nextInt()

	ans := (N - 2) * 180
	fmt.Fprintln(w, ans)
}

func main() {
	solve(os.Stdout, os.Stdin)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void){
    int n,cnt = 0;
    cin >> n;
    vector<int> d(n);
    for(int i = 0;i < n;i++) cin >> d[i];
     sort(d.begin(),d.end());
    if(n %2 == 1 || d[n/2] == d[n/2-1]){
        cout << 0 << endl;
        return 0;
    }
    cout << d[n/2]-d[n/2-1] << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
typedef std::pair<int,int> P;


	ll ans=0;
	ll N,K,A[500010];
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin>>N;
	REP(i,N){cin>>A[i];ans+=A[i]-1;}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b,c;
    cin>>a>>b>>c;
    cout<<a[0]<<b[0]<<c[0]<<endl;
    
    return 0;   
}




 
 


Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define pb push_back
using ll = long long;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main(){
  string s;
  bool flag = false;//false even, true odd
  cin >> s;
  REP(i,s.length()){
    if(flag && s[i]== 'R'){
  cout << "No" << endl;
  return 0;
    }else if(flag == false&& s[i]== 'L'){
  cout << "No" << endl;
    return 0;
    }
    flag = !flag;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long n,d,x;
    scanf("%ld", &n);
    scanf("%ld %ld", &d, &x);

    long a[101]={0};
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &(a[i]));
        x+=(d-1)/a[i]+1;
    }   

    printf("%ld\n", x);

    return 0;
}


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

int main() {
	int X,Y;
	cin >> X >> Y;
	
	rep(i,X+1)
		if(i*2 + (X-i)*4 == Y) {
			cout << "Yes" << endl;
			return 0;
		}
	cout << "No" << endl;
}

Measured memory_bytes: 3636
/*It’s going to be hard,
but hard does not mean impossible.*/

#include <bits/stdc++.h>

// definitions
#define __Imperial_Lord__         \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define _cps CLOCKS_PER_SEC
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define acc(a) (accumulate((a).begin(), (a).end(), 0ll))
#define high(x) __builtin_popcountll(x)
#define pb push_back
#define pf push_front
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define exec cerr << "Time taken : " << (ld)(clock()) / _cps << "s" << endl
#define mod1 998244353
#define mod 1000000007
#define pi 3.1415926535897932384

using namespace std;

// alias name for common data types
typedef vector<long long> vl;
typedef vector<long double> vld;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<long long, long long>> vp;
typedef vector<tuple<long long, long long, long long>> vtup;
typedef deque<long long> dql;
typedef deque<char> dqc;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const ll INF = 1e18;

template <class... Args>
istream &read_args(Args &... args) { return (cin >> ... >> args); }
#define read(...) \
    __VA_ARGS__;  \
    read_args(__VA_ARGS__)

// cin and cout overloaded for vectors
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (auto &i : v)
        is >> i;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    for (auto &i : v)
        os << i << ' ';
    return os;
}

// code beigns in main
int main()
{
    __Imperial_Lord__
        ll t = 1;
    // cin >> t;
    while (t--)
    {
        ll read(a);
        p1(a + a * a + a * a * a);
    }
    exec;
}


Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll MOD=1e9+7 ;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    // input part
    string a,b;cin >> a >> b;

    int ans = 0;
    rep(i,3)
    {
        if (a[i]==b[i]) ans++;
    }

    // main part

    // output part
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (int i = k; i < (int)(n); ++i)
#define MAX 500010
typedef long long int ll;

using namespace std;


int main() {
	int N;
	cin >> N;
	int L[MAX];
	rep(i, N) {
		cin >> L[i];
	}

	sort(L, L + N);
	int cnt = 0;
	rep(a, N) {
		repk(b,a+1,N) {
			int *c = lower_bound(L, L + N, L[a] + L[b]); // key以上の要素の左側のイテレーターを返す
			// cout << a << b << c - (L+b+1) << endl;
			cnt += c - (L + b + 1);
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

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

	int N, A, B;
	string S;
	cin >> N >> A >> B >> S;

	int pass = 0;
	int rankb = 0;
	for( int i = 0; i < N; ++i ) {
		if( S[i] == 'a' ) {
			if( pass < A+B ) {
				pass += 1;
				cout << "Yes\n";
			}
			else {
				cout << "No\n";
			}
		}
		else if( S[i] == 'b' ) {
			rankb += 1;
			if( pass < A+B && rankb <= B ) {
				pass += 1;
				cout << "Yes\n";
			}
			else {
				cout << "No\n";
			}
		}
		else if( S[i] == 'c' ) {
			cout << "No\n";
		}
	}
	
	return 0;
}


Measured memory_bytes: 848
s=int(input())
a=ls=[s]
i=2
tmp=0
for i in range(2,1000001):
    if a[-1]%2==0:
        tmp=a[-1]/2
    else:
        tmp=3*a[-1]+1
    if tmp in a:
        print(i)
        break
    else:
        a.append(tmp)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

ll binpow(ll a, ll b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if (a>=k)
    {
        cout<<k;
        return 0;
    }
    if (a+b>=k)
    {
        cout<<a<<"\n";
        return 0;
    }
    cout<<a-(k-a-b);
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  string s;
  char c[5][6] =
    {{'a','f','k','p','u','z'},
     {'b','g','l','q','v','.'},
     {'c','h','m','r','w','?'},
     {'d','i','n','s','x','!'},
     {'e','j','o','t','y',' '}
    };
 
  while(cin>>s){
    string out;
    if (s.size() % 2){
      cout << "NA" << endl;
    }else{
      bool flag = false;
      for(int i = 1 ; i < s.size() ; i += 2){
	int y = s[i - 1] - '1';
	int x = s[i] - '1';
	if(y < 0 || x < 0 || y >= 6 || x >= 5){
	  flag = true;
	  break;
	}
	out += c[x][y]; 	
      }
      if(flag)
	cout << "NA" << endl;
      else 
	cout << out << endl;
    }
  }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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; }
const int INF = 1<<29;
using Graph = vector<vector<int>>;
int main() {
    int D,G,p[11],c[11]; 
    cin >> D >> G;
    for (int i=0; i<D; ++i) cin >> p[i] >> c[i];

    int ans = 1e9;
    
    for (int mask = 0; mask < (1<<D); ++mask){
        int s = 0, num = 0, rest_max = -1;
        for (int i=0; i<D; ++i){
            if (mask & (1<<i)){
                s += 100 * (i+1) * p[i] + c[i];
                num += p[i];
            }else {
                rest_max = i;
            }
        }
        if (s < G){
            int s1 = 100 * (rest_max + 1);
            int need = (G - s + (s1 - 1)) / s1;
            if (need >= p[rest_max]) continue;
            num += need;
        }
        chmin(ans, num);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main(){
	int n,a;
	cin>>n>>a;
	if(n<500){
		if(n<=a) cout<<"Yes";
		else cout<<"No";
	}
	if(n>=500){
		if(n%500<=a) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
} 

Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


# --------------------------------------------

dp = None


def main():
    N, X = li_input()
    C = li_input()
    D = []

    for c in C:
        D.append(abs(X - c))

    print(gcd_list(D))



main()


Measured memory_bytes: 16472
#include <bits/stdc++.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef int32_t i32;

#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>=b;i--)
#define FILL(a,b,c) for(ll i=0;i<c;i++) a[i]=b;

#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

#define endl "\n"
#define setpri(x) setprecision(x)
#define vp(x) cout<<#x<<" : "<< (x)<<" | "
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define forf(i,a,b) for(int i=a;i<b;i++)

#define INF 1e17+4
#define MINF 
#define MAX_INT 100000
#define MOD 1000000007
ll mod(ll n) { n %= MOD; if (n < 0) return n + MOD; else return n;}
// vector<int> adj[1000002];
// int vis[1000002],dep[1000002],siz[1000002];

// void dfs(ll cur,ll par)
// {
//     vis[cur]=1;siz[cur]=1;
//     for(auto x:adj[cur])
//     {
//         if(vis[x]!=1)
//         {
//             dep[x]=dep[cur]+1;
//             dfs(x,cur);
//             siz[cur]+=siz[x];
//         }    
//     }
// }

// bool sortfunc(const pair<int,int> &a, const pair<int,int> &b) 
// { 
//     return ;
// }

void solve()
{
    int n,k;
    cin>>n>>k;
    unordered_map<int,int> m;
    while(k--)
    {
        int l;
        cin>>l;
        while(l--)
        {
            int x;cin>>x;
            m[x]=k;
        }
    }
    cout<<n-m.size();
}




signed main()
{
    FAST;
    
    // ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
#define N 100010
using namespace std;
int a[N];
int main()
{
    int n, i, x, ans;
    scanf("%d", &n);
    for(i = 1; i <= n; ++i)
    {
        scanf("%d", &x);
        a[x]++;
    }
    ans = 0;
    for(i = 1; i <= 100000; ++i)
    {
        ans = max(ans, a[i] + a[i - 1] + a[i + 1]);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define PI acos(-1)
using namespace std;
int main () {
   double a,b,h,m,angle,res;
   cin>>a>>b>>h>>m;
   angle=abs(((11.0*m)/2.0)-(30.0*h));
   angle=min(angle,360.0-angle);
   res=sqrt((a*a)+(b*b)-(2.0*a*b*cos(angle * PI / 180.0)));
   printf("%0.20f\n",res);

   return(0);
}

Measured memory_bytes: 4132
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
int n;
int p;
int ans = 1;
map<int, int>mp;
ll modpow(ll a, int b) {
	if (!b)return 1;
	if (b % 2)return modpow(a, b - 1)*a;
	return modpow(a, b / 2)*modpow(a, b / 2);
}
signed main() {

	cin >> n >> p;
	if (n == 1) {
		cout << p << endl;
		return 0;
	}
	while (p%2 == 0) {
			mp[2]++;
			p /= 2;
			if (p == 1)goto got;
	}
	for (ll i = 3;i <= 100000;i += 2) {
		while (p%i == 0) {
			mp[i]++;
			p /= i;
			if (p == 1)goto got;
		}
	}
got:;
	for (auto x : mp) {
		ans *= modpow(x.first, x.second / n);
	}
	cout << ans << endl;
	getchar();getchar();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int n,m,i,s=0,a,b;
	scanf("%d%d",&n,&m);
	s=m;
	for(i=0;i<n;i++){
		scanf("%d%d",&a,&b);
		m=m+a-b;
		if(m<0){
			s=0;
		}
		else if(s<m){
			if(s!=0){
			s=m;
			}
		}
	}
	printf("%d\n",s);
	return 0;
}


Measured memory_bytes: 2048
from functools import lru_cache


@lru_cache(maxsize=None)
def is_prime(n):
    """
    nが素数かどうか判定する
    """
    if n < 2:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False
    else:
        i = 3
        while i ** 2 <= n:
            if n % i == 0:
                return False
            i += 2
        return True


size = 10 ** 5 + 1
memo = [0] * size
for n in range(3, size):
    memo[n] = memo[n - 1]
    if n % 2 == 1 and is_prime(n) and is_prime((n + 1) // 2):
        memo[n] += 1

Q = int(input())
for _ in range(Q):
    left, right = map(int, input().split(' '))
    print(memo[right] - memo[left - 1])


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  ll ans = 0;
  while (true) {
    bool flag = true;
    for (int i = 0; i < n; i++) {
      if (a.at(i) >= n) flag = false;
    }
    if (flag) break;
    
    vector<ll> keep(n);
    ll count = 0;
    for (int i = 0; i < n; i++) {
      count += a.at(i) / n;
      keep.at(i) = a.at(i) / n;
      a.at(i) %= n;
    }
    for (int i = 0; i < n; i++) {
      a.at(i) += count - keep.at(i);
    }
    ans += count;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
const int inf = 1e8;
const int sz = 1e5 + 10;
int n;
int ar[sz];
int dp[sz];
int ans = 0;

int rec(int x) {
    if (x == n) return 0;
    int& ret = dp[x];
    if (~ret) return ret;
    ret = 0;
    if (x + 1 < n && ar[x] >= ar[x + 1]) {
        ret = 1 + rec(x + 1);
    }
    return ret;
}

int main() {

    while (cin >> n) {
        
        ans = 0;

        memset(dp, -1, sizeof dp);

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

        for (int i = 0; i < n; i++) {
            ans = max(ans, rec(i));
        }

        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    lint a, b, n;
    cin >> a >> b >> n;
    lint x = min(n, b-1);
    cout << (a * x) / b << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
char a[1000000],b[1000000];
int main()
{
    int l;
    cin>>a>>b;
    l=strlen(a);
    for(int i=0;i<l;i++)
    {
        if(a[i]!=0)
            cout<<a[i];
        if(b[i]!=0)    
            cout<<b[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 998244353
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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;
}
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
vector<long long> fact_inv, inv, Com;

void init_nCk(int n, int SIZE) {
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
    Com.resize(SIZE + 5);
    Com[0] = 1;
    for (int i = 1; i < SIZE + 5; i++) {
        Com[i] = Com[i - 1] * ((n - i + 1) * inv[i] % MOD) % MOD;
    }
}
 
long long nCk(int k) {
    assert(!(k < 0));
    return Com[k];
}
int main()
{
  ll N,M,K;
  cin >> N >> M >> K;
  init_nCk(N-1,K);
  mint ans = 0;
  REP(i,K+1){
    mint x=M-1;
    mint cnt = x.pow(N-i-1);
    cnt*=nCk(i);
    cnt*=M;
    ans+=cnt;
  }
  cout << ans << endl;
}

Measured memory_bytes: 7840
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> s(m),c(m);
    bool result=true;
    rep(i,m){
        cin >> s[i] >> c[i];
    }
    vector<int> val(4);
    rep(i,4){
        val[i]=-1;
    }
    rep(i,m){
        if((s[i]==2||s[i]==3)&&n==1){
            result=false;
        }else if(s[i]==3&&n==2){
            result=false;
        }else if(n!=1&&c[i]==0&&s[i]==1){
            result=false;
        }else if(val[s[i]]==-1||val[s[i]]==c[i]){
            val[s[i]]=c[i];
        }
        else{
            result=false;
        }
    }
    int ans=0;
    int ten=1;
    int count_n=n;
    if(result==false){

        cout << -1 << endl;
        return 0;
    }if(n==1&&m==0){
        cout << 0 << endl;
        return 0;
    }
    FOR(i,n+1,1){
        rep(i,count_n-1)ten*=10;
        if(val[i]==-1&&i==1){
            ans+=ten;
        }else if(val[i]==-1&&i!=1){
            ans+=0;
        }else{
            ans+=val[i]*ten;
        }
        ten=1;count_n--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100005];
	scanf("%s", s);
	int n = strlen(s);
	int ans = 0; 
	int i, j;
	i = 0; j = n - 1;
	while (i < j)
	{
		if (s[i] == s[j])
		{
			i++;
			j--;
		}
		else
		{
			ans++;
			if (s[i] != 'x' && s[j] != 'x')
			{
				printf("-1\n");
				return 0;
			}
			if (s[i] == 'x')
				i++;
			else
				j--;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a[5],k;
  for(int i=0;i<5;i++){
  	cin>>a[i];
  }
  cin>>k;
  
  if(a[4]-a[0]>k){
  	cout<<":(";
  }else if(a[4]-a[0]<=k){
  	cout<<"Yay!";
  }
  return 0;
}

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

int main() {
    char ch[101];
    cin>>ch;
    int contor=0;
    for(int i=0; i<strlen(ch)/2; ++i)
    {
        if(ch[i] != ch[strlen(ch)-i-1])
        {
            contor++;
        }
    }
    cout<<contor;
    return 0;
}

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

int main(void){
  int n,k,z,a=0,d;
  std::cin >> n >> k;
  
  std::vector<int> p(n);
  for(int i=0;i<n;i++){
    std::cin >> z;
    p.at(i)=z;
  }
  
  std::sort(p.begin(), p.end());

  for(int i=0;i<k;i++){
    d=p.at(i);
    a=a+d;
  }
  std::cout << a;
  return 0;
}

Measured memory_bytes: 3600
program main;
var a,b,c: integer;

begin
readln(a,b,c);

if (a=b) or (b=c) or (a=c) then 
  begin 
  if (a=b) and (b=c) and (a=c) then writeln('No')
  else writeln('Yes');
  end 
else 
  writeln('No');

end.


Measured memory_bytes: 1380
import collections
S = list(map(int, list(input())))
N = len(S)

dp = [0]*N
if N < 4:
    print(0)
    exit(0)

ans = 0

D = [0]*N
D[0] = 1
for i in range(1, N):
    D[i] = D[i-1]*10 % 2019
t = collections.defaultdict(int)
tmp = 0

t[0] += 1
for i in range(N):
    tmp += S[N-1-i]*D[i]
    tmp %= 2019
    t[tmp] += 1

for x in t:
    ans += t[x]*(t[x]-1) // 2

# print(N)
# print(*dp, sep='\n')

print(ans)


Measured memory_bytes: 19468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);

const int N = 2e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
int tc;

int main()
{
    FIO
    int n; cin>>n;
    vector<ll> heights(n);
    for(auto &it : heights)
        cin>>it;
    ll mx = heights[0];
    ll ans = 0;
    for(auto x : heights){
        mx = max(mx, x);
        if(x < mx)
            ans += mx - x;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4752
s[50],j,p,q;
main(i){for(;j=i=atoi(gets(s));printf("%d\n",i)){
for(;i;s[j-i--]=strlen(gets(s+j)));
for(;j;)for(p=i++,q=j=1677207;q>1;j/=16)for(q=j%16;q>2;)q-=s[p++];
}}

Measured memory_bytes: 532
N=int(input())
A,B,C=input(),input(),input(),

ans=0
for i in range(N):
  if A[i]==B[i]==C[i]:
    ans+=0
  elif A[i]!=B[i] and A[i]!=C[i] and B[i]!=C[i]:
    ans+=2
  else:
    ans+=1
  #print(i,ans)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
template<typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int from, int to, T cost) {
        this->from = from;
        this->to = to;
        this->cost = cost;
    }
};
bool operator == (Edge<int> e1, Edge<int> e2) {
    return e1.from == e2.from &&
            e1.to == e2.to &&
            e1.cost == e2.cost;
}
template<typename T>
using Edges = std::vector<Edge<T>>;
template<typename T>
using Graph = std::vector<Edges<T>>;
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i] << " ";
  }
  cout << endl;
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, m; cin >> n >> m;
  vector<vector<int>> g(n);
  for(int i=0;i<m;++i) {
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
  }
  vector<int> ans;
  int mi = INF;
  for(int i=0;i<n;++i) {
    vector<int> dist(n, INF);
    vector<int> prev(n, -1);
    queue<int> que;
    dist[i] = 0;
    que.push(i);
    bool end = false;
    while(!que.empty()) {
      if(end) break;
      int now = que.front(); que.pop();
      for(int j=0;j<(int)(g[now].size());++j) {
        int next = g[now][j];
        if(next == i) {
          vector<int> tmp;
          int pos = now;
          tmp.push_back(pos);
          while(prev[pos] != -1) {
            pos = prev[pos];
            tmp.push_back(pos);
          }
          if(mi > (int)(tmp.size())) {
            mi = tmp.size();
            ans = tmp;
          }
          end = true;
          break;
        } else if(dist[next] == INF) {
          prev[next] = now;
          dist[next] = dist[now] + 1;
          que.push(next);
        }
      }
    }
  }
  if(mi == INF) cout << -1 << endl;
  else {
    cout << mi << endl;
    for(int i=0;i<mi;++i) {
      cout << ans[i]+1 << endl;
    }
  }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<a*b/2;
	if(a*b%2)cout<<".5";
	if(a/2.0==c&&b/2.0==d)
		cout<<' '<<1;
	else
		cout<<' '<<0;
}

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

static int paint(std::string org, char color)
{
    std::string s = org;
    int chg = (s[0] != color) ? 1 : 0;
    s[0] = color;
    for (size_t i = 1; i < s.length(); i++) {
        if (s[i-1] == s[i]) {
            s[i] = (s[i] == '1') ? '0' : '1';
            chg++;
        }
    }
    return chg;
}

int main()
{
    std::string s;
    std::cin >> s;

    std::cout << std::min(paint(s, '0'),  paint(s, '1')) << std::endl;
    return 0;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := readint() // 人数
	A := make([]int, N+1)
	x := make([][]int, N+1)
	y := make([][]int, N+1)
	for i := 1; i <= N; i++ {
		A[i] = readint()
		x[i] = make([]int, N+1)
		y[i] = make([]int, N+1)
		for j := 1; j <= A[i]; j++ {
			x[i][j] = readint()
			y[i][j] = readint()
		}
	}

	ans := 0
	for bits := 1; bits < (1 << uint(N)); bits++ {
		ok := true
		for i := 1; i <= N; i++ {
			if (bits & (1 << uint(i-1))) == 0 {
				continue
			}
			for j := 1; j <= A[i]; j++ {
				shift := uint(max(0, x[i][j]-1))
				if (((bits >> shift) & 1) ^ y[i][j]) == 1 {
					ok = false
				}
			}
		}
		if ok {
			ans = max(ans, counter(bits))
		}
	}
	fmt.Println(ans)
}

func max(x, y int) int {
	if x < y {
		return y
	}
	return x
}

func counter(x int) int {
	if x == 0 {
		return 0
	}
	return (x & 1) + counter(x>>1)
}

const (
	iobufsize = 1 * 1024 * 1024 // 1 MB
)

var stdinsc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, iobufsize), iobufsize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func readint() int {
	stdinsc.Scan()
	v, err := strconv.Atoi(stdinsc.Text())
	if err != nil {
		panic(err)
	}
	return v
}

func readstr() string {
	stdinsc.Scan()
	return stdinsc.Text()
}

func pow(x, y int) int {
	if y == 0 {
		return 1
	}
	return x * pow(x, y-1)
}


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

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N+1);
    rep(i, 1, N+1) cin >> a[i];

    // 累積和
    vector<ll> s(N+1, 0);
    rep(i, 1, N+1) s[i] = a[i] + s[i-1];

    // 部分列列挙
    vector<ll> sub;
    rep(l, 1, N+1){
        rep(r, l, N+1){
            sub.push_back(s[r]-s[l-1]);
        }
    }

    // bitの数をカウント
    ll ans = 0;
    for(ll i = 40; i >= 0; i--){
        ll c = 0;
        for(auto p : sub){
            if((p & (ans+(1LL<<i))) == (ans+(1LL<<i))) c++;
        }
        if(c >= K) ans += (1LL<<i);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6516