akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 7;
int inf = 1e9 + 7;


int x[maxn], y[maxn];
pair<int, int> p[maxn];
bool my_cmp2(pair<int, int> x, pair<int, int> y){
    if(x.second < y.second)return true;
    if(x.second > y.second)return false;
    if(x.first > y.first)return true;
    return false;
}
bool my_cmp(pair<int, int> x, pair<int, int> y){
    if(x.first < y.first)return true;
    if(x.first > y.first)return false;
    if(x.second > y.second)return true;
    return false;
}
int main() 
{
    int n;
    cin >> n;
    int f1 = 0, f2 = 0, f3 = 0;
    int s1 = 0, s2 = 0;
    int mxa = 0, mxb = 0;
    vector<pair<int, int>> vl, vr;
    for(int i = 1; i <= n; ++i){
        string s;
        cin >> s;
        int a = 0, b = 0;
        for(int j = 0; j < s.size(); ++j){
            if(s[j] == '('){
                a++;
            }
            else{
                if(a > 0)--a;
                else ++b;
            }
        }
        if(a == 0 && b == 0) ++f3;
        else if(a == 0) f1 = 1;
        else if(b == 0) f2 = 1;
        s1 += a;
        s2 += b;
        p[i] = make_pair(a, b);
        x[i] = a;
        y[i] = b;
        if(a > b)mxa += a - b;
        else mxb += b - a;
        if(a > b){
            vl.push_back(make_pair(b, a - b));
        }
        else{
            vr.push_back(make_pair(a, b - a));
        }
    }
    int flag = 1, now = 0;
    sort(vl.begin(), vl.end(), my_cmp);
    now = 0;
    for(int i = 0; i < vl.size(); ++i){
        if(now < vl[i].first){
            flag = 0;
            break;
        }
        now += vl[i].second;
    }
    sort(vr.begin(), vr.end(), my_cmp);
    now = 0;
    for(int i = 0; i < vr.size(); ++i){
        if(now < vr[i].first){
            flag = 0;
            break;
        }
        now += vr[i].second;
    }
    //for(int i = 0; i < vr.size(); ++i)cout << vr[i].first << " " << vr[i].second << '\n';
    /*
    for(int i = 1; i <= n; ++i){
        int a = x[i], b = y[i], ma = mxa, mb = mxb;
        if(a > b)ma -= a - b;
        else mb -= b - a;
        if(ma < b)flag = 0;
        if(mb < a)flag = 0;
    }
    for(int i = 1; i <= n; ++i){
        int a = x[i], b = y[i];
        if(s2 - b < a)flag = 0;
        if(s1 - a < b)flag = 0;
    }
    */
    if((f3 == n || f1 + f2 == 2) && s1 == s2 && flag == 1)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 26836
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    int N;cin>>N;
    int A[200010];

    for(int i=0;i<N;i++){
        cin>>A[i];
        A[i]-=(i+1);
    }
    sort(A,A+N); 
    long long S[200010];
    S[0]=0;
    for(int i=1;i<=N;i++)
        S[i]=S[i-1]+A[i-1];

    if(N%2==0)
        cout<<S[N]-2*S[N/2]<<endl;
    else 
        cout<<S[N]-2*S[N/2]-A[N/2]<<endl;
    
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<set>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  int a = 0, b = 0;
  if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) {
    a = 1;
  }
  else if (x == 4 || x == 6 || x == 9 || x == 11) a = 2;
  else a = 3;

  if (x == y ||y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
    b = 1;
  }
  else if (y == 4 || y == 6 || y == 9 || y == 11) b = 2;
  else b = 3;

  if (a == b)  cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )
#define mt( ... ) make_tuple( __VA_ARGS__ )

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()

#define MOD ( 1e9 + 7 )


int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	int tmp = B / A;

	if ( tmp >= C )
	{
		tmp = C;
	}

	cout << tmp << endl;

	return ( 0 );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
typedef pair<int,int> P;
const int MOD = 998244353;
const ll mod = 1e9 + 7;
const int mxN = 1e5 + 9;

ll ar[mxN];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,tmp;
	cin >> n;
	ll sm = 0;
	for(int i=1; i <= n; i++){
        cin >> tmp;
        sm += tmp;
        ar[tmp] += 1;
	}
    int t;
    cin >> t;
    ll b,c;
    while(t--){
        cin >> b >> c;
        sm += 1LL*(c-b)*ar[b];
        ar[c] += ar[b]; ar[b] = 0;
        cout << sm << "\n";
    }




}


Measured memory_bytes: 4344
line = input()
n, k = line.split(" ")
n, k = int(n), int(k)
kashi_list = []

for i in range(k):
    d = int(input())
    line = input()
    temp = line.split(" ")
    for t in temp:
        kashi_list.append(t)

print(n - len(set(kashi_list)))
    


Measured memory_bytes: 9528
#include<iostream>

