akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[30][30],b[30][30],c[30][30];

void init(){
	int i,j;
	for(i=0; i<21; ++i){
		for(j=0; j<21; ++j){
			a[i][j] = (i==j);
		}
	}
	for(i=0; i<21; ++i){
		for(j=0; j<21; ++j){
			b[i][j] = 0ll;
		}
	}
	for(i=0; i<10; ++i){
		b[i][i^1] += 1ll;
	}
	for(i=0; i<8; i+=2){
		for(j=i+3; j<10; j+=2){
			b[i][j] += 1ll;
		}
		b[i][10] += 1ll;
	}
	for(i=8; i<20; i+=2){
		b[i][i+2] += 1ll;
	}
	for(i=10; i<20; ++i){
		b[i][i] += 1ll;
		b[i][i+1] += 1ll;
	}
	b[20][20] += 1ll;
}

void mulmat1(){
	int i,j,k;
	for(i=0; i<21; ++i){
		for(j=0; j<21; ++j){
			for(k=0; k<21; ++k){
				add_mod(c[i][j],a[i][k]*b[k][j]%MOD);
			}
		}
	}
	for(i=0; i<21; ++i){
		for(j=0; j<21; ++j){
			a[i][j] = c[i][j];
			c[i][j] = 0ll;
		}
	}
}

void mulmat2(){
	int i,j,k;
	for(i=0; i<21; ++i){
		for(j=0; j<21; ++j){
			for(k=0; k<21; ++k){
				add_mod(c[i][j],b[i][k]*b[k][j]%MOD);
			}
		}
	}
	for(i=0; i<21; ++i){
		for(j=0; j<21; ++j){
			b[i][j] = c[i][j];
			c[i][j] = 0ll;
		}
	}
}

