akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define mp(a, b) make_pair(a, b)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)
#define MIN(a, b) ((a) < (b)) ? (a) : (b)
#define LLONG_MAX     9223372036854775807i64

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;
typedef vector<vpl> vvpl;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 29;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

struct edge { ll to; ll cost; };

/*<ここから>***********************************************************/


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

	string st = s;
	sort(all(st));

	string top;
	top.push_back(st[0]);
	rep(i, st.length()) {
		if (top.length() >= 5 || i + 1 >= st.length()) break;
		if (st[i] != st[i + 1]) top.push_back(st[i + 1]);
	}

	vs buf;

	rep(i, s.length()) {
		rep(j, top.size()) {
			if (top[j] == s[i]) {

				string b;
				rep(k, 5) {
					if (i + k >= s.length()) break;
					b.push_back(s[i + k]);
					buf.push_back(b);
				}
			}
		}
	}

	sort(all(buf));

	int n = 1;
	rep(i, buf.size()) {
		if (n == K) {
			cout << buf[i] << endl;
			break;
		}

		if (buf[i] != buf[i + 1]) n++;
	}


	return 0;
}

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

int main() {

    int n;
    cin >> n;

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

    long long ans[n];
    ans[n-1] = 0;
    ans[n-2] = abs(arr[n-1] - arr[n-2]);
    for (int i=n-3; i>=0; i--)
        ans[i] = min(abs(arr[i] - arr[i+1]) + ans[i+1], abs(arr[i] - arr[i+2]) + ans[i+2]);
    
    cout << ans[0] << endl;
}

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

int main(){
  int N;
  vector<int> v(51);

  cin >> N;
  for(int i=0; i<N; i++) cin >> v[i];

  sort(v.begin(), v.begin()+N, greater<int>());

  double ans = (v[N-1] + v[N-2])/pow(2,N-1);
  for (int i=0; i<N-2; i++){
    ans += v[i] / pow(2,i+1);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        int min = a[0];
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (min >= a[i]) {
                min = a[i];
                count++;
            } else {
            }
        }
        System.out.println(count);
        sc.close();
    }
}


Measured memory_bytes: 65036
/*
क्षमाशील हो रिपु-समक्ष
तुम हुये विनत जितना ही
दुष्ट कौरवों ने तुमको
कायर समझा उतना ही।
*/
#include<bits/stdc++.h>
using namespace std;
 
#define int                 long long int
#define ull                 unsigned int
#define ld                  long double
#define pb                  push_back
#define ff                  first
#define ss                  second
#define S(arr)              sort(arr.begin(),arr.end());
#define all(p)              p.begin(), p.end()
#define RS(arr)             sort(arr.rbegin(),arr.rend());
#define R(arr)              reverse(arr.begin(),arr.end());
#define pii                 pair <int, int>
#define vpi                 vector <pii>
#define vi                  vector <int>
#define vld                 vector <ld>
#define vvi                 vector <vector <int>>
#define vvpi                vector <vector <pii>>
#define vs                  vector <string>
#define si                  set <int>
#define spi                 set <pii>
#define setbits(x)          __builtin_popcountll(x)
#define zrobits(x)          __builtin_ctzll(x)
#define mii                 map <int, int>
#define mci                 map<char, int>
#define mpi                 map <pii, int>
#define T                   int tcf;cin>>tcf;while(tcf--)
#define que_max(t)          priority_queue <t>
#define que_min(t)          priority_queue <t, vector<t>, greater<t>>
#define endl                "\n"
#define dba(a, l, r)        for(auto x:a)cout<<x<<" ";cout<<endl;
#define db1(x)              cout << #x " = " << x << endl;
#define db2(x,y)            cout << #x " = " << x << " " << #y " = " << y << endl;
#define db3(x,y,z)          cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define db4(x,y,z,w)        cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << endl;
#define db5(x,y,z,w,v)      cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << " " << #v " = " << v << endl;
#define db6(x,y,z,w,v,a)    db3(a, y, x)db3(w, v, a)
#define p2d(v)              for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)              for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppi(v)              for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;

// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;  
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//  // *( hsh.find_by_order(k) ) kth smallest, from 0
//  // hsh.order_of_key(k) num of ele str less than k
//  // change less to less_equal for multiset pbds
 
void read(int n=10){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
    #ifndef ONLINE_JUDGE
         freopen("input.txt",  "r",  stdin);
         freopen("output.txt", "w", stdout);
    #endif
}
 
int M = 1e9 + 7;
int M1 = 998244353;
#define qqq 4000005
#define pi 3.14159265358979323851



int32_t main(){
    read();
    int n,m;
    cin>>n>>m;
    vi arr(m);int sum = 0;
    for(int i=0;i<m;i++)
        cin>>arr[i],sum+=arr[i];
    if(sum<=n)
        cout<<n-sum;
    else
        cout<<-1;
}  

