akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    ll X,K,D; cin >> X >> K >> D;
    if (X < 0) X = -X;
    ll Q = X / D;
    ll R = X % D;
    ll ans = 0;

    if (Q > K) ans = X - D * K;
    else{
        if ((K - Q) % 2 == 0) ans = R;
        else ans = D - R;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define REPR(i, n) for(int i = n - 1; 0 <= i; i--)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define FORR(i, s, e) for(int i = s; e <= i; i--)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

struct Node {
    vector<pair<int, int>> v;
    int col = -1;
};

int main() {
    int N;
    cin >> N;
    vector<Node> node(N);
    REP(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        Node n;
        node[u].v.push_back(make_pair(v, w));
        node[v].v.push_back(make_pair(u, w));
    }
    deque<int> d;
    REP(i, N) {
        if(node[i].col == -1) {
            d.push_back(i);
        } else {
            continue;
        }
        node[i].col = 0;

        while(!d.empty()) {
            int j = d.front();
            d.pop_front();
            for(auto f : node[j].v) {
                if(node[f.first].col == -1) {
                    if(f.second & 1) {
                        node[f.first].col = !node[j].col;
                    } else {
                        node[f.first].col = node[j].col;
                    }
                    d.push_back(f.first);
                }
            }
        }
    }
    REP(i, N) { cout << node[i].col << endl; }
    return 0;
}

Measured memory_bytes: 7168
//AtCoder AGC034 A - Kenken Race
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N,A,B,C,D; cin>>N>>A>>B>>C>>D;
    string S; cin>>S;    
    S.insert(0," ");
    //--N; --A; --B; --C; --D;
    vector<char> a(N+1,0); //aがいけるところ
    vector<char> b(N+1,0); //bが
    a[A]=1;
    for(ll i=A+1;i<=C;++i){
        if(S[i]=='.')
            if(a[i-1]||a[i-2]) a[i]=1;
    }
    if(!a[C]) {
        cout<<"No"<<endl;
        return 0;
    }
    b[B]=1;
    for(ll i=B+1;i<=D;++i){
        if(S[i]=='.')
            if(b[i-1]||b[i-2]) b[i]=1;
    }
    if(!b[D]) {
        cout<<"No"<<endl;
        return 0;
    }
    if(C<D) { //こえなくてよい
        cout<<"Yes"<<endl;
    } else {
        bool ans=false;
        for(ll i=B; i<=D;++i){
            if(b[i] && a[i-1] && a[i+1]){
                ans=true;
            }
        }
        cout<<(ans?"Yes":"No")<<endl;
    }
    return 0;
}


