akhauriyash/Code-Regression huggingface dataset:
#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; 
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
typedef tree<int, null_type, less<int>, 
rb_tree_tag, tree_order_statistics_node_update> pbset; 
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 2e+5+5;
int big = 1e+18+3;
int mod = 1e+9+7;
int n,k;
int ar[N];

bool check(int maxLen)
{
    int rem = k;

    repa(i,1,n)
    {
        if (ar[i]<=maxLen)
            continue;

        int fct = ar[i]/maxLen;
        rem-=fct;

        if ( ar[i]%maxLen==0 )
            rem++;
    }

    if (rem>=0)
        return true;
    return false;
}

signed main()
{
    IOS;
        
    cin>>n>>k;

    repa(i,1,n)
        cin>>ar[i];

    int low = 1; int high = 1e9;
    int ans = 1e9;

    while(low<=high)
    {
        int mid = (low+high)/2;

        if (check(mid))
            ans = mid, high = mid - 1;
        else
            low = mid + 1;
    }

    cout<< ans <<endl;             
}

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

#define __ ios::sync_with_stdio(0),  cin.tie(0);
#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

int main(){__
  int a, b; cin >> a >> b;
  cout << a*b << endl;
  return 0;
}

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
    
    (a, b) = [int(e) for e in lines[0].split(" ")]

    return (a, b)


def solve(a, b):

   
    x1f = math.floor(a / 0.08)
    x1c = math.ceil(a / 0.08)
    x2f = math.floor(b / 0.1)
    x2c = math.ceil(b / 0.1)

    both = []
    if math.floor(x1f * 0.08) == a and math.floor(x1f * 0.1) == b:
        both.append(x1f)

    if math.floor(x1c * 0.08) == a and math.floor(x1c * 0.1) == b:
        both.append(x1c)

    if math.floor(x2f * 0.08) == a and math.floor(x2f * 0.1) == b:
        both.append(x2f)

    if math.floor(x2c * 0.08) == a and math.floor(x2c * 0.1) == b:
        both.append(x2c)


    result = -1
    if len(both):
        result = min(both)
    

    return  result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll tyo=(ll)1e12*2;
using namespace std;

int main(){
  string S;
  cin>>S;
  if(S[0]==S[1]&&S[1]==S[2]) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <utility>

const int N = 100000;

int n, a[N], b[N], c[N], order[N], fw[N];
std::pair<double, int> order2[N];

bool by_slope(int i, int j)
{
    return a[i] * b[j] < a[j] * b[i];
}

long long count(double x)
{
    for (int i_ = 0; i_ < n; ++ i_) {
        int i = order[i_];
        order2[i] = {(c[i] - a[i] * x) / b[i], i_};
    }
    std::sort(order2, order2 + n);
    memset(fw, 0, sizeof(*fw) * n);
    long long result = 0;
    for (int i = 0; i < n; ++ i) {
        for (int k = order2[i].second; k < n; k += ~k & k + 1) {
            result += fw[k];
        }
        for (int k = order2[i].second; k >= 0; k -= ~k & k + 1) {
            fw[k] ++;
        }
    }
    return result;
}

double solve()
{
    for (int i = 0; i < n; ++ i) {
        if (b[i] < 0) {
            a[i] *= -1;
            b[i] *= -1;
            c[i] *= -1;
        }
    }
    std::sort(order, order + n, by_slope);
    auto need = (1LL * n * (n - 1) >> 1) + 1 >> 1;
    double x_min = -2e8;
    double x_max = +2e8;
    for (int _ = 0; _ < 70; ++ _) {
        double x = 0.5 * (x_min + x_max);
        if (count(x) >= need) {
            x_max = x;
        } else {
            x_min = x;
        }
    }
    return 0.5 * (x_min + x_min);
}

int main()
{
#ifdef LOCAL_JUDGE
    freopen("E.in", "r", stdin);
#endif
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i) {
        scanf("%d%d%d", a + i, b + i, c + i);
        order[i] = i;
    }
    double x = solve();
    for (int i = 0; i < n; ++ i) {
        std::swap(a[i], b[i]);
    }
    double y = solve();
    printf("%.11f %.11f\n", x, y);
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t,u;
    cin>>s>>t;
    int sn,tn;
    cin>>sn>>tn;
    cin>>u;
    if(s==u)
        cout<<--sn<<" "<<tn;
    else
        cout<<sn<<" "<<--tn;
    cout<<endl;

}


Measured memory_bytes: 256
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]

H = int(fetch_one_line())
W = int(fetch_one_line())
N = int(fetch_one_line())

large_num = H if H > W else W
import math
print(math.ceil(N / large_num))


Measured memory_bytes: 38256
#include <stdio.h>
#include <string.h>
int main (int argc, char * argv[])
{
    char p[100];
    char s[100];
    char s1[100];
    scanf("%s",s);
    scanf("%s",p);
    strcpy(s1,s);
    strcat(s,s1);
    if ( strstr(s, p) == NULL ) printf("No\n");
    else printf("Yes\n");
    return 0;

}


Measured memory_bytes: 2100
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')


#import numpy as np

def main():
	n,k=MI()
	ans=n%k

	print(min(ans,k-ans))










if __name__ == "__main__":
	main()

Measured memory_bytes: 9236
n = int(input())
timeList = list(map(int, input().split()))
m = int(input())
argList = [list(map(int, input().split())) for _ in range(m)]