Measured memory_bytes: 3728
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
using namespace std;
#define LL long long
#define pi (4*atan(1.0))
#define eps 1e-14
#define bug(x)  cout<<"bug"<<x<<endl;
const int N=1e5+10,M=1e6+10,inf=1e9+10;
const LL INF=1e18+10,mod=2147493647;


LL com(LL n,LL m)
{
    LL ans=1;
    for(int i=1,j=n;i<=m;i++,j--)
    {
        ans*=j;
        ans/=i;
    }
    return ans;
}
int main()
{
    int n,p;
    scanf("%d%d",&n,&p);
    int a=0,b=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        if(x%2)a++;
        else b++;
    }
    if(p==0)
    {
        LL ans=0;
        for(int i=0;i<=a;i+=2)
            ans+=com(a,i);
        for(int i=1;i<=b;i++)
        ans*=2;
        printf("%lld\n",ans);
    }
    else
    {
        LL ans=0;
        for(int i=1;i<=a;i+=2)
            ans+=com(a,i);
        for(int i=1;i<=b;i++)
            ans*=2;
        printf("%lld\n",ans);
    }
    return 0;
}


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

struct point{
	char l;
	char r;
};

int move(point area[10][30], int h, int w, int m){
	int goal = m - 1;
	for(int i = 0; i < h; i++){
		if(area[i][goal].l == '1'){
			goal--;
		}else if(area[i][goal].r == '1'){
			goal++;
		}
	}
	return goal + 1;
}