Measured memory_bytes: 900
#include <cstdio>
int a[305][305],b[305],cnt[305];
bool u[305];
int main(){
	int n,m;
	scanf("%d%d\n",&n,&m);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++) scanf("%d",&a[i][j]);
	int ans=n;u[0]=1;
	for (int i=1;i<=m;i++){
		for (int j=1;j<=m;j++) cnt[j]=0;
		for (int j=1;j<=n;j++){
			for (;u[a[j][b[j]]];b[j]++);
			cnt[a[j][b[j]]]++;
		}
		int k=0;
		for (int j=1;j<=m;j++) k=cnt[j]>cnt[k]?j:k;
		ans=cnt[k]<ans?cnt[k]:ans;
		u[k]=1;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>

using namespace std;

long long a[100005];

int main()
{
    long long n,x;
    while(~scanf("%lld%lld",&n,&x))
    {
        long long sum = 0;
        a[0] = 0;

        for(int i = 1; i <= n; i++)
        {
            scanf("%lld",&a[i]);
            if(a[i] + a[i-1] > x)
            {
                sum += a[i] + a[i-1] - x;
                a[i] -= a[i] + a[i-1] - x;
            }
        }
        printf("%lld\n",sum);

    }
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

ll getidx(ll i, ll j, map<pll, ll>& mp) {
  if (i < j) {
    return mp[{i,j}];
  } else {
    return mp[{j,i}];
  }
}

class Graph {
 public:
  vvl g;
  vl indeg;

 public:
  Graph(ll n) : g(n), indeg(n, 0) {}
  void addEdge(ll a, ll b) {
    g[a].push_back(b);
    indeg[b]++;
  }
  size_t size() { return g.size(); }
  void tsort(vector<pll>& ans) {
    priority_queue<pll, vector<pll>, greater<pll>> que;
    for (int i = g.size() - 1; i >= 0; i--) {
      if (indeg[i] == 0) que.push({i, 1});
    }
    while (!que.empty()) {
      pll i = que.top();
      que.pop();
      ans.push_back(i);
      for (auto& j : g[i.first]) {
        indeg[j]--;
        if (indeg[j] == 0) que.push({j, i.second+1});
      }
    }
  }
};

int main() {
  //
  ll n;
  cin >> n;
  map<pll, ll> mp;
  rep(i, n) {
    REP(j, i+1, n) {
      mp[{i,j}] = 0;
    }
  }
  ll idx = 0;
  for (auto& m : mp) {
    m.second = idx++;
  }

  Graph g(n * (n-1) / 2);
  vvl a(n, vl(n-1));
  rep(i, n) {
    rep(j, n - 1) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }

  rep(i, n) {
    rep(j, n - 2) {
      // cout << i<<a[i][j] << "," << i<< a[i][j+1] << endl;
      // cout << getidx(i, a[i][j], mp) << "->" << getidx(i, a[i][j+1], mp) << endl;
      g.addEdge(getidx(i, a[i][j], mp), getidx(i, a[i][j+1], mp));
    }
  }
  vector<pll> c;
  g.tsort(c);
  if (c.size() < n * (n-1)/2) {
    cout << -1 << endl;
    return 0;
  }
  vl dist(n*(n-1)/2, 1);
  ll ans = 0;
  for (auto& u : c) {
    for (auto& v : g.g[u.first]) {
      if (dist[v] <= dist[u.first] + 1) {
        dist[v] = dist[u.first] + 1;
        ans = max(ans, dist[v]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 82280
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (int i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF const ll INF = 1001001001;
#define PI const ld PI = 3.14159265358979323846;



int main(){
int a,b;scanf("%d%d",&a,&b);
double ret=0;
for(int i=1;i<=a;i++){
double tmp=1.0/a;
int now=i;
while(now<b){
now*=2;
tmp/=2;
}
ret+=tmp;
}
printf("%.12f\n",ret);
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n;

	cin >> n;

	ll ans = n * (n - 1) / 2;

	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
from heapq import heappop, heappush

n, m = map(int, input().split())

class Graph(object):

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):

    def __init__(self, graph, start):
        self.g = graph.graph

        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        self.prev = defaultdict(lambda: None)

        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def print_ans(self):
        for i in range(1, n):
            print(self.prev[i]+1)

g = Graph()

for _ in range(m):
    a, b = map(int, input().split())
    g.add_edge(a-1, b-1, 1)
    g.add_edge(b-1, a-1, 1)

d = Dijkstra(g, 0)
print('Yes')
d.print_ans()

Measured memory_bytes: 86724
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>h>>w;
    rep(i,n){
        cin>>a>>b;
        if(a>=h&&b>=w)ans++;
    }
    Cout(ans);
    return 0;
}


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

int main(){
  char N[5];
  scanf("%s",N);
  printf("%s\n",(N[0]==N[1]&&N[1]==N[2] || 
                 N[1]==N[2]&&N[2]==N[3])?
                 "Yes":"No");
}


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

int main(void){
    int n = 0;
    int x;
    int len;
    char in[10001],out[10001];
    scanf("%d",&n);
    scanf("%s",in);
    len = strlen(in);
    for(int i = 0; i < len; i++){
        printf("%c",(in[i] - 'A' + n) % 26 + 'A');
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
def resolve():
    N, X, M = map(int,input().split())
    A_list = [X]
    preA = X
    A_set = set(A_list)
    for i in range(N-1):
        A = preA**2%M

        if A == 0:
            answer = sum(A_list)
            break
        elif A in A_set:
            finished_count = len(A_list)
            # 何番目か確認
            same_A_index = A_list.index(A)
            one_loop = A_list[same_A_index:]
            loop_count, part_loop = divmod(N-finished_count, len(one_loop))
            answer = sum(A_list) + sum(one_loop)*loop_count + sum(one_loop[:part_loop])
            break

        A_list.append(A)
        A_set.add(A)
        preA = A
    else:
        answer = sum(A_list)
    print(answer)
resolve()

Measured memory_bytes: 76872
#include<iostream>

#include<cstdio>
#include<cstring>

using namespace std;

#define LEN (50)
#define SIZE ((LEN)+(1))

bool strmat(char*s, char*t){//match
	for(; *t; t++, s++){
		if( *s == *t ){
			//
		}
		else if( *s == '?' ){
			//
		}
		else{
			return false;
		}
	}
	return true;
}

char* strpos(char* s, char* t){//position
	for( ; *s; s++){
		if( strmat(s, t) ){
			return s;
		}
	}
	return NULL;
}

char* strposi(char* s, char* t){//position inverse
	const char* p = s-1;
	
	//for(;*s;s++);
	while(*s++);
	s--;
	
	for( ; s!=p; s--){
		if( strmat(s, t) ){
			return s;
		}
	}
	return NULL;
}

char* strrep(char* p, const char s, const char d){//replace
	char* const q = p;
	for(; *p; p++){
		if(*p == s) *p = d;
	}
	return q;
}

char* strpst(char* s, char* t){//paste
	char *p = s;
	for( ; *s && *t; s++, t++){
		*s = *t;
	}
	return p;
}

int main(void){
	char sd[SIZE];
	char t[SIZE];
	
	//scanf("%s", sd);
	//scanf("%s", t);
	
	cin >> sd >> t;//ver5
	
	//char* pt = strpos(sd, t);
	char* pt = strposi(sd, t);//ver5
	
	if(pt == NULL){
		printf("UNRESTORABLE");
	}else{
		strpst(pt, t);
		strrep(sd, '?', 'a');
		printf("%s", sd);
	}
	
	return 0;
}


Measured memory_bytes: 256
import math
import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,c = map(int,ipt().split())
    cc = [[] for _ in [0]*c]
    tma = 0
    for i in range(n):
        s,t,c = map(int,ipt().split())
        hpq.heappush(cc[c-1],(s,t))
        if t > tma:
            tma = t
    cnt = np.zeros(tma+1,dtype=int)
    for i in cc:
        ps = -1
        pt = -1
        while len(i) > 0:
            ns,nt = hpq.heappop(i)
            if pt == ns:
                pt = nt
                continue
            elif not pt == -1:
                cnt[ps:pt+1:] += np.ones(pt-ps+1,dtype=int)
            ps = ns
            pt = nt
        if not pt == -1:
            cnt[ps:pt+1:] += np.ones(pt-ps+1,dtype=int)
    print(max(cnt))
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 27360
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9 + 7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcountll
#define setbitcnt __builtin_ctz
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define roundup(a,b)  std::cout << std::fixed;std::cout << std::setprecision(b); std::cout << a
const int siz = (1e6 + 10);
const int logi = 21;
const double epsilon = 1e-6;
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}



signed main()
{
	#ifndef ONLINE_JUDGE
 	freopen("in.txt", "r", stdin);
 	freopen("out.txt", "w", stdout);
 	#else
// // online submission
 	#endif 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	int val = 0;
	while(t--)
	{
		int x;
		cin>>x;

		if(x >= 400 and x < 600)
		{
			cout<<8<<"\n";
			continue;
		}

		if(x >= 600 and x < 800)
		{
			cout<<7;
		}

		if(x >= 800 and x < 1000)
		{
			cout<<6;
		}

		if(x >= 1000 and x < 1200)
		{
			cout<<5;
		}

		if(x >= 1200 and x < 1400)
		{
			cout<<4;
		}

		if(x >= 1400 and x < 1600)
		{
			cout<<3;
		}

		if(x >= 1600 and x < 1800)
		{
			cout<<2;
		}

		if(x >= 1800 and x < 2000)
		{
			cout<<1;
		}
	}
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ConsoleApp6
{
	class Program
	{
		static void Main(string[] args)
		{
			int c = int.Parse(Console.ReadLine());
			int t_count = 0, h_count = 0;

			for (int c_i = 0; c_i < c; c_i++)
			{
				var card = Console.ReadLine().Split(' ');
				var t = card[0];
				var h = card[1];

				switch (t.CompareTo(h))
				{
					case -1:
						h_count += 3;
						break;
					case 0:
						t_count++;
						h_count++;
						break;
					case 1:
						t_count += 3;
						break;
				}
			}

			Console.WriteLine("{0} {1}", t_count, h_count);
		}
	}
}



Measured memory_bytes: 16744
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;

int N;
ll T[100000 + 100], A[100000 + 100];
ll max_ok[100000 + 100], determined[100000 + 100];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++)cin >> T[i];
	for (int i = 0; i < N; i++)cin >> A[i];

	for (int i = 0; i < N; i++)max_ok[i] = -1;
	ll bef = 0;
	for (int i = 0; i < N; i++) {
		if (bef != T[i]) {
			determined[i] = T[i];
		}
		max_ok[i] = T[i];
		bef = T[i];
	}

	bef = 0;
	for (int i = N - 1; i >= 0; i--) {
		if (!determined[i] && bef != A[i]) {
			determined[i] = A[i];
		}
		else if(determined[i]){
			if (determined[i] > A[i]) {
				cout << 0 << endl;
				return 0;
			}
		}
		if (bef != A[i]) {
			
		}
		max_ok[i] = min(A[i], T[i]);
		bef = A[i];
	}
	ll ans = 1;
	for (int i = 0; i < N; i++) {
		if (determined[i] == 0) {
			ans *= max_ok[i];
			ans %= 1000000007;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    cout<<"square1001"<<endl;
}



Measured memory_bytes: 3000
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s;
		while ((s = br.readLine()) != null) {
			int data = Integer.parseInt(s);

			int num = 0;
			for (int a = 0; a < 10; a++)
				for (int b = 0; b < 10; b++)
					for (int c = 0; c < 10; c++)
						for (int d = 0; d < 10; d++)
							if (a + b + c + d == data)
								num++;

			System.out.println(num);
		}
	}
}

Measured memory_bytes: 24916
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int m,d;
  cin >> m >> d;
  int ans = 0;
  
  rep(i,4,m+1){
    rep(j,22,d+1){
      if(j%10<=1) continue;
      if(j/10<=1) continue;
      if((j%10)*(j/10)==i) ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 768
// https://atcoder.jp/contests/abc138/tasks/abc138_a
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        a: usize, s: String
    };

    if a >= 3200 {
        println!("{}", s);
    } else {
        println!("red");
    }
}


Measured memory_bytes: 4352
N, M = map(int, input().split()) 

start = set() #  島1から渡ることのできる島
goal = set()  #  島Nへ渡ることのできる島

for _ in range(M):
  x, y = map(int, input().split())
  if x == 1:
    start.add(y)
  elif y == N:
    goal.add(x)

if start & goal:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 19024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] S_char = sc.next().toCharArray();
    int[] count = new int[26];
    for (int i = 0; i < S_char.length; i++) {
      count[S_char[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++) {
      if (count[i] == 0) {
        System.out.println((char)(i + 'a'));
        return;
      }
    }
    System.out.println("None");
  }
}

Measured memory_bytes: 26964
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(){
    int n,k; cin>>n>>k;
    vector<int> a(n);
    rep(i,n)cin>>a.at(i);
    vector<int> bits(40,0);
    rep(i,40)rep(j,n)if(a.at(j)&((int)1<<i))bits.at(i)++;
    int ans=0; k++;
    for(int i=39; i>=0; i--){
        if(k&((int)1<<i)){
            int sum=0;
            for(int j=39; j>i; j--){
                if(k&((int)1<<j))sum+=((int)1<<j)*(n-bits.at(j));
                else sum+=((int)1<<j)*bits.at(j);
            }
            sum+=((int)1<<i)*bits.at(i);
            for(int j=i-1; j>=0; j--){
                if(bits.at(j)>=(n+1)/2)sum+=((int)1<<j)*bits.at(j);
                else sum+=((int)1<<j)*(n-bits.at(j));
            }
            chmax(ans, sum);
        }
    }
    cout<<ans<<endl;
}

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

typedef long long ll;

vector<ll> score(int D, vector<ll> c, vector<ll> t, vector<vector<ll>> s) {
    vector<vector<ll>> last(D + 1, vector<ll>(26, 0));
    vector<ll> ret(D);
    ll p = 0;
    rep(d, D) {
        p += s[d][t[d] - 1];
        rep(i, 26) last[d + 1][i] = last[d][i];
        last[d + 1][t[d] - 1] = d + 1;
        rep(i, 26) {
            p -= c[i] * (d + 1 - last[d + 1][i]);
        }
        ret[d] = p;
    }
    return ret;
}

int main() {
    int D;
    cin >> D;
    vector<ll> c(26), t(D);
    rep(i, 26) cin >> c[i];
    vector<vector<ll>> s(D, vector<ll>(26)), last(D + 1, vector<ll>(26, 0));
    rep(i, D) rep(j, 26) cin >> s[i][j];
    ll p = 0;
    rep(d, D) {
        ll q, r = 0, maxq = -1e18;
        rep(j, 26) {
            q = s[d][j];
            rep(i, 26) last[d + 1][i] = last[d][i];
            last[d + 1][j] = d + 1;
            rep(i, 26) {
                q -= c[i] * (d + 1 - last[d + 1][i]);
            }
            if (q > maxq) {
                maxq = q;
                r = j;
            }
        }
        t[d] = r + 1;
        p += maxq;
        rep(i, 26) last[d + 1][i] = last[d][i];
        last[d + 1][r] = d + 1;
    }
    auto ans = score(D, c, t, s);
    ll maxs = ans.back();
    //cout << maxs << "\n";
    rep(i, 40000) {
        int x = rand() % D;
        int y = rand() % D;
        swap(t[x], t[y]);
        ans = score(D, c, t, s);
        if (ans.back() > maxs) {
            maxs = ans.back();
        } else {
            swap(t[x], t[y]);
        }
    }
    rep(i, D) cout << t[i] << "\n";
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

// MOD p でいくつクラス
#define MOD 1000000007 // 10^9 + 7
class mll {
	unsigned long long val = 0;
public:
	mll(long long y = 0) : val(((y % MOD) + MOD) % MOD) {}
	mll operator + (const mll& y) { return mll(*this) += y; }
	mll& operator += (const mll& y) {
		val = (val + y.val) % MOD;
		return *this;
	}
	mll operator - (const mll& y) { return mll(*this) -= y; }
	mll& operator -= (const mll& y) {
		val = (val - y.val + MOD) % MOD;
		return *this;
	}
	mll operator * (const mll& y) { return mll(*this) *= y; }
	mll& operator *= (const mll& y) {
		val = (val * y.val) % MOD;
		return *this;
	}
	mll operator / (const mll& y) { return mll(*this) /= y; }
	mll& operator /= (const mll& y) {
		long long a = y.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		mll c = val * u; // この計算でoverflowしないか？
		val = c.val;
		return *this;
	}
	bool operator >= (const mll& y) {
		return this->val >= y.val;
	}
	mll pow(long long t) const {
		if (!t) return 1;
		mll a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	unsigned long long getVal() {
		return val;
	}
	friend ostream& operator <<(ostream& os, mll& y) {
		os << y.val;
		return os;
	}
};
#undef MOD

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

	vector<mll> P(S,1); // 階乗 X! = S[X]
	for(int i = 1; i < S; i++){
		P[i] = P[i-1] * i;
	}

	mll c = 0;
	for(int i = 1; i <= (S / 3); i++){
		c += P[S - 2 * i - 1] / (P[i - 1] * P[S - 3*i]);
	}

	cout << c.getVal() << endl;
	return(0);
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
struct node
{
    int a[maxn];
    int len;
}s[505];
int main()
{
    int n,m,q;
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=500;i++) s[i].len=0;
    for(int i=0;i<m;i++)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        s[l].a[s[l].len++]=r;
    }
    for(int i=1;i<=n;i++)
        sort(s[i].a,s[i].a+s[i].len);
    while(q--)
    {
        int p,k;
        scanf("%d%d",&p,&k);
        int ans=0;
        for(int i=p;i<=k;i++)
            ans+=upper_bound(s[i].a,s[i].a+s[i].len,k)-s[i].a;
        printf("%d\n",ans);
    }
}


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

bool ask(ll x){
	cout<<"? "<<x<<'\n';
	cout<<flush;
	char r;
	cin>>r;
	return r=='Y'?true:false;
}

void ans(ll x){
	cout<<"! "<<x<<'\n';
	cout<<flush;
}

const ll MX=1e10;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll res=0,lim=10,len=1;
	while(lim<=MX&&ask(lim)) lim*=10,++len;
	if(lim>MX){
		ll k=MX-1;
		res=lim/10;
		while(k>0&&ask(k))
			k/=10,res/=10;
		ans(res);
		return 0;
	}
	for(int i=0;i<len-1;++i){
		int l=!i?1:0,r=9;
		while(l<=r){
			int m=(l+r)/2;
			ll x=res*10+m;
			if(ask(x)) l=m+1;
			else r=m-1;
		}
		res=res*10+r;
	}
	for(int i=!res?1:0;i<=9;++i)
		if(ask(res*100+i*10+1)){
			ans(res*10+i);
			return 0;
		}
}




Measured memory_bytes: 3704
// youngjinp20
// 2020 03

#include <bits/stdc++.h>
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }
#define byr(x) [](const auto& a, const auto& b) { return a.x > b.x; }
#define smax(a, b) ((a) < (b) ? ((a)=(b), true) : false)
#define smin(a, b) ((a) > (b) ? ((a)=(b), true) : false)
using namespace std;

typedef long long ll;

const int MAX = 1e5+1;
int N, K;
int a[MAX];
int dp[MAX];

int main() {
	cin >> N >> K;
	for (int i=0; i<N; i++){
		cin >> a[i];
	}

	dp[0] = 0;

	for (int i=1; i<=K; i++) {
		bool flag = false;
		dp[i] = false;

		for (int k=0; k<N; k++) {
			if (i>=a[k]) {
				if (!dp[i-a[k]]) {
					dp[i] = true;
				}
				flag = true;
			}
		}

		if (!flag) dp[i] = dp[i-1];
	}

	string s = dp[K] ? "First" : "Second";
	cout << s << endl;

	return 0;
}


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

int main() {

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

	vector<vector<char>> c(h + 2, vector<char>(w + 2,'-1'));
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> c[i][j];
		}
	}
	
	vector<vector<char>> ans(h + 2, vector<char>(w + 2, '#'));
	for (int i = 1; i <= h; i++) {		
		for (int j = 1; j <= w; j++) {
			int cnt = 0;
			if (c[i][j] == '#') continue;
			if (c[i - 1][j] == '#') cnt++;
			if (c[i + 1][j] == '#') cnt++;
			if (c[i][j - 1] == '#') cnt++;
			if (c[i][j + 1] == '#') cnt++;
			if (c[i - 1][j - 1] == '#') cnt++;
			if (c[i - 1][j + 1] == '#') cnt++;
			if (c[i + 1][j - 1] == '#') cnt++;
			if (c[i + 1][j + 1] == '#') cnt++;
			ans[i][j] = (char)(cnt + '0');
		}	
	}

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cout << ans[i][j];
		}
		cout << endl;
	}

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <random>
#include <functional>


#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

template <class T> inline bool chmax(T& a, T b){
    if(a < b){a = b; return true;}
    return false;
}
template <class T> inline bool chmin(T& a, T b){
    if(a > b){a = b; return true;}
    return false;
}



// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

constexpr int MAX_SIZE = 1e6;
char str[MAX_SIZE + 10];
std::vector<int> D;
std::vector<lli> A;

lli solve(int n, int k){
    // A[i] := [i, i+k)で作れるMCの数
    A[0] = 0;
    lli res = 0;
    int i, j;
    int m = 0, c = 0;
    for(j = 0; j < k; ++j){
        if(str[j] == 'M')  m++;
        else if(str[j] == 'C'){ c++; A[0] += m; }
    }
    for(i = 1; i < n; ++i){
        A[i] = A[i-1];
        if(str[i-1] == 'M'){
            m--; A[i] -= c;
        }
        else if(str[i-1] == 'C') c--;

        if(j < n){
            if(str[j] == 'M')  m++;
            else if(str[j] == 'C'){ c++; A[i] += m; }
            j++;
        }
    }


    for(int v : D) res += A[v];

    return res;
}



int main(void){
    int n; scanf("%d", &n);
    scanf("%s", str);

    REP(i, n) if(str[i] == 'D') D.push_back(i);

    A.resize(n+1);

    int q; scanf("%d", &q);
    // クエリに答える
    while(q--){
        int query; scanf("%d", &query);
        printf("%lld\n", solve(n, query));
    }

    return 0;
}

Measured memory_bytes: 13036
public partial class IntroductionToProgramming{
	public static void Main(){
		int n = int.Parse(System.Console.ReadLine());

		string[] ss = new string[13];
		string[] hs = new string[13];
		string[] cs = new string[13];
		string[] ds = new string[13];

		for (int i = 0; i < n; i++)
		{
			string[] line = System.Console.ReadLine().Split(' ');
			switch (line[0])
			{
				case "S":
					ss[int.Parse(line[1]) - 1] = "1";
					break;
				case "H":
					hs[int.Parse(line[1]) - 1] = "1";
					break;
				case "C":
					cs[int.Parse(line[1]) - 1] = "1";
					break;
				case "D":
					ds[int.Parse(line[1]) - 1] = "1";
					break;
			}
		}

		for (int s = 0; s < 13; s++)
		{
			if (string.IsNullOrEmpty(ss[s]))
			{
				System.Console.WriteLine("S " + (s + 1).ToString());
			}
		}
		for (int h = 0; h < 13; h++)
		{
			if (string.IsNullOrEmpty(hs[h]))
			{
				System.Console.WriteLine("H " + (h + 1).ToString());
			}
		}
		for (int c = 0; c < 13; c++)
		{
			if (string.IsNullOrEmpty(cs[c]))
			{
				System.Console.WriteLine("C " + (c + 1).ToString());
			}
		}
		for (int d = 0; d < 13; d++)
		{
			if (string.IsNullOrEmpty(ds[d]))
			{
				System.Console.WriteLine("D " + (d + 1).ToString());
			}
		}

		
	}
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int M, D;
	cin >> M >> D;

	int result = 0;
	for( int i = 1; i <= M; ++i ) {
		for( int j = 1; j <= D; ++j ) {
			int a = j%10;
			int b = j/10;

			if( a >= 2 && b >= 2 && i == (a*b) ) {
				result += 1;
			}
		}
	}

	cout << result << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    import sys
    input = sys.stdin.readline

    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    for i in range(n - k):
        if a[i + k] > a[i]:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


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

int a, b;
int main() {
    cin >> a >> b;
    if(a >= 1 && b >=1 && a*b % 2 != 0) {
        cout << "Odd" << endl;
    } else if(a >= 1 && b >=1 && a*b % 2 == 0) {
        cout << "Even" << endl;
    }
}

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

#define ll   long long int
#define rep(i,n)    for(int i=0;i<(int)n;i++)
#define show(s)     cout<<s<<endl

int main() {

    int N;
    cin >> N;

    vector<int> V(N);
    vector<int> C(N);

    rep(i,N)    cin >> V[i];
    rep(i,N)    cin >> C[i];

    int ans = 0;

    rep(i,N){
        int val = V[i]-C[i];
        if(val >=0){
            ans += val;
        }
    }

    show(ans);

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s1 = input()
s2 = input()
mod = 10 ** 9 + 7

com = 1
pre = "e"
flag = True
for i in range(n):
    if s1[i] == s2[i]:
        if pre == "e":
            com *= 3
        elif pre == "v":
            com *= 2
            com %= mod
        else:
            pass
        pre = "v"
    else:
        if flag == True:
            if pre == "e":
                com *= 6
            elif pre == "v":
                com *= 2
                com %= mod
            else:
                com *= 3
                com %= mod
            flag = False
        else:
            flag = True
        pre = "h"
print(com)

Measured memory_bytes: 3064
import java.util.*;
class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      	String S = sc.next();
      	String spt[] =S.split("");
      	String ans="";
      	for(int i=0;i<spt.length;i++){
      	    if(spt[i].equals("0")){
      	        ans+="0";
      	    }else if(spt[i].equals("1")){
      	        ans+="1";
      	    }else if(spt[i].equals("B")){
      	        if(!(ans.isEmpty())){
      	            ans =ans.substring(0, ans.length()-1);
      	        }
      	        
      	    }
      	}
      	
      System.out.println(ans);
    }
}


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

typedef pair<int,int> P;
bool B[1000][1000];
vector<P> ANS;

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

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if((i+j)%2==0){
                B[i][j]=true;
            }
        }
    }
    for(int i=0;i<N;i+=3){
        for(int j=0;j<N;j++){
            if(!B[i][j]){
                B[i][j]=true;
                ANS.emplace_back(i,j);
            }
        }
    }
    for(int i=0;i<N;i++){
        if(!B[N-1][i]){
            B[N-1][i]=true;
            ANS.emplace_back(N-1,i);
        }
    }
    for(int i=0;i<N;i++){
        if(!B[i][0]){
            B[i][0]=true;
            ANS.emplace_back(i,0);
        }
    }
    cout<<ANS.size()<<endl;
    for(auto ans:ANS){
        cout<<ans.first<<' '<<ans.second<<endl;
    }

    return 0;
}

