akhauriyash/Code-Regression huggingface dataset:
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}

typedef long long int ll;
#define int ll
#define endl '\n'
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll inf = 1e18+123;
const int maxn = 2000001;

int32_t main()
{

   IOS
   int a,b,n;
   cin>>a>>b>>n;
   int x = min(n,b-1);
   int ans = ((a*x))/b - a*(x/b);
   cout<<ans<<endl;
  
} 


Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
using namespace std;

int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  char bit = '0';
  int a=0, b=0;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == bit){
      a++;
    }else{
      b++;
    }
    if(bit == '1'){
      bit = '0';
    }else{
      bit = '1';
    }
  }

  cout << min(a,b) << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int A,P;
    cin >> A >> P;
    P += A * 3;
    cout << P / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << ' ' << y << ' ' << z << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<iostream>
#include<cmath>
#define LL long long
#define N (100005)
using namespace std;
int a,b,k; 
template <typename T> void read(T&t) {
	t=0;
	bool fl=true;
	char p=getchar();
	while (!isdigit(p)) {
		if (p=='-') fl=false;
		p=getchar();
	}
	do {
		(t*=10)+=p-48;p=getchar();
	}while (isdigit(p));
	if (!fl) t=-t;
}
int main(){
	read(a),read(b),read(k);
	for (int j=min(a,b);j>=1;j--){
		if (a%j==0&&b%j==0){
			if (k==1){
				printf("%d",j);
				return 0;
			}
			else k--;
		}
	}
	return 0;
}


Measured memory_bytes: 256
/*
 * (c) fushar (Ashar Fuadi)
*/

#include <bits/stdc++.h>

#define REP(i,n) for (int i = 0, _n = n; i < _n; i++)
#define FOR(i,a,b) for (int i = a, _b = b; i <= _b; i++)
#define FORD(i,b,a) for (int i = b, _a = a; i >= _a; i--)
#define RESET(c,v) memset(c, v, sizeof c)
#define ALL(c) c.begin(), c.end()

using namespace std;
using ll = long long;

/***********************************************************/

ll N, A, B;

ll solve() {
    if (N == 1) {
        return A == B ? 1 : 0;
    }
    if (A > B) {
        return 0;
    }
    return (N-2) * (B-A) + 1;
}

int main() {
    cin >> N >> A >> B;
    cout << solve() << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace test
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			List<String> resultList = new List<String> ();

			int n = int.Parse (Console.ReadLine ());
			for(int j=0;j<n;j++)  {
				string[] inputArray = Console.ReadLine().Split (' ');
				List<int> aList = new List<int>();
				List<int> bList = new List<int> ();

				aList.Add(int.Parse(inputArray[0]));
				string judge = "YES";
				for (int i=1; i<10; i++) {
					if (aList [aList.Count - 1] < int.Parse (inputArray [i])) {
						aList.Add (int.Parse (inputArray [i]));
					} else if (bList.Count == 0 || bList [bList.Count - 1] < int.Parse (inputArray [i])) {
						bList.Add (int.Parse (inputArray [i]));
					} else {
						judge = "NO";
						break;
					}
				}

				resultList.Add (judge);
			}

			foreach (string j in resultList) {
				Console.WriteLine (j);
			}



		}


	}
	
}

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


int main() {
  string S, ans = "Yes";
  cin >> S;
  int a = S.size();
  
  for(int i=0; i < a; i++){
    if((i%2 == 0 && S[i] == 'L') || (i%2 == 1 && S[i] == 'R')){
      ans = "No";
      break;
    }
  }
  
  cout << ans << endl;
  return 0;
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
template<class T> int gmax(T &a, T b) { if (b > a) { a = b; return 1; } return 0; }
template<class T> int gmin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; }
using namespace std;

const int N = 25;
int h[N];
int main() {
    int n;
    while(~scanf("%d", &n)) {
        for(int i = 0; i < n; ++i) {
            scanf("%d", &h[i]);
        }
        int maxx = -1;
        int cnt = 0;
        for(int i = 0; i < n; ++i) {
            if(h[i] >= maxx)
                cnt ++;
            maxx = max(maxx, h[i]);
        }
        printf("%d\n", cnt);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
	return os << "(" << p.first << ", " << p.second << ")";
}

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

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin()) os << ", ";
		os << *it;
	}
	return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << it -> first << " = " << it -> second ;
	}
	return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
	for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
	FASTIO
	///*
