akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>

using namespace std;

int main()
{
        int set_number, L, R, flag = 0;
        cin >> set_number;
        array< int, 10 > ar;

        for ( int i = 0 ; i < set_number ; i++ )
        {
                for ( int j = 0 ; j < 10 ; j++ )
                {
                        cin >> ar[j];
                }

                L = ar[0];
                R = 0;
                for ( int j = 1 ; j < 10 ; j++ )
                {
                        if ( L < ar[j] )
                        {
                                L = ar[j];
                        }
                        else
                        {
                                if ( R < ar[j] )
                                {
                                        R = ar[j];
                                }
                                else
                                {
                                        cout << "NO" << endl;
                                        flag = 1;
                                        break;
                                }
                        }
                }

                if ( flag == 0 )
                {
                        cout << "YES" << endl;
                }
                flag = 0;
        }

        return 0;
}

Measured memory_bytes: 2980
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, K;
ll A[MAX_N];
ll S[MAX_N];

void solve() {
	cin >> N >> K;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, min(K, 50)) {
		memset(S, 0, sizeof(S));
		rep(j, 0, N) {
			int l = j - A[j], r = j + A[j] + 1;
			MAX(l, 0);
			MIN(r, N);
			S[r]--; S[l]++;
		}
		rep(j, 0, N) {
			S[j + 1] += S[j];
		}
		rep(j, 0, N) {
			A[j] = S[j];
		}
	}
	rep(i, 0, N) {
		cout << A[i] << " ";
	}
	cout << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}




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

int N;
char W[128][16];

int main(void) {
	int i, j;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%15s", W[i]) != 1) return 1;
	}
	for (i = 1; i < N; i++) {
		if (W[i - 1][strlen(W[i - 1]) - 1] != W[i][0]) {
			puts("No");
			return 0;
		}
		for (j = 0; j < i; j++) {
			if (strcmp(W[j], W[i]) == 0) {
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

struct edge{ll from, to, weight;};

int main(){
  ll L;
  cin >> L;
  ll N = floor(log2(L))+1;
  vector<edge> E;
  for(ll i = 1; i <= N-1; i++){
    edge e;
    e.from = i, e.to = i+1, e.weight = 1<<(i-1);
    E.push_back(e);
    e.weight = 0;
    E.push_back(e);
  }
  ll max = (1<<(N-1)) - 1;
  while(max!=L-1){
    edge e;
    e.from = floor(log2(L-max-1))+1, e.to = N; e.weight = max+1;
    E.push_back(e);
    max += 1<<(e.from-1);
  }
  cout << N << " " << E.size() << endl;
  for(auto e: E){
    cout << e.from << " " << e.to << " " << e.weight << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    string S;
    cin >> S;
    int maximum = 0;
    int count = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G') {
            count++;
        } else {
            maximum = max(maximum, count);
            count = 0;
        }
    }
    maximum = max(maximum, count);
    cout << maximum << endl;
    return 0;
}

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

class Parsing
{
private:
  string parse;
  int pos;
  int size;
  int x;
public:

  Parsing(string parse,int x):parse(parse),pos(0),x(x),size(0){}

  int StringToInt(string v)
  {
    int ret = 0;
    for(int i=0;i<v.size();i++)
      ret += (v[i]-'0')*(int)pow(10.0,v.size()-i-1);
    return ret;
  }

  string getCnt()
  {
    string v;
    while('0' <= parse[pos] && parse[pos] <= '9') 
      v += parse[pos++];
    return v;  
  }

  int getCntInt(){return StringToInt(getCnt());}

  string decode()
  {
    int power = getCntInt();
    if(parse[pos] == '(')
      pos++;
    else 
      {
	string mes,ret;
	while('A' <= parse[pos] && parse[pos] <= 'Z')	
	  mes += parse[pos++];
	
	for(int i=0;i<power;i++)
	  {
	    ret += mes;
	    if(ret.size() >= x)
	      break;
	  }
	return ret;	  
      }
    string message;
    while(('0' <= parse[pos] && parse[pos] <= '9') || ('A' <= parse[pos] && parse[pos] <= 'Z') )
      {
	if('0' <= parse[pos] && parse[pos] <= '9')
	  message += decode();
	else if('A' <= parse[pos] && parse[pos] <= 'Z')
	  message += parse[pos++];
      }  
    
    if(parse[pos] == ')')
      pos++;
    
    string ret;
    for(int i=0;i<power;i++)
      {
	ret += message,size += message.size();
	if(ret.size() >= x)
	  break;
      }
    return ret;
  }
  
  string exp()
  {
    string ret;
    for(;pos<parse.size();)
      {
	if('0' <= parse[pos] && parse[pos] <= '9')
	  ret += decode();
	else
	  ret += parse[pos++],size++;
	if(ret.size() >= x)
	  break;
      }
    return ret;
  }

  int getSize()
  {
    return size;
  }

};

int main()
{
  string Genome;  
  int pos;
  while(cin >> Genome >> pos, Genome != "0" || pos != 0)
    {
      Parsing par = Parsing(Genome,pos+1);
      string message = par.exp();
      if(message.size() <= pos)
	cout << 0 << endl;
	else
	  cout << message[pos] << endl;
    }
  return 0;
}

Measured memory_bytes: 6744
X = str(input())
em = 0
Return = []
for spam in range(len(X)):
    if X[spam] == " ":
        Return.append(int(X[em:spam]))
        em = spam+1
Return.append(int(X[em:]))
x = 1
for a in Return:
    x = x * a

print(x)

Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String u = sc.next();
		if (s.equals(u)) {
			System.out.println(a - 1);
			System.out.println(b);
		} else {
			System.out.println(a);
			System.out.println(b - 1);
		}
		
		
		
	}
}




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
using ll = long long;

