akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int n,k;
    cin>>n>>k;
    vi h(n+1),dp(n+1,INF);
    rep(i,n)cin>>h[i+1];
    dp[0]=0;
    dp[1]=0;
    for(int i=2;i<=n;i++){
        for(int j=1;j<=k;j++){
            if(i-j<1)break;
            chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n]<<endl;
    
    

//////////////////////////////////////////////////////
return 0;}


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

int64_t pow_mod(int64_t a, int64_t n, int64_t mod) {
	int64_t r = 1;
	for (; n; n >>= 1) {
		if (n & 1) {
			(r *= a) %= mod;
		}
		(a *= a) %= mod;
	}
	return r;
}

int64_t fact_mod[200001], fact_mod_inv[200001];

int main() {
	int64_t h, w, a, b, mod = 1e9 + 7;
	cin >> h >> w >> a >> b;
	//int64_t fact_mod[h + w], fact_mod_inv[h + w];
	fact_mod[0] = 1;
	for (int64_t i = 1; i < h + w; i++) {
		fact_mod[i] = fact_mod[i - 1] * i % mod;
	}
	fact_mod_inv[h + w - 1] = pow_mod(fact_mod[h + w - 1], mod - 2, mod);
	for (int i = h + w - 2; 0 <= i; i--) {
		fact_mod_inv[i] = fact_mod_inv[i + 1] * (i + 1) % mod;
	}
	/*
	for (int64_t i = 0; i < h + w; i++) {
		cerr << fact_mod[i] * fact_mod_inv[i] % mod << ' ';
	}
	cerr << endl;
	for (auto &i : fact_mod) {
		cerr << i << ' ';
	}
	cerr << endl;
	for (auto &i : fact_mod_inv) {
		cerr << i << ' ';
	}
	cerr << endl;
	*/
	int64_t ans = 0;
	for (int64_t i = b; i < w; i++) {
		(ans += (fact_mod[h - a - 1 + i] * fact_mod_inv[i] % mod * fact_mod_inv[h - a - 1] % mod) * (fact_mod[a - 1 + w - i - 1] * fact_mod_inv[w - i - 1] % mod * fact_mod_inv[a - 1] % mod) % mod) %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
import java.util.Arrays;
import java.util.Scanner;

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

        int n = sc.nextInt();
        int l = sc.nextInt();
        String[] s = new String[n];

        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }

        Arrays.sort(s);
        
        for (String s1 : s)
            System.out.print(s1);
    }
}

Measured memory_bytes: 23252
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int n, a[111111];

  std::cin >> n;

  for (int i = 0; i < n; i ++)
    std::cin >> a[i];

  std::sort(a, a + n);

  int p = a[n - 1], m1 = p / 2, m2 = p % 2 == 0 ? m1 : m1 + 1, dm = INF, xm = -1;

  for (int i = 0; i < n - 1; i ++) {
    int d = std::min(std::abs(a[i] - m1), std::abs(a[i] - m2));

    if (d < dm) {
      dm = d;
      xm = a[i];
    }
  }

  std::cout << p << ' ' << xm << std::endl;

  return 0;
}


Measured memory_bytes: 640
# python3.4.2用
import math
import fractions
import collections
import itertools
import heapq
import string
import sys
import copy
import numpy as np
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')

N = iin()
A = np.array(sys.stdin.readline().split(), np.int64)

two_factor = 1
ans = 0
for i in range(60):
    B = A >> i & 1
    ones = np.count_nonzero(B)
    zeros = N - ones
    zeroone_cmb = ones*zeros%MOD
    ans = (ans + (zeroone_cmb*two_factor%MOD))%MOD
    two_factor = (two_factor*2)%MOD

print(ans)
    


Measured memory_bytes: 64216
t1,n1 = map(int,input().split())
t2,n2 = map(int,input().split())
t3,n3 = map(int,input().split())
t4,n4 = map(int,input().split())

if t1 == 1:
    print(6000 * n1)
elif t1 == 2:
    print(4000 * n1)
elif t1 == 3:
    print(3000 * n1)
