akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
#include<deque>
#include<chrono>
using namespace std;
#define pi 3.141592653589793238


#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
typedef vector<ll> vi;
typedef vector<vi> vvi;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    
    //cin >> T;
    while (T--) {
        ll m, d;
        cin >> m >> d;
        ll count = 0;
        for(i = 1; i <= m; i++){
            for(j = 10; j <= d; j++){
                ll d1, d2;
                d1 = j % 10;
                d2 = (j / 10) % 10;
                if(d1 < 2 || d2 < 2){
                    continue;
                }
                if(d1 * d2 == i){
                    //cout << j <<" " << i << endl;
                    count++;
                }
            }
        }
        cout << count;
    }

    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

short dp[200005][2020];

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

  rep(i,S.size()){
    {
      int nxt = (S[i]-'0')%2019;
      dp[i+1][nxt] += 1;
    }
    rep(j,2019){
      {
        int nxt = (j*10 + (S[i]-'0'))%2019;
        dp[i+1][nxt] += dp[i][j];
      }
    }
  }

  int ret = 0;
  rep(i,S.size()+1){
    ret += dp[i][0];
  }
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 792788
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
/*
// Create a vector containing n 
//vectors of size m.  
    vector<vector<int> > vec( n , vector<int> (m, 0));  
*/
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
signed main() 
{
    fastio;
    //cout << fixed << setprecision(0);
    int c=1;
    while(true)
    {
        int x;
        cin>>x;
        if(x==0)
        {
            cout<<c<<endl;
            break;
        }
        c+=1;
        
    }
    
}


Measured memory_bytes: 3580
// Why do we fall ? So we can learn to pick ourselves up.
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(Math.max(0,a-2*b));
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, A[100000];

int main(void) {
  cin >> N;
  REP(i, 0, N) cin >> A[i];

  map<ll, ll> mp;
  REP(i, 0, N) mp[A[i]]++;

  ll ans = 0;
  for(auto p : mp) {
    if(p.first > p.second) ans += p.second;
    if(p.first < p.second) ans += p.second - p.first;
  }
  cout << ans << endl;
}


Measured memory_bytes: 7040
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DGridComponents solver = new DGridComponents();
        solver.solve(1, in, out);
        out.close();
    }

    static class DGridComponents {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt() - 1, b = in.nextInt() - 1;
            System.out.println("100 100");
            for (int y = 0; y < 49; y++) {
                for (int x = 0; x < 100; x++) {
                    if (b > 0 && x % 2 == 0 && y % 2 == 0) {
                        System.out.print('#');
                        b--;
                    } else {
                        System.out.print('.');
                    }
                }
                System.out.println();
            }
            for (int i = 0; i < 100; i++) {
                System.out.print('.');
            }
            System.out.println();
            for (int i = 0; i < 100; i++) {
                System.out.print('#');
            }
            System.out.println();
            for (int y = 51; y < 100; y++) {
                for (int x = 0; x < 100; x++) {
                    if (a > 0 && x % 2 == 0 && y % 2 == 0) {
                        System.out.print('.');
                        a--;
                    } else {
                        System.out.print('#');
                    }
                }
                System.out.println();
            }
        }

    }
}



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

int f(int i,vector<int> a){
    bool p=true;
    for(int k=0;k<i;k++){
        if(a[i]>=a[k])
            continue;
        else{
            p=false;
            break;
        }        
    }
    if(p)
        return 1;
    else
        return 0;
}

int main(){
    int n,count=1;
    cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;i++)
        cin >> h[i];
    for(int i=1;i<n;i++){
        count+=f(i,h);
    }
    cout << count;
}

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

using namespace std;

int main()
{
	long long n,m,ans;
	cin >> n >> m;

	if(n == m)
		cout << "Yes" << endl;
	else
		cout << "No " << endl;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    auto X = new long[](10 ^^ 5 + 1);
    foreach (_; 0 .. N)
    {
        long a, b;
        scan(a, b);
        X[a] += b;
    }
    foreach (i; 0 .. X.length)
    {
        K -= X[i];
        if (0 >= K)
        {
            writeln(i);
            return;
        }
    }
}


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

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

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL) x = x->left;
  return x;
}

/*Node treeMaximum(Node x){


}*/

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key) return u;

  if(k < u->key)return treeSearch(u->left, k);
  else return treeSearch(u->right, k);

  return NIL;
}

