akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define nl printf("\n")
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
using namespace std;
int main(){
    string a,b;
    cin>>a;
    cin>>b;
    int al=a.length();
    int bl=b.length();
    int dp[al+1][bl+1];
    for(int i=0;i<=al;i++) dp[i][0]=0;
    for(int i=0;i<=bl;i++) dp[0][i]=0;

    for(int i=1;i<=al;i++){
        for(int j=1;j<=bl;j++){
            if(a[i-1]==b[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    string s;
    int i=al;
    int j=bl;
    while(i>0&&j>0){
        if(dp[i][j]==dp[i-1][j]) i--;
        else if(dp[i][j]==dp[i][j-1]) j--;
        else if(dp[i][j]==dp[i-1][j-1]){
            i--; j--;
        }
        else{
            s.pb(a[i-1]);
            i--; j--;
        }
    }
    reverse(s.begin(),s.end());
    cout<<s;
    nl;
}


Measured memory_bytes: 38816
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a(3),b(3),c(3);
  cin>>a[0]>>a[1]>>a[2]>>b[0]>>b[1]>>b[2]>>c[0]>>c[1]>>c[2];
  int p=a[1]-a[0],q=a[2]-a[1],j=0;
  if (b[1]-b[0]!=p||b[2]-b[1]!=q||c[1]-c[0]!=p||c[2]-c[1]!=q) j=1;
  if (j==1) cout<<"No";
  else cout<<"Yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Endl '\n'
typedef long long int lli;
void solve();
signed main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  solve();
}
void solve(){
  lli A, B, N;
  cin>>A>>B>>N;
  lli x = min(N, B-1);
  cout<<((A*x)/B) - A*(x/B)<<Endl;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        string left = s.substr(0, i);
        for (int j = 0; j < n - i; j++) {
            string res = left + s.substr(i + j);
            if ("keyence" == res) {
                puts("YES");
                return 0;
            }
        }
    }
    puts("NO");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;


void solve(){

    string a;
    cin >> a;
    ll mp[30];
    rep(i,30){
        mp[i]=0;
    }
    rep(i,a.size()){
        mp[a[i]-'a']++;
    }

    ll n = a.size();
    ll ans = n*(n-1)/2+1;
    rep(i,30){
        ll t = mp[i];
        ans -= (t*(t-1)/2);
    }

    cout << ans << endl;

}

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


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

int main() {
	int a, b;
	char s[10];
	cin >> a >> b >> s;
	string ans = "Yes";
	for (int i;i < a;i++) {
		if (s[i] == '-' ) {
			ans = "No";break;
		}
	}
	if (ans == "Yes") {
		for (int i = a + 1;i < a + b + 1;i++) {
			if (s[i] == '-') {
				ans = "No";break;
			}
		}
	}
	if (s[a] != '-')ans = "No";
	cout << ans << endl;
}

Measured memory_bytes: 256
N,M,C=map(int, input().split())
B=list(map(int,input().split()))
count=0
for i in range(N):
    A=list(map(int, input().split()))
    p=C
    for j in range(M):p+=A[j]*B[j]
    if p>0:count+=1
print(count)



Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

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

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    cin >> h >> w;
    int n_sharp = 0;
    vector<vector<char>> c(h + 2, vector<char>(w + 2));
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> c.at(i).at(j);
            if (c.at(i).at(j) == '#') n_sharp++;
        }
    }
    
    vector<vector<int>> a(h + 2, vector<int>(w + 2, -1));
    a.at(1).at(1) = 0;
    queue<vector<int>> q;
    q.push({1, 1});
    while (q.size()) {
        int x = q.front().at(0), y = q.front().at(1);
        if (x == h && y == w) break;
        q.pop();
        for (int j = 0; j < 4; j++) {
            if (c.at(x + dx[j]).at(y + dy[j]) == '.' && a.at(x + dx[j]).at(y + dy[j]) == -1) {
                a.at(x + dx[j]).at(y + dy[j]) = a.at(x).at(y) + 1;
                q.push({x + dx[j], y + dy[j]});
            }
        }
    }
    int n_min_step = a.at(h).at(w);
    
    if (a.at(h).at(w) == -1) cout << -1 << endl;
    else cout << h * w - n_sharp - (n_min_step + 1) << endl;
    
    return 0;
}


Measured memory_bytes: 256
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005
ll par[100005];
ll find_set(ll v) {
    if (v == par[v])
        return v;
    return par[v] = find_set(par[v]);
}
void make_set(ll v) {
    par[v] = v;
}

