akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n, m; cin >> n >> m;
  int MOD = 1e9 + 7;
  vector<ll> hoge(n + 1);
  vector<int> ng(n + 1);
  // vector<int> M(m);
  int tmp;
  rep_i(i, m){
    cin >> tmp;
    ng[tmp] = 1;
  }
  hoge[0] = 1;
  // if(n >= 2){
    // if(!ng[2]){
    //   hoge[2] = 2;
    // }
  if(!ng[1]){
    hoge[1] = 1;
  }

  for (int i = 2; i < n + 1; i++){
    if(ng[i]){
      continue;
    }
    if(!ng[i - 1] && !ng[i - 2]){
      hoge[i] = (hoge[i - 1]%ll(MOD) + hoge[i - 2]%ll(MOD))%ll(MOD);
    }else if(!ng[i - 1]){
      hoge[i] = hoge[i - 1]%ll(MOD);
    }else if(!ng[i - 2]){
      hoge[i] = hoge[i - 2]%ll(MOD);
    }
    hoge[i] %= ll(MOD);
  }
  // }

  cout << hoge[n] % ll(MOD) << endl;
  // for (int i = 0; i < m - 1; i++){
  //   /* code */
  //   if(M[i] + 1 == M[i + 1]){
  //     say(0);
  //     return 0;
  //   }
  // }

  // int p = 0;
  // int sum = 0;
  // int a, b;
  // for (int i = 0; i < m; i++){
  //   a = (M[i] - 1) - p;
  //   b = 0;
  //   while(a >= 0){
  //     // combの処理
  //     if(a*b == 0){
  //       sum += 1;
  //     }else{
  //       int bunbo = 1;
  //       int bunshi = 1;
  //       for (int i = 0; i < b; i++){
  //         bunbo *= ((a+1) - i);
  //         bunbo %= MOD;
  //       }
  //       for (int i = 0; i < b; i++){
  //         bunshi *= (b - i)%MOD;
  //         bunshi %= MOD;
  //       }
  //       sum += bunbo/bunshi;
  //     }
  //     a -= 2;
  //     b += 1;
  //   }
  //   p = M[i] + 1;
  // }
  // if(p == n){
  //   cout << sum << endl;
  // }else{
  //   a = (n - 1) - p;
  //   b = 0;
  //   while(a >= 0){
  //     // combの処理
  //     if(a*b == 0){
  //       sum += 1;
  //     }else{
  //       int bunbo = 1;
  //       int bunshi = 1;
  //       for (int i = 0; i < b; i++){
  //         bunbo *= ((a+1) - i);
  //       }
  //       for (int i = 0; i < b; i++){
  //         bunshi *= (b - i);
  //       }
  //       sum += bunbo/bunshi;
  //     }
  //     a -= 2;
  //     b += 1;
  //   }
  //   cout << sum << endl;
  // }
}

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

int main() {
	map<P, int>mp;
	int n, f; cin >> n >> f;
	rep(i, n) {
		int m; cin >> m;
		vector<string>v(m);
		rep(i, m)cin >> v[i];
		rep(i, m)for (int j = i + 1; j < m; j++)
			mp[P(min(v[i], v[j]), max(v[i], v[j]))]++;
	}
	vector<P>v;
	for (auto p : mp) {
		if (p.second >= f)v.push_back(p.first);
	}
	cout << v.size() << endl;
	for (P p : v)cout << p.first << ' ' << p.second << endl;
}

Measured memory_bytes: 3524
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int sum;
	int m,f,r;



	for(;;){
	    
	scanf("%d%d%d", &m, &f,&r);
	 if(m!=-1&&f!=-1)
	 sum=m+f;
	 
	  if(m==-1&&f==-1)
	     break;
	     
	  if(m==-1||f==-1) 
	     printf("F\n");
	     
	     if(m!=-1&&f!=-1){
	  if(sum>=80)
	    printf("A\n");
	  if(sum<80&&sum>=65)
	    printf("B\n");
	  if(sum<65&&sum>=50)
	    printf("C\n");
	  if(sum<50&&sum>=30&&r<50)
	    printf("D\n");
	  if(sum<50&&sum>=30&&r>=50)
	    printf("C\n");
	   if(sum<30)
	      printf("F\n");
}
	}
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<vector<long long>> matrix;