using namespace std;

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      int dice[]={1,2,3,5,4,6};//top,S,E,N,W,botton;
      int sum=1;
      for(int i=0;i<n;i++)
	{
	  string move;
	  cin>>move;
	  int tmp;
	  if(move=="North")
	    {
	      tmp=dice[0];
	      dice[0]=dice[1];
	      dice[1]=dice[5];
	      dice[5]=dice[3];
	      dice[3]=tmp;
	    }
	  if(move=="East")
	    {
	      tmp=dice[0];
	      dice[0]=dice[4];
	      dice[4]=dice[5];
	      dice[5]=dice[2];
	      dice[2]=tmp;
	    }
	  if(move=="South")
	    {
	      tmp=dice[0];
	      dice[0]=dice[3];
	      dice[3]=dice[5];
	      dice[5]=dice[1];
	      dice[1]=tmp;

	    }
	  if(move=="West")
	    {
	      tmp=dice[0];
	      dice[0]=dice[2];
	      dice[2]=dice[5];
	      dice[5]=dice[4];
	      dice[4]=tmp;
	    }
	  if(move=="Right")
	    {
	      tmp=dice[1];
	      dice[1]=dice[2];
	      dice[2]=dice[3];
	      dice[3]=dice[4];
	      dice[4]=tmp;
	    }
	  if(move=="Left")
	    {
	      tmp=dice[1];
	      dice[1]=dice[4];
	      dice[4]=dice[3];
	      dice[3]=dice[2];
	      dice[2]=tmp;
	    }	  
	  sum+=dice[0];
	}
      cout<<sum<<endl;
    }
}

Measured memory_bytes: 1212
import bisect
import itertools
n,m,k=map(int,input().split())
A=list(itertools.accumulate([0]+list(map(int,input().split()))))
B=list(itertools.accumulate([0]+list(map(int,input().split()))))

ans=0
for i,a in enumerate(A):
    if a>k:
        break
    cnt=bisect.bisect_right(B,k-a)-1
    ans=max(ans,i+cnt)
print(ans)

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

using usize = ::std::size_t;
//using u64 = ::std::uint_least64_t;
typedef long long u64;
//static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;

u64 N;
u64 dp[4010][4010], A[4010];

u64 dfs(int l , int r){
    if (~dp[l][r]) return dp[l][r];
    if (r == l + 1) {
        if (A[l] - A[r] > 1 || A[r] - A[l] > 1) {
            return dp[l][r] = 0LL;
        }
        return dp[l][r] = 2LL;
    } else if (r == l) {
        return dp[l][r] = 0LL;
    }
    bool valid = false;
    if (l + 1 < r - 1) {
        int i = l + 1, j = r - 1;
        dp[i][j] = dfs(i, j);
        if (j - i + 1 > 2) {
            for (int k = i; k < j; k++) {
                if (dp[i][j] <= dfs(i, k) + dfs(k + 1, j)) {
                    dp[i][j] = dp[i][k] + dp[k + 1][j];
                }
            }
        }
        
        if (dp[i][j] == r - l - 1 && (A[l] - A[r] <= 1 && A[r] - A[l] <= 1)) {
            valid = true;
            if (dp[l][r] <= dp[i][j] + 2) {
                dp[l][r] = dp[i][j] + 2;
            }
        }
        
    }
    
    if (!valid) {
        for (int k = l; k < r; k++) {
            if (dp[l][r] <= dfs(l, k) + dfs(k + 1, r)) {
                dp[l][r] = dp[l][k] + dp[k + 1][r];
            }
        }
    }
    
        
    
    
    return dp[l][r];
    
}

int main(int argc, char *argv[])
{
   
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while (cin >> N, N != 0) {
        for (int i = 0; i < N; i++) {
            cin >> A[i];
        }
        
        
        memset(dp, -1, sizeof(dp));
        dfs(0, N - 1);
        
        cout << dp[0][N - 1] << endl;
        
    }
    
    
    return 0;
}



Measured memory_bytes: 128792
#a, b, c, d = (int(i) for i in input().split())  

#a = [int(i) for i in input().split()] 

#N = (int(i) for i in input().split())  
N = int(input())
# A = [int(i) for i in input().split()] 
#S_dict = {}
#P_dict = {}
# for i in range(N):
#     tmp = input()
#     S = tmp.split()[0]
#     P = int(tmp.split()[1])
#     if S in S_dict.keys() and P < S_dict[S]:
#         pass
#     else:
#         S_dict[S] = P
#         pass
#     pass
# S_dict = sorted(S_dict.items())

# print(type(S_dict))
# name_lisy = []

# for k in S_dict:
#     name_lisy.append(k)
#     pass
# print(name_lisy)
S_list = []
P_list = []
for i in range(N):
    tmp = input()
    S = tmp.split()[0]
    P = int(tmp.split()[1])
    #print(S,P)
    S_list.append([S,P])
    #P_list.append(P)
    pass
#S_list.sort()
#print(S_list)
sorted_S_list = sorted(S_list, key=lambda x:x[1], reverse=True)
sorted_S_list = sorted(sorted_S_list, key=lambda x:x[0])
#print(sorted_S_list)

for i,k in enumerate(sorted_S_list):
    for j,l in enumerate(S_list):
        if sorted_S_list[i] == S_list[j]:
            print(j+1)
            break
        pass
    pass


#print(P_list)

# for i in range(M):
#     # A.sort()
#     if min(A) < C_list[i]:
#         for j in range(B_list[i]):        
#             if min(A) < C_list[i]:
#                 A.append(C_list[i])
#                 pass
#             pass
#         A.sort(reverse=True)
#         A = A[:N]
#         pass
#     pass
# #sum(A[:N-1])
# print(sum(A[:N]))
# for i in range(M):
#     A.sort()
#     cnt = 0
#     for j in range(N):
#         if cnt < B_list[i] and A[j] < C_list[i]:
#             A[j] = C_list[i]
#             cnt += 1
#             pass
#         pass
#     #print(A)
#     pass
# print(sum(A))


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