int main(void){
	int i,j,k,t;
	ll n,ans,tmp;
	std::cin >> t;
	while(t--){
		std::cin >> n; ++n;
		init();
		while(n){
			if(n%2){
				mulmat1();
			}
			mulmat2();
			n /= 2;
		}
		std::cout << a[0][20] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;

int main(){
	int n;
	while( cin >> n , n ){
		vector<P> vc;

		for(int i=0 ; i < n ; i++ ){
			int c,m1,m2,m3,m4,s1,s2,s3,s4;
			cin >> c >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
			int time = m1*60 + s1 + m2*60 + s2 + m3*60 + s3 + m4*60 + s4;
			P p( time , c );
			vc.push_back( p );
		}
		sort( vc.begin() , vc.end() );
		cout << vc[0].second << endl;
		cout << vc[1].second << endl;
		cout << vc[vc.size()-2].second << endl;
	}
}

Measured memory_bytes: 972
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

struct Mod{
  unsigned n;
  Mod() : n(0){}
  Mod( ll x ){
    if( x < 0 ) n = x%MOD+MOD;
    else n = x%MOD;
  }
};
Mod operator + ( Mod a  , Mod b ){ return Mod( a.n + b.n ); }
Mod operator +=( Mod &a , Mod b ){ return a = a + b; }
Mod operator - ( Mod a ){ return Mod( MOD - a.n ); }
Mod operator - ( Mod a  , Mod b ){ return Mod( a.n + MOD - b.n ); }
Mod operator -=( Mod &a , Mod b ){ return a = a - b; }
Mod operator * ( Mod a  , Mod b ){ return Mod( (ll)a.n * b.n ); }
Mod operator *=( Mod &a , Mod b ){ return a = a * b; }
Mod modpow( Mod x , ll k ){
  Mod res = 1;
  while( k ){
    if( k & 1 ) res *= x;
    k /= 2;
    x *= x;
  }
  return res;
}
ll extgcd( ll a , ll b , ll &x , ll &y ){
  ll d = a;
  if( b != 0 ){
    d = extgcd( b , a % b , y , x );
    y -= a / b * x;
  } else {
    x = 1, y = 0;
  }
  return d;
}
Mod inv( Mod a ){ ll x, y; assert( extgcd( a.n , MOD , x , y ) == 1 ); return Mod( x ); }
Mod operator / ( Mod a  , Mod b ){ return Mod( (ll)a.n * inv(b).n ); }
Mod operator /=( Mod &a , Mod b ){ return a = a / b; }

int main(){

  ll n = in();
  ll m = in();
  ll t = in();

  ll p = __gcd(n, t) * __gcd(m, t);
  n /= __gcd(n, t);
  m /= __gcd(m, t);

  Mod q = modpow(2, __gcd(n, m)) - 2 + modpow(2, n) + modpow(2, m) - 1;

  Mod ans = modpow(q, p);

  // cout << n << " " << m << endl;

  cout << ans.n << endl;

  return 0;
}


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

class Main{
    public static void main(String[] args)throws IOException{
        int h, w;

        InputStreamReader isr =new InputStreamReader(System.in);
   		BufferedReader br =new BufferedReader(isr);
    	String buf = br.readLine();
        StringTokenizer st = new StringTokenizer(buf," ");
        h = Integer.parseInt(st.nextToken());
        w = Integer.parseInt(st.nextToken());
        
        while(true) {
        	if (h == 0 && w == 0) break;
        	int i, j;
            for (i = 0;i < h;i++) {
                for (j = 0;j < w;j++) {
                    System.out.printf("#");
                }
                System.out.printf("\n");
    	    }
            System.out.printf("\n");
            buf = br.readLine();
            st = new StringTokenizer(buf," ");
            h = Integer.parseInt(st.nextToken());
            w = Integer.parseInt(st.nextToken());
        }
    }
}

Measured memory_bytes: 62324
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
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;
}

int main(){
    int n;
    cin >> n;
    vector<int>a(n*n);
    vector<pair<int,int> >b;
    rep(i,n){
        int k;
        cin >> k;
        b.push_back(MP(k-1,i+1));
    }
    sort(b.begin(),b.end());
    int id = 0;
    queue<int> q;
    bool ng = 0;
    rep(i,n){
        int c = b[i].second;
        int xid = b[i].first;
        if(a[xid]!=0){
            ng = 1;
            break;
        }
        a[xid] = c;
        rep(k,c-1){
            while(a[id]!=0)id++;
            if(id>=xid)ng = 1;
            a[id] = c;
        }
        rep(k,n-c){
            q.push(c);
        }
    }
    if(ng){
        cout << "No\n";
        return 0;
    }
    while(!q.empty()){
        auto x = q.front();
        q.pop();
        while(a[id]!=0){
            id++;
        }
        a[id] = x;
    }
    vector<int> res(n+1);
    vector<int> cnt(n+1);
    rep(i,n*n){
        cnt[a[i]]++;
        if(cnt[a[i]] == a[i]){
            res[a[i]] = i;
        }
    }
    for(auto x:b){
        if(res[x.second]!=x.first){
            ng = 1;
        }
    }
    if(ng){
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    rep(i,n*n){
        cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2688
n, k, q = map(int, input().split())

menber = [0]*n
if q-k >= 0:
    for i in range(q):
        ans = int(input())
        menber[ans-1] += 1
else:
    menber = [1000000]*n

for j in menber:
    if j > q-k:
        print('Yes')
    else:
        print('No')


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	string s;
	cin >> s;
	set<char> ans;
	for (int i = 0; i < s.size(); i++) {
		ans.insert(s[i]);
	}
	if (ans.size() == 2) cout << "Yes" << "\n";
	else cout << "No" << "\n";
	return 0;
}


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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

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

const int L=1e5+1;
const int inf=1<<29;
vector<int> path[L][10];
int dist[L];
int K;
int main() {
	cin >> K;
	for(int q=0;q<=K;q++){
		dist[q]=inf;
		for(int i=0;i<10;i++){
			int w=q+K*i;
			path[w/10][w%10].push_back(q);
#if 0
			if(i==0&&(q==7||q==79||q==799||q==7999||q==79992)){
				cerr << q << ", " << w/10 << ", " << w%10 << endl;
			}
#endif
		}
	}
	dist[0]=0;
	priority_queue<P,vector<P>,greater<P> > pq;
	pq.push(P(0,0));
	while(pq.size()){
		int s=pq.top().second;
		int d=pq.top().first;
		pq.pop();
		if(d>dist[s]){
			continue;
		}
#if 0
		int q=s;
		if((q==7||q==79||q==799||q==7999||q==79992)){
			cerr << q << endl;
		}
#endif
		for(int i=0;i<10;i++){
			for(auto v:path[s][i]){
#if 0
				if(s==7){
					cerr << v << ", " << dist[v] << ", " << d+i << endl;
				}
#endif
				if(dist[v]>d+i){
					dist[v]=d+i;
					pq.push(P(d+i,v));
				}
			}
		}
	}
	cout << dist[K] << endl;

	return 0;
}



Measured memory_bytes: 57460
A, B, C, D = map(int, input().split())

import fractions
ccount = ((B//C*C)-((A-1)//C*C +C))//C +1
dcount = ((B//D*D)-((A-1)//D*D +D))//D +1
lcm = (C * D) // fractions.gcd(C, D)
cdcount = ((B//lcm*lcm)-((A-1)//lcm*lcm +lcm))//lcm +1
count = B - A + 1 - ccount - dcount + cdcount
print(int(count))

Measured memory_bytes: 5176
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
countA = Counter(A)
ansA = [v*(v-1)//2 for k,v in countA.items()]
sumA = sum(ansA)

for i in range(N):
  t =  countA[A[i]]
  ans = sumA - t*(t-1)//2 + (t-1)*(t-2)//2
  print(ans)

Measured memory_bytes: 26772
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

void Move(int n, char c)
{
    for (int i = 0; i < n; ++i)
    {
        cout << c;
    }
}

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    Move(tx - sx, 'R');
    Move(ty - sy, 'U');
    Move(tx - sx, 'L');
    Move(ty - sy, 'D');
    Move(1, 'D');
    Move(tx - sx + 1, 'R');
    Move(ty - sy + 1, 'U');
    Move(1, 'L');
    Move(1, 'U');
    Move(tx - sx + 1, 'L');
    Move(ty - sy + 1, 'D');
    Move(1, 'R');
    cout << endl;
    return 0;
}


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

public class Main
{
	static long min(long a,long b) {
		if(a<b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static void main (String[] args) throws java.lang.Exception
	{
		
		Scanner cin = new Scanner(System.in);
		long q,h,f,s;
		q = cin.nextLong();
		h = cin.nextLong();
		f = cin.nextLong();
		s = cin.nextLong();
		long n = cin.nextLong();
		long v1 = min(min(q*4,h*2),f);
		if(n%2==0) {
			System.out.println(min(n*v1,s*(n/2)));
		}
		else {
			System.out.println(min(n*v1,(s*(n/2))+v1));
		}
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h> 
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
using namespace std;
signed main() 
{
    fast
    ll x;
    cin>>x;
    ll f=x/500;
    ll h=f*1000;
    x=x-(500*f);
    ll q=x/5;
    h=h+(5*q);
    cout<<h;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
const int MOD = 1000000007;
const int INF = 1e9;
typedef long long ll;


int main(){
    int a,p;
    cin >> a >> p;

    int sum=0;
    sum += 3*a+p;

    cout << sum/2 << endl;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


void Main()
{
    LL n,l,t;cin>>n>>l>>t;
    LL w;
    VVL a(n);
    REP(i,n){
        a[i].resize(3); // p, i, w;
        a[i][1] = i;
        cin>>a[i][0]>>a[i][2];
    }
    w = a[0][2];

    LL col = 0;
    FOR(i,1,n){
        if(w == a[i][2]){
            continue;
        }
        LL diff;
        if(w == 1){
            diff = a[i][0] - a[0][0];
        }
        else{
            diff = a[0][0] + l-a[i][0];
        }
        col += (t*2)/l;
        if(diff <= (t*2)%l){
            col++;
        }
        col%=n;
    }
    

    REP(i,n){
        if(a[i][2] == 1){
            a[i][0] += t;
        }
        else{
            a[i][0] -= t;
        }
        a[i][0] = ((a[i][0]%l)+l)%l;
    }

    SORT_ASC(a);

    LL point = 0;
    REP(i,n){
        if(a[i][1] == 0){
            if(w==1 && i!=n-1 && a[i][0] == a[i+1][0]){
                point = (i+1)%n;
            }
            else{
                point = i;
            }
            break;
        }
    }
    if(w == 1){
        point -= col;
    }
    else{
        point += col;
    }
    point = (point+n)%n;

    REP(i,n){
        cout<<a[(i+point)%n][0]<<endl;
    }





	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 6656
#include<stdio.h>
#include<stack>
using namespace std;
int tu[1000][1000];
int a[10000];
int an[10000];
int d[10000];
int f[10000];
int shijian,n;
int next(int q){
for(int i=an[q];i<n;i++){
    an[q]=i+1;
    if(tu[q][i])return i;
}
return -1;
}
void sou(int u){
     stack<int > s;
     s.push(u);
     a[u]=2;
     d[u]=++shijian;
     while(!s.empty()){
        int x=s.top();
        int v=next(x);
        if(v!=-1){
            if(a[v]==1){
                a[v]=2;
                d[v]=++shijian;
                s.push(v);
            }
        }
        else {
            s.pop();
            a[x]=3;
            f[x]=++shijian;
        }
     }
}
void shensou(){
     for(int u=0;u<n;u++){
        a[u]=1;
        an[u]=0;
     }
     shijian=0;
     for(int u=0;u<n;u++){
        if(a[u]==1)sou(u);
     }
     for(int u=0;u<n;u++){
         printf("%d %d %d\n",u+1,d[u],f[u]);
     }
}


int main(){
   int v;
   int m;
   int x;
   scanf("%d",&n);
   for(int i=0;i<n;i++){
        scanf("%d%d",&v,&m);
        v--;
        for(int j=0;j<m;j++){
            scanf("%d",&x);
            x--;
            tu[v][x]=1;
        }
   }
   shensou();
return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll a, b;
  cin >> a >> b;
  ll ans = -1;
  rep(i, 1, 10000000){
    if(i * 0.08 >= a && i * 0.08 < a + 1 && i * 0.1 >= b && i * 0.1 < b + 1){
      ans = i;
      break;
    }  
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll a[100002];
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i];
    }
    for (int i = 0; i < n-1; ++i)
    {
    	if(a[i]<=0 && a[i+1]<=0)
    	{
    		// cout<<i<<'\n';
    		a[i]=-a[i];
    		a[i+1]=-a[i+1];
    	}
    }
    ll cou=0;
    for (int i = 0; i < n; ++i)
    {
    	if(a[i]<0)
    	{
    		cou++;
    		a[i]=-a[i];
    	}
    }

    // cout<<cou<<'\n';
    sort(a,a+n);
    ll ans=0;
    if(cou%2==0)
    {
    	for (int i = 0; i < n; ++i)
    	{
    		ans+=a[i];
    	}
    }
    else
    {
    	ans=-a[0];
    	for (int i = 1; i < n; ++i)
    	{
    		ans+=a[i];
    	}
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 1024
n, k, d = list(map(int, input().split()))

val = n % d

left = 0
if n >= 0:
	if n - (k * d) < 0:
		left = k - ((n - val)/d)
		if left % 2 == 0:
			print(val)
		else:
			print(abs(val - d))
	else:
		print(abs(n - (k * d)))
else:
	if n + (k * d) > 0:
		left = k - ((val - n)/d)
		if left % 2 == 0:
			print(val)
		else:
			print(abs(val - d))
	else:
		print(abs(n + (k*d)))

Measured memory_bytes: 9224
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int h=scanner.nextInt();
		int w=scanner.nextInt();
	
		String gr[][]=new String[h][w];
		for(int i=0;i<h;i++){
			gr[i]=scanner.next().split("");
		}
		
		boolean dotH[]=new boolean [h];
		boolean dotW[]=new boolean [w];
		for(int i=0;i<h;i++){
			if(gr[i][0].equals(".")){
				for(int j=1;j<w;j++){
					if(gr[i][j].equals("."))dotH[i]=true;
					else{
						dotH[i]=false;
						break;
					}
				}
			}
		}
		for(int i=0;i<w;i++){
			if(gr[0][i].equals(".")){
				for(int j=1;j<h;j++){
					if(gr[j][i].equals("."))dotW[i]=true;
					else{
						dotW[i]=false;
						break;
					}
				}
			}
		}
		
		for(int i=0;i<h;i++){
			if(dotH[i])continue;
			for(int j=0;j<w;j++){
				if(dotW[j])continue;
				System.out.print(gr[i][j]);
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 26844
#include<stdio.h>
int main()
{
    int h,w;
    scanf("%d%d",&h,&w);
    int i,j;
    while(h!=0||w!=0)
    {
        for(i=0;i<h;i++)
        {
            if(i==0||i==h-1) for(j=0;j<w;j++) printf("#");
            else
            {
                printf("#");
                for(j=0;j<w-2;j++) printf(".");
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
        scanf("%d%d",&h,&w);
    }
    return 0;
}



Measured memory_bytes: 2040
#define _USE_MATH_DEFINES

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

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

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

int main(){
	
	int n;
	cin >> n;
	
	int ans = 0;
	for(int i = 0; i < n; i++){
		int num;
		cin >> num;
		bool flag = true;
		for(int j = 2; j * j <= num; j++){
			if(num % j == 0){
				flag = false;
				break;
			}
		}
		if(flag){
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main()
{
    int ans = 0;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); ++i) if(s[i] == '1') ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp make_pair
#ifdef LOCAL
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define check(...) assert(__VA_ARGS__)
#else
#define debug(fmt, ...)
#define check(...)
#endif

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

    int a, b;
    cin >> a >> b;
    int ans = -1;
    rep(x, 1, 1252) {
        if ((int)(x * 0.08) == a && (int)(x * 0.1) == b) {
            ans = x;
            break;
        }
    }
    cout << ans;
    // cout << a / 0.08 << ' ' << b / 0.10 << el;
    // cout << 25 * 0.08 << ' ' << (int) (25 * 0.10) << el;
    // cout << 20 * 0.08 << ' ' << (int) (20 * 0.10) << el;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  VI a(3);
  REP(i,3)cin >> a[i];
  sort(ALL(a));
  cout << a[2]-a[0] << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  for (int i : irange(0, n, 2))  {
    cout << s[i];
  }
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int L=scan.nextInt();
        int R=scan.nextInt();
        int d=scan.nextInt();
int S1=(int)(L-1)/d;
        int S2=(int)R/d;
        int p=S2-S1;
        System.out.println(p);



    }
}


Measured memory_bytes: 26912
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

ll dp[4001][4001];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n=s.size();
	vl r(2*n+1),b(2*n+1);
	rep(i,n){
		r[i+1]=r[i]+2-(s[i]-'0');
		b[i+1]=b[i]+(s[i]-'0');
	}
	rep(i,n){
		r[n+i+1]=r[n+i];
		b[n+i+1]=b[n+i];
	}
	dp[0][0]=1;
	rep(i,2*n){
		rep(j,i+1){
			int k=i-j;
			//puta(j,k);
			if(j<b[i+1]){
				dp[j+1][k]+=dp[j][k];
				dp[j+1][k]%=998244353;
			}
			if(k<r[i+1]){
				dp[j][k+1]+=dp[j][k];
				dp[j][k+1]%=998244353;
			}

		}
	}
	cout<<dp[b[n]][r[n]]<<endl;
}

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

typedef long long int64;
typedef std::complex<double> C;

const int N = 4e5, MOD = 2e5 + 3, G = 2;
const double PI = acos(-1);

int n;
int64 cnt[N + 5];
std::unordered_map<int, int> map;

inline int power(int x, int k, int mod) {
	int ans = 1;
	for (; k > 0; k >>= 1, x = (int64)x * x % mod) {
		if (k & 1) {
			ans = (int64)ans * x % mod;
		}
	}
	return ans;
}
inline int inv(int x, int mod) {
	return pow(x, mod - 2);
}
void fft(C *a, int k, bool opt) {
	int n = 1 << k;
	std::vector<int> rev(n);
	for (int i = 0; i < n; i++) {
		rev[i] = rev[i >> 1] >> 1 | (i & 1) << (k - 1);
		if (i < rev[i]) {
			std::swap(a[i], a[rev[i]]);
		}
	}
	for (int l = 1; l < n; l <<= 1) {
		C w = C(cos(PI / l), sin(PI / l));
		for (int i = 0; i < n; i += l << 1) {
			C wk = C(1, 0);
			for (int j = 0; j < l; j++, wk *= w) {
				C x = a[i + j + l] * wk;
				a[i + j + l] = a[i + j] - x;
				a[i + j] += x;
			}
		}
	}
	if (opt) {
		std::reverse(a + 1, a + n);
		for (int i = 0; i < n; i++) {
			a[i] /= n;
		}
	}
}
void dft(C *a, int k) {
	fft(a, k, false);
}
void idft(C *a, int k) {
	fft(a, k, true);
}
void selfMul(int64 *a) {
	static C b[1 << 19];
	int k = 19, n = 1 << k;
	std::fill(b, b + n, C(0, 0));
	for (int i = 0; i < MOD; i++) {
		b[i] = C(a[i], 0);
	}
	dft(b, k);
	for (int i = 0; i < n; i++) {
		b[i] *= b[i];
	}
	idft(b, k);
	for (int i = 0; i < MOD * 2; i++) {
		a[i] = (int64)(b[i].real() + 0.5);
	}
}
int main() {
	scanf("%d", &n);
	for (int w = 1, i = 0; i < MOD; i++, w = (int64)w * G % MOD) {
		map[w] = i;
	}
	int64 ans = 0;
	for (int x, i = 1; i <= n; i++) {
		scanf("%d", &x);
		if (x > 0) {
			ans -= (int64)x * x % MOD;
			cnt[map[x]]++;
		}
	}
	selfMul(cnt);
	for (int w = 1, i = 0; i < MOD * 2; i++, w = (int64)w * G % MOD) {
		ans += cnt[i] * w;
	}
	printf("%lld\n", ans / 2);
	return 0;
}

Measured memory_bytes: 25296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

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

int main() {
    int N, X, a;
    cin >> N >> X;
    vector<int> V(N+1);
    V[0] = X;
    vector<int> D;
    for(int i=1; i<N+1; i++) cin >> V[i];

    for(int i=0; i<N; i++) {
        a = abs(V[i]-V[i+1]);
        D.push_back(a);
    }
    if(D.size() == 1) {
        cout << D[0] << endl;
        return 0;
    }

    int Z = gcd(D[0], D[1]);

    for(int i=2; i<D.size(); i++) {
        Z = gcd(Z, D[i]);
    }
    cout << Z << endl;
}

Measured memory_bytes: 4300
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	auto count = 0;
	for (auto i = 1; i < S.length(); ++i)
	{
		if (S[i] != S[i - 1])
		{
			++count;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;

LL inf = 1000000000000;
LL mod = 1000000007;

int main()
{
	string s;
	cin >> s;
	bool ans = true;
	map<LL, char> m;
	m[0] = 'h', m[1] = 'i';
	for (LL i = 0; i < s.size(); ++i ) {
		if (s[i] == m[i%2]) {

		}
		else {
			ans = false;
			break;
		}
	}

	if (ans && s.size()%2 == 0) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int M[2], D[2];
    for(int i=0;i<2;i++)
        cin >> M[i] >> D[i];

    if(M[0] != M[1])
        cout << 1 << endl;
    else
        cout << 0 << endl;

}

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

using namespace std;


 
int main() {
    int n=55555;
    vector<int>vec;
    vector<char> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
    if (is_prime[i] && (long long)i * i <= n) {
        for (int j = i * i; j <= n; j += i)
            is_prime[j] = false;
    }
    }
    for(int i=1;i<55555;++i)
    {
        if(is_prime[i]&&i%5==1)
        vec.push_back(i);
    }
    int q;
    cin>>q;
    for(int i=0;i<q;++i)
    cout<<vec[i]<<" ";

	
	return 0;
}	


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.lang.StringBuilder
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    for (i in 0 until 100000) {
        if ((i * 0.08).toInt() == a && (i * 0.1).toInt() == b) {
            println(i)
            return
        }
    }
    println(-1)
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 31260
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;

    map<char,int> mp;
    mp['r']=p;
    mp['s']=r;
    mp['p']=s;
    int ans=0;
    for(int i=0; i<n; ++i){
        ans += mp[t[i]];
        if(i+k<n && t[i]==t[i+k]) t[i+k]='x';
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[200001];
  for(int i=0;i<n;i++)
    cin>>a[i];
  long long ans=0;
  int go=0;
  long long cnt=0;
  for(int i=0;i<n;i++){
    while(go<n && (cnt&a[go])==0){
      cnt|=a[go];
      go++;}
      ans+=go-i;
      cnt^=a[i];}
  cout<<ans;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long d, n;
    cin >> d >> n;
    long long ans = 1;
    for (int i = 0; i < d; i++) {
        ans *= 100;
    }
    if (n == 100) {
        cout << ans * 101 << endl;
    } else {
        cout << ans * n << endl;
    }
    return 0;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sb_sum = 0
for i in range(n):
	s = a[i]
	sb = b[s-1]
	sb_sum += sb
	if i >=1:
		if a[i]-a[i-1]==1:
			sb_sum += c[s-2]
print(sb_sum)    

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
void Merge(int L[],int R[],int A[],int N);
void merge_sort(int A[],int N);

int main()
{
    int X,Y,A,B,C;
    int i,j=0;
    long long MAX=0;
    cin >> X >> Y >> A >> B >> C;

    int red[A];
    int green[B];
    int Colorless[C];

    int largest[X+Y+C]; /*contain the largest X numbers in red[], largest
                        Y numbers in green[] and all numbers in colorless[]*/

    for(i=0;i<A;i++) cin >> red[i];
    for(i=0;i<B;i++) cin >> green[i];
    for(i=0;i<C;i++) cin >> Colorless[i];

    merge_sort(red,A);
    merge_sort(green,B);
    merge_sort(Colorless,C);

    /*load the largest[] with X numbers in red[], largest
    Y numbers in green[] and all numbers in colorless[]*/
    for(i=0;i<X;i++)
    {
        largest[j]=red[A-1];
        A--;
        j++;
    }

    for(i=0;i<Y;i++)
    {
        largest[j]=green[B-1];
        B--;
        j++;
    }

    for(i=0;i<C;i++)
    {
        largest[j]=Colorless[i];
        j++;
    }

    //sort it
    merge_sort(largest, j);

    /* sum of the (X+Y) largest numbers */
    for(i=0;i<X+Y;i++)
    {
        MAX+=largest[j-1];
        j--;
    }

    cout << MAX<<endl;

    return 0;
}

void merge_sort(int A[],int N)
{
    if(N==1) return;
    int I=N/2;
    int J=(N+1)/2;
    int L[I];
    int R[J];
    int i,j,k=0;

    for(i=0;i<I;i++)
    {
        L[i]=A[k];

        k++;
    }


    for(j=0;j<J;j++)
    {
        R[j]=A[k];

        k++;
    }

    merge_sort(L,sizeof(L)/4);
    merge_sort(R,sizeof(R)/4);
    Merge(L,R,A,N);
}

void Merge(int L[],int R[],int A[],int N)
{
    int Size=N;
    int i=0,j=0,k;
    for(k=0;k<Size;k++)
    {
        if(j==((Size+1)/2))
        {
            A[k]=L[i];
            i++;
            continue;
        }
        if(i==Size/2)
        {
            A[k]=R[j];
            j++;
            continue;
        }
        if(L[i]<=R[j])
        {
            A[k]=L[i];
            i++;
        }
        else
        {
            A[k]=R[j];
            j++;
        }

    }
}


Measured memory_bytes: 8084
N = int(input())
list_ai = map(int,input().split())
list1 = [pow(2,i) for i in range(1,35)]
count1 =0
for elem in list_ai:
  for x in list1:
    if elem % x ==0:
      count1 +=1
    else:
      break

print(count1)


Measured memory_bytes: 40560
import sys
S = input()

if S[0] != 'A':
    print('WA')
    sys.exit()

ccnt = 0
for i in range(2,len(S)-1):
    if S[i] == 'C':
        ccnt += 1
if ccnt != 1:
    print('WA')
    sys.exit()

csml = 0
for i in range(len(S)):
    if S[i].isalpha() and S[i].islower():
        csml += 1
if csml == len(S)-2:
    print('AC')
else:
    print('WA')


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

using namespace std;


int main()
{
  int64_t N;

  cin >> N;

  vector<int64_t> a;
  a.resize(N);
  vector<int64_t> b;
  b.resize(log2(1000000000) + 1, 0);

  for(int64_t i = 0;
      i < N;
      ++i)
    {
      cin >> a[i];
      int64_t k = a[i];
      for(int64_t j = 0;
          k != 0;
          ++j)
        {
          b[j] += (k & 1);
          k = (k >> 1);
        }
    }

  for(int64_t i = 0;
      i < b.size();
      ++i)
    {
      if(b[i] % 2 == 1)
        {
          cout << "No" << endl;
          return 0;
        }
    }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 1024
import collections, copy

h, w = map(int, input().split())
maze = []
maze.append("#" * (w + 2))
for i in range(h):
    maze.append("#" + input() + "#")
maze.append("#" * (w + 2))
dis = []
for i in range(h + 2):
    temp = [-1] * (w + 2)
    dis.append(temp)

def search(x, y):
    dis2 = copy.deepcopy(dis)
    move = [[-1, 0], [1, 0], [0, 1], [0, -1]]
    queue = collections.deque([[x, y]])
    dis2[x][y] = 0
    while queue:
        test = queue.popleft()
        for i in move:
            place = [test[0] + i[0], test[1] + i[1]]
            if maze[place[0]][place[1]] == ".":
                if dis2[place[0]][place[1]] == -1:
                    dis2[place[0]][place[1]] = dis2[test[0]][test[1]] + 1
                    queue.append(place)
    return max([max([dis2[i][j] for j in range(w + 2)]) for i in range(h + 2)])

ans = 0
for i in range(h):
    for j in range(w):
        if maze[i + 1][j + 1] == ".":
            dist = search(i + 1, j + 1)
            ans = max(ans, dist)
print(ans)

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

int cmpnum(const void * n1, const void * n2) {
	if (*(long *)n1 > *(long *)n2)
	{
		return -1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  qsort(a, n, sizeof(long), cmpnum);
  long start = 0;
  long end = a[0]*2+1;
  long center;
  long count,cur;
  while (start+1 != end) {
    center = (start+end)/2;
    count = 0;
    cur = n-1;
    for (long i = 0; i < n; i++) {
      if (a[i]+a[0] < center) {
        break;
      }
      for (long j = cur; j >= 0; j--) {
        if (a[i]+a[j] >= center) {
          count += j+1;
          cur = j;
          break;
        }
      }
    }
    if (count >= m) {
      start = center;
    } else {
      end = center;
    }
  }
  long limit = start;
  long sum[n];
  sum[0] = a[0];
  for (long i = 1; i < n; i++) {
    sum[i] = sum[i-1]+a[i];
  }
  long happiness = 0;
  count = 0;
  cur = n-1;
  for (long i = 0; i < n; i++) {
    if (a[i]+a[0] <= limit) {
      break;
    }
    for (long j = cur; j >= 0; j--) {
      if (a[i]+a[j] > limit) {
        happiness += a[i]*(j+1)+sum[j];
        count += j+1;
        cur = j;
        break;
      }
    }
  }
  happiness += limit*(m-count);
  printf("%ld\n", happiness);

  return 0;
}

Measured memory_bytes: 1788
s=[]
(1..gets.to_i).each do |i|
  x=i
  if x%3 == 0
    s << i
  else
    while x!=0
      if x%10 == 3
        s << i
        break
      else
        x = (x/10).to_i
      end
    end
  end
end
puts " "+s.join(" ")

Measured memory_bytes: 6172
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
string s;
ll n,i,a[101010],te,SZ;
vector<ll> isi;
char ct;
void dfs(ll aa,ll bb,ll cc)
{
    if(cc==SZ)
        return ;
    te++;
    cout<<aa<<" "<<te<<"\n";
    dfs(te,isi[cc],cc+1);
    ll ii;
    for(ii=1;ii<(bb-isi[cc]);ii++)
    {
        te++;
        cout<<aa<<" "<<te<<"\n";
    }
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>s;
    n=s.length();
    for(i=0;i<n;i++)
    {
        ct=s[i];
        if(ct=='1')a[i+1]=1;
    }
    if(a[1]==0||a[n]==1)
    {
        cout<<-1<<"\n";
        return 0;
    }
    for(i=1;i<=n;i++)
        if(a[i]==1&&a[n-i]==0)
        {
            cout<<-1<<"\n";
            return 0;
        }
    for(i=n;i>=1;i--)
        if(a[i]==1)
            isi.pb(i);
    SZ=isi.size();
    te=1;
    dfs(1,n,0);
}


Measured memory_bytes: 9412
module Main where

import Data.Functor

main :: IO ()
main =  do
 { [h,w] <- getInts
 ; if h == 0 && w == 0 then done
   else putStrLn (unlines (frame h w)) >> main
 }


frame :: Int -> Int -> [String]
frame h w = tb : (cylindre ++ [tb])
  where
    tb = replicate w '#'
    cy = '#':(bd ++ "#")
    bd = replicate (w-2) '.'
    cylindre = replicate (h-2) cy 

done :: IO ()
done = return ()

getInts :: IO [Int]
getInts = map read . words <$> getLine

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
}

Node treeMaximum(Node x){
}

Node treeSearch(Node u, int k){
}

Node treeSuccessor(Node x){
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x=x->left;
    else
      x=x->right;
  }
  z->parent=y;
  

  if(y==NIL)
    root=z;
  else if(z->key < y->key)
    y->left = z;
  else
    y->right = z;

}

void inorder(Node u){
  if(u==NIL)
    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
  if(u==NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 24040
//2?????¢?´¢????????£????§£????????????????????????????????§??????
#include<cstdio>
#include<iostream>

using namespace std;

int gcd(int m, int n)
{
	if ((0 == m) || (0 == n))
		return 1;
	while (m != n)
	{
		if (m > n) m = m - n;
		else         n = n - m;
	}
	return m;
}




int main(void) {

	while (1) {

		int floor, n, book[1000] = { 0 };
		cin >> floor >> n;

		if (floor == 0)return 0;

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

		//?????§??¬?´???°????±???????
		int m = book[0];
		int w_avr = book[0];
		for (int i = 1; i < n; i++) {
			m = gcd(m, book[i]);
			w_avr += book[i];
		}
		//?????????????????§?????¬??????????????????????????°??§?????£?????°??????????????¬????????§?????????
		int ans = w_avr / floor;

		for (int i = 0; i < n; i++) {
			if (ans < book[i]) {
				ans = book[i];
			}
		}
		while (ans%m != 0) {
			ans=ans-1;
		}
		while (1) {
			int count = floor;
			int length = ans;
			int i = 0;
			while (count != 0 && i < n) {
				if (length >= book[i]) {
					length -= book[i];
					i++;
				}
				else {
					length = ans;
					count = count - 1;
				}
			}
			if (count != 0) {
				break;
			}
			ans += m;
		}
		cout << ans << endl;

	}
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <iterator>

using namespace std;

int main(){
    int N, R, ans;
    cin  >> N >> R;

    if( N >=10 ){
        ans = R;
    }else{
        ans = 100 * (10 - N) + R;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main() {
int K;
string S;
cin >> K >> S;
if( S.size() <= K ){
  cout << S << endl;
}
else{
  S = S.erase(K);
  S = S + "...";
  cout << S << endl;
}
}


Measured memory_bytes: 3600
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
	
#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n, u;
	while (scanf("%d%d", &n, &u), n | u)
	{
		int c[32], r[32];
		for (int i = 0; i < n; ++i)
		{
			int k;
			scanf("%d%d", c + i, &k);
			r[i] = 0;
			while (k--)
			{
				int t;
				scanf("%d", &t);
				r[i] |= 1 << t;
			}
		}
		if (u == 0)
		{
			puts("0");
			continue;
		}

		int res = n;
		for (int bits = 1; bits < n; ++bits)
		{
			int i = (1 << bits) - 1;
			do
			{
				bool ok = true;
				int s = 0;
				for (int j = 0; j < n; ++j)
				{
					if (i >> j & 1)
					{
						if ((i & r[j]) != r[j])
						{
							ok = false;
							break;
						}
						else
							s += c[j];
					}
				}
				if (ok)
				{
					//int s = 0;
					//for (int j = 0; j < n; ++j)
					//	if (i >> j & 1)
					//		s += c[j];
					if (s >= u)
					{
						res = bits;
						goto end;
					}
				}

				// combination
				int leastBit = i & -i;
				int mostBits = i + leastBit;
				int leastSequentialBits = i & ~mostBits;
				i = mostBits | ((leastSequentialBits / leastBit) >> 1);
			} while (i < 1 << n);
		}
end:
		printf("%d\n", res);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define T int t;cin>>t;while(t--)
#define f(i,n) for (int i=0;i<n;i++)
#define fa(i,a,b) for (int i=a;i<b;i++)
#define b(i,a,b) for (int i=a;i>=b;i--)
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define fi first    
#define se second
#define SZ(x) ((int)(x).size())
#define debug(x) cout<<'>'<<#x<<" = "<<x<<endl;
#define MOD 1000000007
#define ce cout<<"\n"
int main()
{
    int n, m, i, j, a1=0, a2=0;
    cin>>n>>m;
    int hsh1[n+1] = {0}, hsh2[n+1] = {0};
    f(i, m)
    {
        string s;
        cin>>j>>s;
        if(s == "AC")
            hsh2[j] = 1;
        else if(!hsh2[j])
        {
            hsh1[j]++;
        }
    }
    for(i=1; i<=n; i++)
    {
        if(hsh2[i] == 1){
            a1+=hsh2[i];
            a2+=hsh1[i];
        }
    }
    cout<<a1<<" "<<a2<<'\n';

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,counter;counter=0;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int k=1;k<=n;k++)
    {
        while(a[k]%2==0)
        {
            a[k]=a[k]/2;
            counter++;
        }
    }
    cout<<counter<<endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = list(map(lambda x : (x + 1) / 2, P))
cur = sum(P[0 : K])
ans = cur

for i in range(K, N):
	cur -= P[i - K]
	cur += P[i]
	ans = max(ans, cur)
	
print(ans)

Measured memory_bytes: 77320