#普通にやると
res_time = sum(timeList)

for a in argList:

    #a[0]問目を解くのに　a[1]秒かかるよ
    print(res_time - timeList[a[0]-1] + a[1])



Measured memory_bytes: 9172
#include <bits/stdc++.h>
 
#define int long long
#define MOD 1000000007
 
using namespace std;
 
template <class T> ostream &operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for (auto v : V)
        os << v << " ";
    os << "]";
    return os;
}
template <class T> ostream &operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for (auto s : S)
        os << s << " ";
    return os << "}";
}
template <class L, class R> ostream &operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for (auto m : M)
        os << "(" << m.first << ":" << m.second << ") ";
    return os << "}";
}
template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
 

 
void solve() {
    int a[5];
    int flag = 0;
    for(int i = 0;i < 5; i++) {
        cin >> a[i];
        if(a[i] == 0) {
            flag = i;
        }
    }
    cout << flag + 1 << endl;
}
 
int32_t main() {
    int t;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    // cin >> t;
    // while(t--) {
    //     solve();
    // }
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>

using  namespace std;

static const int SIZE = 100;

int bubbleSort(int A[], int N)
{
    int count = 0;
    for(int i = 0; i < N; i++)
    {
        for(int j = N - 1; j > i; j--)
        {
            if(A[j - 1] > A[j])
            {
                swap(A[j], A[j - 1]);
                count++;
            }
        }
    }
    return count;
}

int main()
{
    int A[SIZE];
    int N;
    int count;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    count = bubbleSort(A, N);
    for(int i = 0; i < N; i++)
    {
        cout << A[i];
        if(i != N - 1)
        {
            cout << ' ';
        }
    }
    cout << endl << count << endl;
    return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int main()
{
    char str[20],s[20]="CODEFESTIVAL2016";

    while(scanf("%s",str)==1)
    {
        int cnt=0;

        for(int i=0; i<16; i++)
        {
            if(str[i]!=s[i])
                cnt++;
        }

        printf("%d\n",cnt);
    }

    return (0);
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
MOD = 10 ** 9 + 7
N,K = map(int,input().split())
fac = [1, 1]
inv = [0, 1]
finv = [1, 1]
for i in range(2, N+1):
    fac.append(fac[-1] * i % MOD)
    inv.append(MOD - inv[MOD%i] * (MOD//i) % MOD)
    finv.append(finv[-1] * inv[-1] % MOD) 
def comb_mod(n, r, m):
    if (n<0 or r<0 or n<r): return 0
    r = min(r, n-r)
    return fac[n] * finv[n-r] * finv[r] % m
ans = 0
for i in range(1,K+1):
    c = comb_mod(K-1,i-1,MOD)
    d = comb_mod(N-K+1,i,MOD)
    ans = c * d
    print(ans%MOD)

Measured memory_bytes: 22812
from collections import defaultdict
from bisect import bisect_right
s = input()
t = input()
ss = set(s)
tt = set(t)
count = 0
for i in tt:
  if not i in ss:
    print(-1)
    break
else:
  dic = defaultdict(list)
  for i in range(len(s)):
    dic[s[i]] += [i+1]
  ans = 0
  for i in range(len(t)):
    x = ans%len(s)
    if dic[t[i]][-1]<=x:
      ans = ans - x + len(s) + dic[t[i]][0]
    else:
      ind = bisect_right(dic[t[i]], x)
      ans = ans - x + dic[t[i]][ind]
  print(ans)

Measured memory_bytes: 52464
#include <stdio.h>
int main(void) {
int i,n,x;
scanf("%d", &n);
for( i=0; i<n; ++i) {
x=i+1;
if(x%3==0) {
printf(" %d", i+1);
}else {
while(x){
if(x%10==3){
printf(" %d", i+1);
break;
}
x /= 10;
}
}
}
putchar('\n');
}

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

using namespace std;

int main()
{
	int n; cin >> n;
	map<string, int> m;
	for (int i = 0; i < n; i++) {
		string tmp; cin >> tmp;
		m[tmp]++;
	}
	map<int, set<string>> rm;
	for (const auto &p : m) {
		rm[p.second].insert(p.first);
	}
	auto it = rm.rbegin();
	for (const auto &s : it->second) {
		cout << s << endl;
	}

	return 0;
}


Measured memory_bytes: 34560
k = int(input())

from math import gcd

gcd_sum = [0] * 201
ans = 0


for i in range(1, k+1):
    for j in range(1, k+1):
        gcd_sum[i] += gcd(i,j)

       
for a in range(1,k+1):
    for b in range(1,k+1):
        g = gcd(a,b)
        ans += gcd_sum[g]

print(ans)

Measured memory_bytes: 9192
#include <algorithm>
#include <cstdio>
using std::scanf;
using std::printf;

const int kMaxN = 1000;
const int kMaxWi = 10000;

int BinarySearch(int A[], int n, int key) {
  int left = 0, right = n, mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key) { return mid; }
    if (key < A[mid]) { right = mid; }
    if (A[mid] < key) { left = mid + 1; }
  }
  return -1;
}

// w[i]?????????????????????????????????cycle???????????????????????????remain????????£?????????????¨????
// ????????????cycle?????????
int MakeCycle(int w[], int i, int n, int index_sorted[], int remain[], int cycle[]) {
  int j = 0;
  cycle[0] = -1; //?????????while?????????????????????
  while(w[i] != cycle[0]) {
    cycle[j] = w[i];
    ++j;
    remain[i] = 0;
    i = index_sorted[w[i]];
  }
  return j;
}

int CompareCosts(int cycle[], int n_cycle, int min_cycle, int min_w) {
  if (n_cycle == 1) {
    return 0;
  } else if (n_cycle == 2) {
    return cycle[0] + cycle[1];
  } else {
    int cycle_sum, i, cost1, cost2;
    cycle_sum = 0;
    for (i = 0; i < n_cycle; ++i) { cycle_sum += cycle[i]; }
    cost1 = cycle_sum + (n_cycle - 2) * min_cycle;
    cost2 = cycle_sum + min_cycle + (n_cycle + 1) * min_w;
    return std::min(cost1, cost2);
  }
}

int main() {
  int n, i, j, min_w, n_cycle, min_cycle, cnt;
  int index_sorted[kMaxWi + 1];
  scanf("%d", &n);
  int w[n], sorted[n], remain[n], cycle[n];
  for (i = 0; i < n; ++i) { scanf("%d", &w[i]); }
  min_w = kMaxWi;
  for (i = 0; i < n; ++i) { min_w = std::min(min_w, w[i]); }
  for (i = 0; i < n; ++i) { sorted[i] = w[i]; }
  std::sort(sorted, sorted + n);
  for (i = 0; i < n; ++i) { index_sorted[sorted[i]] = i; }
  for (i = 0; i < n; ++i) { remain[i] = 1; }
  cnt = 0;
  for (i = 0; i < n; ++i) {
    if (remain[i]) {
      n_cycle = MakeCycle(w, i, n, index_sorted, remain, cycle);
      min_cycle = kMaxWi;
      for (j = 0; j < n_cycle; ++j) { min_cycle = std::min(min_cycle, cycle[j]); }
      cnt += CompareCosts(cycle, n_cycle, min_cycle, min_w);
    }
  }
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 2828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=200005;
ll a[N],b[N];
void GG(){
	puts("-1"); exit(0);
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read();
	For(i,0,n)a[i]=read();
	if(n==0){
		if(a[0]!=1)GG();
		else puts("1");
		return 0;
	}
	if(a[0])GG();
	Rep(i,n,1)b[i]=b[i+1]+a[i];
	ll dq=1,ans=1;
	For(i,1,n){
		if(a[i]>dq*2)GG();
		if(dq*2<=b[i])dq*=2;
		else dq=b[i];
		ans+=dq; dq-=a[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5140
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
#endif

  int x, y;
  while (scanf("%d%d", &x, &y) == 2) {
    if (x % y == 0) {
      printf("-1\n");
    } else {
      printf("%d\n", x);
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n, k;
  cin >> n >> k;
  if(n%k == 0) cout << 0 << endl;
  else cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int n, a;
        scanf("%d %d", &n, &a);
        if (a >= n % 500) puts("Yes");
        else puts("No");
        return 0;
}



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

const int N=200005;
const int mod=1000000007;

struct E{
	int to,next;
}mem[N<<1];
int n,num,x,y,ssr,siz,res,ns,sum,ans,h,t,m;
int head[N],fac[N],inv[N],dp[N],sz[N],q[N],tp[N],d[N];
bool vis[N];

void addedge(int x,int y){
	num++;
	mem[num].to=y; mem[num].next=head[x];
	head[x]=num; d[x]++;
}

int quickpow(int x,int y){
	int s=1;
	for (;y;y>>=1,x=1ll*x*x%mod)
		if (y&1) s=1ll*s*x%mod;
	return s;
}

void init(int n){
	int i; fac[0]=inv[0]=1;
	for (i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=quickpow(fac[n],mod-2);
	for (i=n-1;i>=1;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}

int C(int x,int y){
	if (x<y) return 0;
	return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}

void bfs(int st){
	int k,u,j;
	h=t=0; q[++t]=st;
	while (h<t){
		k=q[++h]; vis[k]=1;
		for (j=head[k];j;j=mem[j].next){
			u=mem[j].to;
			if (!vis[u]){
				vis[u]=1; q[++t]=u;
			}
		}
	}
}

void topsort(){
	int k,u,j;
	while (h<t){
		k=tp[++h];
		for (j=head[k];j;j=mem[j].next){
			u=mem[j].to; d[u]--;
			if (d[u]==1) tp[++t]=u;
		}
	}
}

void dfs(int k,int pre,int rt){
	int j,u;
	for (j=head[k];j;j=mem[j].next){
		u=mem[j].to;
		if (u==pre||u==rt) continue;
		dfs(u,k,rt);
	}
	dp[k]=1; sz[k]=0;
	for (j=head[k];j;j=mem[j].next){
		u=mem[j].to;
		if (u==pre||u==rt) continue;
		if (u<pre){
			dp[k]=1ll*dp[k]*dp[u]%mod*C(sz[k]+sz[u],sz[u])%mod;
			sz[k]+=sz[u];
		}
		else{
			ssr=1ll*ssr*dp[u]%mod*C(siz+sz[u],sz[u])%mod;
			siz+=sz[u];
		}
	}
	sz[k]++;
}

void solve(int x,int &res,int &ns){
	int i,k,st=0,j; res=0;
	bfs(x);
	ns=t; h=t=0; m=0;
	for (i=1;i<=ns;i++){
		k=q[i];
		for (j=head[k];j;j=mem[j].next) m++;
		if (d[k]==1) tp[++t]=k;
	}
	if (m/2!=ns) return;
	topsort(); t=0;
	for (i=1;i<=ns;i++)
		if (d[q[i]]>1&&q[i]>st) st=q[i];
	for (i=head[st];i;i=mem[i].next)
		if (d[mem[i].to]>1) tp[++t]=mem[i].to;
	for (i=1;i<=t;i++){
		ssr=1; siz=0;
		dfs(st,tp[i],st);
		ssr=1ll*ssr*dp[st]%mod*C(siz+sz[st],sz[st])%mod;
		res=(res+ssr)%mod;
	}
}

int main(){
	int i;
	scanf("%d",&n);
	for (i=1;i<=n+n;i++){
		scanf("%d%d",&x,&y);
		addedge(x,y+n); addedge(y+n,x);
	}
	init(2*n);
	ans=1;
	for (i=1;i<=n;i++)
		if (!vis[i]){
			solve(i,res,ns);
			ans=1ll*ans*res%mod*C(sum+ns,ns)%mod;
			sum+=ns;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 13056
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222


ll dp[111][11];

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

  ll h, w, k;
  cin >> h >> w >> k;
  dp[0][0] = 1;
  rep(i, h) {
    rep(bit, 1 << (w - 1)) {
      if (bit&bit << 1) continue;
      rep(j, w) {
        if (!j) {
          if (bit & 1) (dp[i + 1][j + 1] += dp[i][j]) %= mod;
          else (dp[i + 1][j] += dp[i][j]) %= mod;
        }
        else if (j == w - 1) {
          if (bit >> (w - 2) & 1) (dp[i + 1][j - 1] += dp[i][j]) %= mod;
          else (dp[i + 1][j] += dp[i][j]) %= mod;
        }
        else {
          if (bit >> (j - 1) & 1) (dp[i + 1][j - 1] += dp[i][j]) %= mod;
          else if (bit >> j & 1) (dp[i + 1][j + 1] += dp[i][j]) %= mod;
          else (dp[i + 1][j] += dp[i][j]) %= mod;
        }
      }
    }
  }


  cout << dp[h][k - 1] << endl;


  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private void doit() {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0){
				break;
			}
			int [] data = new int[7];
			while(n-- > 0){
				int now = sc.nextInt();
				if(now < 10){
					data[0]++;
				}
				else if(now > 59){
					data[6]++;
				}
				else{
					data[now / 10]++;
				}
			}
			for(int s: data){
				System.out.println(s);
			}
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
import math
A,B,C,D = map(int,input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

lcm = lcm(C,D)

u_b_ans = (B//C + B//D) - B//lcm
u_a_ans = ((A-1)//C + (A-1)//D) - (A-1)//lcm

print(B-A+1 - u_b_ans + u_a_ans)

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

int N;
int A, B, C;
int l[8];
int ans = INT_MAX;

void myplus(int depth, int nA, int nB, int nC, int synth) {
  if (depth < N) {
    myplus(depth + 1, nA + l[depth], nB, nC, synth + 1);
    myplus(depth + 1, nA, nB + l[depth], nC, synth + 1);
    myplus(depth + 1, nA, nB, nC + l[depth], synth + 1);
    myplus(depth + 1, nA, nB, nC, synth);
  } else {
    if (nA != 0 && nB != 0 && nC != 0)
      ans = min(ans, (abs(nA - A) + abs(nB - B) + abs(nC - C) + synth * 10));
  }
}

int main() {
  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }
  myplus(0, 0, 0, 0, -3);
  cout << ans;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define Rep(i,n) for(int i=0; i<(n); i+=2)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
const int INF = 1e9;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数
 


int main() {
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    ll ans = 0;

    for (int i = 2; i <= g / i; i++)
    {
        if(g%i==0){
            ans++;
            while (g%i==0){
                g /= i;
            }
        }
    }
    if(g>1){
        ans++;
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
using namespace std;

set<string> st;
set<string>::iterator it;

int main() {
	st.clear();
	
	int n; cin>>n;
	string last;
	for(int i=0;i<n;i++) {
		string s;
		cin>>s;
		if(i>0) {
			it=st.find(s);
			bool chk = true;
			if(it!=st.end()) chk = false;
			if(s[0] != last[last.length()-1]) chk = false;
			if (!chk) {
				puts("No");
				return 0;
			}
		}
		st.insert(s);
		last = s;
	}
	puts("Yes");
	
	return 0;
}

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

template <class T>
inline void read(T &res)
{
	char ch; bool flag = false; res = 0; 
	while (ch = getchar(), !isdigit(ch) && ch != '-');
	ch == '-' ? flag = true : res = ch ^ 48;
	while (ch = getchar(), isdigit(ch))
		res = res * 10 + ch - 48;
	flag ? res = -res : 0;
}

const int N = 305;
const int M = 605;
const int mod = 1e9 + 7;
int s1[M], s2[M], a[M], b[M], f[2][N][M];
bool tag[M], del[M]; 
int n, m, cnt;

inline void add(int &x, int y)
{
	x += y;
	x >= mod ? x -= mod : 0;
}

inline void Delete(int x)
{
	del[x] = true;
	for (int i = 1; i <= m; ++i)
		if (!del[i] && a[i] > a[x])
			--a[i];
}

int main()
{	
	read(n);
	m = n << 1;
	for (int i = 1; i <= m; ++i)
		read(a[i]);
	for (int i = 1; i <= m; i += 2)
		if (~a[i] && ~a[i + 1])
		{
			Delete(i);
			Delete(i + 1);
		}
	n = 0; 
	for (int i = 1; i <= m; i += 2)
		if (!del[i])
		{
			if (~a[i])
				tag[a[i]] = true;
			if (~a[i + 1])
				tag[a[i + 1]] = true;
			if (a[i] == -1 && a[i + 1] == -1)
				++cnt;
			++n;
		}
	m = n << 1;
	f[m + 1 & 1][0][0] = 1;
	for (int i = m; i >= 1; --i)
	{
		int now = i & 1, lst = now ^ 1;
		s1[i] = s1[i + 1] + tag[i];
		s2[i] = s2[i + 1] + !tag[i];
		if (tag[i])
		{
			for (int j = 0; j <= s1[i]; ++j)
				for (int k = 0; k <= s2[i]; ++k)
				{
					f[now][j][k] = j > 0 ? f[lst][j - 1][k] : 0;
					add(f[now][j][k], f[lst][j][k + 1]);
				}	
		}
		else
		{
			for (int j = 0; j <= s1[i]; ++j)
				for (int k = 0; k <= s2[i]; ++k)
					f[now][j][k] = (1ll * f[lst][j + 1][k] * (j + 1) 
				                  + (k > 0 ? f[lst][j][k - 1] : 0) + f[lst][j][k + 1]) % mod; 
		}
	}
	int res = f[1][0][0];
	for (int i = 1; i <= cnt; ++i)
		res = 1ll * res * i % mod;
	printf("%d\n", res);
	return 0;
}
/*
10
10 9 -1 -1 8 -1 17 -1 11 12 3 -1 4 -1 15 -1 -1 -1 18 19
*/


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

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N;
    cin>>N;
	vector<int> a(N),b(N);
	for(int i=0;i<N;i++){
		//www
		cin>>a.at(i)>>b.at(i);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	cout<<a.at(N-1)+b.at(N-1)<<endl;
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
 
/// Typedef
typedef long long           ll;
typedef unsigned long       ul;
typedef unsigned long long  ull;
typedef vector<int>         vi;
typedef vector<vi>          vvi;
typedef vector<ll>          vll;
typedef pair<int,int>       pii;
typedef pair<ll,ll>         pll;
 
#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define ff                  first
#define ss                  second
#define sf                  scanf
#define pf                  printf
#define SQR(x)              ((x)*(x))
#define loop(i, y)          for(int i=0; i<int(y); i++)
#define FOR(i, x, y)        for(int i=int(x); i<int(y); i++)
#define ROF(i, x, y)        for(int i=int(x); i>=int(y); i--)
#define all(c)              c.begin(), c.end()
#define sz(c)               int(c.size())
#define clr(x, y)           memset(x, y, sizeof(x))
#define si(x)               scanf("%d", &x)
#define sii(x, y)           scanf("%d %d", &x, &y)
#define siii(x, y, z)       scanf("%d %d %d", &x, &y, &z)
#define sl(x)               scanf("%lld", &x)
#define sll(x, y)           scanf("%lld %lld", &x, &y)
#define slll(x, y, z)       scanf("%lld %lld %lld", &x, &y, &z)
#ifdef VAMP
     #define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define dbg(...)
#endif
/// Constants
#define N                   111
#define MOD                 1000000007
#define base                1000000007
#define eps                 1e-9
#define INF                 1llu<<61    // 2,305,843,009,213,693,952
#define inf                 (ll)1e18     // 536,870,912
#define PI                  acos(-1.0)  // 3.1415926535897932
// #define INF              0x3f3f3f3f3f3f3f3f
// #define inf              0x3f3f3f3f
struct Point{
    int x,y;
    Point(){}
    Point(int _x,int _y){
        x = _x;
        y = _y;
    }
};
double dist(Point a,Point b){
    return sqrt(SQR(a.x-b.x) + SQR(a.y-b.y));
}
vector<Point> v; int a[10];
int main(){
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("C:\\Users\\raiha.DESKTOP-5M3GJRN\\Videos\\Raihan\\input.txt", "r", stdin);
        freopen("C:\\Users\\raiha.DESKTOP-5M3GJRN\\Videos\\Raihan\\output.txt", "w", stdout);
    #endif
    int n,x,y;
    si(n);
    FOR(i,0,n){
        sii(x,y);
        v.pb(Point(x,y));
        a[i]=i;
    }
    double ans = 0,tmp=1;
    do{
        FOR(i,0,n-1){
            ans += dist(v[a[i]],v[a[i+1]]);
            // tmp++;
        }
    }while(next_permutation(a,a+n));
    FOR(i,1,n+1)tmp*=i;
    pf("%f\n",ans/(tmp*1.0));
    #ifdef VAMP
       printf("\n>>Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;


int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll arr[n];
	for(ll i=0; i<n; i++){
		cin>>arr[i];
	}
	for(ll i=1; i<n; i++){
		ll flag=arr[i]-arr[i-1];
		ll g=flag*a;
		ans +=min(g,b);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> point;
const double pi = std::acos(-1.0);
const double eps = 1e-10;
point p[10][10];
int order[10];
struct line: vector<point> {
    line() {}
    line(const point& a, const point& b) {
        push_back(a), push_back(b);
    }
};
inline double dot(const point& a, const point& b) {
    return (a * conj(b)).real();
}
inline point symmetric(const line &l, const point &p) {
    double t = dot(p - l[0], l[0] - l[1]) / norm(l[0] - l[1]);
    return (l[0] + t * (l[0] - l[1])) * 2.0 - p;
}

bool between(double l, double r, double x)
{

	if (r < 0) {
		r += 2 * pi;
		if (l < 0) l += 2 * pi;
	}
	if (x < 0 && l > 0) {
		x += 2 * pi;
	}
	return l < x + eps && x < r + eps;
}

bool solve(const vector< pair<double, double> >& v) {
	double l = v[0].first, r = v[0].second;
	for(int i = 1; i < v.size(); i ++){
		if (between(v[i].first, v[i].second, l) && between(v[i].first, v[i].second, r)) continue;
		bool flag = false;
		if (between(l, r, v[i].first)) {
			flag = true;
			l = v[i].first;
		}
		if(between(l, r, v[i].second)) {
			r = v[i].second;
			flag = true;
		}
		if (!flag){
			return false;
		}
	}
    return true;
}

int main() {
    int n, sx, sy;
    while(cin >> n && n) {
        scanf("%d %d", &sx, &sy);
        point s = point(sx, sy);
        for(int i = 0, x, y; i < n; i ++) {
            scanf("%d %d", &x, &y);
            p[0][i] = point(x, y);
        }
        p[0][n] = p[0][0];
        for(int i = 0; i < n; i ++) {
            order[i] = i;
        }
        int ans = 0;
        do {
            vector< pair<double, double> > v;
            double l = -pi, r = pi;
            for(int f = 1; f <= n; f ++) {
                int x = order[f - 1], y = (x + 1) % n;
                for(int i = 0; i < n; i ++) {
                    p[f][i] = symmetric(line(p[f - 1][x], p[f - 1][y]), p[f - 1][i]);
                }
                double l1 = std::arg(p[f - 1][x] - s);
                double r1 = std::arg(p[f - 1][y] - s);
				if (l1 * r1 > 0) {
					if (l1 > r1) swap(l1, r1);
				}
				else{
					if ((l1 > 0 || r1 < 0) && pi - l1 + r1 > 0) swap(l1, r1);
					else if((r1 > 0 || l1 < 0) && r1 - l1 > pi) swap(l1, r1);
				}
				l1 += eps;
				r1 -= eps;
                v.push_back(make_pair(l1, r1));
            }
            if(solve(v)) {
                ans ++;
            }
        } while(next_permutation(order, order + n));
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3464
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

map<ll, ll> prime_factor(ll n){
	map<ll, ll> res;
	for(ll i = 2; i*i <= n; i++){
		while(n%i == 0){
			res[i]++;
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	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;
	}
	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;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

mint choose(int n, int a){
	mint x = 1, y = 1;
	rep(i,a){
		x *= n-i;
		y *= i+1;
	}
	return x / y;
}

struct Combination{
	vector<mint> fact, ifact;
	Combination(int n):fact(n+1),ifact(n+1){
		assert(n < mod);
		fact[0] = 1;
		for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k){
		if(k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    Combination comb(1e6);
    map<ll, ll> pf = prime_factor(m);
    mint ans = 1;
    for(auto p : pf){
        if(p.second + n - 1 < 1e6) ans *= comb(p.second + n - 1, p.second);
        else ans *= choose(p.second + n - 1, p.second);
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 15872
#include<iostream>
using namespace std;
const int mod = 1e9 + 7;

int main(){
	int n,i;
	cin>>n;
	long long sum=1;
	for(i=2;i<=n;i++){
		sum=sum*i%mod;
	}
	cout<<sum<<endl;
	
	
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define int long long
const int N = 500000;
int n, m, k;
int ax[N], ay[N];

struct Node{
    int r, c, a;
};
Node A[N];

bool comp1(Node A, Node B)
{
    return A.r < B.r;
}

bool comp2(Node A, Node B)
{
    return A.c < B.c;
}


struct DSU{
    int root[N];
    vector<int> s[N];
    int val[N];
    int mv[N];

    int Root(int x)
    {
        if (x == root[x]) return x;
        return Root(root[x]);
    }

    void Merge(int v, int u, int w)
    {
        int x = Root(v);
        int y = Root(u);
        if (x == y)
        {
            int W = val[v] - val[u];
            if (W != w)
            {
                cout << "No";
                exit(0);
            }
            return;
        }
        if (s[x].size() > s[y].size())
        {
            swap(x, y);
            swap(v, u);
            w *= -1;
        }
        int W = val[u] + w - val[v];
        for (auto e : s[x])
        {
            s[y].push_back(e);
            val[e] += W;
        }
        root[x] = y;
        return;
    }

    void calc()
    {
        for (int i = 0; i < N; i++)
        {
            int mn = 2e9;
            if (root[i] == i)
            {
                for (auto it : s[i])
                    mn = min(mn, val[it]);
            }
            mv[i] = mn;
        }
    }
}P, Q;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> k;
    for (int i = 0; i < k; i++)
    {
        cin >> A[i].r >> A[i].c >> A[i].a;
    }
    for (int i = 1; i < N; i++) P.root[i] = i, P.s[i] = {i}, P.val[i] = 0;
    for (int i = 1; i < N; i++) Q.root[i] = i, Q.s[i] = {i}, Q.val[i] = 0;
    sort(A, A + k, comp1);
    for (int i = 1; i < k; i++)
    {
        if (A[i].r == A[i - 1].r)
        {
            P.Merge(A[i].c, A[i - 1].c, A[i].a - A[i - 1].a);
        }
    }
    sort(A, A + k, comp2);
    for (int i = 1; i < k; i++)
    {
        if (A[i].c == A[i - 1].c)
        {
            Q.Merge(A[i].r, A[i - 1].r, A[i].a - A[i - 1].a);
        }
    }
    P.calc(), Q.calc();
    for (int i = 0; i < k; i++)
    {
        int fi = P.val[A[i].c] + Q.val[A[i].r];
        int mv = P.mv[P.Root(A[i].c)] + Q.mv[Q.Root(A[i].r)];
        if (A[i].a - fi + mv < 0) cout << "No", exit(0);
    }
    cout << "Yes";
}


Measured memory_bytes: 89720
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<deque>
#include<string>
using namespace std;
#define ll long long
#define pb push_back
#define end "\n"
#define lar 1000000007;
int main()
{
    ll i,cnt=1;
    cin>>i;
    while(1){
        if((i*cnt)%360==0)break;
        cnt+=1;
    }
    cout<<cnt;
}

Measured memory_bytes: 3636
# coding: utf-8
# Your code here!

N = input()
n = len(N)

N1 = N
N2 = N[:int((n-1)/2)]
N3 = N[int(((n+3)/2)-1):]

N1r = ''.join([N1[i] for i in range(len(N1)-1, -1, -1)])
N2r = ''.join([N2[i] for i in range(len(N2)-1, -1, -1)])
N3r = ''.join([N3[i] for i in range(len(N3)-1, -1, -1)])

if N1 == N1r and N2 == N2r and N3 == N3r : 
    print('Yes')
else : 
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,ans = 0;
    cin >> N;
    vector<int> s(N);
    rep(i,N){
        cin >> s[i];
        ans += s[i];
    }
    sort(ALL(s));
    if(ans%10!=0)cout << ans << endl;
    else {
        rep(i,N){
            if((ans-s[i])%10!=0){
                cout << ans - s[i] << endl;
                return 0;
            }
        }
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
// aoj_test

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	const int MAX = 10000000000;

	int n;
	int max_benefit;
	int r1, r2;

	cin >> n;

	max_benefit = -MAX;
	r1 = MAX;

	while (n-- > 0) {
		cin >> r2;
		if (r1 == MAX) {
			r1 = r2;
		}
		else {
			max_benefit = max(max_benefit, r2 - r1);
			r1 = min(r1, r2);
		}
	}

	cout << max_benefit << endl;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;

int main() {
  long long n;
  cin>>n;
  vector<long long>vec(87);
  vec.at(0)=2;
  vec.at(1)=1;
  for(long long i=2;i<87;i++) {
    vec.at(i)=vec.at(i-2)+vec.at(i-1);
  }
  cout<<vec.at(n)<<endl;
}

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

using namespace std;

using ll = long long;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define INF 1e9

int main(void)
{
    int n, m, i, j, k, l, f;
	string a[55], b[55];

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

	for(i = 0; i <= n - m; i++){
		for(j = 0; j <= n - m; j++){
			if(a[i][j] == b[0][0]){
				f = 1;
				for(k = i; k < i + m; k++){
					for(l = j; l < j + m; l++){
						if(a[k][l] != b[k - i][l - j]){
							f = 0;
						}
					}
				}
				if(f){
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

  int n,i,sum,k;
  int j;

  while(1) {
    sum = 0;
    k = 0;
    scanf("%d",&n);

    if(n == 0) break;

    for(j=1;j<=n;j++) {
      sum = 0;
    for(i=j;i<=n;i++) {
      sum += i;

      if(sum == n && i != n) k++;
      else if(sum > n) i = n+1;

    }
    }

    printf("%d\n",k);

  }

  return 0;

}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <string>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<int, int> P;

int bina(vector<int> &da, int x, int ok, int ng) {
	if (ng - ok == 1) {
		return ok;
	}
	int mi = (ok + ng) / 2;
	if (da[mi] < x) {
		ok = mi;
	}
	else {
		ng = mi;
	}
	return bina(da, x, ok, ng);
}

int main() {
	int n;
	cin >> n;
	vector<int> da(n);
	rip(i, n, 0) {
		cin >> da[i];
	}
	sort(all(da));
	int ans = 0;
	rip(i, n - 1, 1) {
		rip(j, i, 0) {
			ans += bina(da, da[i] + da[j], i, n)-i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
public static class P {
  public static void Main() {
    var nw = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int n = nw[0];
    int W = nw[1];
    int[] v = new int[n];
    int[] w = new int[n];
    foreach (int i in Enumerable.Range(0, n)) {
      var vw = Console.ReadLine().Split().Select(int.Parse).ToArray();
      v[i] = vw[0];
      w[i] = vw[1];
    }
    int inf = int.MaxValue;
    int[] dp = Enumerable.Repeat(-inf, W + 1).ToArray();
    dp[0] = 0;
    foreach (int j in Enumerable.Range(0, n)) {
      foreach (int i in Enumerable.Range(0, W)) {
        if (W < i + w[j]) continue;
        dp[i + w[j]] = Max(dp[i + w[j]], dp[i] + v[j]);
      }
      // Console.WriteLine("dp: {0}", String.Join(" ", dp.Select(x => x.ToString("D"))));
    }
    int ans = dp.Max();
    Console.WriteLine(ans);
  }
}



Measured memory_bytes: 20520
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int dx[]{1,0},dy[]{0,1};
int dp[2000][2000];
char s[2000][2000];

int main(){
	int h,w;scanf("%d%d",&h,&w);
	rep(i,h)scanf("%s",s[i]);
	dp[0][0]=1;
	rep(i,h)rep(j,w){
		if(dp[i][j]==0)continue;
		rep(k,2){
			int nx=i+dx[k],ny=j+dy[k];
			if(0<=nx&&nx<h&&0<=ny&&ny<w&&s[nx][ny]!='#'){
				(dp[nx][ny]+=dp[i][j])%=MOD;
			}
		}
	}
	cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 12416
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include<bitset>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); ++i)
#define loops(i,f,n) for(int i = (f); i < (n); ++i)
#define INF 9999999
#define lint long long int
#define VEC vector<int>
#define VEC2 vector<vector<int>>

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int m, f, b;
	cin >> m >> f >> b;

	if (b > m + f)
	{
		cout << "NA" << endl;
	}
	else
	{

		if (b <= m) cout << 0 << endl;
		else cout << b - m << endl;
	}
}


Measured memory_bytes: 3176
#[好きなだけ]移動できる
#解説参照、stackで管理
import sys
input=sys.stdin.readline
n=int(input())
xy=[0]*(n+1)
xid=[0]*(n+1)
for i in range(n):
    xi,yi=map(int, input().split())
    xy[xi]=yi
    xid[xi]=i


*p,=range(n+1)
r=[0]*(n+1)
def par(x):
    if p[x]==x:
        return x
    res = p[x]=par(p[x])
    return res

def union(x,y):
    px=par(x);py=par(y)
    if px==py:
        return
    if r[px]>r[py]:
        p[py]=px
        r[py]+=1
    elif r[px]<r[py]:
        p[px]=py
        r[px]+=1
    else:
        p[px]=py
        r[py]+=1

stk=[(xy[1],1)]
for x in range(2,n+1):
    y=xy[x]
    if y>stk[-1][0]:
        yy,xx=stk.pop()
        union(x,xx)
        while stk and y>stk[-1][0]:
            union(x,stk[-1][1])
            stk.pop()
        stk.append((yy,xx))
    else:
        stk.append((y,x))
for i in range(1,n+1):par(i)

from collections import Counter
cp=Counter(p)
ans=[0]*n
for i in range(1,n+1):
    ans[xid[i]]=cp[par(i)]
for ai in ans:
    print(ai)


Measured memory_bytes: 86856
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,m = map(int,readline().split())
data = list(map(int,read().split()))
ab = data[:2*m]
q = data[2*m]
vdc = data[2*m+1:]

links = [[] for _ in range(n+1)]
it = iter(ab)
for a,b in zip(it,it):
    links[a].append(b)
    links[b].append(a)

ans = [0] * (n+1)
length = [-1] * (n+1)

for i in range(q-1,-1,-1):
    v,d,c = vdc[i*3:i*3+3]
    if( length[v] >= d):
        continue
    length[v] = d

    stack = [(v,d)]
    while(stack):
        vj,dj = stack.pop()
        if(ans[vj]==0):
            ans[vj] = c
        if(dj > 0):
            for vk in links[vj]:
                if( length[vk] < dj-1):
                    stack.append((vk,dj-1))
                    length[vk] = dj-1

print('\n'.join(map(str,ans[1:])))

Measured memory_bytes: 141656
line = input()
line = input()
numbers = [int(n) for n in line.split()]
predicted_value = 0
for i in range(len(numbers)):
    is_smaller = False
    for k in range(i):
        if numbers[i] < numbers[k]:
            is_smaller = True
            break
    if not is_smaller:
        predicted_value += 1
print(predicted_value)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define N 100005
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define LL long long
#define F first
#define S second
 
int n;
LL ans;
LL sum1,sum2;
bool ok[N];
vector<pii> v;
 
int main()
{
	
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x,y;
		cin>>x>>y;
		sum1+=x; sum2+=y;
		v.pb(mp(x,i)); v.pb(mp(y,i));
	}
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++)
		ans+=v[i].F;
	for(int i=0;i<n;i++)
	{
		if(ok[v[i].S]) return cout<<ans<<'\n',0;
		ok[v[i].S]=1;
	}
	cout<<min(min(sum1,sum2),ans-v[n-1].F+((v[n-1].S!=v[n].S)?v[n].F:min(v[n+1].F,v[n-1].F-v[n-2].F+v[n].F)))<<'\n';
	
	return 0;
}

Measured memory_bytes: 2548
function Main(input) {
	input = input.trim().split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var T = parseInt(input[0].split(" ")[1]);
  input.shift();
  var notTLE = [];
  for(var i = 0; i < N; i++){
    var tmp1 = parseInt(input[i].split(" ")[0]);
    var tmp2 = parseInt(input[i].split(" ")[1]);
    if(tmp2 <= T){
       notTLE.push(tmp1);
    }
  }
  if(notTLE.length == 0){
     console.log("TLE");
     }else{
       console.log(Math.min.apply(null,notTLE));
     }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468