int main()
{
  string S;
  cin >> S;
  int x=0;
  int y=0;
  rep(i,S.length()){
    int w = atoi(S.substr(i,1).c_str());
    if(i%2){
      if(w==1){
        x++;
      }else{
        y++;
      }
    }else{
      if(w==1){
        y++;
      }else{
        x++;
      }
    }
  }
  int ans = min(S.length()-x,S.length()-y);
  cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		String S = sc.next();
		StringBuilder sb = new StringBuilder();

		String a = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";

		for(int i=0;i < S.length();i++) {
			int s =a.indexOf(S.substring(i,i+1));
				sb.append(a.substring(s+N , s+N+1));
		}
		System.out.println(sb);

	}
}


Measured memory_bytes: 24912
_, vs, c = input(), list(map(int, input().split())), 0
for i in range(len(vs)):
    for j in range(len(vs)-1, i, -1):
        if vs[j] < vs[j-1]:
            vs[j], vs[j-1] = vs[j-1], vs[j]
            c += 1
print(' '.join(map(str, vs)))
print(c)

Measured memory_bytes: 7672
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

double dist(pair<double, double> a, pair<double, double> b){
    return sqrt(pow(a.first-b.first, 2)+pow(a.second-b.second, 2));
}
int n;
pair<double, double> arr[1000];
double last2;
double gett(double x){
  double l = 0;
   double r = 1001;

   double mid1 = 0;
   double mid2 = 0;
   for (int i=0; i<100; i++){
     mid1 = (r-l)/3+l;
     mid2 = r-(r-l)/3;
     double fmid = 0;
    for (int j=0; j<n; j++){
        fmid = max(fmid, dist(arr[j], {x, mid1}));
    }
    double fmidp1 = 0;
    for (int j=0; j<n; j++){
        fmidp1 = max(fmidp1, dist(arr[j], {x, mid2}));
    }
     if (fmid < fmidp1){
       r = mid2;
     }else{
       l = mid1;
     }
     last2 = mid1;
   }
  
  double val = 0;
  for (int i=0; i<n; i++){
      val = max(val, dist(arr[i], {x, last2}));
  }
  return val;
}
int main ()
{
  prep();
  
  cin >> n;
  
  for (int i=0; i<n; i++){
      double a, b;
      cin >> a >> b;
      arr[i] = {a, b};
  }
  double randy = 5;
  double l = 0;
   double r = 1001;
   double last = 0;
   double mid1 = 0;
   double mid2 = 0;
   for (int i=0; i<100; i++){
     mid1 = (r-l)/3+l;
     mid2 = r-(r-l)/3;
     double fmidp1 = gett(mid2);
    
    double fmid = gett(mid1);
    
     if (fmid < fmidp1){
       r = mid2;
     }else{
       l = mid1;
     }
     last = mid1;
     //cout << mid1 << " " << mid2 << " "<< fmid << " " << fmidp1 << endl;
   }
  //cout << last << " " << last2 << endl;
  double rad = 0;
  for (int i=0; i<n; i++){
      rad = max(rad, dist(arr[i], {last, last2}));
  }
  printf("%.7lf", rad);
  return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
    {
	int a,b;
	scanf("%d %d",&a,&b);
	if (a > b){
		printf ("a > b\n");
	}
	else if (a == b){
		printf ("a == b\n");
	}
    else if (a < b){
		printf ("a < b\n");
	}
    return 0;
}	

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vector<pll> A(N);
        rep(i, 0, N) {
                ll x;
                cin >> x;
                A[i].first = x;
                A[i].second = i;
        }
        sort(all(A));
        rep(i, 0, N) {
                if (i != N-1) cout << A[i].second+1 << ' ';
                else cout << A[i].second+1 << endl;
        }
}

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
string s;
int n=700;
int main()
{
    cin>>s;
    for (int i=0;i<s.size();i++)
    {
        if (s[i]=='o')
            n+=100;
    }
    cout<<n;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  double N,K;
  cin>>N>>K;
  
  int ans=0;
  int co=K;
  while(N>=co){
    ans+=1;
    co*=K;
  }
  ans+=1;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>



unsigned long long gcd(unsigned long long a, unsigned long long b){
    if(b==0) return a;
    return gcd(b, a%b);
}

int main(){
    int N;
    scanf("%d", &N);
    unsigned long long rst=1, cur;
    scanf("%llu", &rst);
    for(int i=1; i<N; i++){
        scanf("%llu", &cur);
        unsigned long long g = gcd(rst, cur);
        rst = cur/g*rst;
    }
    printf("%llu\n", rst);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string s;
    int n=0,m=0,i;
    cin >> s;
    for(i=0;i<s.length();i++){
        if(i%2==0 and s[i]=='0') n++;
        if(i%2==1 and s[i]=='1') n++;
    }
    for(i=0;i<s.length();i++){
        if(i%2==0 and s[i]=='1') m++;
        if(i%2==1 and s[i]=='0') m++;
    }
    cout << min(n,m);
}

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)
#define ans(a, b, c) if(x >= a && x < b){cout << c << endl;}