// #ifndef ONLINE_JUDGE
// 	freopen("in.txt", "r", stdin);
// 	freopen("out.txt", "w", stdout);
// 	freopen("error.txt", "w", stderr);
// #endif
//*/
	int T;
	//scanf("%d", &T);
	T = 1;
	for (int cs = 1; cs <= T; cs++) {
		int n;
		cin >> n;
		int sm = 0;
		int mx = 0;
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			sm += x;
			mx = max(mx, x);
		}
		sm -= mx;
		if (sm > mx) cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
mod = 10**9 + 7

L = input()

N = len(L)

dp = [[0]*2 for _ in range(N+1)]
dp[0][0] = 1

for i in range(1,N+1):
    if L[i-1] == "1":
        dp[i][0] = 2 * dp[i-1][0]
        dp[i][1] = dp[i-1][0] + 3 * dp[i-1][1]
    elif L[i-1] == "0":
        dp[i][0] = dp[i-1][0]
        dp[i][1] = 3 * dp[i-1][1]
    
    dp[i][0] %= mod
    dp[i][1] %= mod

ans = dp[N][0] + dp[N][1]
ans %= mod
print(ans)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    IOS;

    string s;
    cin >> s;

    bool ok = false;

    sort(all(s));

    map<char, int>mp;

    loop(i, s.length()) {

        mp[s[i]]++;
    }

    vector<int>v;

    for (auto it : mp)
    {
        v.pb(it.second);
    }

    for (int i = 0; i < v.size(); i++)
    {
        if (v[i] % 2 != 0)
        {
            ok = true;
        }
    }

    if (ok == true)
    {
        cout << "No" << endl;

    }

    else
    {
        cout << "Yes" << endl;
    }


}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 100005;


int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);

    string st;
    cin >> st;
    int ans = 0;
    rep(i,sz(st)) {
    	if(st[i] != 'A' and st[i] != 'C' and st[i] != 'G' and st[i] != 'T')
    			continue;
    	int le = 1;
    	repA(j,i+1,sz(st)-1) {
    		if(st[j] != 'A' and st[j] != 'C' and st[j] != 'G' and st[j] != 'T')
    			break;
    		le++;
    	}
    	ans = max(ans, le);
    }
    cout << ans << '\n';
}

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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int a,b;
  cin >> a >> b;
  if(a == b){
    cout << a*2 << endl;
    return 0;
  }else{
    int tmp = max(a,b);
    cout << 2*tmp-1 << endl;
  }
}

Measured memory_bytes: 256
from collections import deque

N,M = map(int, input().split())
to_nodes = [[] for _ in range(N)] #終点ノード
deg = [0]*N #入力辺

for _ in range(M):
    x,y = map(int, input().split())
    to_nodes[x-1].append(y-1)
    deg[y-1] += 1

st = deque()
push, pop = st.append, st.popleft

for n in range(N):
    if deg[n] == 0:
        push(n) #入力辺が無く、最長パスの始点になりうる点を取得

dp = [0]*N
#print(deg,dp)
while st:
    n = pop()
    nodes = to_nodes[n]
    for ni in nodes:
        deg[ni] -= 1 #使ったエッジをグラフから削除する
        if deg[ni] == 0:
            push(ni)
            dp[ni] = max(dp[ni], dp[n] + 1)
        #print('n',n,'ni',ni,deg,dp)

print(max(dp))

'''''
@input
4 5
1 2
1 3
3 2
2 4
3 4
@output
[0, 2, 1, 2] [0, 0, 0, 0]
n 0 ni 1 [0, 1, 1, 2] [0, 0, 0, 0]
n 0 ni 2 [0, 1, 0, 2] [0, 0, 1, 0]
n 2 ni 1 [0, 0, 0, 2] [0, 2, 1, 0]
n 2 ni 3 [0, 0, 0, 1] [0, 2, 1, 0]
n 1 ni 3 [0, 0, 0, 0] [0, 2, 1, 3]
3
'''''