int main(){
	const int maxw = 10;
	const int maxh = 30;
	int n, m, g, d;
	char c;
	point area[maxw][maxh];
	while(cin >> n >> m >> g >> d){
		if(n == 0) break;
		for(int i = 0; i < d; i++){
			for(int j = 0; j < n; j++){
				area[i][j].l = '0';
				area[i][j].r = '0';
			}
		}
		for(int i = 0; i < d; i++){
			for(int j = 1; j < n; j++){
				cin >> c;
				if(c == '1'){
					area[i][j-1].r = '1';
					area[i][j].l = '1';
				}
			}
		}
		if(move(area, d, n, m) == g){
			cout << 0 << endl;
		}else{
			int i = 0, j = 0, count = 0;
			for(;i < d; i++){
				j = 0;
				for(;j < n-1; j++){
					if(area[i][j].l == '0' && area[i][j+1].r == '0' && area[i][j].r == '0'){
						area[i][j].r ='1'; 
						area[i][j+1].l = '1';
						if(move(area, d, n, m) == g){
							count++;
							break;
						}
						area[i][j].r = '0';
						area[i][j+1].l = '0';
					}
				}
				if(count == 1) break;
			}
			if(i == d && j == n - 1) cout << 1 << endl;
			else cout << i+1 << " " << j+1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

void solve(){
	while (true) {
		string s;
		cin >> s;
		if (s == "#") return;
		vector<vector<string>> inputs;
		REP(i, 4) {
			inputs.push_back(vector<string>());
			REP(q, 13) {
				string s;
				cin >> s;
				inputs.back().push_back(s);
			}
		}
		map<char, int> calc;
		for (int i = 2; i <= 9; ++i) {
			calc[i + '0'] = i;
		}
		calc['T'] = 10;
		calc['J'] = 11;
		calc['Q'] = 12;
		calc['K'] = 13;
		calc['A'] = 14;
		int ans[2] = { -6,-6 };
		int nowTurn = 0;
		REP(i, 13) {
			int winning = -1;
			int now_max = -1;
			REP(q, 4) {
				int go = calc[inputs[q][i][0]];
				if (inputs[q][i][1] == s[0]) {
					go += 100;
				}
				if (inputs[q][i][1] == inputs[nowTurn][i][1]) {
					go += 20;
				}
				if (go > winning) {
					winning = go;
					now_max = q;
				}
			}
			ans[now_max & 1]++;
			nowTurn = now_max;
		}
		if (ans[0] > 0) {
			cout << "NS " << ans[0] << endl;
		}
		else {
			cout << "EW " << ans[1] << endl;
		}
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3124
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n,sum = 0;
        ArrayList<Integer> list = new ArrayList<Integer>();
        
        n = sc.nextInt();
        
        for(int i = 0; i < n; i++){
            list.add(sc.nextInt());
        }
        
        while(list.size() > 0){
            for(int i = 1; i < list.size(); i++){
                sum += list.get(0) * list.get(i); 
            }
            list.remove(0);
        }
        
        System.out.println(sum);
        
    }
}

Measured memory_bytes: 22740
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int x,y;
  while(cin>>x>>y,x+y){
    int Map[y+10][x+10]={};
    int Map2[y+10][x+10]={};
    for(int i=0;i<y;i++)
      for(int j=0;j<x;j++){
	cin>>Map2[i][j];
	if(i==0&&Map2[i][j]==0)
	  Map[i][j]=1;
      }
    for(int i=0;i<y-1;i++){
      for(int j=0;j<x;j++){
	if(Map2[i][j]==0){
	  if(Map2[i+1][j+1]==0)
	    Map[i+1][j+1]+=Map[i][j];
	  if(Map2[i+1][j]!=1)
	    Map[i+1][j]+=Map[i][j];
	  if(j-1>=0&&Map2[i+1][j-1]==0)
	    Map[i+1][j-1]+=Map[i][j];
	}else if(Map2[i][j]==2){
	  if(Map2[i+2][j]!=1)
	    Map[i+2][j]+=Map[i][j];
	}
      }
    }
    ll ans=0;
    for(int i=y-1;i<=y;i++)
      for(int j=0;j<x;j++)
	ans+=Map[i][j];
    cout<<ans<<endl;
  }
  return 0;
}
  

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

int a,b,c;
string s, w;

int main() {
	cin>>a>>b>>c;
	if(a==b && a!=c){
		cout<<"Yes";
		return 0;
	}
	if(a==c && a!=b){
		cout<<"Yes";
		return 0;
	}
	if(b==c && a!= b){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(void) {
  string s;
  cin>>s;
  char a = s[0];
  char b = s[1];
  if(a!=b) {
    if(a==s[2]) {
      if(b==s[3]) {
	std::cout << "Yes" << std::endl;
      } else {
	std::cout << "No" << std::endl;
      }
    } else if(b==s[2]) {
      if(a==s[3])
	std::cout << "Yes" << std::endl;
      else
	std::cout << "No" << std::endl;
    }else{
      std::cout << "No" << std::endl;
    }
  } else {
    if (a==s[2])
      std::cout << "No" << std::endl;
    else {
      if(s[2]==s[3])
	std::cout << "Yes" << std::endl;
      else
	std::cout << "No" << std::endl;
    }
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
	ll s;
	if(k > 1){
		s = k*facctorialMethod(k-1);
	} else {
		s = 1;
	}
	return s;
}
vl primes(ll n){
	vl x(n);
	REP(i, n){
		x[i] = 0;
	}
	for(ll i = 2; i < sqrt(n) + 2; i++){
		while(n % i == 0){
			n /= i;
			x[i-1] += 1;
		}
	}
	if(n > 1){
		x[n-1] += 1;
	}
	return x;
}
const ll mod = 1000000007;

// 変数定義start(vectorはresizeしようね)
ll N;
vl h;
// 変数定義end

void solve(){
	cin >> N;
	h.resize(N);
	REP(i, N){
		cin >> h[i];
	}
	ll dp[N+1];
	dp[0] = 0;
	dp[1] = 0;
	for(ll i = 1; i < N; i++){
		if(i == 1){
			dp[i+1] = dp[i] + abs(h[i]-h[i-1]);
		} else {
			dp[i+1] = min(dp[i] + abs(h[i]-h[i-1]), dp[i-1] + abs(h[i] - h[i-2]));
		}
	}
	cout << dp[N] << endl;
}

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


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <vector>
#include <functional>
#include <unordered_set>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

const int N = 100;
const int K = 1e5 + 1;
const int MOD = 1e9 + 7;
int a[N];
bool winning[K];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i <= k; ++i) {
		winning[i] = false;
		for (int j = 0; j < n; ++j) {
			int to = i - a[j];
			if (to >= 0 && !winning[to]) {
				winning[i] = true;
				break;
			}
		}
	}
	if (winning[k]) {
		cout << "First\n";
	} else {
		cout << "Second\n";
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

bool comb(pair<int,int> a,pair<int,int> b){
    if(a.first==b.first){
        return a.second>b.second;
    }else return a>b;
}

int main(){
    int n;cin>>n;cout<<n*32<<endl;
    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

const int MAX_N = 2015;
char g[MAX_N][MAX_N];
int RC[MAX_N][MAX_N], CC[MAX_N][MAX_N];
int N, M;

void dorow(const int x, const int y)
{
	int L = y, R = y+1;
	int cnt = 0;
	while(L>=0&&g[x][L]!='#')L--,cnt++;
	while(R<M &&g[x][R]!='#')R++,cnt++;
	//cout << x << " " << y << "-->: " << cnt << "\n";
	for(int i=L+1;i<R;++i)RC[x][i]=cnt;
}

void docol(int x, int y)
{
	int T=x,B=x+1;
	int cnt = 0;
	while(T>=0&&g[T][y]!='#')T--,cnt++;
	while(B<N&&g[B][y]!='#')B++,cnt++;
	//cout << cnt << " ";
	for(int i=T+1;i<B;++i)CC[i][y]=cnt;
}

void solve()
{
	int ans = 0;
	for(int i=0;i<N;++i)for(int j=0;j<M;++j)if(g[i][j]!='#'&&!RC[i][j]){
		dorow(i,j);
	}
	for(int i=0;i<N;++i)for(int j=0;j<M;++j)if(g[i][j]!='#'&&!CC[i][j]){
		docol(i,j);
	}
	for(int i=0;i<N;++i)for(int j=0;j<M;++j)if(g[i][j]!='#')ans=max(ans,RC[i][j]+CC[i][j]-1);
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> M;
	string ss;
	for(int i=0;i<N;++i){
	    cin >> ss;
	    for(int j=0;j<M;++j) g[i][j]=ss[j];
	}
	solve();
	return 0;
}

Measured memory_bytes: 35968
#-------------
N = int(input())
#-------------
N_1 = N
F = []
while True :
  if N_1 != 0:
    F.append(N_1%10)
    N_1 = N_1//10
  else:
    break
ans = 0  
for i in range(len(F)):
  ans += F[i]

if N%ans == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9108
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))
c = {'odd': 0,
     'even': 0,
     'four': 0,
     'even_not_four': 0}

for x in a_list:
    if x % 2 == 0:
        c['even'] += 1
    else:
        c['odd'] += 1

    if x % 4 == 0:
        c['four'] += 1

ans = 'No'

if c['even'] == N:
    ans = 'Yes'
else:
    if c['odd'] == 1:
        if c['four'] >= 1:
            ans = 'Yes'
    else:
        if c['even'] - c['four'] >= 1:
            if c['four'] >= c['odd']:
                ans = 'Yes'
        else:
            if c['four'] >= c['odd'] - 1:
                ans = 'Yes'

print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N,D;
  cin>>N>>D;
  ll x[N][D];
  rep(i,N){
    rep(j,D){
      cin>>x[i][j];
    }
  }
  ll ans=0;
  ll dist=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int k=0;k<D;k++){
        dist+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      for(int k=1;k<=dist;k++){
        if(k*k==dist){
          ans++;
          dist=0;
          break;
        }
      }
      dist=0;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
string u="abcdefghijklmnopqrstuvwxyz";

struct edge {int to;LL cost;};

const int M_N=10000;

vector<edge> G[M_N+1];
LL d[M_N+1];

struct Dijkstra{

    void dijkstra(int s){
        priority_queue<P,vector<P>,greater<P>> que;
        que.push(P(0,s));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int v=p.second;
            if(d[v]<p.first) continue;
            for(int i=0;i<G[v].size();i++){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(P(d[e.to],e.to));
                }
            }
        }
    }

};

int main(){
    Dijkstra Ds;
    fill(d,d+M_N+1,LINF);
    d[0]=0;
    int N;
    cin >> N;
    int u,k,v,c;
    while(cin >> u >> k){
        for(int i=0;i<k;i++){
            cin >> v >> c;
            G[u].push_back({v,c});
        }
    }
    Ds.dijkstra(0);
    for(int i=0;i<N;i++){
        cout << i <<" "<< d[i] << endl;
    }
    return 0;
}


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

int main(void)
{
    int n, x;
    
    while (true) {
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        
        int i, j, k;
        int cnt = 0;
        
        for (i = 1; i <= n -2; ++i) {
            for (j = i + 1; j <= n -1; ++j) {
                for (k = j + 1; k <= n; ++k) {
                    if (i + j + k == x) cnt++;
                    }
                }
            }
        cout << cnt << endl;
        }
    
    return 0;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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;
}

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vec<ll> x(n), y(n), p(n);
    REP(i, n) {
        cin >> x[i] >> y[i] >> p[i];
    }

    ll all2 = 1LL << n;
    Matrix xx(all2, Array(n, 0));
    Matrix yy(all2, Array(n, 0));
    REP(bit, all2) {
        REP(i, n) {
            xx[bit][i] = abs(x[i]);
            yy[bit][i] = abs(y[i]);
            REP(j, n) {
                if((bit >> j) & 1) {
                    chmin(xx[bit][i], abs(x[i] - x[j]));
                    chmin(yy[bit][i], abs(y[i] - y[j]));
                }
            }
        }
    }

    ll all3 = 1;
    REP(i, n) {
        all3 *= 3;
    }
    Array ans(n + 1, INF);
    REP(bit, all3) {
        ll con = n;
        ll t = bit;
        ll xs = 0;
        ll ys = 0;
        REP(i, n) {
            int tt = t % 3;
            t /= 3;
            if(tt == 0) {
                con--;
            } else if(tt == 1) {
                xs |= (1LL << i);
            } else {
                ys |= (1LL << i);
            }
            //out << tt << " ";
        }
        //cout << en;

        ll sum = 0;
        REP(i, n) {
            sum += min(xx[xs][i], yy[ys][i]) * p[i];
        }
        //cout << con << " " << sum << en;
        chmin(ans[con], sum);
    }

    for(auto i : ans)
        cout << i << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 12964
#include<stdio.h>
int main(void) {
  int N,L[10],i,sum=0,p=0;
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&L[i]);
  for(i=0;i<N;i++)sum+=L[i];
  for(i=0;i<N;i++)if(sum-L[i]<=L[i])p=1;
  if(p)printf("No");
  else printf("Yes");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll N, n = -1;
    cin >> N;
    // 1, 3, 6, 10, 15....
    ll acc = 0;
    for(ll i = 1; ; i++) {
        acc += i;
        if (acc > N) {
            break;
        } else if (acc == N) {
            n = i;
        }
    }
    if (n == -1) {
        cout << "No" << endl;
    } else {
        vector<vector<int>> arr = {{1}, {1}};
        int cur = arr.back().back()+1;
        for(int i = 2; i <= n; i++) {
            for(int j = 0; j < i; j++) {
                arr[j].push_back(cur+j);
            }
            vector<int> nxt(i, 0);
            for(int j = 0; j < i; j++)
                nxt[j] = (cur+j);
            arr.push_back(nxt);
            cur = nxt.back()+1;
        }
        cout << "Yes" << endl << arr.size() << endl;
        for(int i = 0; i < arr.size(); i++) {
            cout << arr[i].size() << " ";
            for(int val: arr[i])
                cout << val << " ";
            cout << endl;
        }
    }
    return 0;
}




Measured memory_bytes: 2688
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container;

void main()
{
  auto bi = new int[](2_000_000);
  auto ai = bi.heapify(0);

  for (;;) {
    auto rd = readln.chomp.splitter(' '), cmd = rd.front;
    switch (cmd) {
    case "insert":
      rd.popFront;
      ai.insert(rd.front.to!int);
      break;
    case "extract":
      writeln(ai.front);
      ai.removeFront;
      break;
    case "end":
      return;
    default:
      assert(0);
    }
  }
}

Measured memory_bytes: 11176
/*
ID: victorn2
LANG: C++
TASK: heritage
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <chrono>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define fin cin
#define fout cout
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
#define int long long
#define left vadia
#define right puta
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<char>> mat;
typedef pair<int, string> pis;
const ll mod = 1e9+7;
const int MAXN = 1e5+5;
const int MAXV = 1e6+5;
typedef vector<int> vi;
typedef pair<vi, string> pvs; 

int32_t main() {

	string s;
	cin >> s;
	int n = s.size();

	int x = 0, pot = 1;
	vector<int> v(2020);

	v[0]++;
	int ans = 0;
	for(int i = n-1; i >= 0; i--) {
		x = (x + (s[i] - '0') * pot) % 2019;
		pot = (pot * 10) % 2019;
		ans += v[x];
		v[x]++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3692
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
const int maxn = 2e5+5;
typedef struct node{
	int cnt;
	string str;
	node(){
	}
	node(int a,string b){
		cnt=a,str=b;
	}
}node;
node res[maxn];
map<string,int> mp;
string a[maxn];
int n;
int cmp(node a,node b){
	if(a.cnt==b.cnt)return a.str<b.str;
	return a.cnt>b.cnt;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	int ind=0;
	for(auto it:mp){
		res[ind++]=node(it.second,it.first);
	}
	sort(res,res+ind,cmp);
//	for(int i=0;i<ind;i++){
//		cout<<res[i].cnt<<" "<<res[i].str<<endl;
//	}
	int ma=res[0].cnt;
	cout<<res[0].str<<endl;
	for(int i=1;i<ind;i++){
		if(res[i].cnt!=ma)break;
		cout<<res[i].str<<endl;
	}
	return 0;
} 

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif
	int k,n;
	cin>>k>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int maxi=-1;
	for(int i=0;i<n-1;i++)
		maxi=max(maxi,a[i+1]-a[i]);
	maxi=max(maxi,k-a[n-1]+a[0]);
	cout<<k-maxi<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#define N 100000
#define MAX (1<<31)-1
using namespace std;
long long A[N+1], T[4*N+1], lazy[4*N+1];

void build(int l, int r, int k) {
    if (l == r) {
        T[k] = A[l];
        return;
    }
    int mid = (l + r) / 2;
    build(l, mid, k * 2);
    build(mid + 1, r, k * 2 + 1);
    T[k] = T[2 * k] + T[2 * k + 1];
}
void pushdown(int k, int l, int r, int mid) {
    if (lazy[k]) {
        lazy[2*k] += lazy[k];
        lazy[2*k+1] += lazy[k];
        T[2*k] += lazy[k]*(mid-l+1);
        T[2*k+1] += lazy[k]*(r-mid);
        lazy[k] = 0;
    }
}
void updata(int L, int R, int data ,int l, int r ,int k) {
    if (L <= l && r <= R) {
        T[k] += data*(r-l+1);
        lazy[k] += data;
        return;
    }
    int mid = (l + r) / 2;
    pushdown(k, l, r, mid);
    if (mid >= L) updata(L, R, data, l, mid, 2*k);
    if (mid < R) updata(L, R, data, mid+1, r, 2*k+1);
    T[k] = T[2 * k] + T[2 * k + 1];
}
long long find(int L, int R, int l, int r, int k) {
    if (L <= l && r <= R) return T[k];
    int mid = (l + r) / 2;
    pushdown(k, l, r, mid);
    long long ans = 0;
    if (mid >= L) ans = ans + find(L, R, l, mid, k * 2);
    if (mid < R) ans = ans + find(L, R, mid + 1, r, k * 2 + 1);
    return ans;
}
int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    for (int i = 0; i <= n; i++)
        A[i] = 0;
    for (int i = 0; i <= 4*n; i++)
        lazy[i] = 0;
    build(1, n, 1);
    int com, s, t, x, y;
    while (q--) {
        scanf("%d", &com);
        if (com == 0) {
            scanf("%d%d%d", &s, &t, &x);
            updata(s, t, x, 1, n, 1);
        }
        else {
            scanf("%d", &s);
            printf("%ld\n", find(s, s, 1, n, 1));
        }
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<string> v(n);
  for(int i=0; i<n; i++){
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  
  int ans=1;
  for(int i=0;i<n-1;i++){
    if(v.at(i)!=v.at(i+1)){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int x,y;
  cin >> x >> y;
  vector<int> a = {1,3,1,2,1,2,1,1,2,1,2,1};
  if(a.at(x-1)==a.at(y-1)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

bool find(int i, int j, vector<char> str){
    if(j==3){
        return true;
    }
    else if(i == n){
        return false;
    }
    else if(s[i] == str[j]){
        return find(i+1, j+1, str);
    }
    else return find(i+1, j, str);
}
int main(void){
    cin>>n;
    cin>>s;
    int ans=0;
    rep(k, 1000){
        string tmp = to_string(k);
        vector<char> str(3);
        rep(i, 3-tmp.size()) str[i]='0';
        rep(i, tmp.size()) str[i+3-tmp.size()]=tmp[i];
        for(int i=str.size()+1;i<=3;i++){
            str.push_back('0');
        }
        if(find(0, 0, str)) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
  for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
  for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (int i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < v.size() - 1; ++i) {
    os << v[i] << " ";
  }
  if (v.size() > 0) {
    os << v[v.size() - 1] << endl;
  }
  return os;
}

int main() {
  int n, c;
  cin >> n >> c;
  vector<vector<pair<int, int>>> pavec1(c);
  REP(i,n){
    int a, b, chan;
    cin >> a >> b >> chan;
    --chan;
    pavec1[chan].push_back(make_pair(a, b));
  }

  vector<pair<int, int>> pavec;
  REP(i,c){
    if (pavec1[i].size() == 0) continue;
    sort(pavec1[i].begin(), pavec1[i].end());
    pair<int,int> prev = pavec1[i][0];
    FOR(j, 1, pavec1[i].size()){
      if (pavec1[i][j].first == prev.second){
        prev.second = pavec1[i][j].second;
      }else{
        pavec.push_back(make_pair(prev.first, 0));
        pavec.push_back(make_pair(prev.second, 1));
        prev = pavec1[i][j];
      }
    }
    pavec.push_back(make_pair(prev.first, 0));
    pavec.push_back(make_pair(prev.second, 1));
  }

  sort(pavec.begin(), pavec.end());
  int ans = 0, tmp = 0;
  REP(i,pavec.size()){
    pint now = pavec[i];
    if (now.second == 0){
      ++tmp;
      ans = max(ans, tmp);
    } else {
      --tmp;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in).useDelimiter("\\D");
		int w = s.nextInt();
		int n = s.nextInt();
		int[] l = new int[w];
		for(int i = 0; i < w; ++i) {
			l[i] = i + 1;
		}
		for(int i = 0; i < n; ++i) {
			int a = s.nextInt();
			int b = s.nextInt();
			int t = l[a - 1];
			l[a - 1] = l[b - 1];
			l[b - 1] = t;
		}
		for(int i : l) {
			System.out.println(i);
		}
	}
}

Measured memory_bytes: 17216
//abc088_d.cpp
//Sun Feb 18 19:35:41 2018

#include <iostream>
#include <string>
#include <queue>
using namespace std;




int proceed(int w, int h, int x, int y, int memo[50][50]){
	queue<int> qx;
	queue<int> qy;

	qx.push(x);
	qy.push(y);

	memo[x][y] = 1;

	while (!qx.empty() && !qy.empty()){
		int tempx = qx.front();
		qx.pop();
		int tempy = qy.front();
		qy.pop();

		if (tempx==w-1 && tempy==h-1){
			return memo[w-1][h-1];
		}

		if (memo[tempx+1][tempy] == 0 && tempx+1 <= w-1){
			memo[tempx+1][tempy] = memo[tempx][tempy]+1;
			qx.push(tempx+1);
			qy.push(tempy);
		}
		if (memo[tempx-1][tempy] == 0 && tempx-1 >= 0){
			memo[tempx-1][tempy] = memo[tempx][tempy]+1;
			qx.push(tempx-1);
			qy.push(tempy);
		}
		if (memo[tempx][tempy+1] == 0 && tempy+1 <= h-1){
			memo[tempx][tempy+1] = memo[tempx][tempy]+1;
			qx.push(tempx);
			qy.push(tempy+1);
		}
		if (memo[tempx][tempy-1] == 0 && tempy-1 >= 0){
			memo[tempx][tempy-1] = memo[tempx][tempy]+1;
			qx.push(tempx);
			qy.push(tempy-1);
		}
	}
	return -1;
}


int main(){

	int h;
	int w;
	cin >> h;
	cin >> w;

	int wallcount = 0;

	string s[50][50];
	int memo[50][50];

	for (int j=0;j<h;j++){
		string temp;
		cin >> temp;
		for (int i=0;i<w;i++){
			s[i][j] = temp[i];
			if (s[i][j]=="#"){
				wallcount++;
				memo[i][j] = -1;
			}else{
				memo[i][j] = 0;
			}
		}
	}

	int answer;
	int path = proceed(w,h,0,0,memo);
	if (path == -1){
		answer = -1;
	}else{
		answer = h*w-path-wallcount;
	}
	cout << answer << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e8;
using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

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

	int a[5], k;
	bool b=false;
	cin >> a[0] >> a[1] >> a[2] >> a[3]>> a[4] >> k;

	for (int i = 0;i < 4;i++)
	{
		for (int j = i + 1;j < 5;j++)
		{
			if (abs(a[i] - a[j]) > k)
				b = true;
		}
	}

	if (b)
	{
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,b,ans;
int main()
{
	cin>>n;
	ans=0;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		ans+=max(a,b)-min(a,b)+1;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
#define first f
#define second s
#define N 1000000
vector<ll>v(N);
ll l,m,n,sum,ans,maximum,minimum,mahakal,a,b,c,t,i,j,k;
ll cnt,cnt1,cnt2,cnt3;
string str,str1,str2;
ll arr[N];
int main(){
    cin>>n;
  cin>>str;
  if(n&1){
    cout<<"No"<<endl;
    return 0;
  }
  str1=str.substr(0,n/2);
  str2=str.substr(n/2,n/2);
  //cout<<str1<<" "<<str2<<endl;
  if(str1==str2){
      cout<<"Yes"<<endl;
  }
  else{
      cout<<"No"<<endl;
  }
  
    return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int arr[n],sum(0);
string s,arr1[n];
map<string,int>pos;
for(int i=0; i<n; ++i)
{
cin>>arr1[i]>>arr[i];
pos[arr1[i]]=i;
}
cin>>s;
for(int i=pos[s]+1; i<n; ++i)
sum+=arr[i];
cout<<sum;
return 0;
}


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 MOD 1000000007
using ll = long long;
using vi = vector<int>;

int main()
{
  int N; cin >> N;
  vi A(N);
  REP( i, N ) {
    cin >> A[i];
  }
  
  ll ans = 0, tmp = A[N-1];
  FOR( i, 1, N ) {
    int n = N-1-i;
    ans += tmp * A[n];
    tmp += A[n];
    ans %= MOD; tmp %= MOD;
    
  }
  cout << ans;
}

Measured memory_bytes: 3968
/*    Author : Hariom_Pandey
	  Created: 08-12-2019 17:31:37
*/
#include<bits/stdc++.h>
using namespace std;

#define All(a)          (a).begin(), (a).end()
#define Sort(x)         sort(All(x))
#define ll              long long int 
#define ull             unsigned ll
#define ld              long double
#define vll             vector<ll>
const ll MOD = (ll) 1e9 + 7;
inline long long int LD(long long int n) { return (n % 10);}
inline long long TT(long long int n){int digits = (int)log10(n);}
#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define co_od(arr) count_if(arr.begin(), arr.end(),[=](ll x){return x % 2 != 0;});
#define Unique(v)       Sort(v); (v).resize(unique(All(v)) - (v).begin())
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

signed main(){
	IOS;
	vector<long long int>arr;
   	auto pushito=[&](long long int m){arr.push_back(m);};

   	ll a,b,c;
   	cin>>a>>b>>c;
   	if(a+b+c>=22){
   		cout<<"bust"<<"\n";
   	}
   	else{
   		cout<<"win"<<"\n";
   	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

typedef pair <int, int> pii;
typedef long long ll;

const int inf = 1e9 + 1;
const double eps = 1e-9;
const int MAXN = 1e5 + 1;

int dp[MAXN][3];
int n;
int a[MAXN], b[MAXN], c[MAXN];

int main(){

    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
        dp[i][0] = dp[i][1] = dp[i][2] = 0;
    }
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for (int i = 1; i < n; i++){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }

    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));

    return 0;

}