int main(){
    int x;
    cin >> x;
    ans(400, 600, 8);
    ans(600, 800, 7);
    ans(800, 1000, 6);
    ans(1000, 1200, 5);
    ans(1200, 1400, 4);
    ans(1400, 1600, 3);
    ans(1600, 1800, 2);
    ans(1800, 2000, 1);
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;

const int MN = 100010;

int N, M;
int A[MN], B[MN];
vector<int> adj[MN];
priority_queue<pii> pq;
int fa[MN], dp[MN];
ll sz[MN];

void init() {
    for(int i = 0; i < N; i++) {
        fa[i] = i;
        sz[i] = B[i];
    }
}
int find(int u) {
    if(fa[u] == u) return u;
    else return fa[u] = find(fa[u]);
}
void mrg(int u, int v) {
    u = find(u);
    v = find(v);
    fa[v] = u;
    sz[u] += sz[v];
}

int main() {
    scanf("%d %d", &N, &M);

    ll sum = 0;
    for(int i = 0; i < N; i++) {
        scanf("%d %d", &A[i], &B[i]);
        sum += B[i];
        pq.push({ B[i] - A[i], i });
    }

    for(int i = 0; i < M; i++) {
        int u, v, w; scanf("%d %d", &u, &v);
        u--; v--;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    for(int i = 0; i < N; i++) dp[i] = 2e9;
    init();
    int la = -1;
    while(!pq.empty()) {
        int u = pq.top().second; pq.pop();
        la = u;

        vector<int> tmp;
        for(int i = 0; i < adj[u].size(); i++) {
            int v = adj[u][i];
            if(dp[v] == 2e9) continue;

            tmp.push_back(find(v));
        }
        sort(tmp.begin(), tmp.end());
        tmp.resize(unique(tmp.begin(), tmp.end()) - tmp.begin());

        ll mx = 0;
        for(int i = 0; i < tmp.size(); i++) {
            int v = tmp[i];
            if(sz[v] + dp[v] >= A[u] - B[u]) {
                dp[u] = min(dp[u], dp[v]);
            }
            mx = max(mx, sz[v]);
            mrg(u, v);
        }
        if(dp[u] == 2e9) dp[u] = A[u] - B[u] - mx;
        dp[u] = max(dp[u], 0);
    }

    printf("%lld", sum + dp[la]);
}


Measured memory_bytes: 9460
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#include<cstring>
#define INF 1000000000
using namespace std;
string x;
int sn[101],n,k,d,a,tim=0;
int main(){
    cin>>n>>k;
    memset(sn,0,101);
    for(int g=1;g<=k;g++){
        cin>>d;
        for(int i=1;i<=d;i++){
            cin>>a;
            sn[a]=1;
        }
    }
    for(int i=1;i<=n;i++){
        if(!sn[i])
            tim++;
            }
    cout<<tim;
}

Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>
using namespace std;
int tmp,D[100]={},ans;
void north(){
    tmp=D[0];
    D[0]=D[1];
    D[1]=D[5];
    D[5]=D[4];
    D[4]=tmp;
}
void south(){
    tmp=D[0];
    D[0]=D[4];
    D[4]=D[5];
    D[5]=D[1];
    D[1]=tmp;
}
void east(){
    tmp=D[0];
    D[0]=D[3];
    D[3]=D[5];
    D[5]=D[2];
    D[2]=tmp;
}
void west(){
    tmp=D[0];
    D[0]=D[2];
    D[2]=D[5];
    D[5]=D[3];
    D[3]=tmp;
}
void around(){
    tmp=D[1];
    D[1]=D[3];
    D[3]=D[4];
    D[4]=D[2];
    D[2]=tmp;
}
void serch(int a){
    for(int k=0;k<6;k++){
        if(a==D[k]){
            ans=k;
            break;
        }
    }
    if(ans==1){
        north();
    }
    else if(ans==2){
        west();
    }
    else if(ans==3){
        east();
    }
    else if(ans==4){
        south();
    }
    else if(ans==5){
        south();
        south();
    }
}
int main(){
    int n,a,b;
    for(int i=0;i<6;i++){
        cin>>D[i];
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        serch(a);
        while(1){
            if(b==D[1]){
                break;
            }
            around();
        }
        cout<<D[2]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3088
from collections import Counter 
from collections import defaultdict
from collections import deque
import itertools
import heapq
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))


n,m=input_list()
a=[input_list() for _ in range(m)]
p=input_list()
ans=0
for i in range(2**n):
    bit=bin(i)[2:].zfill(n)
    flag=True
    for num,each in enumerate(a):
        now=0
        light=each[1:]
        #print(light)
        for v in light:
            
            if bit[int(v)-1]=="1":
                now=1-now
        if now!=p[num]:
            flag=False
            break
    if flag:
        ans+=1
print(ans)





Measured memory_bytes: 3436
import java.util.ArrayList;
import java.util.Scanner;


class Class_Visitor {
	private String class_name;
	private int visitor_am;
	private int visitor_pm;

	Class_Visitor(String class_name, int visitor_am, int visitor_pm){
		setClass_name(class_name);
		setVisitor_am(visitor_am);
		setVisitor_pm(visitor_pm);
	}

	public void setClass_name(String class_name) {
		this.class_name = class_name;
	}

	public void setVisitor_am(int visitor_am) {
		this.visitor_am = visitor_am;
	}

	public void setVisitor_pm(int visitor_pm) {
		this.visitor_pm = visitor_pm;
	}

	public String getClass_name() {
		return class_name;
	}
	public int getVisitor_am() {
		return visitor_am;
	}
	public int getVisitor_pm() {
		return visitor_pm;
	}
}

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		ArrayList<Class_Visitor> vis = new ArrayList<Class_Visitor>();

		for (int i = 0; i < 9; i++) {
			String[] data = sc.nextLine().split(" ");
			Class_Visitor c_v = new Class_Visitor(data[0], Integer.parseInt(data[1]),
												   Integer.parseInt(data[2]));
			vis.add(c_v);

			String c_name = vis.get(i).getClass_name();
			int v_sum = vis.get(i).getVisitor_am() + vis.get(i).getVisitor_pm();
			int f_sum = 200 * vis.get(i).getVisitor_am() + 300 * vis.get(i).getVisitor_pm();

			System.out.printf("%s %d %d\n",c_name ,v_sum ,f_sum);
		}

	}

}