Measured memory_bytes: 60448
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename TYPE>
void print_vec(const vector<TYPE>& v, int num=0){
  if(num == 0) num = (int)v.size();
	for(int i=0; i<num; i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

template<typename T>
struct BIT{
  int n;
  vector<T> d;
  BIT(int n=0): n(n), d(n+1){}

  void add(int i, T x=1){
    for(i++; i<=n; i+=i&(-i)){
      d[i] += x;
    }
  }
  
  T sum(int i){
    T x = 0;
    for(i++; i; i-=i&(-i)){
      x += d[i];
    } 
    return x;
  }
};

int main(){

  int INF = 100000;
  vector<int> num_divisor(INF+1, 0);
  for(int i=2; i<=INF; i++){
    for(int j=i; j<=INF; j+=i){
      num_divisor[j]++;
    }
  }

  BIT<int> bi(INF+1);
  for(int i=2; i<=INF; i++){
    if(num_divisor[i] == 1){
      if(num_divisor[(i+1)/2] == 1) bi.add(i);
    }
  }
  // cout << " num_divisor: "; print_vec(num_divisor, 10);
  int Q;
  cin >> Q;
  for(int i=0; i<Q; i++){
    int l, r;
    cin >> l >> r;
    // cout << " bi.sum(r): " << bi.sum(r) << "   bi.sum(l-1): " << bi.sum(l-1) << "   bi.sum(r) - bi.sum(l-1): " << bi.sum(r) - bi.sum(l-1) << endl;
    cout << bi.sum(r) - bi.sum(l-1) << endl;
  }

	return 0;
}



Measured memory_bytes: 3864
// Problem : C - Many Requirements
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_c?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、 
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 vi a,b,c;
 vl d;
int N,M,Q;
vi v;
ll mx=-1;
void calc(int lv,int level)
{
	if(level==N)
	{
		ll ans=0;
		F0R(x,Q)
		{
			if(v[b[x]]-v[a[x]]==c[x])
				ans+=d[x];
			// if(v[0]==1 && v[1]==3 && v[2]==4)
			// {
				// bug(v[a[x]]-v[b[x]]);
				// bug(c[x]);
			// }
		}
		ckmax(mx,ans);
		return;
	}
	FOR(x,lv,M+1)
	{
		v[level]=x;
		calc(x,level+1);
	}
}
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	cin>>N>>M>>Q;
	F0R(x,Q)
	{
		int n1,n2,n3,n4;
		cin>>n1>>n2>>n3>>n4;
		a.pb(n1-1),b.pb(n2-1),c.pb(n3),d.pb(n4),v.pb(0);
	}
	calc(1,0);
	cout<<mx;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

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

int main()
{
	int h, w; cin >> h >> w;
	
	const int cSize = 10;

	vector<vector<int>> c(cSize, vector<int>(cSize));
	for (int i = 0; i < cSize; i++) {
		for (int j = 0; j < cSize; j++) {
			cin >> c[i][j];
		}
	}

	const int rangeMaximum = 10;
	vector<int> num(rangeMaximum, 0);
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			int tmp_a;
			cin >> tmp_a;
			if(0 <= tmp_a) num[tmp_a]++;
		}
	}

	int n = cSize;
	for (int k = 0; k < n; k++) {       // 経由する頂点
		for (int i = 0; i < n; i++) {    // 始点
			for (int j = 0; j < n; j++) {  // 終点
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < rangeMaximum; i++) ans += c[i][1] * num[i];

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
	n = int(input().strip())
	s = [0] * 5
	for i in range(5):
		s[i] = int(input().strip())
	m = min(s)
	if n % m == 0:
		print(n // m + 4)
	else:
		print(n // m + 5)

if __name__ == '__main__':
	main()


Measured memory_bytes: 38384
#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()

status = 0

for i in range(2):
    if n[i] == n[i+1] and n[i] == n[i+2]:
        status = 1
        break

if status == 1:
    print "Yes"
else:
    print "No"


Measured memory_bytes: 2572
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define  rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i>=0; i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1e9+7;
struct mint {
  typedef long long ll;
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, M; std::cin >> N >> M;
  if ( std::abs(N-M) >= 2 ) std::cout << 0 << std::endl;
  else {
    mint ans = 1.;
    for(int i=1; i<=N; i++) ans *= i;
    for(int i=1; i<=M; i++) ans *= i;
    if ( N == M ) ans *= 2;
    std::cout << ans.x << std::endl;
  }
  return 0;
}


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

#define TRUE	(1)
#define FALSE	(0)

#define IS_IN_RANGE_X(c) ((('1' <= (c)) && ((c) <= '6'))? TRUE : FALSE)
#define IS_IN_RANGE_Y(c) ((('1' <= (c)) && ((c) <= '5'))? TRUE : FALSE)

int convert(char *str);

char converted[101];

char table[5][6] = 	{
					 {'a', 'f', 'k', 'p', 'u', 'z'},
					 {'b', 'g', 'l', 'q', 'v', '.'},
					 {'c', 'h', 'm', 'r', 'w', '?'},
					 {'d', 'i', 'n', 's', 'x', '!'},
					 {'e', 'j', 'o', 't', 'y', ' '}
					};

int main(void)
{
	char input[201];
	
	while (~scanf("%s", input)){
		memset(converted, 0, sizeof(converted));
		
		if (TRUE == convert(input)){
			printf("%s\n", converted);
		}
		else {
			puts("NA");
		}
	}
	
	return (0);
}

int convert(char *str)
{
	int now, convert_cnt;
	int pos_x, pos_y;
	char ret = TRUE;
	
	for (now = convert_cnt = 0; *(str + now) != '\0'; now += 2, convert_cnt++){
		pos_x = *(str + now);
		pos_y = *(str + now + 1);
		
		if (FALSE == IS_IN_RANGE_X(pos_x) || FALSE == IS_IN_RANGE_Y(pos_y) || '\0' == pos_y){
			ret = FALSE;
			break;
		}
		
		converted[convert_cnt] = table[pos_y - '0' - 1][pos_x - '0' - 1];
	}
	
	return (ret);
}


Measured memory_bytes: 2056
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A & a, const B & b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A & a, const B & b) { a = max(a, (A)b); };

ll N;
struct node {
	bool state;
	vector<ll> link;
	vector<ll> dist;
};
vector<node> nod;

void f(ll ind, ll par) {
	REP(i, 0, nod[ind].link.size()) {
		if (nod[ind].link[i] == par) {
			if (nod[ind].dist[i] % 2 == 0) nod[ind].state = nod[par].state;
			else nod[ind].state = !nod[par].state;
			break;
		}
	}
	for (ll c : nod[ind].link) {
		if (c != par)f(c, ind);
	}
}

int main() {
	cin >> N;
	nod.resize(N);
	REP(i, 0, N-1) {
		ll u, v, w;
		cin >> u >> v >> w;
		--u; --v;
		nod[u].link.push_back(v);
		nod[v].link.push_back(u);
		nod[u].dist.push_back(w);
		nod[v].dist.push_back(w);
	}
	nod[0].state = true;
	f(0, -1);
	REP(i, 0, N) PRI((nod[i].state ? 1 : 0));
	return 0;
}

Measured memory_bytes: 16296
n,k=map(int,input().split())

def cmb(n, r, mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return (fact[n] * factinv[r] * factinv[n-r])%mod

mod=10**9 + 7
fact=[1,1]
factinv=[1,1]
inv=[0,1]
 
for i in range(2, 2*n + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)
    
ans=0

if k>=(n-1):
    ans=cmb(2*n-1,n,mod)
else:
    for i in range(k+1):
        ans+=cmb(n,i,mod)*cmb(n-1,i,mod)
        ans%=mod
    
    
    
print(ans)




Measured memory_bytes: 119660
#include <bits/stdc++.h>
using namespace std;
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(){

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

long long int k,n;
cin>>k>>n;

long long int a[n];
long long int b[n];



for(long long int i=0;i<n;i++){
cin>>a[i];
}

for(long long int i=1;i<n;i++){
b[i]=a[i]-a[i-1];
}
b[0]=a[0]+(k-a[n-1]);

sort(b,b+n);

cout<<k-b[n-1]<<endl;




}


Measured memory_bytes: 3328
N = int(input())
last_fizz = (N // 3) * 3
last_buzz = (N // 5) * 5
last_fibu = (N // 15) * 15

N_sum = N * (N + 1) / 2
if N >= 3:
  fizz_sum = (N // 3) * (3 + last_fizz) / 2
  N_sum -= fizz_sum
if N >= 5:
  buzz_sum = (N // 5) * (5 + last_buzz) / 2
  N_sum -= buzz_sum
if N >= 15:
  fibu_sum = (N // 15) * (15 + last_fibu) / 2
  N_sum += fibu_sum
print(int(N_sum))

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a + n);
    for(int i = 0; i < n; i++){
        if(a[i] == a[i + 1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long unsigned int ull;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    int mod2019[n];
    mod2019[0] = 1;
    REP(i,n-1){
        mod2019[i+1] = mod2019[i]*10%2019;
    }
    REP(i,n){
        mod2019[i] *= s[n-i-1]-'0';
    }
    REP(i,n-1){
        mod2019[i+1] += mod2019[i];
        mod2019[i+1] %= 2019;
    }
    ll cnt[2019] = {};
    REP(i,2019){
        REP(j,n){
            if(mod2019[j]==i){
                cnt[i]++;
            }
        }
    }
    ll ans = cnt[0];
    REP(i,2019){
        ans += cnt[i]*(cnt[i]-1)/2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4472
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner itr = new Scanner(System.in);
        int X = itr.nextInt();

        int res = 0;
        res += 1000 * (X / 500);
        X = X % 500;
        res += 5 * (X / 5);

        System.out.println(res);

    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x)	make_pair(x);
    
#define debug(x) 		cerr << #x << '=' << x << endl;
#define debug2(x, y)	cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << _x << ' '; cerr << endl;
#define debugm(a) 		cerr << #a << ":\n"; \
						for (auto v: a) { for(const auto x: v) cout << x << ' '; cerr << "\n"; }
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long
 
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;
 
const int INF  = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 1000000007;

const int N = 85;

int a[N][N];
int b[N][N];
int dp[N][N][20000];

int32_t main()
{
	FAST_IO;
	
	int h, w;
	cin >> h >> w;
	
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) cin >> a[i][j];
	
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) cin >> b[i][j];
	
	dp[0][0][abs(b[0][0]-a[0][0])] = true;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int lim = (i+j+1)*80;
			for (int k = 0; k <= lim; k++) {
				if (dp[i][j][k]) {
					if (i+1 < h) {
						dp[i+1][j][abs(k-(a[i+1][j]-b[i+1][j]))] = true;
						dp[i+1][j][abs(k+(a[i+1][j]-b[i+1][j]))] = true;
					}
					if (j+1 < w) {
						dp[i][j+1][abs(k-(a[i][j+1]-b[i][j+1]))] = true;
						dp[i][j+1][abs(k+(a[i][j+1]-b[i][j+1]))] = true;
					}
				}
			}
		}
	}
	int ans = 0;
	while (!dp[h-1][w-1][ans]) ans++;
	cout << ans << endl; 
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


Measured memory_bytes: 1020928
import java.io.*;
import java.util.*;



public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
                    
        str = br.readLine();
        int N = Integer.parseInt(str);
        str = br.readLine();
        
        String[] strs = str.split("\\s");
        int[] line = new int[N];
        for(int i=0;i<N;i++){
            line[i] = Integer.parseInt(strs[i]);
        }

        int ans =0;

        for(int i=0;i<N;i++){
            for(int j = N-1;j >= 1; j--){
                if(line[j] < line[j -1]){
                    ans++;
                    int temp = line[j-1];
                    line[j -1] = line[j];
                    line[j] = temp;
                }
            }
        }

        StringBuilder sb = new StringBuilder();
        for(int i =0;i<N;i++){
            if(i != N -1){
            sb.append(String.valueOf(line[i]));
            sb.append(" ");
            }else{
                sb.append(String.valueOf(line[i]));
            }
        }
        sb.append("\n");
        sb.append(String.valueOf(ans));
        System.out.println(sb.toString());
        br.close();
    }

    
}


Measured memory_bytes: 24588
#include<stdio.h>

int a, n, m;

int dfs(int k, int num, int sum){
        if(num>m) return 0;
        if(k==0){
                int i=n+1, ans = 1;
                while(--i) ans *= sum+a;
                return ans==num && num!=0;
        }

        int i, ans = 0;
        for(i=0; i<10; i++) ans += dfs(k-1, num*10+i, sum+i);
        return ans;
}

int main(void){
        scanf("%d %d %d", &a, &n, &m);
        int ans = dfs(8, 0, 0);
        printf("%d\n", ans);
        return 0;
}


Measured memory_bytes: 2132
#include<iostream>
using namespace std;
#define MAX 100100
#define ll long long
int a[MAX],n;
ll ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	for(int i=1;i<=n;++i)
	{
		ans+=a[i]/2,a[i]%=2;
		if(a[i]&&a[i+1])++ans,--a[i+1];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 
int main() {
    ll l,r,d,cnt=0;
    cin>>l>>r>>d;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0){cnt++;}
    }
    cout<<cnt;
}


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

using namespace std;

int main()
{
    string S;

    cin >> S;
    reverse(S.begin(), S.end());

    uint32_t len = S.length();
    uint32_t i;

    for (i = 0; i < len;)
    {
        if (S.compare(i, 6, "resare") == 0)
        {
            i += 6;
        }
        else if (S.compare(i, 5, "esare") == 0)
        {
            i += 5;
        }
        else if (S.compare(i, 5, "maerd") == 0)
        {
            i += 5;
        }
        else if (S.compare(i, 7, "remaerd") == 0)
        {
            i += 7;
        }
        else
        {
            break;
        }
    }
    if (i != len)
        cout << "NO\n";
    else
        cout << "YES\n";
    return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
int a[300];
int main(){
string s;
cin>>s;
for(int i=0;i<s.size();i++)
a[(int)s[i]]++;
int p=min(a[(int)'K'],a[(int)'U']);
int t=min(a[(int)'P'],a[(int)'C']);
cout<<min(p,t)<<endl;
}

Measured memory_bytes: 3196
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;
long h[100005];

int main(){
    scanf("%ld", &n);
    for(int i = 0; i < n; i++){
        scanf("%ld", h+i);
    }
    for(int i = n-2; i >= 0; i--){
        if(h[i] == h[i+1] + 1){
            h[i]--;
        }else if(h[i] > h[i+1]){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
}


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

int main() {
    int n;
    std::cin >> n;

    int k;
    std::cin >> k;

    std::vector<int> bs{};
    for (int i = 0; i < k; ++i) {
        int b;
        std::cin >> b;
        bs.push_back(b);
    }

    // XXX: using `test` function with bitset failed. why?
    for (int i = 0; i < (1 << n); ++i) {
        bool is_ok = true;
        for (int b : bs)
            if (~i & (1 << b)) {
                is_ok = false;
                break;
            }
        if (!is_ok) continue;

        std::vector<int> members{};
        for (int j = 0; j < n; ++j)
            if (i & (1 << j)) members.push_back(j);

        std::cout << i << ':';
        for (int j : members) std::cout << ' ' << j;
        std::cout << std::endl;
    }
}

/**
 * ref: https://onlinejudge.u-aizu.ac.jp/
 *        solutions/problem/ITP2_11_B/review/3113216/face4/C++14
 */


Measured memory_bytes: 3156
import math
import itertools

N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]

t = 2*math.factorial(N-1)

ans = 0
for p1,p2 in itertools.combinations(XY,2):
    x1,y1 = p1
    x2,y2 = p2
    l = ((x1-x2)**2+(y1-y2)**2)**.5
    ans += l*t
ans /= math.factorial(N)
print(ans)

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, m;
  cin >> n >> m;

  vvll g(n);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  rep(i, n) sort(all(g[i]));

  vll v;
  rep(i, n) v.push_back(i);

  ll ans = 0;
  do {
    bool ok = true;
    rep(i, n - 1) {
      if (!binary_search(all(g[v[i]]), v[i + 1])) {
        ok = false;
        break;
      }
    }
    if (ok)
      ans++;
  } while (next_permutation(v.begin() + 1, v.end()));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3612
fun main(args: Array<String>) {
  val (H, N) = readLine()!!.split(" ").map{it.toInt()}
  val A = readLine()!!.split(" ")
  var atack_sum = 0
  var noFlag = true
  for(i in A) {
    atack_sum += i.toInt()
    if(atack_sum >= H) {
      print("Yes")
      noFlag = false
      break
  	}
  }
  if(noFlag) {
  	print("No")
  }
}

Measured memory_bytes: 48324
//g++  5.4.0

#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pii pair< int,int >
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;


signed main()
{
    fast;
    int x;
    cin >> x;
    cout << (x/500)*1000 + ( (x%500 )/5 * 5 );
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end();
int main() {
  int a,b;
  cin >> a >> b;
  int c,d,MIN=999999,flag=0;
  rep(i,a){
    cin >> c >> d;
    if(d<=b){
      MIN = min(MIN,c);
      flag = 1;
  }
  }
  if(flag) cout << MIN;
  else cout << "TLE";
}

Measured memory_bytes: 3544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.HashMap;

public class Main{
	

	
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num[] = new int[101];
		String price;
		
		while((price = br.readLine()) != null){
			num[Integer.parseInt(price)]++;
		}
		
		int max = -1;
		
		for(int i = 1;i <= 100;i++){
			
			if(max<num[i]){
				max = num[i];
			}
			
		}
		
		for(int i = 1;i <= 100;i++){
			
			if(max == num[i]){
				System.out.println(i);
			}
			
		}
	}
}

Measured memory_bytes: 24176
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

h,w,d=nii()

a_dict={}
for i in range(h):
  a=lnii()
  for j in range(w):
    a_dict[a[j]]=(i,j)

b_dict={}
for i in range(1,h*w+1):
  if i-d<=0:
    b_dict[i]=0
  else:
    oy,ox=a_dict[i-d]
    ny,nx=a_dict[i]
    b_dict[i]=b_dict[i-d]+abs(ny-oy)+abs(nx-ox)

q=int(input())
for i in range(q):
  l,r=nii()
  ans=b_dict[r]-b_dict[l]
  print(ans)

Measured memory_bytes: 38892
#include<iostream>
using namespace std;
int main(){
	int a=0;
	int b=0;
	int s[100];
	int n=0;
	int i=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a>>b;
		s[i]=a%b;
		if(s[i]==0){
			s[i]=b;
		}
	}
	for(i=0;i<n;i++){
		cout<<s[i]<<endl;
	}
}

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <bitset>
using namespace std;
using ll = long long;

const int N = 2000;
bitset<N> left_wins[N];
bitset<N> right_wins[N];
bitset<N> wins[N];

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

	int n;
	cin >> n;
	for (int i = 1; i < n; ++i) {
		string str;
		cin >> str;
		for (int j = 0; j < i; ++j) {
			if (str[j] == '1') wins[i][j] = 1;
			else wins[j][i] = 1;
		}
	}
	for (int b = 0; b < n; ++b) {
		right_wins[b][b] = 1;
		left_wins[b][b] = 1;
		for (int a = b-1; a >= 0; --a) {
			bitset<N> mask;

			mask = wins[b] & left_wins[a] & right_wins[b-1];
			if (mask.count() > 0) left_wins[a][b] = 1;
			// cerr << "b win [" << a << ", " << b << "] = " << mask.count() << '\n';

			mask = wins[a] & left_wins[a+1] & right_wins[b];
			if (mask.count() > 0) right_wins[b][a] = 1;
			// cerr << "a win [" << a << ", " << b << "] = " << mask.count() << '\n';

			/*
			cerr << "Int bits:\n\t";
			for (int j = a; j <= b; ++j) cerr << left_wins[a][j]; cerr << "\n\t";
			for (int j = a; j <= b; ++j) cerr << right_wins[b][j]; cerr << '\n';
			*/
		}
	}

	bitset<N> res = left_wins[0] & right_wins[n-1];
	cout << res.count() << '\n';
}


Measured memory_bytes: 1792
/*
 *  Lang    : C++
 *  Author  : little_angel
 */
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int mod = 1e9 + 7;

inline int mul(int a, int b) {
    return a * b % mod;
}

inline void add(int &a, int b) {
    a += b;
    if (a >= mod)a -= mod;
}

string k;
int d, dp[10001][101][2];
// pos, sum, is_small

int dfs(int pos, int sum, bool small) {
    if (pos == k.length())return sum == 0;
    if (~dp[pos][sum][small])return dp[pos][sum][small];
    int res = 0;
    for (int dig = 0; dig < 10; ++dig) {
        if (dig > k[pos] - '0' && !small)break;
        add(res, dfs(pos + 1, (sum + dig) % d, small || dig < k[pos] - '0'));
    }
    return dp[pos][sum][small] = res;
}

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

    cin >> k >> d;
    memset(dp, -1, sizeof(dp));
    cout << (dfs(0, 0, false) - 1 + mod) % mod << endl;
}

Measured memory_bytes: 16896
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
 
using namespace std;
 
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

#ifdef __BORLANDC__
	typedef __int64 ll;
#else
	typedef long long ll;
#endif


int main(){
	int n;
	cin>>n;
	
	rep(i,n){
		const int H = 8;
		vector<string> m(H);
		rep(i,H){
			cin>>m[i];
		}
		
		int stx,sty;
		cin>>stx>>sty;
		stx--;sty--;
		
		if(m[sty][stx]=='1')m[sty][stx]='2';
		
		
		while(1){
			bool moved = false;
			
			rep(i,H){
				rep(j,H){
					if(m[i][j]=='2'){
						reps(k,-3,4){
							reps(p,-3,4){
								int ny = i+k;
								int nx = j+p;
								if(k!=0 && p!=0)continue;
								if(ny<0||nx<0||ny>=H || nx>=H)continue;
								if(m[ny][nx]=='1'){
									m[ny][nx]='2';
									moved=true;
								}
							}
						}
						m[i][j]='0';
						moved=true;
					}
				}
			}
			
			if(!moved)break;
		}
		
		printf("Data %d:\n",i+1);
		rep(i,H){
			cout<<m[i]<<endl;
		}
	}
}

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

int main () {
  int N;	cin >> N ;
  
  set<int> s;
  for (int i=0; i<N; i++) {
    int a; cin >> a;
    if (s.count(a)) {
      s.erase(a);
    }
    else {
      s.insert(a);
    }
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 4864
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int h,w,n;
    cin >> h >> w >> n;
    int M = max(h,w);
    cout << (n+M-1)/M << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def gcd(a, b):
    if a > b:
        a, b = b, a
    while a != 0:
        a, b = b % a, a
    return b


# input = sys.buffer.readlines()
n = int(input())
a = list(map(int, input().split()))
# 左右からの累積和を計算し、どのいちを消すかでループ回す
r_cum = [0] * n
l_cum = [0] * n
r_cum[n - 1] = a[-1]
l_cum[0] = a[0]
for i in range(1, n):
    l_cum[i] = gcd(l_cum[i - 1], a[i])
for i in range(n - 2, -1, -1):
    r_cum[i] = gcd(r_cum[i + 1], a[i])
# 本当は番兵を入れると実装が楽だった
ans = max(l_cum[n - 2], r_cum[1])
# print(r_cum, l_cum)
for i in range(1, n - 1):
    ans = max(ans, gcd(r_cum[i + 1], l_cum[i - 1]))
print(ans)


Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+7;
map<string,int>mp;
string s[maxn];
std::map<string,int>::iterator it;
bool cmp(string a,string b){
	return a<b;
}
int main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s[i];
		mp[s[i]]++;
	}
	it=mp.begin();
	int maxx=-1;
	while(it!=mp.end()){
		maxx=max(maxx,it->second);
		it++;
	}
	//cout<<maxx<<endl;
	sort(s+1,s+1+n,cmp);
	for(int i=1;i<=n;i++){
		if(mp[s[i]]==maxx){
			cout<<s[i]<<endl;
			mp[s[i]]=0;
		}
	}
	return 0;
}

Measured memory_bytes: 33024
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

ll exp(ll);

int main() {

	int a, b;
	cin >> a >> b;

	if (a <= 5) cout << 0 << endl;
	else if (a <= 12) cout << b / 2 << endl;
	else cout << b << endl;

	return 0;
}

Measured memory_bytes: 256