Node treeSuccessor(Node x){
  if(x->right != NIL)return treeMinimum(x->right);

  Node y;
  y = x->parent;
  while(y !=NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;

  }

void treeDelete(Node z){
  Node y; 
  Node x; 

  if(z->left == NIL || z->right == NIL) y=z;
  else y = treeSuccessor(z);

  if(y->left != NIL)x = y->left;
  else x = y->right;

  if(x != NIL)x->parent = y->parent;

  if(y->parent == NIL)root = x;
  else if(y == y->parent->left)y->parent->left = x;
  else y->parent->right = x;

  if(y != z)z->key = y->key;
}

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

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

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

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

   
}

void inorder(Node u){
  int i=0;
  if(u != NIL){
    inorder(u->left);
   
    printf(" %d",u->key);
    
    inorder(u->right);
  }
}

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



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

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

  return 0;
}




Measured memory_bytes: 20480
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(ll i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<ll>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const ll max_n = 2e5 + 9;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
ll n , k;
ll arr[max_n];
vi a[max_n];
ll loop_index;
ll visited[max_n];
vi ans;
ll flag;
map<ll,ll> m;
void dfs(ll s , ll cnt = 0){
    if(visited[s]){
        loop_index = m[s];
        flag = 1;
    }
    visited[s] = 1;
    if(flag)return;
    ans.pb(s);
    m[s] = ans.size() - 1;
    for(auto it : a[s]){
        dfs(it , cnt + 1);
    }
}
int main()
{
    cin >> n >> k;
    for(ll i = 0 ; i < n ; i++){
        cin >> arr[i];
        a[i+1].pb(arr[i]);
    }

    dfs(1);
    if(k < ans.size()){
        cout << ans[k] << endl;
        return 0;
    }
    else{
        k -= loop_index;
        ll num = ans.size() - loop_index;
        k %= num;
        cout << ans[loop_index + k] << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 46528
#include<stdio.h>
int main(void){
  long long int k,n,i,j,a[20][50000],b,l,c,p;
  scanf("%lld",&k);
  for(i=1;i<10;i++){
    a[1][i]=i;
    if(i==k){
      printf("%lld\n",i);
      break;
    }
    /*printf("%lld\n",a[1][i]);*/
  }
 c=10;
 b=9;
 if(k>=10){
 for(i=2;i<12;i++){
   n=c-1;
   c=1;
   for(j=1;j<=n;j++){
       if(a[i-1][j]%10!=0&&a[i-1][j]%10!=9){
	 for(l=0;l<=2;l++){
       a[i][c]=10*a[i-1][j]+a[i-1][j]%10+(l-1);
       /*printf("%lld\t",a[i][c]);*/
       b=b+1;
       if(b==k){
	 break;
       } 
       c=c+1;
      }}else if(a[i-1][j]%10==0){
	 for(l=1;l<=2;l++){
	   a[i][c]=10*a[i-1][j]+a[i-1][j]%10+(l-1);
	   /*printf("%lld\t",a[i][c]);*/
	   b=b+1;
	   if(b==k){
	     break;
	   } 
	   c=c+1;
       }
       }else{
	 for(l=0;l<=1;l++){
	 a[i][c]=10*a[i-1][j]+a[i-1][j]%10+(l-1);
	 /*printf("%lld\t",a[i][c]);*/
	 b=b+1;
	 if(b==k){
	   break;
	 }
	 c=c+1;
         }
       }
       if(b==k){
         break;
       }
   }
   p=i;
   /*printf("%lld %lld\n",c,b);*/
   if(b==k){
     break;
   }
   /*if(i==3){
     break;
     }*/
 }
 printf("%lld\n",a[p][c]);
 }
 return 0;
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <math.h>
#include <time.h>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>

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 answer(formula) formula ? cout << "Yes" << endl : cout << "No" << endl
#define ANSWER(formula) formula ? cout << "YES" << endl : cout << "NO" << endl

#define PI M_PI
#define INF 1050000000
#define MOD 1000000007
#define EPS (1e-10)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<bool>> vvb;
typedef vector<vector<string>> vvs;

constexpr int dir[4][2] = { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };

ll Pow(ll a, ll b, ll mod) {
	ll x = 1;
	while (b > 0) {
		if (b & 1) x = x * a;
		a = a * a;
		b = b >> 1;
	}
	return x;
}


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


int main()
{
	int c[3][3];
	rep(i, 3) rep(j, 3) cin >> c[i][j];

	int a[3];
	rep(i, 3) {

		int cnt = 0;
		rep(j, 3) {
			if (c[i][0] <= c[j][0] && c[i][1] <= c[j][1] && c[i][2] <= c[j][2]) {
				cnt++;
			}
		}

		if (cnt == 3) {
			rep(j, 3) a[j] = c[i][j];
		}
	}

	rep(i, 3) {
		c[i][0] -= a[0];
		c[i][1] -= a[1];
		c[i][2] -= a[2];
	}

	int cnt = 0;
	rep(i, 3)
	{
		if (c[0][0] == c[0][i] && c[1][0] == c[1][i] && c[2][0] == c[2][i]) cnt++;
	}

	answer(cnt == 3);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000005
#define MOD (ll)(1e9+7)
#define INF INT32_MAX
#define INFL INT64_MAX
using namespace std;

void solve()	{
	int n,m;
	cin >> n >> m;
	pair<int,int>	s[n], cp[m];
	for(int i=0; i<n; i++)	{
		int x,y;
		cin >> x >> y;
		s[i] = {x,y};
	}
	for(int i=0; i<m; i++)	{
		int x,y;
		cin >> x >> y;
		cp[i] = {x,y};
	}
	for(int i=0; i<n; i++)	{
		int mx = INF,ans;
		for(int j=0; j<m; j++)	{
			if(mx>abs(s[i].first-cp[j].first)+abs(s[i].second-cp[j].second))	{
				ans = j+1;
				mx = abs(s[i].first-cp[j].first)+abs(s[i].second-cp[j].second);
			}
		}
		cout << ans << endl;
	}
}

int main()	
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin >> t;
	for(int i=1; i<=t; i++)	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int read()
{
   int x=0,f=1;char ch=getchar();
   while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
   while (ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
   return x*f;
}

int cnt,head[N],a[N],b[N],id[N],u,v,fa[N],n,m,x,vis[N];
long long f[N],bsum[N];
struct node{int to,next;}num[N*2];
void add(int x,int y) {num[++cnt].to=y;num[cnt].next=head[x];head[x]=cnt;}
bool cmp(int A,int B) {return a[A]<a[B];}
int getfather(int x) {return fa[x]?fa[x]=getfather(fa[x]):x;}
int main()
{
	n=read();m=read();
	for (int i=1;i<=n;i++) a[i]=read(),b[i]=read(),a[i]=max(a[i]-b[i],0),id[i]=i;
	for (int i=1;i<=m;i++) u=read(),v=read(),add(u,v),add(v,u);
	sort(id+1,id+n+1,cmp);
	for (int i=1;i<=n;i++)
	{
		x=id[i];vis[x]=1;f[x]=a[x];bsum[x]=b[x];
		for (int j=head[x];j;j=num[j].next)
		  if (vis[num[j].to])
		  {
		  	  int y=getfather(num[j].to);
		  	  if (x==y) continue;
		  	  fa[y]=x;bsum[x]+=bsum[y];
		  	  f[x]=min(f[x],max(f[y],a[x]-bsum[y]));
		  }
	}
	printf("%lld\n",bsum[id[n]]+f[id[n]]);
    return 0;
}

Measured memory_bytes: 5760
#include<cstdio>

int n,m,l,k;

void solve(int p, int d){

  if(p == m){
    printf("%d\n",p);
    return;
  }

  printf("%d ", p);

  if(p == 9) solve(5, 0);
  else if(!p || d) solve(p+1, 1);
  else solve(p-1, 0);

}

int main(){

  scanf("%d", &l);

  while( l-- ){

    scanf("%d %d",&n, &m);

    if(n == 9 || (n < 6 && n > m)) k = 0;
    else k = 1;
    
    solve(n, k);

  }

}

Measured memory_bytes: 1024
import java.util.Scanner;

/**
 * https://abc064.contest.atcoder.jp/tasks/abc064_c
 */
public class Main {

	public static void main(String[] args) {
		
		int[] kind = new int[9];
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for(int i=0; i<N; i++){
			int c = sc.nextInt();
			kind[Math.min(8,c/400)]++;
		}
		sc.close();
		
		int ans = 0;
		for(int i=0; i<8; i++){
			if(kind[i]>0){
				ans++;
			}
		}		
		int min = Math.max(1, ans);
		int max = ans+kind[8];
		System.out.println(String.format("%d %d", min, max));

	}

}


Measured memory_bytes: 21972
#include<iostream>
#include<string>
using namespace std;
static const int MAX_N = 1000;
static const int MOD = 10007;

int N;
string S;
int memo[1 << 3][1 << 3][MAX_N];
int main(){
	cin >> N >> S;
	
	for(int i = 0; i < N; i++){
		for(int j = 1; j < (1 << 3); j++){
			for(int k = 1; k < (1 << 3); k++){
				if((S[i] == 'J' && !(k & (1 << 2))) || (S[i] == 'O' && !(k & (1 << 1))) || (S[i] == 'I' && !(k & 1))) continue;
				if(i == 0){
					if(!(k & (1 << 2))) continue;
					memo[0][k][i] = 1;
				}else{
					if(!(j & k)) continue;
					for(int l = 0; l < (1 << 3); l++){
						memo[j][k][i] += memo[l][j][i - 1];
						memo[j][k][i] %= MOD;
					}
				}
			}
		}
	}
	
	int res = 0;
	for(int i = 0; i < (1 << 3); i++){
		for(int j = 0; j < (1 << 3); j++){
			res += memo[i][j][N - 1];
			res %= MOD;
		}
	}
	cout << res << endl;
	return 0;
}


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

int n,s,l,p,m,w;
int dp[400];
int ans[400];

int main(){
  cin >> n;
  memset(dp,-1,sizeof(dp));
  dp[0] = 0;

  for(int i=0;i<n;i++){
    cin >> s >> l >> p;
    for(int j=0;j<=393;j++){
      if(dp[j]>=0){
	for(int k=s;k<=l;k++){
	  if(j+k>393)break;
	  dp[j+k] = max(dp[j+k], dp[j] + p);
	}
      }
    }
  }

  cin >> m;
  for(int i=0;i<m;i++){
    cin >> w; ans[i] = dp[w];
    if(ans[i]==-1){
      cout << -1 << endl;
      return 0;
    }
  }

  for(int i=0;i<m;i++)cout << ans[i] << endl;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <math.h>
#include <limits>
#include<bits/stdc++.h> 


using namespace std;

int main()
{
   
   int N;
   cin>>N;
   
   if(N<4)
   	cout<<"No";
   else
   {
   	int x=1,y=1;
   	int flag = 0;
   	for(x=0;x<=N/4;x++)
   	{
   		for(y=0;y<=N/7;y++)
   		{
   			if( (4*x + 7*y )==N )
   			{
   				flag = 1;
				break;	   			
   			}
   		}
   		if(flag==1)
   			break;
   	}
   	
   	if(flag==1)
   		cout<<"Yes";
   	else
   		cout<<"No";
   }
   
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
 
const int N=505;
char a[N][N],t[N][N],p[N][N],q[N][N];
int32_t main(){
    int n,m;
    cin>>n>>m;
    forn(i,n)forn(j,m){
        cin>>a[i][j];
        if(a[i][j]=='#'){
            t[i][j]='#';
        }else{
            if(i==0)t[i][j]='1';
            else if(i==n-1)t[i][j]='2';
            else if(j==0)t[i][j]='2';
            else if(j==m-1)t[i][j]='1';
            else if(i&1)t[i][j]='2';
            else t[i][j]='1';
        }
        p[i][j]=q[i][j]='.';
        if(t[i][j]=='#')p[i][j]=q[i][j]='#';
        if(t[i][j]=='1')p[i][j]='#';
        if(t[i][j]=='2')q[i][j]='#';
    }
    forn(i,n){
        forn(j,m)cout<<p[i][j];
        cout<<'\n';
    }
    cout<<'\n';
    forn(i,n){
        forn(j,m)cout<<q[i][j];
        cout<<'\n';
    }

    return 0;
}

Measured memory_bytes: 4668
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))
    res = 0
    for i in range(n):
        res += A[-(i + 1) * 2]

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 119520
package main

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

func lib_CountIntAsList(values []int, max int) []int {
	m := make([]int, max, max)
	for _, value := range values {
		m[value]++
	}
	return m
}
func lib_Pow10Int(y int) int {
	return int(math.Pow10(int(y)))
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	A := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		A[i], _ = strconv.Atoi(scanner.Text())
	}
	var Q int
	scanner.Scan()
	Q, _ = strconv.Atoi(scanner.Text())
	B := make([]int, Q)
	C := make([]int, Q)
	for i := 0; i < Q; i++ {
		scanner.Scan()
		B[i], _ = strconv.Atoi(scanner.Text())
		scanner.Scan()
		C[i], _ = strconv.Atoi(scanner.Text())
	}
	solve(N, A, Q, B, C)
}
func solve(N int, A []int, Q int, B []int, C []int) {
	counter := lib_CountIntAsList(A, lib_Pow10Int(5)+1)
	cnt := 0
	for i, c := range counter {
		cnt += i * c
	}
	for i := 0; i < Q; i++ {
		bCnt := counter[B[i]]
		cnt -= bCnt * B[i]
		cnt += bCnt * C[i]
		counter[B[i]] = 0
		counter[C[i]] += bCnt
		fmt.Println(cnt)
	}
}


Measured memory_bytes: 7008
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200010;
int n,l[MAXN],r[MAXN];
int main () {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d%d",&l[i],&r[i]);
	}
	sort(l+1,l+n+1);
	sort(r+1,r+n+1);
	if (n&1) {
		printf("%d\n",r[n/2+1]-l[n/2+1]+1);
	} else {
		printf("%d\n",r[n/2]+r[n/2+1]-l[n/2]-l[n/2+1]+1);
	}
	return 0;
}

Measured memory_bytes: 5284
using System;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            int k = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            if (k < s.Length)
            {
                Console.WriteLine(s[0..k] + "...");
            }
            else
            {
                Console.WriteLine(s);
            }
        }
    }
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n, a, b;
    cin >> n >> a >> b;

    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int ans = 0, start = v[0];
    for (int i = 1; i < n; i++) {
        ans += min((v[i] - start) * a, b);
        start = v[i];
    }
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1024
//__n1colai__
#include <bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define vi vector<int>
#define pb emplace_back
#define w(t)   int t;cin>>t;while(t--)
#define show(ar) for(int i=0;i<ar.size();i++) cout<<ar[i]<<" "; cout<<endl;
#define mod 1e9+7
#define ff first
#define ss second
#define fio ios::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
#define all(x) (x.begin(),x.end())
#define inf 1e9+7
#define MAX 90000000
#define ll long long


vi inp(int n)
{
	vi v; int x;
	for(int i=0;i<n;i++) {
		cin>>x; v.pb(x);
	}
	return v;
}


int main()
{
	fio
	int n,k; cin>>n>>k;
	vi ar=inp(n);
	int sum=0;
	sort all(ar);
	for(int i=0;i<k;i++) sum+=ar[i];
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3660
a, b, c, x, y = map(int, input().split())

cost = 0
if (a + b) / 2 > c:
    cost = 2 * c * min(x, y)
    cost += min(a, 2 * c) * max(0, x - y) + min(b, 2 * c) * max(0, y - x)
else:
    cost = a * x + b * y

print(cost)

Measured memory_bytes: 38384
#include<stdio.h>
int main(){
    int i,n,u,p,x,k[5][14]={0},s[52];
    char t;
    scanf("%d",&n);
    for(i=1;i<=n;i+=1){
        scanf(" %c%d",&t,&s[i]);
        x=s[i];
        if(t=='S'){
            k[1][x]=1;
        }
        else if(t=='H'){
            k[2][x]=1;
        }
        else if(t=='C'){
            k[3][x]=1;
        }
        else if(t=='D'){
            k[4][x]=1;
        }
    }
    for(u=1;u<=4;u+=1){
        for(p=1;p<=13;p+=1){
            if(u==1){
                if(k[1][p]!=1){
                    printf("S %d\n",p);
                }
            }
            else if(u==2){
                if(k[2][p]!=1){
                    printf("H %d\n",p);
                }
            }
            else if(u==3){
                if(k[3][p]!=1){
                    printf("C %d\n",p);
                }
            }
            else if(u==4){
                if(k[4][p]!=1){
                    printf("D %d\n",p);
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 596
while True :
    m, f, r = map(int, input().split())
    s = m + f
    if m == f == r == -1 :
        break
    if m == -1 or f == -1 or s < 30 :
        print('F')
    elif s >= 80 :
        print('A')
    elif s >= 65 :
        print('B')
    elif s >= 50 or r >= 50 :
        print('C')
    else :
        print('D')


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 int main(){
   long long n;
   cin >> n;
    long long sum=0;
    vector<long long> a(n);
   rep(i,n){
    cin >> a[i];
    sum+=a[i];
   }
    // rep(i,n){
    //   //  cout << a[i] << endl;
    // }

   long long sa=0;
   long long sumf=a[0];
   long long sumsu=a[n-1];
   
   int j=2;
   int d=1;
   rep(i,n-2){
       if(sumf>sumsu){
         sumsu+=a[n-j];
       //  cout << sumsu << "su" << endl;
         j++;
       }
       else{
           sumf+=a[d];
           //cout << sumf << "f" << endl;
           d++;
       }
     
//        sumh+=a[i];
//     if(abs((sum/2)-sumh)<sa && sumh+a[i+1]-sum/2>0){
//         sa=abs(sum-sumh);
//    }
// if(i+1==n/2 && abs(sum/2-(sumh+a[i+1])<sa) && sumh+a[i+1]-sum/2>0){
//     sa=abs(sum/2-(sumh+a[i+1]));
// }
// if(sum==sumh*2){
//     sa=0;
// }
   }
   sa=abs(sumf-sumsu);
   if(sumf==sumsu){
       sa=0;
   }
  cout << sa << endl;
   return 0;
 }

Measured memory_bytes: 4844
/* 
 * Project: AtCoder Beginners Contest 170 A - Five Variables
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/14
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
using namespace std;

int n;
int r;

void solve() {
    
    if (n > 10) {
        printf("%d\n", r);
        return;
    }
    printf("%d\n", r+100*(10-n));

}

int main() {

    scanf("%d", &n);
    scanf("%d", &r);

    solve();

}

Measured memory_bytes: 3212
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();

    if ((B / A) < C) {
      System.out.println(B / A);
    } else {
      System.out.println(C);
    }

  }
}

Measured memory_bytes: 23764
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {

    int n, m; cin >> n >> m;
    bool f[n+1]; rep(i,n+1) f[i] = false;
    int cnt[n+1]; rep(i,n+1) cnt[i] = 1;
    f[1] = true;

    rep(i,m) {
        int x, y; cin >> x >> y;
        if (f[x]) {
            f[y] = true;
        }
        --cnt[x];
        ++cnt[y];
        if (cnt[x] == 0) f[x] = false;
    }

    int ans = 0;
    rep(i,n+1) {
        if (f[i]) ++ans;
    }
    out(ans);

    return 0;
}









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

int main(){
int A[3];
int z = 0;
for(int i= 0;i<3;i++){
    cin >> A[i];
    z +=A[i];
}
if(z>=22){
    cout << "bust"<<endl;
}else{
    cout << "win" <<endl;
}
}

Measured memory_bytes: 256
a,b,c=map(int,raw_input().split())
if a+b >= c:
    print "No"
else:
    ans1 = 4 * a * b;
    ans2 = (c - a - b) * (c - a - b)
    if ans1 < ans2:
        print "Yes"
    else:
        print "No"

Measured memory_bytes: 2568
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n, m;
string s;
char tmp[maxn];
int ls[maxn], rs[maxn];

int read() {
  if (scanf("%s", tmp) < 1) {
    return false;
  }
  s = tmp;
  n = sz(s);
  scanf("%d", &m);
  int m0 = 0;
  for (int i = 0; i < m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    l--;
    if (n & 1) {
      if (l <= n / 2 && r > n / 2) {
        if (n / 2 - l > r - n / 2 - 1) {
          r = n - r;
        } else {
          l = n - l;
        }
      }
    } else {
      if (l < n / 2 && r > n / 2) {
        if (n / 2 - l > r - n / 2) {
          r = n - r;
        } else {
          l = n - l;
        }
      }
    }
    if (l < r) {
      if (l < n / 2) {
        ls[m0] = l;
        rs[m0] = r;
      } else {
        ls[m0] = n - r;
        rs[m0] = n - l;
      }
      m0++;
    }
  }
  m = m0;
  return true;
}

int go[maxn];
vector<int> g[maxn];
int val[maxn];
int p[maxn], ts[maxn];
set< pair<int, int> > st[maxn];

int get(int x) {
  return x == p[x] ? x : p[x] = get(p[x]);
}

void unite(int x, int y) {
  x = get(x);
  y = get(y);
  if (x == y) {
    return;
  }
  if (ts[x] < ts[y]) {
    swap(x, y);
  }
  p[y] = x;
  ts[x] += ts[y];
  for (auto it = st[y].begin(); it != st[y].end(); it++) {
    st[x].insert(*it);
  }
  st[y].clear();
}

void solve() {
  for (int i = 0; i <= n / 2; i++) {
    go[i] = -1;
    p[i] = i;
    ts[i] = 1;
    st[i].clear();
  }
  for (int i = 0; i < m; i++) {
    st[ls[i]].insert(make_pair(rs[i], i));
  }
  for (int i = 0; i < n / 2; i++) {
    int id = get(i);
    if (st[id].empty()) {
      continue;
    }
    go[i] = st[id].begin()->first;
    while (!st[id].empty() && st[id].begin()->first == go[i]) {
      st[id].erase(st[id].begin());
    }
    unite(i, go[i]);
  }
  for (int i = 0; i <= n / 2; i++) {
    g[i].clear();
  }
  for (int i = 0; i < n / 2; i++) {
    g[go[i]].push_back(i);
  }
  int cur = 0;
  for (int i = 0; i < n / 2; i++) {
    for (int j = 0; j < sz(g[i]); j++) {
      cur = (cur + 26 - val[g[i][j]]) % 26;
    }
    int d = ((int) s[i] + 26 - (int) s[n - i - 1]) % 26;
    if (go[i] == -1) {
      if (d != cur) {
        printf("NO\n");
        return;
      }
      continue;
    }
    val[i] = (d + 26 - cur) % 26;
    cur = (cur + val[i]) % 26;
  }
  printf("YES\n");
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

using namespace std;

#define MAXN 1005
#define INF (1LL << 30)

char m[MAXN][MAXN];
long long dist[MAXN][MAXN];
    
int r, c;
int sx, sy;
int dx, dy;

int dirx[] = { 0, 0, -1, 1 };
int diry[] = { -1, 1, 0, 0 };

bool check(int x, int y)
{
    return (x >= 1 and x <= r and y >= 1 and y <= c and m[x][y] == '.');
}

void bfs(int x, int y)
{
    deque<pair<int,int>> q;
    q.push_front({ x, y });
    dist[x][y] = 0;
    
    while (not q.empty())
    {
        pair<int,int> cur = q.front();
        q.pop_front();
        
        x = cur.first;
        y = cur.second;
        
        for (int i = 0; i < 4; i++) {
            if (check(x + dirx[i], y + diry[i])) {
                if (dist[x + dirx[i]][y + diry[i]] > dist[x][y]) {
                    dist[x + dirx[i]][y + diry[i]] = dist[x][y];
                    q.push_front({ x + dirx[i], y + diry[i] });
                }
            }
        }
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                if (check(x + i, y + j)) {
                    if (dist[x + i][y + j] > dist[x][y] + 1) {
                        dist[x + i][y + j] = dist[x][y] + 1;
                        q.push_back({ x + i , y + j });
                    }
                }
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    cin >> r >> c;
    cin >> sx >> sy;
    cin >> dx >> dy;
    
    for (int i = 1; i <= r; i++) {
        for (int j = 1; j <= c; j++) {
            cin >> m[i][j];
            dist[i][j] = INF;
        }
    }
    
    bfs(sx, sy);

    cout << (dist[dx][dy] == INF ? -1 : dist[dx][dy]) << '\n';
    
    return 0;
}


Measured memory_bytes: 12564
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>

using namespace std;

int main(){
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    A *= 100;
    B *= 100;
    int water;
    int suger, max_suger = 0;
    int all, max_all = 0;
    double dens, max_dens = -1.0;
    double limit_dens = E / (100.0 + E);
    
    
    for(int a = 0; a <= F; a += A){
        for(int b = 0; a + b <= F; b += B){
            water = a + b;
            for(int c = ((F - (water)) / C) * C; c >= 0; c -= C){
                for(int d = ((F - (water + c)) / D) * D; d >= 0; d -= D){
                    suger = c + d;
                    all = water + suger;
                    dens = suger * 1.0 / all;
                    if(dens > limit_dens) continue;
                    if(max_dens < dens){
                        max_all = all;
                        max_suger = suger;
                        max_dens = dens;
                        break;
                    }
                }
            }
        }
    }



    cout << max_all << " " << max_suger << endl;
    return 0;
}


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

int main(int argc, char *argv[]){
  int N;
  std::cin >> N;
  std::vector<int> d(N);
  for(auto &_d: d){
    std::cin >> _d;
  }
  std::sort(d.begin(), d.end());
  int ts = d[d.size()/2-1];
  int te = d[d.size()/2];
  std::cout << te - ts << std::endl;
  return 0;
}

Measured memory_bytes: 640
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-04-19 21:04:09
 * @LastEditTime: 2020-04-19 21:06:06
 * @FilePath: \VSC\C++\Practice\AC abc163 C.cpp
 */
#include<bits/stdc++.h>
using namespace std;

int n;
int a[200005];
signed main(){
    scanf("%d",&n);
    register int i;

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

    for(i=1;i<=n;++i) printf("%d\n",a[i]);
    return 0;
}

Measured memory_bytes: 4496
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define FOR(i, N) for (long i = 0; i < (N); i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<long> A(N);
    vector<long> Sum(N, 0);
    FOR(n, N) {
        cin >> A[n];
    }

    for (int n = N - 2; n >= 0; n--) {
        Sum[n] = (Sum[n + 1] + A[n + 1]) % MOD;
    }

    long ans = 0;
    FOR(n, N - 1) {
        ans = (ans + (A[n] * Sum[n]) % MOD) % MOD;
    }

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


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

bool is_integer(double x) {
    return floor(x)==x;
}

int main() {
    string a,b,c;
    cin>>a>>b;
    c=a+b;
    double res=stod(c);
    res=sqrt(res);
    if (is_integer(res)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
} 


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int m,f,b;
    cin>>m>>f>>b;

    if(m+f<b)cout<<"NA"<<endl;
    else if(m>=b)cout<<0<<endl;
    else cout<<b-m<<endl;
    return 0;
}

Measured memory_bytes: 3072
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m,q = inpm()
ans = 0
abcd = []
for _ in range(q):
    a,b,c,d = inpm()
    abcd.append((a,b,c,d))

for e in itertools.combinations_with_replacement(range(m),n):
    cnt = 0
    for i in range(q):
        [a,b,c,d] = abcd[i]
        if e[b-1] - e[a-1] == c:
            cnt += d
    ans = max(ans,cnt)
print(ans)

Measured memory_bytes: 31232
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
n,m=map(int,input().split())
uf=UnionFind(n)
l=[]
ans=0
for i in range(m):
  a,b=map(int,input().split())
  l.append([a,b])
for i in range(m):
  for j in range(m):
    if i!=j:
      uf.union(l[j][0]-1,l[j][1]-1)
  if uf.group_count()!=1:
    ans+=1
  uf.__init__(n)
print(ans)


Measured memory_bytes: 68352
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long X = in.nextLong();
		long Y = in.nextLong();
		List<Long> list = new ArrayList<>();
		for (long i = X; i <= Y; i *= 2) {
			list.add(i);
		}
		System.out.println(list.size());
		in.close();
	}
}

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

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

ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; }

int n;
int ett[1001];
vector <int> p;
map <int, int> mp;

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

	for (int i = 2; i <= 1000; i++)
	{
		if (ett[i]) continue;
		for (int j = i + i; j <= 1000; j += i)
			ett[j] = 1;
	}

	for (int i = 2; i <= 1000; i++)
	{
		if (!ett[i]) p.push_back(i);
	}

	int g = 0;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int a; cin >> a;
		g = gcd(g, a);

		int ta = a;
		for (int j : p)
		{
			if (a % j) continue;
			mp[j]++;

			while (a % j == 0) a /= j;
		}

		if (a != 1) mp[a]++;
	}

	if (g != 1)
	{
		cout << "not coprime";
	}
	else
	{
		bool flag = 0;
		for (auto it : mp)
		{
			if (it.second > 1) flag = 1;
		}

		if (flag) cout << "setwise coprime";
		else cout << "pairwise coprime";
	}
}

Measured memory_bytes: 7344
while 1:
    n,k,m=map(int,input().split())
    if not n and not k and not m:break
    l=list(range(1,n+1))
    p=l.index(m)
    while len(l)>1:
        l.pop(p)
        p=(p+k-1)%len(l)
    print(l[0])



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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   int a,b;
   cin>>a>>b;
   if(a<=5)b=0;
   else if(a<=12)b/=2;
   cout<<b;
      return 0;
}


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

int main(){
	while(1){	
		int n;
		scanf(" %d", &n);
		if(n==0) break;
		
		int ans=0;
		
		for(int a=0; a*a<=n; ++a){
			int p=a*a;	
			for(int b=a; p+b*b<=n; ++b){
				int q=b*b;
				for(int c=b; p+q+c*c<=n; ++c){
					int r=c*c;
					int s=n-p-q-r;
					
					double sq=sqrt(s);
					if(sq>=c && sq-(int)sq==0){
						//printf("%d,%d,%d,%f\n", a, b, c, sq);
						ans++;
					}
					
				}
			}
		}	
		
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1188
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	int total = 0;
	for (int i = 0; i < N; i++) {
		total += (i + 1);
	}
	cout << total << endl;
	
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

char c;

int main() {
	cin >> c;
	if (c=='a' || c=='i' || c=='u' || c=='e' || c=='o') cout << "vowel" << ln;
	else cout << "consonant" << ln;
}

Measured memory_bytes: 256
using System;

namespace ABC070_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var T = new long[N];

            for (int i = 0; i < N; i++)
            {
                T[i] = long.Parse(Console.ReadLine());
            }

            Console.WriteLine(Lcm(T));
        }

        private static long Lcm(long[] t)
        {
            var lcm = t[0];
            for (int i = 1; i < t.Length; i++)
            {
                lcm = lcm / Gcd(lcm, t[i]) * t[i];
            }

            return lcm;
        }

        public static long Gcd(long x, long y)
        {
            return (y == 0) ? x : Gcd(y, (x % y));
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}


	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long a[] = new long[n];
		long sum = 0;
		for(int i=0; i<n; i++) {
			a[i]=sc.nextLong();
			a[i]--;
			sum += a[i];
		}
		System.out.println(sum);
		sc.close();
	}


}


Measured memory_bytes: 25576