Measured memory_bytes: 26040
from itertools import accumulate
n=int(input())
A=list(map(int,input().split()))
A.sort()
S=list(accumulate(A))
cnt=1
for i in range(n-1):
    if 3*S[i]>=S[i+1]:
        cnt+=1
    else:
        cnt=1
print(cnt)

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

int main(void){
    char s[1000001];
    char ans[1000001];
    char start;
    int i;
    int cnt = 0;

    scanf("%s", s);
    //printf("入力された文字列は%s\n", s);
    start = s[0];

    //return 0;

    if(start == '0'){
        //printf("初めの文字は0\n");
        for(i = 0; i < strlen(s); i++){
            if(i % 2 == 0){ans[i] = '0';}
            else{ans[i] = '1';}
        }
    }else{
        //printf("初めの文字は1\n");
        for(i = 0; i < strlen(s); i++){
            if(i % 2 == 0){ans[i] = '1';}
            else{ans[i] = '0';}
        }
    }
    //これが必要なのか？？
    ans[strlen(s)] = '\0';

    //printf("あるべき文字列は%s\n", ans);

    //return 0;


    for(i = 0; i < strlen(s); i++){
        if(s[i] != ans[i]){cnt++;}
    }

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

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	char ch;
	for (int i=0;; i++){
		scanf("%c", &ch);
		if (ch >= 65 && ch <= 90){
			ch += 32;
		}
		else if (ch >= 97 && ch <= 122){
			ch -= 32;
		}
		if (ch == '\n'){
			break;
		}
		cout << ch;
	}
	cout << endl;
	return 0;
	}


Measured memory_bytes: 3148
import Control.Applicative

main :: IO ()
main = do
  [a, b] <- map read . words <$> getLine
  print $ euclideanAlgorithm a b

euclideanAlgorithm :: Integral a => a -> a -> a
euclideanAlgorithm a 0 = abs a
euclideanAlgorithm a b = euclideanAlgorithm b (rem a b)



Measured memory_bytes: 3612
//
// Created by watemus on 08.09.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define FF first
#define SS second

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

#define int ll

template<typename T>
using vec = std::vector<T>;

template<typename T>
using uset = std::unordered_set<T>;

template<typename T1, typename T2>
using umap = std::unordered_map<T1, T2>;

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;
const ld PI = acos(-1);

#ifdef LOCAL
std::mt19937 rnd(228);
#else
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
#endif

vec<pair<int, int>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

/*
template<class... Args>
auto Vec(size_t n, Args&&... args) {
  if constexpr(sizeof...(args) == 1)
    return vector(n, args...);
  else
    return vector(n, Vec(args...));
}*/

#ifdef LOCAL
#else
#endif

void run() {
  int n, m;
  cin >> n >> m;
  int k;
  cin >> k;
  vec<int> a(n + 1), b(m + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
  }
  auto pa = a, pb = b;
  for (int i = 1; i <= n; i++) {
    pa[i] += pa[i - 1];
  }
  for (int j = 1; j <= m; j++) {
    pb[j] += pb[j - 1];
  }
  int j = 0;
  while (j + 1 <= m && pb[j + 1] <= k) {
    j++;
   // cout << "ij\n";
  }
  int ans = j;
  for (int i = 0; i <= n; i++) {
    while (j > 0 && pa[i] + pb[j] > k) {
      j--;
     // cout << "dj\n";
    }
   // cout << "ii\n";
   // cout << pa[i] + pb[j] << '\n';
    if (pa[i] + pb[j] <= k) {
      ans = max(ans, i + j);
    }
  }
  cout << ans << '\n';
}

signed main() {
#ifdef LOCAL
  std::freopen("input.txt", "r", stdin);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
#endif
  int t = 1;
  //cin >> t;
  while (t--) {
    run();
  }
  return 0;
}