elif t1 == 4:
    print(2000 * n1)

if t2 == 1:
    print(6000 * n2)
elif t2 == 2:
    print(4000 * n2)
elif t2 == 3:
    print(3000 * n2)
elif t2 == 4:
    print(2000 * n2)

if t3 == 1:
    print(6000 * n3)
elif t3 == 2:
    print(4000 * n3)
elif t3 == 3:
    print(3000 * n3)
elif t3 == 4:
    print(2000 * n3)

if t4 == 1:
    print(6000 * n4)
elif t4 == 2:
    print(4000 * n4)
elif t4 == 3:
    print(3000 * n4)
elif t4 == 4:
    print(2000 * n4)


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



int main()
{
  int n,m;
  cin >> n >> m;
  int a,b;
  a = 0;
  b = n;
  for(int i=0; i<m; i++)
  {
    int tmpl,tmpr;
    cin >> tmpl >> tmpr;
    a = max(a,tmpl);
    b = min(b,tmpr);
  }
  cout << max(b-a+1,0) << endl;
  return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

//-----------------------------------------------------------------------------

ll x;

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

	cin>>x;
	ll n=x/11;
	ll ans=n*2;
	ll dif=x-n*11;
	if(dif>6) ans+=2;
	else if(dif!=0) ans++;
	cout<<ans<<endl;

	return 0;
}


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

int main()
{
	char str[10];
	int w, n, i, j;
	int amida[30], a[30], b[30];
	
	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));
	
	scanf("%d %d", &w, &n);
	
	for (i = 0; i < w; i++){
		amida[i] = i + 1;
	}
	for (i = 0; i < n; i++){
		memset(str, 0, sizeof(str));
		scanf("%s", str);
		j = 0;
		while (str[j] != ','){
			a[i] =a[i] * 10 + str[j] - '0';
			j++;
		}
		j++;
		while (str[j] != '\0'){
			b[i] =b[i] * 10 + str[j] - '0';
			j++;
		}
		amida[a[i] - 1] += amida[b[i] - 1];
		amida[b[i] - 1] = amida[a[i] - 1] - amida[b[i] - 1];
		amida[a[i] - 1] = amida[a[i] - 1] - amida[b[i] - 1];
	}
	
	for (i = 0; i < w; i++){
		printf("%d\n", amida[i]);
	}
	
	return (0);
}

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