Measured memory_bytes: 2560
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define pb(b) push_back(b) 
#define all(a) a.begin(),a.end()
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
const int mod=1e9+7;
/* 
UnionFind：素集合系管理の構造体(union by size)
isSame(x, y): x と y が同じ集合にいるか。 計算量はならし O(α(n))
unite(x, y): x と y を同じ集合にする。計算量はならし O(α(n))
treeSize(x): x を含む集合の要素数。
*/
struct UnionFind{
 vector<int>size,parents;
 UnionFind(){}
 UnionFind(int n){//make n trees.
  size.resize(n,0);
  parents.resize(n,0);
  for(int i=0;i<n;i++)makeTree(i);
 }
 void makeTree(int x){
   parents[x]=x;//the parent of x is x
   size[x]=1;
  }
 bool isSame(int x,int y){return findRoot(x)==findRoot(y);}
 bool unite(int x,int y){
  x = findRoot(x);
  y = findRoot(y);
  if(x==y)return false;
  if(size[x]>size[y]){
   parents[y]=x;
   size[x]+=size[y];
  } 
  else{
   parents[x]=y;
   size[y]+=size[x];
  }
  return true;
 }
 int findRoot(int x){//木の根を探す,計算量削減のため低く
  if(x!=parents[x])parents[x]=findRoot(parents[x]);
  return parents[x];
 }
 int treeSize(int x){return size[findRoot(x)];}
};
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*迷路移動*/const int dx[4]={1,0,-1,0};const int dy[4]={0,1,0,-1};
llfor;////////////////////////////////////////////////////////////
int main(){
 ll n;
 cin>>n;
 ll a[n+10],mx[n+10]={0};
 rep(i,0,n){
  cin>>a[i];
  if(i>0)mx[i]=max(mx[i-1],a[i]);
  else mx[i]=a[i];
 }
 ll ans=0;
 rep(i,0,n){
  ans+=mx[i]-a[i];
 }
 pr(ans);
return 0;}