void union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (a>b)
            swap(a, b);
        par[b] = a;
    }
}
int main()
{
	ios
	ll n,m,i,j,x,y,ans=0,cnt=0;
	cin>>n>>m;
	vector<pii>s;
	s.pb({hell,hell});
	for(i=1;i<=n;i++){
		cin>>x>>y;
		s.push_back({y,x});
	}
	sort(all(s));
	reverse(all(s));
	for(i=0;i<=m;i++){
		make_set(i);
	}
	for(i=1;i<=n;i++){
		ll nxt=m-s[i].S+1;
		if(nxt<=0)continue;
		ll ff=find_set(nxt);
		if(ff>0){
			ans+=s[i].F;
			union_sets(ff,ff-1);

			union_sets(nxt,ff-1);
			cnt++;
			if(cnt>=m){
				break;
			}
		}
	}
	cout<<ans;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> res, b(n);
    for (int i = 0; i < n; i++) cin >> b[i];
    while (b.size() > 0) {
        int f = -1;
        for (int i = 0; i < b.size(); i++) {
            if (b[i] == i + 1) f = i;
        }
        if (f == -1) {
            cout << -1 << endl;
            return 0;
        }
        res.push_back(f + 1);
        b.erase(b.begin() + f);
    }
    reverse(res.begin(), res.end());
    for (int i = 0; i < n; i++) {
        cout << res[i] << endl;
    }
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int>d(N);
    for (int i = 0; i < N; ++i) {
        cin >> d[i];
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <map>
#include <algorithm>
using namespace std;

int main() {
	long int N, L; cin >> N >> L;
	vector<int> S(N);
	long int max = 0, min = 100;
	for (int i = 1; i <= N; i++) {
		S.at(i - 1) = L + i - 1;
		max += S.at(i - 1);
		if (min > abs(S.at(i - 1))) min = abs(S.at(i - 1));
	}
	if (max < 0) cout << max + min << endl;
	else  cout << max - min << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int *array;
 
int fibonachi(int);
 
int main(){
  int n;
  int i;
  int answer;
 
  scanf("%d",&n);
  array = malloc((n+1) * sizeof(int));
 
  for(i=0;i<n+1;i++) array[i] = -1;
 
  answer = fibonachi(n);
 
  printf("%d\n",answer);
 
  free(array);
  return 0;
}
 
int fibonachi(int n){
  if(n == 0 || n == 1){
    array[n] = 1;
    return array[n];
  }
 
  if(array[n] != -1) return array[n];
 
  array[n] = fibonachi(n-2) +  fibonachi(n-1);
 
  return array[n];
}

Measured memory_bytes: 596
/*
*Bismillahir Rahmanir Rahmin
* @Author: {{Syed Yasir Shahriar
{
/*//*\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\*/
 
//أعوذ بالله من الشيطان الرجيم
//بسم الله الرحمن الرحيم
 
/*//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\*/
 
/*};/* @Date:   {{create_time}}typedef int MyCustomType;
* @Last Modified by:   mrinm
* @Last Modified time: 2020-07-05 18:17:46
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define v vector<ll>
#define st stack<ll>
#define pq  priority_queue <int>
#define q queue<ll>
#define mod 1000000005
using namespace std;
 
/* int solve(int arr[],int n){

 	   int res=0;
 	   for (int i =0; i<= n - 1; i++) { 
        int val = 0; 
        for (int j =i; j<= n - 1; j++) { 
            val = val + arr[j]; 
            if (val % 2 != 0) 
                res++; 
        } 
    } 
 	   return (res);
 }*/
 
int main(){
 /*    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/
     //ios::sync_with_stdio(0);
	 int n;
	 cin>>n;
	 string s;
	 int cnt=0,cnt1=0,cnt2=0,cnt3=0;
	 while(n--){
         cin>>s;
         if(s=="AC"){
         	cnt++;
         }
         if(s=="WA"){
         	cnt1++;
         }
         if(s=="TLE"){
         	cnt2++;
         }
         if(s=="RE"){
         	cnt3++;
         }

         
	 }
	 
	 cout<<"AC "<<"x "<<cnt<<endl;
	  cout<<"WA "<<"x "<<cnt1<<endl;
	   cout<<"TLE "<<"x "<<cnt2<<endl;
	    cout<<"RE "<<"x "<<cnt3<<endl;

     return 0;
}

Measured memory_bytes: 3624
//E knapsack approach 1
#include<bits/stdc++.h>
#define int long long
using namespace std;
class event{
public:
  int wt,val;  
};
int32_t main(){
    int n,w;
    cin>>n>>w;
    event arr[n+1];
    for(int i=1;i<=n;i++){
        cin>>arr[i].wt;
        cin>>arr[i].val;
    }
    int maxval=1000*n;
    int dp[n+1][maxval+1];
    memset(dp,INT_MAX,sizeof dp);
    for(int val=0;val<=maxval;val++){
        dp[1][val]=INT_MAX;
    }
    dp[1][0]=0;
    dp[1][arr[1].val]=arr[1].wt;
    for(int i=2;i<=n;i++){
        for(int j=1;j<=maxval;j++){
            dp[i][j]=dp[i-1][j];
            if(arr[i].val<=j){
                dp[i][j]=min(dp[i][j],arr[i].wt+dp[i-1][j-arr[i].val]);
            }
        }
    }
    int ans=0;
    for(int x=0;x<=maxval;x++){
        if(dp[n][x]<=w){
            ans=x;
        }
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define ll          long long
#define dl          double
#define pb          push_back
#define eb          emplace_back
#define mp          make_pair
#define F           first
#define S           second
#define rep(i,a,b)  for(i=a;i<b;i++)
#define all(v)      v.begin(),v.end()
#define allr(v)     v.rbegin(),v.rend()
#define mod         1e9+7
#define CIN(V,s,n)  for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";}
#define SbS         sortbysec
#define fast        ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);   for(ll i=0;i<V.size();i++) V[i] = 0;

using namespace std;

ll cal_W(vector<ll> &Caf,ll D)
{
    ll work=0,s = Caf.size();
    //for(ll j=0;j<D;j++)
    for(ll i=0;i<s;i++)
    {
        work += max(Caf[i] - i/D,0LL);
    }
    return work;
}

ll BS(vector<ll> &Caf,ll m,ll s,ll e)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    ll W = cal_W(Caf,mid);
    if(W==m)
    {
        return mid;
    }
    else if(W > m)
    {
        return BS(Caf,m,s,mid-1);
    }
    else
        return BS(Caf,m,mid+1,e);
}

int main()
{
ll t=1;
//cin >> t;
while(t--)
{
    ll n,m,i,j,k,h,l,w,q,u,v,c;
    cin >> n ;
    vector<pair<ll,ll> > CO;
    for(i=0;i<n;i++)
    {
        cin >> u >> v;
        CO.pb(mp(u,v));
    }
    if(n <=2)
    {
        cout << 1;
        return 0;
    }
    sort(all(CO));
    vector<pair<ll,ll> > pq;
    for(j=0;j<n;j++)
    for(i=0;i<n;i++)
    {
        if(i==j)
            continue;
        u = CO[i].F - CO[j].F;
        v = CO[i].S - CO[j].S;
        pq.pb(mp(u,v));
    }
    sort(all(pq));
    ll max1=0,t_max=0;
    u = pq[0].F;
    v = pq[0].S;
    for(i=0;i<pq.size();i++)
    {
        if(pq[i].F == u and pq[i].S == v)
        {
            t_max++;
        }
        else
        {
            max1 = max(t_max,max1);
            t_max=1;
            u = pq[i].F;
            v = pq[i].S;
        }
    }

    cout << (n-max1);

}
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;

int main(){
  while(true){
    int input[10];
    int a[10];
    REP(i, 10) cin>>input[i];
    if(input[0] == -1) break;
    for(int i = 1; i <= 10; i++) a[i - 1] = i;
    int ans = 0;
    do{
      bool ok = true;
      REP(i, 10)if(input[i] != 0 && input[i] != a[i]) ok = false;
      if(!ok) continue;
      const int& MOD = a[9];
      int v[7][3] = {
        {3,4,5},
        {6,7,8},
        {0,3,6},
        {1,4,7},
        {2,5,8},
        {0,4,8},
        {2,4,6}
      };
      int check = (a[0] + a[1] + a[2]) % MOD;
      REP(i, 7){
        int sum = 0;
        REP(j, 3) sum += a[v[i][j]];
        if(check != sum % MOD){
          ok = false;
          break;
        }
      }
      if(ok) ans++;
    }while(next_permutation(a, a + 10));
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}

void main()
{
  int n; readV(n);
  writeln(n.nsqrt^^2);
}

pure T nsqrt(T)(T n)
{
  import std.algorithm, std.conv, std.range, core.bitop;
  if (n <= 1) return n;
  T m = 1 << (n.bsr/2+1);
  return iota(1, m).map!"a * a".assumeSorted!"a <= b".lowerBound(n).length.to!T;
}


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

int main(void){
    int N;
    cin>>N;
    
    vector<int> L(2*N);
    for(int i=0;i<N*2;i++){
        cin>>L[i];
    }
    
    sort(L.begin(),L.end());
    
    int sum=0;
    for(int i=0;i<2*N-1;i+=2){
        sum+=L[i];
    }
    
    cout<<sum<<endl;

}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int cnt = 0;
		int[] array_rank = new int[N];
		int[] array_score = new int[N];

		for (int i = 0; i < N; i++)
		{
			String[] str = Console.ReadLine().Split(' ');
			array_rank[i] = int.Parse(str[0]);
			array_score[i] = int.Parse(str[1]);
		}
		Array.Sort(array_rank);
		Array.Sort(array_score);

		cnt += N;
		cnt += array_rank[0] - 1;
		cnt += array_score[0];

		for (int i = 0; i < N-1; i++)
		{
			cnt += array_rank[i+1] - array_rank[i] - 1;
		}

		//出力
		Console.WriteLine(cnt);
	}
}

Measured memory_bytes: 15816
N, W = map(int, input().split())

V0 = []
V1 = []
V2 = []
V3 = []

for i in range(N):
    w, v = map(int, input().split())
    if i == 0:
        w1 = w
        V0.append(v)
    else:
        if w == w1:
            V0.append(v)
        elif w == w1+1:
            V1.append(v)
        elif w == w1+2:
            V2.append(v)
        else:
            V3.append(v)

V0.sort(reverse=True)
V1.sort(reverse=True)
V2.sort(reverse=True)
V3.sort(reverse=True)

from itertools import accumulate
CV0 = [0] + V0
CV0 = list(accumulate(CV0))
CV1 = [0] + V1
CV1 = list(accumulate(CV1))
CV2 = [0] + V2
CV2 = list(accumulate(CV2))
CV3 = [0] + V3
CV3 = list(accumulate(CV3))

ans = -float('inf')
for a in range(len(V0)+1):
    for b in range(len(V1)+1):
        for c in range(len(V2)+1):
            for d in range(len(V3)+1):
                if w1*a + (w1+1)*b + (w1+2)*c + (w1+3)*d <= W:
                    sum_v = CV0[a]+CV1[b]+CV2[c]+CV3[d]
                    ans = max(ans, sum_v)

print(ans)

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

template <typename T>
vector<T> dijkstra(int s,vector< vector< pair<int, T> > > & G){
  const T INF = numeric_limits<T>::max();
  using P = pair<T, int>;
  int n=G.size();
  vector<T> ds(n,INF);
  vector<int> bs(n,-1);
  priority_queue<P, vector<P>, greater<P> > pq;
  ds[s]=0;
  pq.emplace(ds[s],s);
  while(!pq.empty()){
    P p=pq.top();pq.pop();
    int v=p.second;
    if(ds[v]<p.first) continue;
    for(auto& e:G[v]){
      int u=e.first;
      T c=e.second;
      if(ds[u]>ds[v]+c){
        ds[u]=ds[v]+c;
        bs[u]=v;
        pq.emplace(ds[u],u);
      }
    }
  }
  return ds;
}

int main() {
    int N; cin >> N;
    vector<vector<pair<int,int>>> G(N);
    for(int i=0;i<N-1;i++){
       int a,b; 
       cin >> a >> b;
       a--; b--;
       G[a].emplace_back(b,1);
       G[b].emplace_back(a,1);
    }
    vector<int> f,s;
    f=dijkstra(0,G);
    s=dijkstra(N-1,G);
    int cnt=0;
    for(int i=0;i<N;i++){
       if(f[i]<=s[i]){
          cnt++;
       }
    }
    if(N/2<cnt){
       cout << "Fennec" << endl;
    } else {
       cout << "Snuke" << endl;
    }
}

Measured memory_bytes: 7672
'use strict'

const read = () => {
  function* iterInput() {
    const input = require('fs').readFileSync('/dev/stdin', 'utf8');
    for (const token of input.trim().split(/\s+/)) {
      yield token;
    }
  }
  const it = iterInput()
  return () => {
    return it.next().value
  }
}

const main = (next) => {
  const a = parseInt(next());
  const b = parseInt(next());
  const c = parseInt(next());
  const abc = [a, b, c];
  abc.sort();
  console.log(abc[2] * 10 + abc[0] + abc[1]);
}


main(read());


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n, m;
    cin >> n >> m;
    vector<long long> a(n);
    unordered_map<long long, int> c;
    c[0] = 1;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] += i ? a[i - 1] : 0;
        a[i] %= m;
        ans += c[a[i]];
        c[a[i]]++;
    }
    cout << ans << endl;

}



Measured memory_bytes: 4492
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

long long int w, h, x, y;

void solve(){
  cin >> w >> h >> x >> y;
  cout << w * h / 2.0 << " ";
  if(w * 0.5 == x && h * 0.5 == y) cout << 1 << endl;
  else cout << 0 << endl;

  return;
}

int main(){
  solve();
  return 0;
}


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

int n;
int f[100][10];
long long p[100][11];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> f[i][j];

		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 11; j++) {
			cin >> p[i][j];
		}
	}
	int count;
	long long ans, answer = -1000000001;
	for (int i = 1; i < pow(2, 10); i++) {
		ans = 0;
		for (int k = 0; k < n; k++) {
			int num = i;
			count = 0;
			for (int j = 0; j < 10; j++) {
				if (num % 2 == 1) {
					if (f[k][j] == 1) {
						count++;
					}
				}
				num /= 2;
			}
			ans += p[k][count];
			
		}
		answer = max(ans, answer);
	}
	cout << answer << endl;
	return 0;
}

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

main = do
  xs <- map toInt . words <$> getContents
  mapM_ print $ switch [] [] xs

toInt :: String -> Int
toInt s = read s

switch :: [Int] -> [Int] -> [Int] -> [Int]
switch acc _ [] = reverse acc
switch acc (s:ss) (0:ts) = switch (s:acc) ss ts
switch acc ss (t:ts) = switch acc (t:ss) ts

Measured memory_bytes: 4016
n, m = map(int, input().split())
A = [list(map(int, input().split())) for i in range(m)]

num = [10]*n
for i in range(m):
    if num[A[i][0]-1] != 10 and num[A[i][0]-1] != A[i][1]:
        print(-1)
        exit()
    else:
        num[A[i][0]-1] = A[i][1]

# print(num)

if n == 1:
    if num[0] == 10:
        print(0)
    else:
        print(num[0])
    exit()

if num[0] == 0:
    print(-1)
    exit()
if num[0] == 10:
    num[0] = 1

for i in range(1,n):
    if num[i] == 10:
        num[i] = 0

ans = 0
for i in range(n):
    ans = ans*10+num[i]

print(ans)

Measured memory_bytes: 38384
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
 
public class Main implements Runnable {
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }
    
    public void run() {
        FastScanner sc = new FastScanner();
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] canW = new boolean[n+1];
        Arrays.fill(canW, true);
        
        for(int i=0;i<m;i++){
        	int a = sc.nextInt();
        	canW[a] = false;
        }
        
        int mod = 1000000007;
        
        int[] dp = new int[n+1];
        dp[0] = 1;
        if(canW[1]){
        	dp[1] = 1;
        }
        
        for(int i=2;i<=n;i++){
        	if(canW[i]){
        		dp[i] = (dp[i-1] + dp[i-2]) % mod;
        	}
        }
        
        System.out.println(dp[n]);
    }

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextIntArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; 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 long long INF = 1LL << 60;
#define PI 3.14159265359 
long long MOD = 1000000007;


template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

long long dp[200100];

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

    rep(i,K){
        cout << "ACL";
    }
    cout  << endl;
    
}



Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    int N;
    std::cin >> N;
    std::vector<char> Arare;
    char buffer;
    for (int i = 0; i != N; i++)
    {
        std::cin >> buffer;

        if (std::find(Arare.begin(), Arare.end(), buffer) == Arare.end()) { Arare.push_back(buffer); }
    }

    if (Arare.size() == 4) { std::cout << "Four" << std::endl; }
    else
    {
        std::cout << "Three" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time,heapq
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n = inp()
    s = insr()
    q = [[0 for x in range(n + 1)] for y in range(n + 1)] 
    w = 0
    qw = ""
    qq = 0
    for i in range(1,n + 1): 
        for j in range(i + 1,n + 1):
            if s[i - 1] == s[j - 1] and q[i - 1][j - 1] < j - i: 
                q[i][j] = q[i - 1][j - 1] + 1
                if q[i][j] > w: 
                    w = q[i][j] 
                    index = max(i,qq)
            else: 
                q[i][j] = 0
    if w > 0: 
        for i in range(qq - w + 1,qq + 1): 
            qw = qw + s[i - 1] 
    print(len(qw))
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1],1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)

def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))

def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()

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

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> ss(h);
	for (auto &&s : ss)
	{
		cin >> s;
	}

	int inf = (1 << 30);

	vector<int> dd({0, 1, 0, -1, 0});

	auto inside = [](int a, int b, int alim, int blim) {
		return 0 <= a && a < alim && 0 <= b && b < blim;
	};

	int ans = -1;

	for (int si = 0; si < h; si++)
	{
		for (int sj = 0; sj < w; sj++)
		{
			for (int gi = 0; gi < h; gi++)
			{
				for (int gj = 0; gj < w; gj++)
				{
					if ((ss[si][sj] == '#') || (ss[gi][gj] == '#'))
					{
						continue;
					}

					vector<vector<int>> dist(h, vector<int>(w, inf));
					queue<pair<int, int>> que;
					dist[si][sj] = 0;
					que.emplace(si, sj);

					while (!que.empty())
					{
						int i = que.front().first;
						int j = que.front().second;
						que.pop();

						for (int k = 0; k < 4; k++)
						{
							int ni = i + dd[k];
							int nj = j + dd[k + 1];

							if (!inside(ni, nj, h, w) || (ss[ni][nj] == '#'))
							{
								continue;
							}

							if (dist[i][j] + 1 < dist[ni][nj])
							{
								dist[ni][nj] = dist[i][j] + 1;
								que.emplace(ni, nj);
							}
						}
					}

					ans = max(ans, dist[gi][gj]);
				}
			}
		}
	}

	cout << ans << endl;

	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++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

ll f(ll a) {
	if (a == 0) {
		return 2;
	} else if (a % 2) {
		return 1;
	} else {
		return 0;
	}
}
ll g(ll a) {
	if (a % 2 == 0) {
		return 1;
	} else {
		return 0;
	}
}

int main() {
	IOS;
	ll n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	vector<vector<ll>> dp(n + 1, vector<ll>(5));
	REP(j, 5) {
		dp[0][j] = 0;
	}
	REP(i, n) {
		REP(j, 5) {
			ll tmp = LLONG_MAX;
			REP(k, j+1) {
				chmin(tmp, dp[i][k]);
			}
			if (j == 0 || j == 4) {
				dp[i + 1][j] = tmp + a[i];
			} else if (j == 1 || j == 3) {
				dp[i + 1][j] = tmp + f(a[i]);
			} else {
				dp[i + 1][j] = tmp + g(a[i]);
			}
		}
	}
	put(*min_element(all(dp.back())));
	return 0;
}


Measured memory_bytes: 15872
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

const int inf = 1012345678;
int main(){
    int n;
    int p[200005];

    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        scanf("%d", &p[i]);
    }

    int flag = 0;
    int cnt = 0;
    int min = p[0];
    for(int i = 0; i < n; ++i){
        if(min >= p[i]){
            min = p[i];
        }
        if(p[i] <= min){
            cnt++;
        }else{
            ;
        }
    }

    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 2492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[2][105],b[105],c[105];
int main(){
	cin>>n;
	rep(i,2) repn(j,n) cin>>a[i][j];
	repn(i,n){
		repn(j,i) b[i] += a[0][j];
	}
	repn(i,n){
		for(int j=i;j<=n;j++) c[i] += a[1][j];
	}
	int ans = 0;
	repn(i,n) ans = max(ans,b[i]+c[i]);
	cout<<ans<<endl;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<int> height(n);
    for(int i = 0; i < n; i++) {
        cin >> height[i];
    }
    
    int dp[n];
    for(int i = 0; i < n; i++) {
        dp[i] = 0;
    }
    dp[0] = 0;
    dp[1] = abs(height[0] - height[1]);
    
    for(int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(height[i - 1] - height[i]), dp[i - 2] + abs(height[i - 2] - height[i]));
    }
    
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007

int main(){
    int n;
    int x=0;
    int ans=0;
    string s;
    cin >> n >> s;
    rep(i,n){
        if(s[i]=='I') x++;
        else x--;
        ans=max(ans,x);
    }
    cout << ans << endl;
    return 0;
}

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

main()
{
	int array[123245];
	priority_queue<int> q;
	int n,k,m,i,j,len,ins;
	int flag=0,max=0;
	int cou=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&array[i]);
		if(array[i]>max)
		max=array[i];
	}
	for(i=0;i<n;i++)
	{
		cou+=array[i];
	}
	cou-=max;
	cou+=max/2;
	printf("%d",cou);
	
}

Measured memory_bytes: 256
start_time = Time.now

N, K = gets.split.map(&:to_i)
As = gets.split.map(&:to_i).sort

def len(a)
  (a == 0 ? 1 : Math.log2(a).floor + 1)
end

def p(s) end

p "1: #{Time.now - start_time}s"

def to_b(n)
  bin = []
  i = 0
  while n > 0
    bin.unshift(n % 2)
    n /= 2
  end
  bin
end

A_len = len(As[-1])
#bin_As = As.map{|a| a.to_s(2).split('').map(&:to_i)}.
#  map{|bin| [0]*(A_len-bin.length) + bin}
bin_As = As.map{|a| to_b(a)}.
  map{|bin| [0]*(A_len-bin.length) + bin}
p "2: #{Time.now - start_time}s"
$bin_sums = bin_As.transpose.map{|bins| bins.reduce(&:+)}
p "3: #{Time.now - start_time}s"
bin_As.map!{|bin| [0]*(40-A_len) + bin}
p "4: #{Time.now - start_time}s"
$bin_sums = [0]*(40-A_len) + $bin_sums
p "5: #{Time.now - start_time}s"
bin_stds = $bin_sums.map{|sum| As.length-sum <= sum ? 0 : 1}

p "6: #{Time.now - start_time}s"

def f(bin)
  bin.zip($bin_sums).map{|max, sum| max == 1 ? N - sum : sum}.
    each_with_index.map{|sum, i| sum * 2**(bin.length - i - 1)}.
    reduce(&:+)
end

bin_K1 = (K+1).to_s(2).split('').map(&:to_i)
bin_K1 = [0]*(40-bin_K1.length) + bin_K1
max = 0
bin_K1.each_with_index do |b, i|
  if b == 1
    tmp_bin_max = bin_K1[0...i] + [0] + bin_stds[(i+1)..-1]
    tmp_max = f(tmp_bin_max)
    if tmp_max > max
      max = tmp_max
    end
  end
end

puts max


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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

const int mod = 1000000007;
int n, k;

int mu[100005];
bool isp[100005];
int h[100005];
int f[100005];

int expo(int a, int b){
	int c = 1, d = a;
	while(b){
		if(b & 1){
			c = 1LL * c * d % mod;
		}
		d = 1LL * d * d % mod;
		b >>= 1;
	}
	return c;
}

int main(){
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= k; i++){
		mu[i] = 1;
		isp[i] = true;
	}
	for(int i = 2; i <= k; i++){
		if(isp[i]){
			for(int j = i; j <= k; j += i){
				isp[j] = false; // yeah this will be inaccurate but whatever
				if((j / i) % i == 0){
					mu[j] = 0;
				}else{
					mu[j] *= -1;
				}
			}
		}
	}
	for(int i = 1; i <= k; i++){
		h[i] = expo(k / i, n);
	}
//	for(int i = 1; i <= k; i++){
//		printf("%d: %d %d\n", i, mu[i], h[i]);
//	}
	// ans = sum(i * f[i])
	// f[i] = sum(j | i) h[j] * mu[i / j]
	int output = 0;
	for(int j = 1; j <= k; j++){
		int fj = 0;
		for(int i = j; i <= k; i += j){
			fj = (fj + 1LL * h[i] * mu[i / j]) % mod;
		}
//		printf("j %d multiply %d\n", j, fj);
		output = (output + 1LL * j * fj) % mod;
	}
	printf("%d\n", (output + mod) % mod);
	return 0;
}

Measured memory_bytes: 4708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int n, m;
    cin >> n >> m;
    set<int> atox;
    set<int> xton;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        if (a == n)
        {
            xton.insert(b);
        }
        else if (b == n)
        {
            xton.insert(a);
        }
        if (a == 1)
        {
            atox.insert(b);
        }
        if (b == 1)
        {
            atox.insert(a);
        }
    }
    for (auto &i : atox)
    {
        if (xton.find(i) != xton.end())
        {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 12868
#include<stdio.h>
main(){
  int a,b,c,i,j;
  while(1){
    if(scanf("%d %d",&a,&b) == EOF) break;
    
    c=a+b;

    for(i=1;c != 0;i++){
      c=c/10;
      if(c==0)printf("%d\n",i);
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int n;cin>>n;
	rep(i,50010){
		if(int(i*1.08)==n){
			cout<<i<<endl;return 0;
		}
	}
	cout<<":("<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  long long a,b,c,d;
  std::cin >>a>>b>>c>>d;
  std::vector<long long> v;
  v.push_back(a*c);
  v.push_back(a*d);
  v.push_back(b*c);
  v.push_back(b*d);
  // for(int i=0; i<v.size(); i++)
  //   std::cout<<v[i]<<std::endl;
  long long  max_ = *std::max_element(v.begin(), v.end());
  std::cout<<max_<<std::endl;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(){
	int H,W;
	char image[105][105]={};
	cin >> H >> W;
	
	for(int i=0;i<105;i++){
		for(int j=0;j<105;j++){
			image[i][j]='#';
		}
	}
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin >> image[i][j];
		}
	}
	
	for(int i=0;i<=H+1;i++){
		for(int j=0;j<=W+1;j++){
			cout << image[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;


ll N,A,B;
ll ans = 0;
int main(){
  cin >> N >> A >> B;
  if(A > B || (N==1 && A!=B)){
    ans = 0;
  }
  else{
    ll tmin = A * (N-1) + B;
    ll tmax = B * (N-1) + A;
    ans = tmax - tmin + 1;
  }
  cout <<ans << endl;
}


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

int main(){
    cout << fixed << setprecision(10);
    double n, m, d;
    cin >> n >> m >> d;
    cout << (d == 0 ? (1 / n) * (m - 1) : (2 * (n - d) / (n * n)) * (m - 1)) << endl;
    return 0;
}

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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define rd(n) scanf("%d", &n)

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

int h, w, n;
ll k;
int board[50][50];

int ask(int sx, int sy, int ex, int ey)
{
    out << "? ";
    out << sx << " ";
    out << sy << " ";
    out << ex << " ";
    out << ey << endl;

    int ret; in >> ret;
    return ret;
}

void fill(int sx, int sy, int ex, int ey)
{
    REPE(i, sx, ex) REPE(j, sy, ey) board[i][j] = 1;
}

void f(int sx, int sy, int ex, int ey, int bomb)
{
    int mx = (sx+ex+1)/2;
    int my = (sy+ey+1)/2;

    int bombLeft = bomb;

    int ans1 = ask(sx, sy, mx-1, my-1);
    int area1 = ((mx-1)-(sx)+1)*((my-1)-(sy)+1);
    if(ans1 == area1) fill(sx, sy, mx-1, my-1);
    else if(ans1 != 0)
    {
        f(sx, sy, mx-1, my-1, ans1);
    }

    bombLeft -= ans1;
    if(bombLeft == 0) return;

    int ans2 = ask(sx, my, mx-1, ey);
    int area2 = ((mx-1)-(sx)+1)*((ey)-(my)+1);
    if(ans2 == area2) fill(sx, my, mx-1, ey);
    else if(ans2 != 0 && bombLeft > 0)
    {
        f(sx, my, mx-1, ey, ans2);
    }

    bombLeft -= ans2;
    if(bombLeft == 0) return;

    int ans3 = ask(mx, sy, ex, my-1);
    int area3 = ((ex)-(mx)+1)*((my-1)-(sy)+1);
    if(ans3 == area3) fill(mx, sy, ex, my-1);
    else if(ans3 != 0 && bombLeft > 0)
    {
        f(mx, sy, ex, my-1, ans3);
    }

    bombLeft -= ans3;
    if(bombLeft == 0) return;

    int ans4 = ask(mx, my, ex, ey);
    int area4 = ((ex)-(mx)+1)*((ey)-(my)+1);
    if(ans4 == area4) fill(mx, my, ex, ey);
    else if(ans4 != 0 && bombLeft > 0)
    {
        f(mx, my, ex, ey, ans4);
        bombLeft -= ans4;
    }
}

int main()
{
#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif

    in >> h >> w >> n >> k;

    REP(i, 10) REP(j, 10)
    {
        f(i*5, j*5, i*5+4, j*5+4, ask(i*5, j*5, i*5+4, j*5+4));
    }

    ll p2 = 1LL;
    ll res = 0;
    REP(i, h) REP(j, w)
    {
        res = (res + board[i][j] * p2) % k;
        p2 = (2LL * p2) % k;
    }

    out << "! " << res << "\n";

    return 0;
}


Measured memory_bytes: 720
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    Integer[] s = new Integer[N];

    int max = 0;

    for (int i = 0; i < N; i++) {
      s[i] = sc.nextInt();
      max += s[i];
    }

    sc.close();

    Arrays.sort(s);
    
    int result = 0;

    if (max % 10 != 0) {
      result = max;
    } else {
      for (int i = 0; i < N; i++) {
        if (s[i] % 10 != 0 ) {
          result = max - s[i];
          break;
        }
      }
    }

    System.out.println(result);

  }

}

Measured memory_bytes: 21844
#include<iostream>

using namespace std;


int main(int argc, char const *argv[]) {
  unsigned int N;
  cin >> N;
  unsigned int t[N+1], x[N+1], y[N+1];

  t[0] = 0; x[0] = 0; y[0] = 0;
  for(int i=1; i<(N+1); i++){
    cin >> t[i] >> x[i] >> y[i];
  }

  for(int i=1; i<(N+1); i++){
    int disX = x[i] - x[i-1];
    int disY = y[i] - y[i-1];
    int term = t[i]-t[i-1];

    if((term < (disX + disY)) || ((term - (disX + disY)) % 2 == 1)) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <set>

using namespace std;

int main() {
	int N; cin >> N;
	set<int> mochi;

	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		mochi.insert(tmp);
	}

	cout << mochi.size() << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    int ans=0;
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        if(2*x<=k){
            ans=ans+2*x;
        }else{
            ans=ans+(2*(k-x));
        }
    }
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    w,h=map(int,input().split())
    PQ=[None]*(w+h)
    for i in range(w):
        PQ[i]=(int(input()),0)
    for j in range(h):
        PQ[w+j]=(int(input()),1)
    PQ.sort()

    ans=0
    cnt=[h+1,w+1]
    for c,q in PQ:
        ans+=cnt[q]*c
        cnt[1-q]-=1
    print(ans)
resolve()

Measured memory_bytes: 49372
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;

void solve(){
    int h, a;
    cin >> h >> a;
    cout << ceil((double)h / a) << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


Measured memory_bytes: 256