int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  int f = 0, b = 0, o = 0;
  rep(i,n){
    cin>>a.at(i);
    if(a.at(i)%4==0)f++;
    else if(a.at(i)%2==0)b++;
    else o++;
  }
  int flag = 0;
  if(b>=2){
    if(f>=o)flag = 1;
  }else{
    o+=b;
    if(f>=o-1)flag = 1;
  }
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    Graph g(n);

    rep(i,n-1){
        int a, b; cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    Graph Pdist(2, (vector<int> (n,1002003004)));
    vector<int> start(2,0);
    start[1] = n-1;

    rep(i,2){
        queue<int> q;
        vector<int> dist(n,1002003004);

        auto push = [&] (int v, int d){
            if(dist[v] != 1002003004) return;
            dist[v] = d;
            q.push(v);
        };

        push(start[i],0);
        while(!q.empty()){
            int p = q.front(); q.pop();
            int d = dist[p];

            for(auto nv: g[p]){
                push(nv, d+1);
            }
        }

        rep(j,n) Pdist[i][j] = dist[j];
    }

    int cntF = 0;
    int cntS = 0;
    rep(i,n){
        if(Pdist[0][i] <= Pdist[1][i]) cntF++;
        else cntS++;
    }

    if(cntF > cntS) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;

}




Measured memory_bytes: 6924
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

// d: 現在のケタ数
// val: 現在の値
// all: ここに格納していく (参照型にしておく)
void rec(int d, long long val, vector<long long> &all) {
  // 格納
  all.push_back(val);

  // 10 桁だったらそれ以上やらずに打ち切り
  if (d == 10) return;

  // 次の桁へ進む処理
  for(int j=-1;j<=1;j++){
    int add=(val%10)+j;
    if(0<=add && add<=9)rec(d+1,val*10+add,all);
  }
} 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  int k;
  scanf("%d",&k);
  vector<ll>all;
  for(int v=1;v<10;v++) rec(1,v,all);
  sort(all.begin(),all.end());
  cout << all[k-1] << endl;
  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
using namespace std;
const int dx[] = { -1 ,0 };// U , L 
const int dy [] = { 0 ,-1 };
const int MOD = 1000 * 1000 * 1000 + 7 ;
const int N = 1000*1000+ 5   ;
const int MAXN = 1000000 ;
const int INF = INT_MAX ;
int main ( ){
fast_io();

int n , m ;
cin >> n >> m ;

vector<int> res ( n , -1) ;
for(int &x : res )
	x = -1 ; 
vector<array<int , 2 >>v(m) ; 
for(int i = 0 ; i < m ; ++i)
{
	int s , c ;
	cin >> s >> c ;
	--s ;
	v[i][0] = s , v[i][1] = c ;
	res[s] = c ;
	
}


for(int i = 0 ; i < n ; ++ i )
{
	if (i==0 and res[i] == -1 )
	res[i] = 1 ;
	else if( res[i] == -1 ) 
	res[i] = 0 ; 	
}
bool ok = true ; 
for(auto x :  v ){
int s  = x[0], c =x[1];

if( res[s] != c   )
	{ok = false ;break ; }
}

int all = (res[0] == 0 and n > 1 )  ; 
if ( n == 1 and m == 0 )
res[0] = 0 ; 	
	
if(ok and !all)
{
	for(auto x : res)
	cout << x ; 
}
else
cout << "-1" ;
br 

return 0 ;
 
}


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