int main(){
  int n;
  cin >> n; 
  vector<int> l(n);
  for(int i=0;i<n;i++){
    cin >> l.at(i);
  }
  
  sort(l.begin(),l.end());
  long long ans =0;
  
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(l.at(k) < l.at(i) + l.at(j)){
          ans++;
        }
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] c = s.toCharArray();
    Arrays.sort(c);
    String k = new String(c);
    if (k.equals("abc")) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int a[n],b[m];
    int xmax=-101;
    int ymin=101;
    rep(i,n){
      cin>>a[i];
      xmax=max(xmax,a[i]);
    }
    rep(i,m){
      cin>>b[i];
      ymin=min(ymin,b[i]);
    }
    if(xmax<ymin&&x<ymin&&xmax<y){
      cout<<"No War"<<endl;
    }else{
      cout<<"War"<<endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
const int MAX_N = 200005;
 
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	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 { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
 
	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
 
int main() {
	int N,K;
	cin >> N>>K;
	vector<long long>P;
	vector<long long>M;
	for (int n = 0;n<N;++n) {
		long long num;
		cin >> num;
		if (num > 0) {
			P.push_back(num);
		}
		else {
			M.push_back(-num);
		}
	}
	sort(P.begin(),P.end(),std::greater<int>());
	sort(M.begin(), M.end(), std::greater<int>());
	//例外処理答えがマイナスになる
	if (P.size() == 0 && 1 == K%2) {
		sort(M.begin(), M.end()); 
		mint ans = 1;
		for (int n = 0;n<K;++n) {
			ans *= (mint)M[n];
		}
		cout << -ans << endl;
		return 0;
	}
	if (M.size() + P.size() ==K &&1 == M.size()%2) {
		mint ans = 1;
		for (int n = 0; n < M.size(); ++n) {
			ans *= (mint)M[n];
		}	
		for (int n = 0; n < P.size(); ++n) {
			ans *= (mint)P[n];
		}
		cout << -ans << endl;
		return 0;
	}
	
 
 
	int p = 0;
	int m = 0;
	mint ans = 1; 
	if (K%2 == 1) {
		ans *= (mint)P[m];
		p++;
		K--;
	}
	while (K != 0) {
			if (P.size()-p < 2 ) {
				ans *= (mint)M[m];
				ans *= (mint)M[m + 1];
				m += 2;
			}
			else if (M.size() - m < 2) {
				ans *= (mint)P[p];
				ans *= (mint)P[p + 1];
				p += 2;
			}
			else {
				if (P[p] * P[p + 1] > M[m] * M[m + 1]) {
					ans *= (mint)P[p];
					ans *= (mint)P[p + 1];
					p += 2;
				}
				else {
					ans *= (mint)M[m];
					ans *= (mint)M[m + 1];
					m += 2;
				}
			}
			K -= 2;
	}
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 5544
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int n, d, x, a[max];
    int sum=0;
    
    scanf("%d%d%d", &n, &d, &x);
    rep(i, n){
        scanf("%d", &a[i]);
    }
    
    rep(j, n){
        rep(i, d){
            if (i*a[j]+1<=d) {
                sum+=1;
            } else {
                break;
            }
        }
    }
    
    printf("%d", x+sum);
    
    return 0;
}


Measured memory_bytes: 1700
//author-micheal corleone
//the godfaher
#include <bits/stdc++.h>
#include <set> 
#include<algorithm>

#include <set> 
#include<algorithm>
#define ll long long int


#define f(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
 
using namespace std;
 
 bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[1] < v2[1]; 
}
 
 

ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
  //  ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
 
int main()
{
   cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    
     ll t;
    // cin>>t;
     t=1;
   while(t--)
    {
        ll i1,i2,k,m,j,j1,f,a1,i31,i3,j2,i5,i4,i6,i7,i;    
       i4=INT_MIN,i1=0;
       f=0;
      // string s1,s2,s3;
      ll res,res1;
      ll s1,s2,s3;
      s2=0;
      s1=0;
      ll q;
      i31=0;
       string s;
        double n;
        cin>>n;
        double ans=n/3;
        
        printf("%0.12lf",ans*ans*ans);
      
   }
}

       
  

Measured memory_bytes: 256
n = int(input())

s = list(map(int, input().strip().split(' ')))

max = s[0]
min = s[0]
sum = 0
for i in range(n):
    sum = sum + s[i]
    if max < s[i]:
        max = s[i]
    if min > s[i]:
        min = s[i]

print(min, end =" ")
print(max, end =" ")
print(sum)


Measured memory_bytes: 6600
//string ver
#include<iostream>
#include<string> //s.size()
#include<cctype> //toupper
 
using namespace std;
 
string toUpper(string s);
 
int main(){
  string w,t; //word, text
  int c=0;
   
  cin >> w;
  w = toUpper(w);
  while (1) {
    cin >> t;
    if (t == "END_OF_TEXT") break;
    t = toUpper(t); //string 自作でやらんと
    if (w == t) c++; 
  }
  cout << c << endl;
}
 
string toUpper(string s) {
  string t; //tは空文字列 size 0
  for ( int i = 0; i < s.size(); i++) {
    t.push_back(toupper(s[i]));
    /*t[i] = toupper(s[i]); としてもtは空
      上のw == tで空文字列どうしを返してるから常に真*/
  }
  return t;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=3e5+100;
const int N=1e6+1000;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}


int a[N];
int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;
    int n,k;cin>>n>>k;
    rep1(i,n) cin>>a[i];
    sort(a+1,a+1+n);
    int ans=0;
    for(int i=1;i<=k;++i) ans+=a[i];
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int a=0,b=0,ans=0;
  
  cin >> a >> b;
  
  for (int i=a; i<=b; i++) {
    int n=0,n1=0,n2=0,n3=0,n4=0,n5=0;
    
    n = i;
    
    n1 = n-(n/10)*10;
    n /= 10;
    n2 = n-(n/10)*10;
    n /= 10;
    n3 = n-(n/10)*10;
    n /= 10;
    n4 = n-(n/10)*10;
    if (n4 != n2) continue;
    n /= 10;
    n5 = n-(n/10)*10;
    if (n5 != n1) continue;
    ans += 1;
  }
  
  cout << ans << endl;
}

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