Measured memory_bytes: 9520
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  ll p=0,z=0;;
  rep(i,n){if(a[i]>0)p++;if(a[i]==0)z++;}
  sort(all(a));
  vector<ll>wari(n);
  if(z==0&&(p==0||p==n)){//saidaimuri
    if(p==n){
      wari[0]=-1;
      repi(i,1,n)wari[i]=1;
    }
    else{
      wari[n-1]=1;
      rep(i,n-1)wari[i]=-1;
    }
  }
  else{
    rep(i,n){
      if(a[i]<0)wari[i]=-1;
      else wari[i]=1;
    }
  }
  ll res=0;
  rep(i,n)res+=a[i]*wari[i];
  cout<<res<<endl;
  int id=0;
  rep(i,n-1){
    if(wari[i]==-1&&wari[i+1]==1)id=i;
  }
  rep(i,n-id-2){
    cout<<a[id]<<" "<<a[id+i+1]<<endl;
    a[id]-=a[id+i+1];
  }
  cout<<a[n-1]<<" "<<a[id]<<endl;
  a[n-1]-=a[id];
  rep(i,id){
    cout<<a[n-1]<<" "<<a[i]<<endl;
    a[n-1]-=a[i];
  }


  return 0;

}


Measured memory_bytes: 3456
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:268435456")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifndef _MSC_VER
#pragma GCC target ("sse4.2")
#endif
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <random>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;