Measured memory_bytes: 6760
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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



signed main () {
    int a;cin >>a;
    cout <<a+a*a+a*a*a<<endl;
}




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



#define REP(i, a, b)    for(int i = a, _b = b; i < _b; ++i)

#define FOR(i, a, b)    for(int i = a, _b = b; i <= _b; ++i)

#define FORD(i, a, b)    for(int i = a, _b = b; i >= _b; --i)

#define endl            "\n"

#define puts(_content_) cout << (_content_) << "\n"

#define newline         cout << "\n"



using namespace std;

typedef pair<int, int> ii;

typedef long long llong;


const int MAXN = 1E5+5;

int A[MAXN], B[MAXN];

vector<int> calc (int K) {
	vector<int> ret;
	ret.push_back(K);
	REP(i, 0, 31) {
		if((K >> i) & 1) {
			int tmp = K;
			tmp &= (~(1 << i));
			tmp |= ((1 << i) - 1);
			ret.push_back(tmp);
		}
	}
	return ret;
}


int main() {

	ios::sync_with_stdio(false);

	cin.tie(NULL);

#ifdef Home 

	freopen("input.txt", "r", stdin);

//   freopen("output.txt", "w", stdout);

#endif

	int N, K;

	cin >> N >> K;

	REP(i, 0, N) {

		cin >> A[i] >> B[i];
	}

	vector<int> X = calc(K);
	llong answer = 0;
	for(int x: X) {
		llong cur = 0;
		REP(i, 0, N) {
			if((x | A[i]) == x) {
				cur += B[i];
			}
		}
		answer = max(answer, cur);
	}
	puts(answer);

	return 0;

}

Measured memory_bytes: 1024