dotlist = [[] for i in range(N)]
sidlist = []
count = 0 

for m in range(M):
    a,b = map(int,input().split())
    dotlist[a -1].append(b)
    dotlist[b -1].append(a)
    sidlist.append([a,b])

def check(anum,bnum,cnum):
    donedot[cnum-1] = True
    for i in dotlist[cnum - 1]: 
        if (anum == cnum and i == bnum) or (bnum == cnum and i == anum):
            pass
        elif donedot[i - 1] == False:
            check(anum,bnum,i)

donedot = None

for m in range(M):
    donedot = [False for i in range(N)]
    a,b = sidlist[m]
    check(a,b,1)
    TorF = True
    for i in donedot:
        TorF  = TorF and i
    if  not TorF:
        count += 1

print(count)


Measured memory_bytes: 3316
#include <stdio.h>
int main(void){
    int H,W,n,m;
    for(;;){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0){
            break;
        }
        for(n=1;n<=H;n++){
            for(m=1;m<=W;m++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
using ll = long long;
//#define int ll
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    int n,k;cin>>n>>k;
    map<int,int>mp;
    rep(i,n){
        int hoge;  cin>>hoge;
        mp[hoge]++;
    }
    if(n<=k)return puts("0")*0;
    vector<pii>v;
    for(auto itr:mp)v.push_back(pii(itr.second,itr.first));
    sort(all(v));
    int sum=0;
    for(auto itr:mp)sum+=itr.second;
    int ans=0;
    rep(i,v.size()){
        if((int)v.size()-i<=k){
            cout<<ans<<endl;
            return 0;
        }
        ans+=v[i].first;
    }
}


Measured memory_bytes: 11768
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

int a[3];
int cnt[4];

int main(void){

	while(~scanf("%d%d%d",&a[0],&a[1],&a[2])){
		sort(a,a+3,greater<int>());
		if(a[1]+a[2]>a[0]){
			cnt[0]++;
			if(a[1]*a[1]+a[2]*a[2]==a[0]*a[0])cnt[1]++;
			else if(a[1]*a[1]+a[2]*a[2]>a[0]*a[0])cnt[2]++;
			else cnt[3]++;
		}else break;
	}
	printf("%d %d %d %d\n",cnt[0],cnt[1],cnt[2],cnt[3]);
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 1000000007LL
#define EPS 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int a, b;
int m;
int ca[MN];
int cb[MN];
pair<pii, int> cou[MN];

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

    cin >> a >> b >> m;
    int ma = INF, mb = INF;
    FOR(i, 1, a){cin >> ca[i]; ma = min(ma, ca[i]);}
    FOR(i, 1, b){cin >> cb[i]; mb = min(mb, cb[i]);}

    int mc = ma+mb;
    F0R(i, m){
        int x, y, co;
        cin >> x >> y >> co;
        int fin = ca[x]+cb[y]-co;
        mc = min(mc, fin);
    }

    cout << mc << "\n";

    return 0;
}


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

template <unsigned M> struct modular {
  using m = modular;
  unsigned v;
  modular(long long a = 0) : v((a %= M) < 0 ? a + M : a) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m r) { if ((v += r.v) >= M) v -= M; return *this; }
  m& operator-=(m r) { if (v < r.v) v += M; v -= r.v; return *this; }
  m& operator*=(m r) { v = (uint64_t)v * r.v % M; return *this; }
  m& operator/=(m r) { return *this *= power(r, M - 2); }
  friend m operator+(m l, m r) { return l += r; }
  friend m operator-(m l, m r) { return l -= r; }
  friend m operator*(m l, m r) { return l *= r; }
  friend m operator/(m l, m r) { return l /= r; }
  friend bool operator==(m l, m r) { return l.v == r.v; }
};

constexpr long long mod = 1e9 + 7;
using mint = modular<mod>;

struct dsu {
  const int n;
  vector<int> p, sz;
  vector<mint> sum;
  dsu(int _n) : n(_n), p(n, -1), sz(n, 1), sum(n) {
    iota(begin(sum), end(sum), 1);
  }
  int root(int v) const {
    while (p[v] != -1) {
      v = p[v];
    }
    return v;
  }
  void unite(int u, int v) {
    u = root(u), v = root(v);
    if (u != v) {
      if (sz[u] < sz[v]) {
        swap(u, v);
      }
      p[v] = u;
      sz[u] += sz[v];
      sum[u] += sum[v];
    }
  }
};

int ctz(int a) { return __builtin_ctz(a); }
int ctz(long long a) { return __builtin_ctzll(a); }
template <class T> T gcd(T a, T b) {
  a = abs(a), b = abs(b);
  if (a == 0) return b;
  int k = ctz(a | b);
  a >>= ctz(a);
  while (b) {
    b >>= ctz(b);
    if (a > b) swap(a, b);
    b -= a;
  }
  return a << k;
}
long long lcm(long long l, long long r) {
  return l / gcd(l, r) * r;
}

struct sparse_table {
  vector<vector<long long>> t;
  sparse_table(const vector<long long>& v) : t{v} {
    for (int k = 1, n = v.size(); 1 << k <= n; ++k) {
      t.emplace_back(n - (1 << k) + 1);
      for (int i = 0; i + (1 << k) <= n; ++i) {
        t[k][i] = lcm(t[k - 1][i], t[k - 1][i + (1 << (k - 1))]);
      }
    }
  }
  long long fold(int l, int r) {
    int k = __lg(r - l);
    return lcm(t[k][l], t[k][r - (1 << k)]);
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  dsu d(n);
  for (int i = 0; i < n; ++i) {
    int p;
    cin >> p;
    --p;
    d.unite(i, p);
  }
  vector<long long> sz(n);
  for (int i = 0; i < n; ++i) {
    sz[i] = d.sz[d.root(i)];
  }
  sparse_table st(sz);
  vector<vector<mint>> cum(41, vector<mint>(n + 1));
  for (int k = 1; k <= 40; ++k) {
    for (int i = n; i--; ) {
      cum[k][i] = (sz[i] == k ? d.sum[d.root(i)] : 0) + cum[k][i + 1];
    }
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    --l;
    long long x = st.fold(l, r);
    mint res;
    for (int k = 1; k <= 40; ++k) {
      res += (cum[k][l] - cum[k][r]) * (x / k);
    }
    cout << res.v << '\n';
  }
}



Measured memory_bytes: 33504
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007ll
#define mod1 998244353ll
#define endl "\n"
using namespace std::chrono;

bool isPrime(ll n)
{
    if(n<=1)return false;
    ll val=sqrt(n);
    for(ll x=2;x<=val;x++)
    {
        if(n%x==0)return false;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll x;
    cin>>x;
    while(true)
    {
        if(isPrime(x))
        {
            cout<<x<<endl;
            return 0;
        }
        x++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(s,t) for (int s = 0; s < t; ++s);
using ll = long long;


int main() {
  string s;

  cin >> s;

  if ((s == "AAA") || (s == "BBB")){
    cout << "No" << endl;
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; string S; cin >> N >> S; 
	int cnt = 0; 
	for(int i = 0; i < N-2; i++){
		if(S.substr(i, 3) == "ABC") cnt ++; 
	}
	cout << cnt << endl; 
}

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

int main(){
  int N;
  cin >> N;
  double x[N],y[N];
  for (int i=0;i<N;i++){
    cin >> x[i] >> y[i];
  }
  long double ans = 0;
  for(int a=0;a<N;a++){
    for(int b=0;b<a;b++){
      if (a==b)break;
      ans+=sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]));
    }
  }
  cout << std::fixed << std::setprecision(15) << ans/double(N)*2 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

long fact (int n, int mod);

int main (void)
{
    int mod = 1000000007;
    int n, m;
    cin >> n >> m;

    if (abs(n - m) >= 2) {
        cout << 0 << endl;
    } else {
        long perm = (fact(n, mod) * fact(m, mod)) % mod;
        cout << ((n == m)? (perm * 2) % mod: perm) << endl;
    }

    return 0;
}

long fact (int n, int mod)
{
    if (n == 1) {
        return 1L;
    } else {
        return ((n % mod) * (fact(n-1, mod) % mod)) % mod;
    }
}

Measured memory_bytes: 3328
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> s;
  rep(i, Size(s)) {
    if (s[i] == 'R') cnt++;
  }
  rep(i, cnt) {
    if (s[i] == 'W') ans++;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     int a,b,c;
     cin>>a>>b>>c;
     cout<<max(0LL,c-a+b)<<endl; 
     return 0;
}

Measured memory_bytes: 256
# 0405の分もやる

#ABC041-C
if False:
    N=int(input())
    A=[int(i) for i in input().split()]
    ans=[(i,a) for i,a in enumerate(A)]
    ans.sort(key=lambda x: x[1],reverse=True)
    for i in range(N): print(ans[i][0]+1)

#AGC017-A
if True:
    N,P=map(int,input().split())
    A=[int(i) for i in input().split()]
    flag=True # 偶数のみか
    for a in A:
        if a%2==1:
            flag=False
            break
    if flag:
        if P==0:
            print(2**N)
        else:
            print(0)
    else:
        print(2**(N-1))


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[4]={0,0,1,1};
int dy[4]={0,1,0,1};
const int SIZE=1000050;
//ここまでテンプレ
int main(){
    int X;
    cin>>X;
    if(X==7 || X==5 || X==3)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
	return 0;
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    ll n, val, cur = 0, ans = 0 ;
    cin >> n ;

    for (int i = 0; i < n; i++) {
        scanf("%lld", &val) ;
        cur = max(cur, val) ;
        ans += (cur - val) ;
    }
    printf("%lld\n", ans) ;

    return 0 ;
}


Measured memory_bytes: 3808
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

std::string solve(long h, long n, const std::vector<long>& techs)
{
  auto sum = std::accumulate(techs.begin(), techs.end(), 0l);
  return sum >= h ? "Yes" : "No";
}

int main()
{
  long h, n;
  std::cin >> h >> n;
  std::vector<long> techs(n);
  for (auto& t : techs) {
    std::cin >> t;
  }

  std::cout << solve(h, n, techs) << std::endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

int main() {
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	int N;
	cin >> N;
	vector<int> p(N);
	REP(i, N) cin >> p[i];

	int count = 0, tmp;
	REP(i, N)
	{
		if (p[i] == i + 1)
		{
			if (i + 1 == N)
			{
				tmp = p[i];
				p[i] = p[i - 1];
				p[i - 1] = tmp;
			} else {
				tmp = p[i];
				p[i] = p[i + 1];
				p[i + 1] = tmp;
			}
			count++;
		}
	}

	cout << count << "\n";

	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n,m,ans,li[505][505],h[10005],a,b;
int main(){
    while(1){
    cin >> n >>m;
    if(n==0&&m==0)break;

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

    for(int i=2;i<=n;i++){
        if(li[1][i]==1||li[i][1]==1){
            if(h[i]==0){
                h[i]=1;
                ans++;
            }
                for(int j=2;j<=n;j++){
        if(li[j][i]==1||li[i][j]==1){
            if(h[j]==0){
                h[j]=1;
                ans++;
            }
        }
    }

        }
    }

    cout << ans << endl;
    for(int i=0;i<=n;i++)h[i]=0;
    std::fill(li[0],li[504],0);
    ans=0;
    }

return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    int N;
    cin>>N;
    ll ANS=0;
    rep(i,N){
        int a,b;
        cin>>a>>b;
        ANS+=(b-a+1);
    }
    cout<<ANS<<endl;

    return 0;
}

//a=97,z=122

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

using namespace std;

int main()
{
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<int> diff;
    for(int i = 1; i < n; i++) {
        diff.push_back(abs(a[i] - a[i-1]));
    }
    diff.push_back(abs(k - a[n-1] + a[0]));
    int ans = INT_MAX;
    for(int d : diff) {
        ans = min(ans, k - d);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    double n, m, d;
    cin >> n >> m >> d;
    double ans;
    if (d == 0) ans = (m-1)/n;
    else ans = (m-1)*2*(n-d)/n/n;
    cout.precision(20);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    int ans = min(c,b/a);

    dunk(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define sz(a) ((int)(a).size())
#define found(m,x) ((m).find(x)!=(m).end())
#define uset unordered_set
#define umap unordered_map
#define a(x) (x).begin(),(x).end()
#define fo(i,n) for(int i=0;i<(int)n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<=(int)n:i>=(int)n;k<n?i++:i--)
#define input(v,n) fo(i,n)cin>>v[i]
using vi = vector<int>;
using vpi = vector<pair<int,int>>;
using pi = pair<int,int>;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667 :: 0xcf : inf, 0xc0 -inf
const int inf = numeric_limits<int> :: max() - (int)9e6;
// ===================== MANASH =================== //

int n;

void test() {

	cin >> n;
	if(n%1000 == 0 ) cout << 0;
	else cout << 1000 - n%1000;
}

signed main() {

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

	#ifdef LOCAL
	freopen("input.txt","r",stdin);
	#endif

	int T = 1;
	//cin >> T;
	while(T--) {
		test();
		cout << "\n";
	}
	return 0;

}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    int l[n];
    rep(i, n) cin >> l[i];
    sort(l, l + n);
    ll ans = 0;
    for (int i = 0; i < n - 2; i++){
        for (int j = i + 1; j < n - 1; j++){
            int idx = lower_bound(l, l + n, l[i] + l[j]) - l;
            idx--;
            ans += idx - j;
            // cout << idx << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
    int n;
    int s;
    int sum=0;
    int min=100;
    int i=0;
    
    
    for(;~scanf("%d",&s);){
        i&&s%10&&(min=fmin(min,s));
        i++&&(sum+=s);
        
    }
    
    
    min>=100&&(sum=min);
    printf("%d",sum%10?sum:sum-min);
}


Measured memory_bytes: 2148
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<61;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100100
ll n, m;
ll a[N];
multiset<ll> st[N];

struct UF {
	vector<int> par, rank, sz;
	
	void init(int n){
		par = rank = vector<int>(n, 0);
		sz = vector<int>(n, 1);
		for(int i = 0; i < n; i++){
			par[i] = i;
		}
	}
	
	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	int size(int x){
		return sz[find(x)];
	}
	
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]){
			par[x] = y;
			sz[y] += sz[x];
		}else{
			par[y] = par[x];
			if(rank[x] == rank[y]) rank[y]++;
			sz[x] += sz[y];
		}
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}
};


int main(){
	cin>>n>>m;
	UF uf;
	uf.init(n);
	rep(i, n) cin>>a[i];
	rep(i, m){
		int x, y;
		cin>>x>>y;
		uf.unite(x, y);
	}
	rep(i, n){
		st[uf.find(i)].insert(a[i]);
	}
	ll e = n-1-m;
	if(2*e>n){
		cout<<"Impossible"<<endl;
		return 0;
	}
	if(e==0){
		cout<<0<<endl;
		return 0;
	}
	ll v = n-2*e;
	ll sum = 0;
	rep(i, n) sum += a[i];
	vector<ll> d, d2; d.reserve(n);
	rep(i, n){
		if(st[i].empty()) continue;
		for(auto it = st[i].begin(); it!=st[i].end(); ++it){
			if(it==st[i].begin()){
				d2.pb(*it);
			} else {
				d.pb(*it);
			}
		}
	}
	sort(all(d)); reverse(all(d));
	cerr<<d.size()<<endl;
	if(d.size()<v){
		cout<<"Impossible"<<endl;
		return 0;
	}
	rep(i, v) sum -= d[i];
	cout<<sum<<endl;
	return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> vec){ return (ll)vec.size(); }
ll sz(string s){ return (ll)s.size(); }


struct unionfind {
    vector<int> par;
    vector<int> sizes;

    unionfind(int n) : par(n),sizes(n,1){
        rep(i,0,n) par[i] = i;
    }

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

    void unite(int x,int y){
        x = root(x);
        y = root(y);

        if(x == y) return;

        if(sizes[x] < sizes[y] ) swap(x,y);

        par[y] = x;
        sizes[x] += sizes[y];
        sizes[y] = 0;

        return;
    }

    bool same(int x,int y){
        return root(x) == root(y);
    }

    int size(int x){
        return sizes[root(x)];
    }
};

int main(){
    ll n,m;
    cin >> n >> m;

    unionfind uf(n);

    rep(i,0,m){
        ll a,b;
        cin >> a >> b;
        uf.unite(a-1,b-1);
    }

    ll memo = 0;
    rep(i,0,n){
        memo = max(memo,(ll)uf.size(i));
    }
    cout << memo << endl;

    return 0;
}




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

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;

ll ksm(ll a, ll b)
{
	ll rul = 1;
	while(b)
	{
		if(b & 1) rul = rul * a % mod;
		b >>= 1;
		a = a * a % mod;
	}
	return rul;
}

int main()
{
	ll n;
	cin>>n;
	ll ans = ((ksm(10, n) - 2 * ksm(9, n) + ksm(8, n) + mod) % mod + mod)% mod;
	cout<<ans;
	return 0;
}

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

#define watch(x) cout<<(#x)<<"="<<(x)<<endl
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264338327
#define INF 0x3f3f3f3f
#define MOD 998244353
#define pqueue priority_queue
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef unsigned long long ull;

#define MAXN 100005

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
  string s; cin>>s;
  int rc=0,bc=0;
  forn(i,0,n){
   if(s[i]=='R') rc++;
    else bc++;
  }
  if(rc>bc) cout<<"Yes\n";
  else cout<<"No\n";
	
	return 0;
}


Measured memory_bytes: 256
var countCommonNumber = function(n, s, q, t) {
  var counter = 0;
  for (var i = 0; i < q; i += 1) {
    for (var j = 0; j < n; j += 1) {
      if (t[i] === s[j]) {
        counter += 1;
        break;
      }
    }
  }
  return counter;
};

(function(stdin) {
  var line = stdin.split('\n');
  var n = parseInt(line[0], 10);
  var s = line[1].split(' ').map(Number);
  var q = parseInt(line[2], 10);
  var t = line[3].split(' ').map(Number);
  console.log(countCommonNumber(n, s, q, t));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 17176
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main {

	public static void main(String[] args) {
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		char[] S = in.next().toCharArray();
		char[] T = in.next().toCharArray();
		int max = 0;
		for(int i=0;i<S.length-T.length+1;i++) {
			//out.println("i "+i);
			int curr = 0;
			for(int j=0;j<T.length;j++) {
				if(S[i+j]==T[j]) curr++;
			}
			max = Math.max(curr, max);
		}
		out.println(T.length-max);
		out.close();
	}

	static final Random random=new Random();
	//	static void ruffleSort(Pair[] a) {
	//		int n=a.length;//shuffle, then sort 
	//		for (int i=0; i<n; i++) {
	//			int oi=random.nextInt(n);
	//			Pair temp=a[oi];
	//			a[oi]=a[i]; a[i]=temp;
	//		}
	//		Arrays.sort(a);
	//	}
	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	static void ruffleSort(char[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n);
			char temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	static class FastReader 
	{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException  e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 

		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	}
}

//class Pair implements Comparable<Pair>{
//    int a;
//    int b;
//    public Pair(int a, int b) {
//        this.a = a;
//        this.b = b;
//    }
//    public int compareTo(Pair o) {
//        if(this.a==o.a)
//            return this.b - o.b;
//        return this.a - o.a;
//    }   
//}


Measured memory_bytes: 25864