int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif

	int x, y;
	cin >> x >> y;
	for (int i = 0; i <= x; i++)
	{
		int j = x - i;
		if (i * 2 + j * 4 == y)
		{
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
using namespace std;
constexpr char nl = '\n';
using ll = long long;
using boost::irange;
using boost::adaptors::reversed;
namespace rng { using namespace boost; using namespace boost::range; }
struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
constexpr auto color_s_ = "\033[2m\033[33m", color_e_ = "\033[0m";
template<class T> void trace_(const T& v) { cerr << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cerr << "\n"; for (const auto& v : m) { trace_(v); cerr << "\n"; } }
template<class T> void trace_(const char* s, const T& v) { cerr << color_s_ << s << "="; trace_(v); cerr << color_e_ << "\n"; cerr.flush(); }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { cerr << color_s_; for (; *s != ','; ++s) { cerr << *s; } cerr << "="; trace_(v); cerr << ","; trace_(++s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    cin >> d;
    vector<int> dcnt(n);
    for (int dn : d) dcnt[dn]++;
    if (d[0] != 0 || dcnt[0] != 1) {
        cout << 0 << nl;
        return 0;
    }
    ll ans = 1;
    for (int i : irange(1, n)) {
        for (int j : irange(0, dcnt[i])) {
            ans *= dcnt[i-1];
            ans %= 998244353;
        }
    }
    cout << ans << nl;
}


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

P f(int x){
  int a = x%10;
  int b = 0;
  while(x){
    b = x;
    x /= 10;
  }
  return P(a,b);
}

int main(){
  int N;
  cin >>N;
  map<P,int> freq;
  rep(i,N){
    int j = i+1;
    P p = f(j);
    freq[p]++;
  }
  ll ans = 0;
  rep(i,N){
    int j = i+1;
    P p = f(j);
    P q(p.second, p.first);
    ans += freq[q];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,m,a[N],num;
int cmp(int x,int y){
	return (x&1)>(y&1);
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=0;i<m;i++)scanf("%d",&a[i]),num+=a[i]&1;
	if (num>2){
		puts("Impossible");
		return 0;
	}
	if (m==1){
		if (n==1)puts("1\n1\n1");
		else printf("%d\n%d\n%d %d",a[0],2,a[0]-1,1);
		return 0;
	}
	sort(a,a+m,cmp);
	for (int i=0;i<m;i++)printf("%d ",a[(i+1)%m]);
	puts("");
	a[0]++;a[1]--;
	if (!a[1]){
		printf("%d\n",m-1);
		for (int i=2;i<m;i++)printf("%d ",a[i]);
		printf("%d\n",a[0]);
		return 0;
	}
	printf("%d\n",m);
	for (int i=0;i<m;i++)printf("%d ",a[(i+1)%m]);
}

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

int main()
{
    ll x, n;
    cin >> x >> n;
    set<ll> pSet;
    for(int i = 0; i < n; i++)
    {
        ll p;
        cin >> p;
        pSet.insert(p);
    }

    ll i = 0;
    while(true)
    {
        if(pSet.find(x - i) == pSet.end())
        {
            cout << x - i;
            break;
        }
        else if(pSet.find(x + i) == pSet.end())
        {
            cout << x + i;
            break;
        }

        i++;
    }

    return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    map<long long, int> cnt;
    cnt[0] = 1;
    long long acc = 0, ans = 0;
    for (int ai: a) acc += ai, ans += cnt[acc %= m]++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4608
fn main() {
    let num: i32 = read_line_as_value();
    let bricks: Vec<i32> = read_line_as_vector();

    let mut next_brick = 1;
    for cur_brick in bricks {
        if cur_brick == next_brick {
            next_brick += 1;
        }
    }

    let ans = if next_brick == 1 {
        -1
    } else {
        num - next_brick + 1
    };
    println!("{}", ans)
}

fn read_line_as_value<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().parse() {
        Ok(val) => val,
        _ => panic!("error while parsing input: {}", input)
    }
}

fn read_line_as_vector<T: std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().split_whitespace().map(|x| x.parse()).collect::<Result<Vec<T>, _>>() {
        Ok(vec) => vec,
        _ => panic!("error while parsing input: {}", input)
    }
}

Measured memory_bytes: 4316
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  char c;
  cin >> c;
  if(c=='a' or c=='i' or c=='u' or c=='e' or c=='o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
int n;
string s;
map<string,int> m;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	int mx = 0;
	for(int i = 0;i < n;i++){
		cin >> s;
		m[s]++;
		mx = max(mx,m[s]);
	}
//	cout << mx << endl;
	map<string,int> :: iterator it;
	for(it = m.begin();it!=m.end();it++){
		if(it->se == mx) cout << it->fi << endl;
	}
	return 0;
}

Measured memory_bytes: 23808
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
mod = 10**9+7
ans = 0 ;count = 0 ;pro = 1

n=int(input())
A=list(map(int,input().split()))
C=collections.Counter(A)
S=sorted(C.items(),reverse=True)
# print(S)
for si in S:
    c=si[1]//2
    if count==0 and c==1:
        ans=si[0]
        count +=1
    elif count==0 and c>=2:
        print(si[0]**2)
        exit()
    elif count==1 and c>=1:
        print(ans*si[0])
        exit()
    # print(ans)
print(0)

    

Measured memory_bytes: 69872
import qualified Data.ByteString.Char8 as BC
import Data.Maybe

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

main :: IO ()
main = do
  getLine
  as <- readIntsLine
  print $ foldr (\a b -> a + b - 1) 0 as

Measured memory_bytes: 1020
n=int(input())
x=[]
y=[]
h=[]
xyh=[list(map(int,input().split())) for _ in range(n)]
xyh.sort(reverse=True ,key=lambda na:(na[2]))
#print(xyh)
for i in range(n):
    x.append(xyh[i][0])
    y.append(xyh[i][1])
    h.append(xyh[i][2])

#print(h)
#中心座標を列挙
for i in range(101):#x
    for j in range(101):#y
        ha=abs(i-x[0])+abs(j-y[0])+h[0]
        for z in range(1,n):#違うかの確かめ作業
            if h[z] != max(ha-abs(i-x[z])-abs(j-y[z]),0):
                break
        else:
            print(i,j,ha)
            exit()
#print("DFGH")





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

using namespace std;

vector < vector<int> > hyou(102, vector<int>(102));

void check(int x, int y, int c) {
	int mx[] = {1, 0, -1, 0};
	int my[] = {0, 1, 0, -1};
	for (int i = 0; i < 4; i++) {
		if (hyou[x+mx[i]][y+my[i]] == c) {
			hyou[x+mx[i]][y+my[i]] = 0;
			check(x+mx[i], y+my[i], c);
		}
	}
}

int main() {
	int w, h;
	while (cin >> w >> h) {
		if (w == 0 && h == 0) {
			break;
		}
		for (int i = 0; i < 102; i++) {
			for (int j = 0; j < 102; j++) {
				hyou[i][j] = 0;
			}
		}
		int xs, ys, xg, yg, n;
		int c, d, x, y;
		cin >> xs >> ys >> xg >> yg >> n;
		for (int i = 0; i < n; i++) {
			cin >> c >> d >> x >> y;
			if (d == 0) {
				for (int j = 0; j < 2; j++) {
					for (int k = 0; k < 4; k++) {
						hyou[x+k][y+j] = c;
					}
				}
			} else {
				for (int j = 0; j < 4; j++) {
					for (int k = 0; k < 2; k++) {
						hyou[x+k][y+j] = c;
					}
				}
			}
		}
		if (hyou[xg][yg] != 0 && hyou[xg][yg] == hyou[xs][ys]) {
			check(xs, ys, hyou[xs][ys]);
			if (hyou[xg][yg] == 0) {
				cout << "OK" << endl;
			} else {
				cout << "NG" << endl;
			}
		} else {
			cout << "NG" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1260
#include<stdio.h>
int main(){
int n,i,j,v,k;
int a[1000];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}  
for(i=0;i<n-1;i++){
printf("%d ",a[i]);
}
printf("%d\n",a[i]);
for(i=1;i<=n-1;i++){
v=a[i];
j=i-1;
while(j>=0&&a[j]>v){
a[j+1]=a[j];
j--;
a[j+1]=v;
}
for(k=0;k<n-1;k++){
printf("%d ",a[k]);
}
printf("%d",a[k]);
printf("\n");
}
return 0;
}



Measured memory_bytes: 2060
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(true){
    int a = sc.nextInt();
    if(a==0){
        break;
    }
    int sum=0;
    double avg,bun=0;
    int[] b;
    b = new int[a];
    for(int i=0;i<a;i++){
b[i]=sc.nextInt();
sum+=b[i];
    }
avg=(double)sum/a;
for(int j=0;j<a;j++){
    bun+=(double)(b[j]-avg)*(b[j]-avg);
}
System.out.println(Math.sqrt(bun/a));
}
    }
}


Measured memory_bytes: 31004
#include <stdio.h>

int main() {
	int m,n,a,zz;  
	int mm[100][100], b[100], c[100];
	scanf("%d %d", &n, &m);

	for (int i = 0; i < 100; i++) {
		c[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		for (int k = 0; k < m; k++) {
			scanf("%d", &a);
			mm[i][k] = a;
		}
	}
	for (int k = 0; k < m; k++) {
		scanf("%d", &zz);
		b[k] = zz;
	}

	for (int i = 0; i < n; i++) {
		for(int k = 0; k<m; k++){
			c[i] += mm[i][k] * b[k];
		}
	}

	for (int i = 0; i < n; i++) {
		printf("%d\n",c[i]);
	}
	


}


Measured memory_bytes: 2768
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

vector<vector<int>> g;
vector<int> color;

bool dfs(int v) {
    for (int u : g[v]) {
        if (color[u] != -1) {
            if (color[u] == color[v]) return false;
        } else {
            color[u] = color[v] ^ 1;
            if (!dfs(u)) return false;
        }
    }
    return true;
}

int main() {
    int V, E; cin >> V >> E;
    g.resize(V);
    for (int i = 0; i < E; i++) {
        int a, b; cin >> a >> b; a--; b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    color = vector<int>(V, -1);
    color[0] = 0;
    ll ans = 0;
    if (!dfs(0)) {
        ans = (ll)V * (V - 1) / 2;
    } else {
        for (int i = 0; i < V; i++) ans += color[i];
        ans *= V - ans;
    }
    ans -= E;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll mod = 998244353;
const int MAX = 510000;

int main() {
  vector<char> alphabet;
  for (char c='a'; c<='z'; c++) alphabet.push_back(c);
  string S;
  cin >> S;
  map<char, bool> dic; // 登場した英小文字
  for (int i=0; i<S.size(); i++) dic[S[i]] = true;
  if (S.size()==26) {
    bool can = false;
    for (int i=0; i<S.size()-1; i++) {
      if (S[i]<S[i+1]) {
        can = true;
        break;
      }
    }
    if (!can) cout << -1 << endl;
    else {
      string T = S;
      bool end = false;
      do {
        if (S>T) {
          for (int i=0; i<S.size(); i++) {
            cout << S[i];
            if (S[i]!=T[i]) {
              cout << endl;
              end = true;
              break;
            }
          }
        }
        if (end) break;
      } while (next_permutation(S.begin(), S.end()));
    }
  }
  else {
    for (int i=0; i<alphabet.size(); i++) {
      if (!dic.count(alphabet[i])) {
        cout << S << alphabet[i] << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
H, W = map(int, input().split())
grid = [input() for _ in range(H)]

inf = 10**18
# dp[i][j]はi.j点に行くまでに何回白→黒の変化があったか
dp = [[inf] * W for _ in range(H)]
if grid[0][0] == "#":
    dp[0][0] = 1
else:
    dp[0][0] = 0

for i in range(H):
    for j in range(W):
        if i != 0: # 下移動
            # 今いてるのがi,j点、前の点(上)が白で次が黒なら1足す
            tmp = dp[i - 1][j] + int(grid[i][j]=="#" and grid[i - 1][j]==".")
            dp[i][j] = min(dp[i][j], tmp)
        if j != 0: # 右移動
            # 前の点(左)が白で次が黒なら1足す
            tmp = dp[i][j - 1] + int(grid[i][j]=="#" and grid[i][j - 1]==".")
            dp[i][j] = min(dp[i][j], tmp)
        # この一連の処理で、i,j点に、下移動した場合と右移動した場合のうちの最小値が得られる。
# こたえは目的地, i.e. 右下の点のdpの値
ans = dp[H - 1][W - 1]
print(ans)

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

using namespace std;

const int MOD = 1000000007;

int n;

vector< int > v;
vector< int > diff;

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

  v.resize( n );

  for(int i = 0 ; i < n ; i++)
    scanf("%d",&v[i]);

  for(int i = 0 ; i < n ; i++)
    diff.push_back( abs( n - 2*i - 1 ) );

  sort( v.begin() , v.end() );
  sort( diff.begin() , diff.end() );

  if( diff != v )
  {
    printf("0\n");
    return 0;
  }

  int ans = 1;

  for(int i = 1 ; i <= n/2 ; i++)
    ans = ( 2*ans )%MOD;

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


Measured memory_bytes: 1276
#include<iostream>

int main(){
  int a,b;
  char op;

  while(1){

    std::cin >> a >> op >> b;
    if(op == '?') break;
    
    switch(op){
    case '+':
      std::cout << a + b << std::endl;
      break;
    case '-':
      std::cout << a - b << std::endl;
      break;
    case '*':
      std::cout << a * b << std::endl;
      break;
    case '/':
      std::cout << a / b << std::endl;
      break;
    }

  }

  return 0;
}

Measured memory_bytes: 3080
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc042/tasks/abc042_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(data):
    ans = 'NO'
    data.sort()
    if data[0] == 5 and data[1] == 5 and data[2] == 7:
        ans = 'YES'
    return ans


def main(args):
    data = [int(x) for x in input().split()]
    ans = solve(data)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3316
#include <iostream>

using namespace std;
int main(){
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  
  int ans = A*X + B*Y;
  
  if(X>Y){
    if(C*X*2 < ans)  ans = C*X*2;
    if(C*Y*2 + A*(X-Y) < ans) ans = C*Y*2 + A*(X-Y);}
  else {
    if(C*Y*2 < ans)  ans = C*Y*2;
    if(C*X*2 + B*(Y-X) < ans) ans = C*X*2 + B*(Y-X);}
  
  cout << ans;
}

Measured memory_bytes: 256
N = int(input())
a = []
for i in range(3):
    a.append(input())

ans = 0
for i in range(N):
    if a[0][i] != a[1][i] and a[1][i] != a[2][i] and a[0][i] != a[2][i]:
        ans += 2
    elif a[0][i] == a[1][i] and a[1][i] == a[2][i] and a[0][i] == a[2][i]:
        continue
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064