#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i<=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int tmp;
    int pans=0;
    int ans=1000;
    rep(i,0,s.size()-2){
        tmp = (s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        if(ans>abs(753-tmp)) ans = abs(753-tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest

from collections import Counter

def resolve():
    n, m = map(int, input().split())
    sc = [list(map(int, input().split())) for _ in range(m)]
    end_flag = False

    # 全列挙 or 条件探索
    # if max([s for s, c in sc]) > n:
    #     end_flag = True
    #
    if n == 2 or n == 3:
        if [1, 0] in sc:
            end_flag = True
    #
    # for i in range(len(sc) - 1):
    #     if sum([1 for s, c in sc[i+1:] if s == sc[i][0] and c != sc[i][1]]) >= 1:
    #         end_flag = True
    #         break

    ans = [''] * n

    # メイン処理
    for s, c in sc:
        if ans[s - 1] == '' or ans[s - 1] == c:
            ans[s - 1] = c
        else:
            end_flag = True
            break

    # 埋まってない場所を埋める
    for i in range(len(ans)):
        if ans[i] == '':
            if i == 0 and n != 1:
                ans[i] = 1
            elif i == 0 and n == 1:
                ans[i] = 0
            elif i != 0:
                ans[i] = 0

    """
    n で桁数決め
    以下の通りならアウト
    - max_sがnより大きい
    - s, cの組み合わせが一致しない、sが複数出てくる
    - n == 2 or 3で頭が0
    
    それ以外の場合
    
        
    """

    if end_flag:
        print(-1)
    else:
        print(int(''.join(map(str, ans))))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3 3
1 7
3 2
1 7"""
        output = """702"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 2
2 1
2 3"""
        output = """-1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """3 1
1 0"""
        output = """-1"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Measured memory_bytes: 5700
#include<iostream>

using namespace std;

int main(){
    int n,min;
    int cnt = 0;
    int a[100];
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++){
        min =i;
        for(int j=i;j<n;j++){
            if(a[j]<a[min]) min=j;
        }
        if(a[i]>a[min]){
        swap(a[i],a[min]);
        cnt++;
        }
    }
    cout << a[0];
    for(int i=1;i<n;i++) cout <<" "<< a[i];
    cout << endl;
    cout << cnt << endl;
}


Measured memory_bytes: 3112
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, long long K){
  if(K==1) cout << 0 << endl;
  else cout << N-K  << endl;
}

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


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        String result;

        if (a * b % 2 == 0) {
            result = "Even";
        } else {
            result = "Odd";
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(result);

        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 21332
import math

def distance(x1, y1, x2, y2):
    return math.sqrt( (x1 - x2)**2 + (y1 - y2)**2 )

n = int(input())
x = []
y = []

for i in range(n):
    X, Y = map(int,input().split())
    x.append(X)
    y.append(Y)

sumlen = 0

for i in range(n-1):
    for j in range(n-i-1):
        sumlen += distance(x[i], y[i], x[i+j+1], y[i+j+1])
ans = sumlen / math.factorial(n) * 2 * math.factorial(n-1)

print(ans)


Measured memory_bytes: 3064
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(n), c(m), d(m);
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < m; ++i) {
		cin >> c[i] >> d[i];
	}
	for (int i = 0; i < n; ++i) {
		int k = 0;
		for (int j = 1; j < m; ++j) {
			if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < abs(a[i] - c[k]) + abs(b[i] - d[k])) {
				k = j;
			}
		}
		cout << (k + 1) << endl;
	}
	return 0;
}


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

using namespace std;

int main(void){

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    double total = 0;
    for(int i = 0;i < n;i++) {
        cin >> a[i];
        total += a[i];
    }

    sort(a.begin(), a.end(), greater<int>());

    int count = 0;
    for(int i = 0;i < n;i++){
        if(a[i] >= total / (4.0 * m)) count++;
    }

    cout << (count >= m ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for (ll i = m ; i < (ll)n ; ++i)
#define VL                vector<ll>
#define VLL               vector<vector<ll>>
#define VLLL              vector<vector<vector<ll>>>
#define INF               2e9;
#define INF_LL            1LL<<60;
#define MOD               1000000007;

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 処理
void Solve()
{
	ll K;
	string S;
	cin >> K >> S;

	string ans;
	if (K >= S.size()) {
		ans = S;
	} else {
		ans = S.substr(0, K) + "...";
	}

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3656
Tmp = []
Tmp  = input().rstrip().split(' ')

A = int(Tmp[0])
B = int(Tmp[1])

Ans = 0
Data = A
while Data <= B:
    C = Data // 10000
    D = (Data - C * 10000 )// 1000
    E = Data // 100
    F = (Data - E * 100 )// 10
    G = Data % 10
    if (C==G) and (D==F):
        Ans += 1    
    Data += 1 

print(Ans)


Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

struct dist{int x, y;};

int main(){

  int h, w, d;
  scanf("%d %d %d", &h, &w, &d);

  vector<dist> a(h * w + 1);
  REP(i,h){
    REP(j,w){
      int tmp;
      scanf("%d", &tmp);
      a[tmp] = {j, i};
    }
  }


  int q;
  scanf("%d", &q);
  
  int dp[90001] = {};
  REP(cur,h * w + 1){
      if(cur != 0 && cur + d <= h * w)
        dp[cur + d] = dp[cur] + abs(a[cur].x - a[cur + d].x) + abs(a[cur].y - a[cur + d].y);
  }
  int l, r;
  REP(i,q){
    scanf("%d %d", &l, &r);
    long long ans = dp[r] - dp[l];
    printf("%lld\n", ans); 
  }


  return 0;
}



Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

vector<int> c;
int l;

struct Graph {
    struct Vertex { int n, c; };
    struct Edge { int i, n; };
    Graph(int n, int m) : v(n, { -1 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n };
        v[i].n = m;
        m++;
    }
    void dfs(int i, int p) {
        v[i].c = c[--l];
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge &o = e[j];
            if (o.i == p) continue;
            dfs(o.i, i);
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    int n;
    cin >> n;

    Graph g(n, (n - 1) * 2);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b);
        g.add_edge(b, a);
    }

    c = vector<int>(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(c.begin(), c.end());

    int m = 0;
    for (int i = 0; i < n - 1; i++) {
        m += c[i];
    }

    l = n;
    g.dfs(0, -1);

    cout << m << '\n';
    for (int i = 0; i < n; i++) {
        cout << g.v[i].c << " \n"[i == n - 1];
    }
    cout << flush;

    //cを小さい順に頂点へ置いていく 接している辺はその数に決まる
    //最小のcは2個（以上）の頂点に現れる
    //差の絶対値の和を最小化する問題じゃん！ 違った
    //

    return 0;
}

Measured memory_bytes: 768
n = int(input())
xs = []
ys = []
for _ in range(n):
    x = input()
    y = input()
    xs.append(x)
    ys.append(y)

for i in range(n):
    a, b = xs[i], ys[i]
    L = []
    for bk in b:
        bgn_idx = 0
        for j, cur_idx in enumerate(L):
            chr_idx = a.find(bk, bgn_idx) + 1
            if not chr_idx:
                break
            L[j] = min(cur_idx, chr_idx)
            bgn_idx = cur_idx
        else:
            chr_idx = a.find(bk, bgn_idx) + 1
            if chr_idx:
                L.append(chr_idx)
    print(len(L))



Measured memory_bytes: 5640
#include<bits/stdc++.h>
#define N 500005
#define LL long long
using namespace std;
int n,l,r,L;
struct dot{
	LL x; double y;
	dot(LL _x=0,double _y=0){ x=_x,y=_y;}
}A[N],p;
dot operator +(const dot &p,const dot &q){ return dot(p.x+q.x,p.y+q.y);}
dot operator -(const dot &p,const dot &q){ return dot(p.x-q.x,p.y-q.y);}
dot operator *(const dot &p,double r){ return dot(p.x*r,p.y*r);}
dot operator *(double r,const dot &p){ return dot(p.x*r,p.y*r);}
double cj(dot p,dot q){ return p.x*q.y-p.y*q.x;}
dot Get(dot p,dot q,double x)
{
	double k=(q.y-p.y)/(q.x-p.x);
	return dot(x,k*x+(p.y-k*p.x));
}
int main()
{
	scanf("%d %d",&n,&L);
	A[l=r=1]=dot(0,0);
	while(n--){
		scanf("%lf %lld",&p.y,&p.x);
		p.y*=p.x,A[r+1]=A[r]+p,r++;
		while(l<r&&A[r].x-A[l+1].x>L) l++;
		if(A[r].x-A[l].x>L)
			A[l]=Get(A[l],A[l+1],A[r].x-L);
		while(l+1<r&&cj(A[r]-A[r-1],A[r]-A[r-2])>=0) A[r-1]=A[r],r--;
		printf("%.7lf\n",(A[r].y-A[l].y)/L);
	  }
	return 0;
}


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

using namespace std;

int main(void) {
  int N, K;
  cin >> N >> K;
  vector<int> V;
  for (int i = 0; i < N; i++) {
    int v; cin >> v;
    V.push_back(v);
  }

  multiset<int> minus[N+1][N+1];
  int cusL[N+1], cusR[N+1];
  cusL[0] = 0, cusR[0] = 0;

  for (int i = 0; i < min(K, N); i++) {
    if (i < N) {
      cusL[i+1] = cusL[i] + V[i];
      cusR[i+1] = cusR[i] + V[N-i-1];
      minus[i+1][0] = minus[i][0];
      if (V[i] < 0) {
        minus[i+1][0].insert(V[i]);
      }
        
      for (int j = 0; i + j < min(K, N); j++) {
        if (i+j < N) {
          minus[i][j+1] = minus[i][j];
          if (V[N-j-1] < 0) {
            minus[i][j+1].insert(V[N-j-1]);
          }
        }
      }
    }
  }

  int ans = -500000001;
  for (int l = 0; l <= min(K, N); l++) {
    for (int r = 0; l+r <= min(K, N); r++) {
      int tmp = cusL[l] + cusR[r];
      int k = K - (l+r);
      if (k > 0)
        for (auto it = minus[l][r].begin(); it != minus[l][r].end(); ++it) {
          tmp -= *it;
          if (--k == 0) break;
        }

      ans = max(ans, tmp);
    }
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

struct UnionFind {
    vector<int> par;
    int cnt;
    UnionFind(int size_) : par(size_, -1), cnt(size_) {}
    void unite(int x, int y) {
        if ((x = find(x)) != (y = find(y))) {
            if (par[y] < par[x]) swap(x, y);
            par[x] += par[y]; par[y] = x; cnt--;
        }
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
    int size(int x) { return -par[find(x)]; }
    int size() { return cnt; }
};

#define int int64_t

struct Edge {
    int src, dst, weight;
    Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

int n, m;
Graph g;

bool check(int l, int r) {
    UnionFind uf(g.size());
    for (auto &es : g) {
        for (auto &e : es) {
            if (l <= e.weight && e.weight <= r) {
                uf.unite(e.src, e.dst);
            }
        }
    }
    return uf.size() == 1;
}

int solve() {
    int ans = 1e9;
    for (int i = 0; i <= 10000; ++i) {
        int lb = i - 1;
        int ub = 10001;
        while (lb + 1 < ub) {
            int mid = (ub + lb) / 2;
            if (check(i, mid)) {
                ub = mid;
            } else {
                lb = mid;
            }
        }
        if (check(i, ub)) {
            ans = min(ans, ub - i);
        }
    }
    return ans == 1e9 ? -1 : ans;
}

signed main() {
    while (cin >> n >> m && n) {
        g.assign(n, {});
        for (int i = 0; i < m; i++) {
            int a, b, w;
            cin >> a >> b >> w;
            --a, --b;
            g[a].emplace_back(a, b, w);
            g[b].emplace_back(b, a, w);
        }
        cout << solve() << endl;
    }
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main()
{
	int n;
	cin >> n;
	vector<pair<int, int>> ba(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ba[i] = make_pair(b, a);
	}
	sort(ba.begin(), ba.end());
	
	int t = 0;
	for (const auto& item : ba) {
		t += item.second;
		if (item.first < t) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
map<int,int> H;

void dec2(int n){
	int a=2;
	while(n>=a*a){
		if(n%a==0){
			H[a]++;
			n/=a;
		}
		else{
			a++;
		}
	}
	H[n]++;
}

bool primeJ(int a){
	if(a==1)return false;
	else if(a==2)return true;
	else if(a%2==0)return false;
	int dim=(int)(sqrt(a));
	for (int i=2;i<=dim;i++){
		if(a%i==0)return false;
	}
	return true;
}

std::vector<int> primeL(int n){
	std::vector<int> v;
	for(int i=1;i<=n;i++){
		if(primeJ(i)){
			v.push_back(i);
		}
	}
	return v;
}

signed main(){
	cin>>N;
	for(int i=2;i<=N;i++){
		dec2(i);
	}
	vector<int> prime=primeL(N);
	int ans=0;
	REP(i,prime.size()){
		int p=prime[i];
		DEB(H[p])END
		if(H[p]>=74){
			ans++;
		}
	}
	REP(i,prime.size()){
		REP(j,prime.size()){
			if(i==j)continue;
			int p=prime[i];
			int p2=prime[j];
			if(H[p]>=2&&H[p2]>=24){
				ans++;
			}
			if(H[p]>=4&&H[p2]>=14){
				ans++;
			}
		}
	}
	for(int i=0;i<prime.size();i++){
		for(int j=i+1;j<prime.size();j++){
			for(int k=0;k<prime.size();k++){
				if(j!=k&&i!=k){
					int p=prime[i];
					int p2=prime[j];
					int p3=prime[k];
					if(H[p]>=4&&H[p2]>=4&&H[p3]>=2){
						ans++;
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()

if len(s) == 2:
    if s[0] == s[1]:
        print(1,2)
        exit()
    print(-1,-1)
    exit()

for i in range(len(s)-2):
    a,b,c = s[i],s[i+1],s[i+2]
    if a == b or b == c or c == a:
        print(i+1,i+3)
        exit()

print(-1,-1)

Measured memory_bytes: 3188
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    n=STR()
    n=int(n[-1])
    p=[0,1,6,8]
    if n==3:
        print('bon')
    elif n in p:
        print('pon')
    else:
        print('hon')
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 9140
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll n,m,k,l,g,i,h,w,a,b,c,x;
    	cin>>a>>b>>c;
    	x=(c-a-b);
    	if(x>0 && x*x>4*a*b)
    	cout<<"Yes";
    	else
    	cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define rep(i,st,end)   for(int i=st;i<end;i++)
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void s_g_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	s_g_c();
	int n;
	cin >> n;
	int a[n + 1];
	int count = 0;
	rep(i, 1, n + 1)
	{
		cin >> a[i];
		if (a[i] % 2 == 1 && i % 2 == 1)
			count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3652
program main;
var
  h, a, n, t, i : longint;
  win : boolean;


begin
  readln(h, n);
  a := 0;
  for i := 1 to n do begin
    read(t);
    inc(a, t);
  end;
  readln;
  if (h-a <= 0) then win := true
  else win := false;
  if win then writeln('Yes')
  else writeln('No');

end.

Measured memory_bytes: 1368
//============================================================================
// Name        : atcoder.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int N,ans=0;
int main() {
	cin>>N;
	for(int i=1;i<=N;++i){
		ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var a = new int[] { 0, 1, 2, 4, 6, 16, 12, 64, 24, 36, 48, 1024, 60 };
        var n = int.Parse(Console.ReadLine().Trim());
        Console.WriteLine(a[n]);
    }
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

using namespace std;

int main() {
	int N, A = 0, B = 0;
	cin >> N;
	vector<int>v(N);
	REP(i, N) {
		cin >> v[i];
	}
	sort(v.begin(), v.end(),greater<int>());
	REP(i, N) {
		if (i % 2 == 0) {
			A += v[i];
		}
		else {
			B += v[i];
		}
	}

	cout << A - B << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
char c[30],d[30];
bool vis[30],v[30];
int main()
{
    memset(vis,false,sizeof(vis));
    memset(v,false,sizeof(v));
    string s,t;
    cin>>s;
    cin>>t;
    bool flag=true;
    for(int i=0;i<s.size();i++)
    {
        int x=s[i]-'a';
        if(!vis[x]) vis[x]=true,c[x]=t[i];
        else if(c[x]!=t[i]) {flag=false;break;}
       x=t[i]-'a';
if(!v[x]) v[x]=true,d[x]=s[i];
        else if(d[x]!=s[i]) {flag=false;break;}
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 776
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main{
	Scanner s=new Scanner(System.in);

	void solve(){
		int[]a=INTS(3).sorted().toArray();
		System.out.println(
				(a[0]==a[1]&&a[1]!=a[2])
				||(a[0]!=a[1]&&a[1]==a[2])
				?"Yes":"No"
				);
	}

	public static void main(String[] A){
		new Main().solve();
	}

	int gInt(){
		return Integer.parseInt(s.next());
	}
	long gLong(){
		return Long.parseLong(s.next());
	}
	double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,this::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,this::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,this::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(this::gInt).limit(n);
	}
	LongStream LONGS(int n){
		return LongStream.generate(this::gLong).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}

class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int t;
	Supplier<T> supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}
}


Measured memory_bytes: 27476
#include <iostream>
#include <cstring>
#define INF 2000
using namespace std;

int graph[105][105],n,closest[105],color[105],p[105];
int sum=0;
void prim(){
    int i,j;
    while(1){
        int v=-1,minv=INF;
        for(i=0;i<n;i++){
            if(minv>closest[i]&&color[i]!=1){
                minv=closest[i];
                v=i;
            }
        }
        if(v==-1)break;
        color[v]=1;
        closest[v]=INF;
        for(i=0;i<n;i++){
            if(color[i]!=1&&graph[v][i]<closest[i]&&graph[v][i]!=-1){
                closest[i]=graph[v][i];
                p[i]=v;
            }
        }
    }

    for(i=1;i<n;i++){
        if(p[i]!=-1)sum+=graph[i][p[i]];
    }
}

int main()
{
    memset(color,0,sizeof(color));
    memset(graph,-1,sizeof(graph));
    cin>>n;
    int i,j;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            cin>>graph[i][j];
        }
    }
    for(i=0;i<n;i++){
        p[i]=-1;
        closest[i]=INF;
    }
    closest[0]=0;
    prim();
    cout<<sum<<endl;
    return 0;
}

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

typedef long long ll;

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

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n,m,c;
	cin >> n >> m >> c;
	int b[m];
	FOR(i,0,m)cin >> b[i];
	int ans = 0;
	FOR(i,0,n){
		int check = c;
		FOR(j,0,m){
			int a;
			cin >> a;
			check += a * b[j];
		}
		if(check > 0)ans++;
	}
	ANS(ans);
	return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    long long ans = 0;
    //iはmod b
    for (int i = 1; i <= n; i++){
        if (i-1 < k) continue;
        ans += (n/i) * (i-k);
        if (k!=0) ans += max(0, (n % i) - k + 1);
        else ans += n % i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    int n;
    cin >> n;
    if(n>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
int main()
{
  int n,x,i=0;
  scanf("%d",&n);
  while(i<n)
  {
    scanf("%d",&x);
    if(x%2==0&&(x%3!=0&&x%5!=0))
    {
      printf("DENIED");
      return 0;
    }
    i++;
  }
  printf("APPROVED");
  return 0;
}


Measured memory_bytes: 128
def main_v2():
    row, column = list(map(int, input().split()))
    lst = [[0 for _ in range(column + 1)] for _ in range(row + 1)]

    for i in range(row):
        tmp = list(map(int, input().split()))
        for j in range(column):
            lst[i][j] = tmp[j]
        lst[i][column] = sum(lst[i])

    for j in range(column + 1):
        for i in range(row):
            lst[row][j] += lst[i][j]

    for i in range(row + 1):
        print(lst[i][0], end="")
        for j in range(1, column + 1):
            print(f" {lst[i][j]}", end="")
        print()

    return 0


if __name__ == "__main__":
    main_v2()


Measured memory_bytes: 6224
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

int a[1000000], s[1000000];
map<int,int> mp;
signed main(){
	int n, ans = 0;
	scanf("%lld", &n);
	rrep(i,n)scanf("%lld", &a[i]);
	rrep(i,n)s[i] = s[i-1]+a[i];
	rep(i,n+1)mp[s[i]]++;
	for(auto it = mp.begin();it != mp.end();it++){
		int tmp = it->second;
		if(tmp >= 2){
			ans += (tmp*(tmp-1))/2;
		}
	}
	printf("%lld\n", ans);
	return 0;
}




Measured memory_bytes: 18432
n = int(input())
a = [int(i) for i in input().split()]
c = [0] * n
for i in a:
    c[i-1] += 1
combinations = [i * (i - 1) // 2 for i in c]
sum = sum(combinations)

for k in range(1,n+1):
    print(sum - combinations[a[k-1]-1] + max(0, c[a[k-1]-1] -1) * max(0, c[a[k-1]-1] - 2) // 2)


Measured memory_bytes: 26268
// Aizu Vol-1 0190: Eleven Puzzle
// 2017.8.23 bal4u@uu
// 2017.11.21

#include <stdio.h>
#define TM 0
#if TM
#include <time.h>
#endif

typedef unsigned long long UL;

#define HASHSIZ 900007
typedef struct { UL s; char m; } HASH;
HASH hash[HASHSIZ+3], *hashend = hash+HASHSIZ;

int lookup(UL s)
{
	HASH *p = hash + s % HASHSIZ;
	while (p->s) {
		if (p->s == s) return p->m;
		if (++p == hashend) p = hash;
	}
	return -1;
}

int insert(UL s, char m)
{
	HASH *p = hash + s % HASHSIZ;
	while (p->s) {
		if (p->s == s) return 0;
		if (++p == hashend) p = hash;
	}
	p->s = s, p->m = m;
	return 1;
}

#define MAX 500000
typedef struct { UL s; char b1, b2; } QUE;
QUE Q[MAX+3], *top, *end, *qmax = Q+MAX;

int move[13][5] = {
	/*  0 */{ 2, -1 },
	/*  1 */{ 2, 5, -1 },
	/*  2 */{ 0, 1, 3, 6, -1 },
	/*  3 */{ 2, 7, -1 },
	/*  4 */{ 5, -1 },
	/*  5 */{ 1, 4, 6, 9, -1 },
	/*  6 */{ 2, 5, 7, 10, -1 },
	/*  7 */{ 3, 6, 8, 11, -1 },
	/*  8 */{ 7, -1 },
	/*  9 */{ 5, 10, -1 },
	/* 10 */{ 6, 9, 11, 12, -1 },
	/* 11 */{ 7, 10, -1 },
	/* 12 */{ 10, -1 } };

UL swap(UL s, int p, int sp)
{
	UL n;
	p = (12 - p) << 2, sp = (12 - sp) << 2;
	n = (s >> p) & 0xf;
	s &= ~(0xfULL << p);
	return s | (n << sp);
}

int seach(UL s, int b1, int b2, int mode, int lim)
{
	int i, j, x, b[2], step = 1;
	UL s2;

	top = end = Q, end->s = s, end->b1 = b1, end->b2 = b2, end++, end->s = 0, end++;
	while (top+1 < end) {
		s = top->s, b[0] = top->b1, b[1] = top->b2, top++;
		if (!s) { step++, end->s = 0, end++; continue; }
		if (step > lim) break;
//	printf("%#15llx, b1 %2d, b2 %2d, step %2d\n", s, b[0], b[1], step);
		for (i = 0; i < 2; i++) {
			for (j = 0; (x = move[b[i]][j]) >= 0; j++) {
				if (x == b[0] || x == b[1]) continue;
				s2 = swap(s, x, b[i]);
				if (mode) { if (lookup(s2) >= 0) return step; }
				else if (!insert(s2, step)) continue;
				end->s = s2;
				if (i) end->b1 = b[0], end->b2 = x;
				else   end->b1 = x, end->b2 = b[1];
				end++;
			}
		}
	}
	return step;
}

#define PAR  14
int main()
{
	UL s;
	int i, ans, p, b1, b2;
#if TM
	clock_t start, finish;
	start = clock();
#endif
	s = 0x123456789ab0ULL, insert(s, 0);
	seach(s, 0, 12, 0, PAR);
	while (1) {
		for (b1 = -1, s = i = 0; i < 13; i++) {
			scanf("%d", &p);
			if (p < 0) goto done;
			if (!p) { if (b1 < 0) b1 = i; else b2 = i; }
			s = (s << 4) | p;
		}
		if ((ans = lookup(s)) < 0) {
			if ((ans = seach(s, b1, b2, 1, 20-PAR)) > 20-PAR) ans = -1;
			else ans += PAR;
		}
		printf(ans < 0 ? "NA\n" : "%d\n", ans);	
	}
done:
#if TM
	finish = clock();
	printf("time %lf\n", (double)(finish-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 17976