#define F 						first
#define S 						second
#define PB 						push_back
#define MP 						make_pair
#define all(c) 					c.begin(), c.end()
#define f(i,a,b) 				for(ll i=a; i<b; i++)
#define rep(i,n) 				f(i,0,n)
#define tr(c,i) 				for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) 			(c.find(x) != c.end())	//for set and map
#define cpresent(c,x) 			(find(all(c),x) != c.end())	//for vectors
#define w(t)					ll t; cin>>t; while(t--)
#define epsilon 				1e-9
#define MOD						(ll)1e9

void doublade() {
	ios::sync_with_stdio(false); cin.tie(0); cout.precision(10);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	doublade();
	// w(t) {
		ll n, x, t;
		cin >> n >> x >> t;
		ll p = n/x, q = n%x;
		ll time = t*p;
		if(q!=0) time += t;
		cout<<time<<"\n";
	// }
	return 0;
}

Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Run(args));
        }

        private static int Run(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            return (int)Math.Pow(n, 3);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>
#include<cstdint>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}



int atcoder(){
    int h,w;
    cin>>h>>w;
    vector< vector<int> > road(10,vector<int>(10));
    REP(i,0,10) REP(j,0,10) cin>>road[i][j];
    vector< vector<int> > board(h,vector<int>(w));
    REP(i,0,h) REP(j,0,w) cin>>board[i][j];
    Vi dist(10,INT_MAX/3);
    Vi used(10,0);

    priority_queue< Pii,vector<Pii>,greater<Pii> > q;
    q.push(make_pair(0,1));
    while(q.size()>0){
        int nowdist = q.top().first;
        int now = q.top().second;
        q.pop();
        if(nowdist>dist[now]) continue;
        dist[now]=nowdist;
        used[now]=1;
        REP(i,0,10) if(used[i]==0) q.push(make_pair(nowdist+road[i][now],i));
    }

    
    int ans=0;
    REP(i,0,h) REP(j,0,w) ans+=dist[board[i][j]];
    cout<< ans << ENT;
    return 0;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

ll insertionSort(vl &a,ll n,ll g){
    ll cnt=0;
    fore(i,g,n-1){
        ll v=a[i];
        ll j=i-g;
        while(j>=0&&a[j]>v){
            a[j+g]=a[j];
            j-=g;
            cnt++;
        }
        a[j+g]=v;
    }
    return cnt;
}

void shellSort(vl &a,ll n){
    ll cnt=0;
    vl g;
    ll b=1;
    while(b==1||b<n)g.push_back(b),b=3*b+1;
    reverse(all(g));
    ll m=g.size();
    rep(i,m){
        cnt+=insertionSort(a,n,g[i]);
    }
    cout<<m<<endl;
    rep(i,m){
        if(i>0)cout<<" ";
        cout<<g[i];
    }
    cout<<endl;
    cout<<cnt<<endl;
}

void solve(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];
    shellSort(a,n);
    rep(i,n)cout<<a[i]<<endl;
    cout<<endl;
}

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



Measured memory_bytes: 10744
import java.io.*;
 
public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        String[] cut = input.split(" ");
        int surface = Integer.parseInt(cut[0]);
        int length = Integer.parseInt(cut[1]);
        System.out.println(surface * length + " " + 2 * ( surface + length ));
    }
}


Measured memory_bytes: 24196
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const ll mod = 1e9 + 7 ;
const ll inf =
 1e9 + 5 ;
 //1e18L + 5;