Measured memory_bytes: 3952
def main():
    N,K=map(int, input().split())
    A = list(map(int, input().split()))

    dp = [float('inf')] * N
    dp[0] = 0
    for i in range(1,len(A)):
        jmp = max(0,i-K)
        dp[i] = min([dp[j]+abs(A[i]-A[j]) for j in range(jmp, i)])
    print(dp[N-1])

main()

Measured memory_bytes: 13980
#[allow(unused)]
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s
    };

    let ans = match &*s {
        "SUN" => 7,
        "MON" => 6,
        "TUE" => 5,
        "WED" => 4,
        "THU" => 3,
        "FRI" => 2,
        _ => 1,
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mem(a) memset(a,0,sizeof a)
const int N=1e5+5;
const int INF=1e9+5;
ll read(ll &a){scanf("%lld",&a);return a;}
int read(int &a){scanf("%d",&a);return a;}
int read(){int a;scanf("%d",&a);return a;}
int read(int &a,int &b){scanf("%d %d",&a,&b);return a;}
#define pii pair<int,int>
struct edge
{
    int w;
    pii u,v;
    edge(pii u=make_pair(0,0),pii v=make_pair(0,0),int w=0):u(u),v(v),w(w){}
}edges[1200000+5];
set<pii>vis;

map<pii,vector<int> >G;
int indx;
void addedges(int p,int q,int c)
{
    pii pc,qc,p0,q0;
    pc=make_pair(p,c);
    qc=make_pair(q,c);
    p0=make_pair(p,0);
    q0=make_pair(q,0);
    if(!vis.count(make_pair(p,c)))
    {
        vis.insert(pc);
        edges[indx]=edge(pc,p0,1);
        G[pc].push_back(indx++);
        edges[indx]=edge(p0,pc,1);
        G[p0].push_back(indx++);
    }
    if(!vis.count(make_pair(q,c)))
    {
        vis.insert(qc);
        edges[indx]=edge(qc,q0,1);
        G[qc].push_back(indx++);
        edges[indx]=edge(q0,qc,1);
        G[q0].push_back(indx++);
    }
    edges[indx]=edge(pc,qc,0);
    G[pc].push_back(indx++);
    edges[indx]=edge(qc,pc,0);
    G[qc].push_back(indx++);
}
int m,n;
int ans;
map<pii,int>dis;
struct node
{
    pii p;
    int d;
    node(pii p=make_pair(0,0),int d=0):p(p),d(d){}
    bool operator <(const node b)const
    {
        return d>b.d;
    }
};
priority_queue<node>pq;
void dij()
{
    ans=INF;
    dis[make_pair(1,0)]=0;
    pq.push(node(make_pair(1,0),0));
    node x;
    pii xp;
    vis.clear();
    int cur,w;
    pii v;
    while(!pq.empty())
    {
        x=pq.top();pq.pop();
        xp=x.p;
        //cout<<"XXX:"<<xp.first<<' '<<xp.second<<' '<<x.d<<endl;
        if(vis.count(xp))
            continue;
        vis.insert(xp);

        if(xp==make_pair(n,0))
        {
            ans=x.d/2;
            break;
        }

        for(int i=0;i<G[xp].size();i++)
        {
            cur=G[xp][i];
            v=edges[cur].v;
            w=edges[cur].w;

            if(vis.count(v))
                continue;

            if(!dis.count(v)||dis[v]>=dis[xp]+w)
            {
                dis[v]=dis[xp]+w;
                pq.push(node(v,dis[v]));
                //cout<<v.first<<' '<<v.second<<' '<<dis[v]<<endl;
            }
        }
    }
    if(dis.count(make_pair(n,0)))
        ans=dis[make_pair(n,0)]/2;
    else
        ans=-1;
}
int main()
{
    read(n,m);
    int p,q,c;
    for(int i=0;i<m;i++)
    {
        read(p,q);
        read(c);
        addedges(p,q,c);
    }
    dij();
    printf("%d\n",ans);
    return 0;
}


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

int main(){
	int n; cin>>n;
	vector<int> v(n);
	rep(i,n) cin>>v[i];
	
	vector<ll> b(n+1,0);
	rep(i,n) b[i+1]=b[i]+v[i];
	
	ll sum=0, ans=0;
	rep(i,n){
		sum=(b[n]-b[i+1])%m;
		ans+=v[i]*sum;
		ans%=m;
	}
	cout<<ans%m<<endl;
}

Measured memory_bytes: 5612
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	int k, x;
	while(scanf("%d%d", &k, &x)==2)
	{
		bool ans=(k*500>=x);

		printf("%s\n", ans?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x

def main():
    S = cin.string()
    m,n = 0,0
    for i,s in enumerate(S):
        if i % 2 == 0:
            if s == "0":
                m+=1
            else:
                n+=1
        else:
            if s == "0":
                n +=1
            else:
                m +=1
    print(min(n,m))
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 40048
import java.util.Scanner;


	public class Main {
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
	        
			int n = sc.nextInt();
			long[] a = new long[n+2];
			long[] b = new long[n+2];
			
			
			for(int i=1;i<=n;i++) {
				a[i] = sc.nextInt();
			}
			
			a[0]=0;
			a[n+1]=0;
			
			b[0] = 0;
			
			long sum = 0;
			
			for(int i=1;i<=n+1;i++) {
				b[i] = Math.abs(a[i]-a[i-1]);
				sum += b[i];
			}
			
			
			for(int i=1;i<=n;i++) {
				long sum2 = sum-b[i]-b[i+1]+Math.abs(a[i+1]-a[i-1]);
				
				System.out.println(sum2);
				
				
			}
	       
		}
		
	}


Measured memory_bytes: 67588
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int [] a = new int[n];
    int i;
    int m;
    int total = 0;
    for(i=0;i<n;i++){
      a[i] = sc.nextInt();
    }
    for(i=0,m=0;i<n;i++){
      if(a[i]==1){
        m += 1;
      }
    }
    if(m==0){
      System.out.println(-1);
      System.exit(0);
    }
    for(i=0,m=1;i<n;i++){
      if(a[i]!=m){
        total += 1;
      }else{
        m++;
        continue;
      }
    }
    System.out.println(total);
    }
 }



Measured memory_bytes: 85004
#include <iostream>

int main()
{
    long long r, d, x_2000;
    std::cin >> r >> d >> x_2000;

    long long current_x = x_2000;
    long long next_x;
    for (int i = 0; i < 10; i++) {
        next_x = r * current_x - d;
        std::cout << next_x << std::endl;
        current_x = next_x;
    }
}


Measured memory_bytes: 256
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <atcoder/all>
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i <= i##_len; ++i)
#define rep3(i, l, r) for (int i = l, i##_len = (r); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = l, i##_len = (r); i <= i##_len; ++i)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef int64_t Int;
typedef long long int ll;
typedef long double Ld;

using namespace std;
using namespace atcoder;
template <class T>
using Graph = vector<vector<T>>;

const Ld pi = M_PI;
const Int MOD = 998244353;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

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

    int n, m;
    cin >> n >> m;
    dsu d(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        d.merge(a, b);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (!d.same(0, i)) {
            ans++;
            d.merge(0, i);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3792
n = int(input())
points = []
center = True
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  iterator = 0
  while iterator<len(points):
    if points[iterator][2]!=0:
      points[iterator], points[0] = points[0], points[iterator]
      break
    iterator+=1
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if points[k][2]!=max(0, temph-abs(points[k][0]-i)-abs(points[k][1]-j)):
          center = False
          break
        k+=1
      if center==True:
        cx = i
        cy = j
        h = temph
        break
  print(str(cx) + ' ' + str(cy) + ' ' + str(h))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int L[n];
    rep(i,n)cin >> L[i];
    sort(L,L+n);
    int ans = 0;
    for(int i = n - 1; i > 1; i--){
        for(int j = i - 1; j > 0; j--){
            int l = 0; int r = j;
            while(l<r){
                int m = (l+r)/2;
                if(L[i] < L[j] + L[m]) r = m;
                else l = m+1;
            }
            ans += j - l;
        }
    }


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


Measured memory_bytes: 256