const ll nax = 2e5 + 5;
void min_self(ll&a , ll b){a=min(a,b);}
void max_self(ll&a , ll b){a=max(a,b);}
void add_self(ll&a , ll b){a=(a+b)%mod;}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll n , m ; cin >> n >> m ; 
if(n < m){
	for(int i = 0 ; i<m ; i++){
		cout << n;
	}
}
else{
	for(int i = 0 ; i<n ; i++){
		cout <<m;
	}
}

	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node{
  int key;
  struct node *left;
  struct node *right;
  struct node *parent;
};
typedef struct node * Node;
#define NIL NULL
Node root = NIL;

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

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
return 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);
}

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

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  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;
  z->parent = NIL;
  while(x != NIL)
    {
      y = x;
      if(z->key < x->key)
	{
	  x = x->left;
	}
      else
	x = x->right;

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

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


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

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




Measured memory_bytes: 20460
#include<stdio.h>
int main()
{
     long int x,i,j;
    scanf("%li",&x);
    for(i=0;x>=0;i++)
    {    if(x<500)
            break;

        x=x-500;

    }
    for(j=0;x>=5;j++)
    {
         if(x<5)
            break;
        x=x-5;

    }
    printf("%li",((1000*i)+(5*j)));

}


Measured memory_bytes: 128
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n"),t=r[0],n=t.length,o=r[1],u=o.length,i=-1,l=n-u;l>=0;l--){for(var f=!0,c=0;c<u;c++)t[l+c]!=o[c]&&"?"!=t[l+c]&&(f=!1);if(f){i=l;break}}if(-1==i||u>n)console.log("UNRESTORABLE");else{var a=t.slice(0,i)+o+t.slice(i+u);a=a.replace(/\?/g,"a"),console.log(a)}}},function(e,r){e.exports=require("fs")}]);

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

using namespace std;

int cnt;

int solve(int n, long long curr, bool tri, bool pet, bool sedam){
	if(curr > n) return 0;
	if(tri && pet && sedam && curr <= n) cnt++;
	solve(n, curr * 10 + 3, 1, pet, sedam);
	solve(n, curr * 10 + 5, tri, 1, sedam);
	solve(n, curr * 10 + 7, tri, pet, 1);
}

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);

    int n;
    cin >> n;
    solve(n, 3, 1, 0, 0), solve(n, 5, 0, 1, 0), solve(n, 7, 0, 0, 1);
    cout << cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n; cin >> n;
	map<ll, ll> m;
	for(ll i = 0; i < n; ++i){
		ll a; cin >> a;
		++m[a];
	}
	ll ans = 0;
	for(auto ite = m.begin(); ite != m.end(); ++ite){
		if(ite->first > ite->second) ans += ite->second;
		else if(ite->first < ite->second) ans += ite->second - ite->first;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
int main(){
   int A,B;
  cin>>A>>B;
  if(A<=5)
    cout<<0<<endl;
  else if(6<=A && A<=12)
    cout<<B/2<<endl;
  else
    cout<<B<<endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  vector<long long> vec(n);
  long long ans=0;
  for(long long i=0;i<n;++i) cin>>vec[i];
  for(long long i=0;i<n;++i){
    if((i+1)%2==1){
      if(vec[i]%2==1){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3624
#include <cstdio>
char s[100001];
int main(){
  scanf("%s", s);
  int n[2] = {};
  for(int i = 0; s[i] != '\0'; i++){
    n[s[i] - '0']++;
  }
  if(n[0] < n[1]){
    printf("%d\n", 2*n[0]);
  }else{
    printf("%d\n", 2*n[1]);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    
    int N;
    string s, t;
    cin >> N >> s >> t;
    
    long int ans[26];
    for(int i = 0; i < 26; i++) {
        ans[i] = 0;
    }

    ans[s[0]-'a'] = 1;
    for(int i = 1; i < N-1; i++) {
      ans[s[i]-'a'] = (ans[s[i]-'a'] + ans[t[i]-'a']) % 1000000007;
    }
    
    cout << ans[t[N-1]-'a'] << endl;
}




Measured memory_bytes: 3296
#include <stdio.h>
#include <string.h>

int n;
char S[11234][6];
int dice[6] = { 1,2,3,5,4,6 }, tmp = 0, ans = 0;

int main(void) {
	while (true) {
		ans = 0;
		dice[0] = 1;
		dice[1] = 2;
		dice[2] = 3;
		dice[3] = 5;
		dice[4] = 4;
		dice[5] = 6;
		scanf("%d", &n);
		if (n == 0) { break; }
		for (int i = 0; i < n; ++i) { scanf("%s", &S[i]); }

		for (int i = 0; i < n; ++i) {
			if (strcmp(S[i], "North") == 0) {
				tmp = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[3];
				dice[3] = tmp;
				ans += dice[0];
			}
			else if (strcmp(S[i], "East") == 0) {
				tmp = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[2];
				dice[2] = tmp;
				ans += dice[0];
			}
			else if (strcmp(S[i], "South") == 0) {
				tmp = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[1];
				dice[1] = tmp;
				ans += dice[0];
			}
			else if (strcmp(S[i], "West") == 0) {
				tmp = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[4];
				dice[4] = tmp;
				ans += dice[0];
			}
			else if (strcmp(S[i], "Right") == 0) {
				tmp = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[3];
				dice[3] = dice[4];
				dice[4] = tmp;
				ans += dice[0];
			}
			else if (strcmp(S[i], "Left") == 0) {
				tmp = dice[1];
				dice[1] = dice[4];
				dice[4] = dice[3];
				dice[3] = dice[2];
				dice[2] = tmp;
				ans += dice[0];
			}
		}
		printf("%d\n", ans + 1);
	}
	return 0;
}

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

// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
/* clang-format off */
#define MOD 998244353
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, k;
  cin >> n >> k;
  vector<ll> l(k), r(k);
  REP(i, k) { cin >> l[i] >> r[i]; }
  vector<ll> dp(n + 1, 0);
  dp[0] = 1, dp[1] = -1;
  REP(i, n) {
    dp[i] %= MOD;
    REP(j, k) {
      if (i + l[j] < n) dp[i + l[j]] += dp[i]%MOD;
      if (i + r[j] + 1 < n) dp[i + r[j] + 1] += (MOD-dp[i]%MOD)%MOD;
    }
    if (i + 1 < n) dp[i + 1] += dp[i];
  }
  cout << dp[n - 1] << '\n';
  return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<int> C(N), S(N), F(N);
  for (int i = 0; i < N - 1; ++i) {
    scanf("%d %d %d", &C[i], &S[i], &F[i]);
  }

  for (int i = 0; i < N - 1; ++i) {
    int t = 0;
    for (int j = i; j < N - 1; ++j) {
      if (t <= S[j]) { t = S[j]; }
      else if (t % F[j] != 0) {
        t += (F[j] - t % F[j]);
      }
      t += C[j];
    }
    printf("%d\n", t);
  }
  printf("0\n");
  return 0;
}


Measured memory_bytes: 256
/* ****AWARE**** */
#include<bits/stdc++.h>
#include <limits.h> 
#define cut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair< ll, ll>
#define vi          vector< ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(  ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp13       make_pair
using namespace std; 
#define MAX  3000000000
#define MODULO 2
using namespace std;   
#define hell 1000000007 
#define hell1 30000000000000000
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define mysizeof(i) (char*)(&i+1)-(char *)(&i);
ll T;

void solve()
{ long long int a=-1,b=-1,c=-1,n,l,r,m,k,i,j,ans=0,ans1,ans2;
  cin>>n;
  vector<ll>v;
  for(i=0;i<n;i++)
    cin>>a,v.pb(a);

  ll dp[n];
  for(i=n-1;i>=0;i--)
  { if(i==n-1)
    dp[i]=0;
    else if(i==n-2)
      dp[i]=dp[i+1]+abs(v[i+1]-v[i]);
    else
    dp[i]=min(dp[i+1]+abs(v[i+1]-v[i]),dp[i+2]+abs(v[i+2]-v[i]));
  }

  cout<<dp[0];
}
             
int main(){ 
cut; 
ll t; 
//cin>>t;
//T=t;
 t=1;
while(t--)
solve();
return 0;
}
       


Measured memory_bytes: 4732
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int N,N2;
    double ans;
    cin >> N;
    N2 = (N+1) /2;
    ans = (double)N2 / (double)N;
    pr(ans);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

enum Shape{
	Circle,
	Triangle,
};

enum Type{
	Normal,
	Option,
};

enum Choice{
	None,
	OR,
	ALT,
};

struct Node{
	void set(Shape arg_shape,Type arg_type,Choice arg_choice){
		shape = arg_shape;
		type = arg_type;
		choice = arg_choice;
	}
	Shape shape;
	Type type;
	Choice choice;
	vector<int> children;
};

Node nodes[1000];

ll calc(int node_id){

	ll sum;
	if(nodes[node_id].shape == Circle){
		sum = 1;
		for(int i = 0; i < nodes[node_id].children.size(); i++){
			sum *= calc(nodes[node_id].children[i])%MOD;
		}
	}else{
		if(nodes[node_id].choice == OR){
			sum = 1;
			for(int i = 0; i < nodes[node_id].children.size();i++){
				sum *= (calc(nodes[node_id].children[i])+1)%MOD;
			}
			sum -= 1;
		}else{
			sum = 0;
			for(int i = 0; i < nodes[node_id].children.size();i++){
				sum += calc(nodes[node_id].children[i])%MOD;
			}
		}
	}
	if(nodes[node_id].type == Option)sum = (sum+1)%MOD;
	return sum%MOD;
}

int main(){

	int N,parent,child;
	char buf[5];

	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		scanf("%s",buf);
		if(buf[0] == 'E'){
			if(buf[1] == '\0'){
				nodes[i].set(Circle,Normal,None);
			}else{
				nodes[i].set(Circle,Option,None);
			}
		}else{
			if(buf[0] == 'A'){
				if(buf[1] == '\0'){
					nodes[i].set(Triangle,Normal,ALT);
				}else{
					nodes[i].set(Triangle,Option,ALT);
				}
			}else{
				if(buf[1] == '\0'){
					nodes[i].set(Triangle,Normal,OR);
				}else{
					nodes[i].set(Triangle,Option,OR);
				}
			}
		}
	}

	for(int i = 0; i < N-1; i++){
		scanf("%d %d",&parent,&child);
		parent--;
		child--;
		nodes[parent].children.push_back(child);
	}

	printf("%lld\n",calc(0)%MOD);

	return 0;
}

Measured memory_bytes: 2748
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

#define MP make_pair

int r[100005];

int FIND(int x){
	return (x==r[x]) ? x : (r[x]=FIND(r[x]));
}

int n;
long long ans;
vector<pair<int,pair<int,int> > > v;
pair<pair<int,int>,int> g[100005];
int cnt;

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	for(int i=0;i<=100000;i++){
		r[i]=i;
	}
	
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>g[i].first.first>>g[i].first.second;
		g[i].second=i;
	}
	sort(g,g+n);
	for(int i=0;i<n-1;i++){
		int x1=g[i].first.first,y1=g[i].first.second,id1=g[i].second;
		int x2=g[i+1].first.first,y2=g[i+1].first.second,id2=g[i+1].second;
		v.push_back(MP( min(abs(x1-x2),abs(y1-y2)) , MP(id1,id2)));
		g[i].first.first=y1;g[i].first.second=x1;
	}
	int x=g[n-1].first.first,y=g[n-1].first.second;
	g[n-1].first.first=y;
	g[n-1].first.second=x;
	sort(g,g+n);
	for(int i=0;i<n-1;i++){
		int x1=g[i].first.first,y1=g[i].first.second,id1=g[i].second;
		int x2=g[i+1].first.first,y2=g[i+1].first.second,id2=g[i+1].second;
		v.push_back(MP( min(abs(x1-x2),abs(y1-y2)) , MP(id1,id2)));
	}
	sort(v.begin(),v.end());
	//cout<<pq.size()<<endl;
	for(int i=0;i<v.size();i++){
		int id1=v[i].second.first,id2=v[i].second.second,len=v[i].first;
		if( !(FIND(id1)==FIND(id2)) ){
			ans+=((long long)len);
			r[FIND(id1)]=FIND(id2);
			cnt++;
		}
		if(cnt>=n-1){
			break;
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
  
long long max(long long a, long long b) { return (a>b) ? a : b; }

long long knapSack(long long W, long long wt[], long long val[], long long n)
{
	long long i,w; 
	long long K[n+1][W+1];
	for(i=0; i<=n; i++)
	{
		for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
	}
	return K[n][W]; 
}	
		
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	long long n, w; cin>>n>>w;
	long long wt[n],val[n];
	for(long long i=0 ; i<n; i++)
	{
		cin>>wt[i]>>val[i];
	}
	
	cout<<knapSack(w, wt, val, n)<<endl;
	
	return 0;
}




Measured memory_bytes: 79232
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
ll binomialCoeff(ll n, ll k) 
{ 
	ll C[n + 1][k + 1]; 
	ll i, j; 


	for (i = 0; i <= n; i++) 
	{ 
		for (j = 0; j <= min(i, k); j++) 
		{ 
			
			if (j == 0 || j == i) 
				C[i][j] = 1; 

			else
				C[i][j] = (C[i - 1][j - 1] + 
										C[i - 1][j])%MOD; 
		} 
	} 

	return C[n][k]; 
}
bool compare(const string &a , const string&b){
	
}
 
void solve()
{
    int h ,w , k ;
    cin>>h>>w>>k ;
    char mat[h][w] ;
    int tb = 0 ;
    rep(i , h){
    	rep(j , w){
    		cin>>mat[i][j] ;
    		if(mat[i][j]=='#'){
    			tb++ ;
    		}
    	}
    }
    // cout<<"ok"
    int ans = 0 ;
    repu(i , 0 ,( 1<<h) -1){
    	repu(j , 0 , (1<<w)-1){
    		int tc = 0 ;
    		// cout<<i<<" "<<j<<endl;
    		rep(k , h){
    			rep(l , w){
    				if((i&(1<<k)) || (j&(1<<l))){
    					if(mat[k][l]=='#'){
    						tc++;
    					}
    				}
    			}
    		}
    		if(tb-tc==k){
    			ans++;
    		}
    	}
    }
    cout<<ans<<endl;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3828
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++) // for簡略表記
#define DUMP(ar) for(int loop=0; loop<(int)ar.size(); loop++) cout << "[" << loop << "]:" << ar[loop] << endl // 配列一覧表示
#define DUMPL(ar) for(int loop=0; loop<(int)ar.size(); loop++) { cout << ar[loop]; if(loop<(int)ar.size()-1) cout << ' '; } cout << endl; // 配列一行一覧表示
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// getline(cin, [変数]); で空白などを含む入力の受け取り(行ごとの受け取り)
// cin >> ws; でそこまでにストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

bool out(int x, int y, int h, int w){
    if(x < 0 || x >= w) return true;
    if(y < 0 || y >= h) return true;
    return false;
}

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

    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    FOR(i, h) cin >> s[i];

    int cnt;
    FOR(i, h){
        FOR(k, w){
            cnt = 0;
            if(s[i][k] == '.'){
                // LOOPD(i);
                if(!out(k, i-1, h, w) && s[i-1][k] == '#') cnt++;
                // COUT(i);
                if(!out(k+1, i-1, h, w) && s[i-1][k+1] == '#') cnt++;
                if(!out(k+1, i, h, w) && s[i][k+1] == '#') cnt++;
                if(!out(k+1, i+1, h, w) && s[i+1][k+1] == '#') cnt++;
                if(!out(k, i+1, h, w) && s[i+1][k] == '#') cnt++;
                if(!out(k-1, i+1, h, w) && s[i+1][k-1] == '#') cnt++;
                if(!out(k-1, i, h, w) && s[i][k-1] == '#') cnt++;
                if(!out(k-1, i-1, h, w) && s[i-1][k-1] == '#') cnt++;
                s[i][k] = cnt + '0';
            }
        }
    }

    FOR(i, h){
        FOR(k, w){
            cout << s[i][k];
        }
        cout << '\n';
    }
    
    return 0;
}

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

int main()
{
    int K;
    cin >> K;
    ll ans = 0;
    for (int i = 1; i <= K; i++)
    {
        for (int j = 1; j <= K; j++)
        {
            int a = __gcd(i, j);
            for (int k = 1; k <= K; k++)
            {
                ans += __gcd(a, k);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

void Input(int *D);
void Output(int Eve_count);

int main(void) {
	int D;
	Input(&D);
	Output(25 - D);
	return 0;
}

void Input(int *D) {
	scanf("%d", D);
	return;
}

void Output(int Eve_count) {
	printf("Christmas");
	for (int i = 0; i < Eve_count; i++) printf(" Eve");
	printf("\n");
	return;
}

Measured memory_bytes: 888
def inpl(): return [int(i) for i in input().split()]

N,M,Q = inpl()
LR = [inpl() for i in range(M)]
pq = [inpl() for i in range(Q)]

H = [[0]*N for i in range(N)]
S = [[0]*N for i in range(N)]

for i in range(M):
    H[LR[i][0]-1][LR[i][1]-1] += 1

S[0][0] = H[0][0]
for i in range(N):
    for j in range(N-1):
        S[i][j+1] = S[i][j] + H[i][j+1]

for i in range(N-1):
    for j in range(N):
        S[i+1][j] = S[i][j] + S[i+1][j]

for i in range(Q):
    if pq[i][1] == 1:
        print(S[0][0])
    elif pq[i][0] == 1:
        print(S[pq[i][1]-1][pq[i][1]-1])
    else:
        ans = S[pq[i][1]-1][pq[i][1]-1] - S[pq[i][1]-1][pq[i][0]-2] - S[pq[i][0]-2][pq[i][1]-1] + S[pq[i][0]-2][pq[i][0]-2]
        print(ans)
        

Measured memory_bytes: 60384
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a1[108], a2[108];

int main(){
	cin >> n;
	for(ll i = 1; i <= n; i++){cin >> a1[i];}
	for(ll i = 1; i <= n; i++){cin >> a2[i];}
	for(ll i = 2; i <= n; i++){a1[i] += a1[i-1];}
	for(ll i = n-1; i >= 1; i--){a2[i] += a2[i+1];}
	
	ll ans = 0;
	for(ll i = 1; i <= n; i++){ans = max(a1[i]+a2[i], ans);}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, h;
  cin >> n >> h;
  vector<pair<int, int>> vp(n);
  rep(i, n){
    int a, b;
    cin >> a >> b;
    vp.at(i) = make_pair(a, b);
  }
  sort(vp.begin(), vp.end());
  auto mx = vp.back();
  vp.pop_back();
  sort(vp.begin(), vp.end(), [](const auto &l, const auto &r){
    return l.second > r.second;
  });
  int ans = 0, index = 0;
  while(h > 0){
    ans++;
    int ac = mx.first;
    if(h <= mx.second) h = 0;
    else{
      if(index != n-1 && ac < vp.at(index).second){
        h -= vp.at(index).second;
        index++;
      }else{
        h -= mx.second;
        // cerr << ans << " " << (h+ac-1)/ac << endl;
        ans += (h+ac-1)/ac;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import math
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
l = []
for i in range(N-1):
    for j in range(i+1, N):
        l.append(math.sqrt((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2))
print(sum(l)*2/N)

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

int main(){

	int arr[5];
	for(int i=0; i<5; i++)cin>>arr[i];
	for(int i=0; i<5; i++){
		if(arr[i]==0){
			cout<<i+1<<endl;
			break;
		}
	}

return 0;

}

Measured memory_bytes: 3628
import java.util.Scanner;

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


Measured memory_bytes: 26348
#include <iostream>
    #include <vector>
    #include <algorithm>
     
    using namespace std;
     
    #define int long long
     
    int32_t main() {
    	int a, b, c, d;
    	cin >> a >> b >> c >> d;
    	cout << max(a * c, max(b * d, max(a * d, b * c)));
    }

Measured memory_bytes: 3616
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  rep(i,0,N) cin>>a[i];
  int sum=accumulate(a.begin(),a.end(),0);
  ll int ans=0;
  rep(i,0,N-1){
    ans+=a[i]*(sum-a[i]);
    sum-=a[i];
    
  }
  cout<<ans;
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int len, plu[15];
string s1;
long long F(string s) {
    long long sum=0,num=0;
    for (int i=0;i<s.size();i++) {
        if(s[i]=='+') {sum+=num, num=0;}
        else
            num=num*10+s[i]-'0';
    }
    return sum+num;
}
int main()
{
	
    cin>>s1;
    len=s1.size()-1;
    long long ans=0;
	while(true) {
        string s;
        for(int i=0;i<len;i++) {
            plu[i+1]+=plu[i]/2;
            plu[i]%=2;
        }
        if(plu[len])
            break;
        
		for (int i=0;i<len;i++) {
            s+=s1[i];
            if(plu[i])
                s+="+";
        }
        s+=s1[len];
        ans+=F(s);
        
		plu[0]++;
    }
    printf("%lld",ans);
}
///////////////////

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a,b;
	int i,j;
	for(;;){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0) break;
		for(i=0;i<a;i++){
			for(j=0;j<b;j++){
				if(i==0||i==a-1||j==0||j==b-1) printf("#");
				else printf(".");
			}
			puts("");
		}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 2060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

ll mod = 1000000007;
//---------------------------------------------------------------------------------------------------
ll f[1010100];
void init() {
    f[0] = 1;
    for (int i = 1; i < 1010100; ++i) f[i] = (f[i - 1] * i) % mod;
}
//---------------------------------------------------------------------------------------------------
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
    ll a = f[n]; // = n!
    ll b = f[n-k]; // = (n-k)!
    ll c = f[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * inv(bc)) % mod;
}

int main() {
    init();
    ll x, y; cin >> x >> y;
    ll ans = 0;
    for (ll a = 0; a <= x; ++a) {
        if ((x - a) % 2 == 1 || y != (x - a) / 2 + 2 * a) continue;
        ans += C(a + (x - a) / 2, a);
        ans %= 1000000007LL;
    }

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

Measured memory_bytes: 8192
import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

n=int(input())
x=[]
y=[]
for i in range(n):
  x1,y1=map(int,input().split())
  x.append(x1)
  y.append(y1)
max1=-10**10
for i in range(n):
  if x[i]+y[i]>max1:
    point1=i
    max1=x[i]+y[i]
max1=-10**10
for i in range(n):
  if x[i]-y[i]>max1:
    point2=i
    max1=x[i]-y[i]
max1=-10**10
for i in range(n):
  if -x[i]-y[i]>max1:
    point3=i
    max1=-x[i]-y[i]
max1=-10**10
for i in range(n):
  if -x[i]+y[i]>max1:
    point4=i
    max1=-x[i]+y[i]
ans=0
for i in range(n):
  ans=max(ans,abs(x[i]-x[point1])+abs(y[i]-y[point1]))
  ans=max(ans,abs(x[i]-x[point2])+abs(y[i]-y[point2]))
  ans=max(ans,abs(x[i]-x[point3])+abs(y[i]-y[point3]))
  ans=max(ans,abs(x[i]-x[point4])+abs(y[i]-y[point4]))
print(ans)

Measured memory_bytes: 89072
import sys

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


def resolve():
    n = int(input())
    S = input()
    White = [0] * (n + 1)
    Black = [0] * (n + 1)

    for i in range(n):
        if S[i] == "#":
            Black[i + 1] = Black[i] + 1
        else:
            Black[i + 1] = Black[i]

    for i in reversed(range(n)):
        if S[i] == ".":
            White[i] = White[i + 1] + 1
        else:
            White[i] = White[i + 1]

    res = f_inf
    for i in range(n + 1):
        res = min(res, White[i] + Black[i])

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 43872
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
/*bool jud(string a,string b){
int i=0,j=0;
int as=1;
while(as){
 if(i<a.size() && j<b.size())
  {
  if(a[i]>b[j]){
   return false;
   as=0;}
  if(a[i]<b[j]){
   return true;
   as=0;}
  i++;
  j++;
  }
  else
  break;
 }
if(a.size()>b.size())
return false;
else
return true;
}*/
vector<string>x;
int main(){
string s;
int k;
cin>>s>>k;
//int n=0;
for(int i=0;i<s.size();i++){
string cur;
 for(int j=i;j<s.size()&&j<i+k;j++){
 cur+=s[j];
 x.push_back(cur);
 }
}
/*if(s.size()==1)
cout<<s[0];
else{
sort(x.begin(),x.end(),jud);*/
sort(x.begin(),x.end());
x.erase(unique(x.begin(), x.end()), x.end());
/*for(int i=1;i<=x.size();i++){
if(x[i]!=x[i-1]){
k--;
}
if(k==1){
cout<<x[i];
break;}
}
}*/
cout<<x[k-1];
system("pause");
return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int D=in();
  cout << "Christmas";
  for(int i=0;i<25-D;i++) cout << " Eve";
  cout << endl;
  return 0;
}


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

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "OK" : "NG"));}
//----------------------------------------------------------------

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

  ll tmp;
  if(n>=b){
    tmp=b-1;
  }
  else{
    tmp=min(b-1,n%b);
  }

  prt(a*tmp/b);
}


Measured memory_bytes: 3636
s=input()
a=sum(s[i]!="0" for i in range(0,len(s),2))
b=sum(s[i]!="1" for i in range(1,len(s),2))
c=sum(s[i]!="1" for i in range(0,len(s),2))
d=sum(s[i]!="0" for i in range(1,len(s),2))
print(min(a+b,c+d))

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

void solve() {
  int a,b;
  cin >> a >> b;
  cout << max(max(a+a-1,b+b-1),a+b);
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)

using namespace std;

void solve(long long N, long long D){
    auto d=2*D+1;
    cout << (N+d-1)/d << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    solve(N, D);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
#include <set>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;

int main(){
	cin>>n;
	set<int> s;
	REP(i,n){
		int a;
		cin>>a;
		if(s.find(a)==s.end()){
			s.insert(a);
		}else{
			s.erase(a);
		}
	}
		cout<<s.size()<<endl;
		return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (n % 1000 ? (1000 - n % 1000) : 0) << '\n';
    return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin >>a>>b;
  int n=0;
  int i;
  if(b == 1) cout << 0 << endl;
  else{
    for(i=1;;i++){
      n += a-1;
      if(n+1>=b) break;
    }
    cout <<i<<endl;
  }

  return 0;
}


Measured memory_bytes: 256