akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

const int MAX_N = 1000;
int N, T, A;
int H[MAX_N];

void _main() {
  cin >> N >> T >> A;
  rep(i, 0, N) cin >> H[i];

  int ans_i = inf;
  float min_diff = inf;
  rep(i, 0, N) {
    float diff = fabs(A - (T - H[i]*0.006));
    if (diff < min_diff) {
      ans_i = i;
      min_diff = diff;
    }
  }

  cout << (ans_i + 1) << "\n";
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, k;
    cin >> a >> b >> k;
    int cnt[100] = {}, tmp = 0;
    for (int i = 1; i <= 100; i++) {
        if (a % i == 0 && b % i == 0) {
            cnt[tmp] = i;
            tmp++;
        }
    }
    cout << cnt[tmp - k] << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
    
int main(){
    ll N, a, ret = 0; cin >> N;
    map<ll, ll> mp;
    for (int i = 0; i < N; i++) {
        cin >> a;
        mp[a]++;
    }
    
    for (auto a : mp) {
        ll val = a.first;
        ll cnt = a.second;
        if(val < cnt) ret += cnt - val;
        else if(val > cnt) ret += cnt;
    }
    
    cout << ret << endstr;
    return 0;
}


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



int main() {
    vector<int> x(5);
    
    rep(i,5) {
        cin >> x[i];
        if(x[i] == 0) {
            cout << i + 1 << endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3620
import itertools

while 1:
    n, m = map(int, input().split())
    if n == 0:
        break

    data = list(map(int, input().split()))

    ans = 0
    for v in itertools.combinations(data, 2):
        if sum(v) <= m and sum(v) > ans:
            ans = sum(v)

    if ans == 0:
        print("NONE")
    else:
        print(ans)



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

using namespace std;

int main(){
    int x = 0;
    int y = 0;
    int x1 = 0;
    cin >> x;
    for(int i = 0; i < x; i++){
        if((i+1) % 15 == 0){
            y += 200;
        }
        x1 += 800;
    }
    cout << x1 - y << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int hikisu;
  int ashi;
  
  cin >> hikisu;
  cin >> ashi;
  
  int i = 0;
  for(i = 0;i <= hikisu;++i){
    int kame = i;
    int turu = hikisu - i;
    if(ashi == kame * 4 + turu * 2){
      if(hikisu == kame + turu){
        break;
      }
    }
  }
  
  if(i == hikisu + 1){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
long long int factorial(long long int x){
  return x==0 ? 1 : x*factorial(x-1);
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main(){
  long long i, j, n, l, r, con=2019, ans=2019*2019, a, tmp;
  cin >> l >> r;
  a=r-l;
  if(r-l>=2019){
    cout << 0 << endl;
    return 0;
  }
  l%=con;
  r=l+a;
  for(i=l; i<r; i++)
    for(j=i+1; j<=r; j++){
      tmp=i*j%con;
      if(tmp<ans) ans=tmp;
    }
  cout << ans << endl;
		 return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
//        int a = int.Parse(input[2]);
//        int b = int.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
//        string ko = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        int b = a.IndexOf("AC");
        if(b >= 0){
            WriteLine("Yes");
        }else{
            WriteLine("No");
        }
    }
}

Measured memory_bytes: 13396
s = list(input())

r = [""]*len(s)
ans = 0

def rec(i: int) -> None:
    if i == len(s)-1:
        global ans
        ans += eval("".join(i+j for i, j in zip(s, r)))
        return

    rec(i + 1)
    r[i] = "+"
    rec(i + 1)
    r[i] = ""

rec(0)
print(ans)


Measured memory_bytes: 3060
#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>;

int main() {
  int k;
  string s;
  cin >> k >> s;
  string ans;
  if (s.size() <= k) ans = s;
  else {
    ans = s.substr(0,k);
    ans.push_back('.');
    ans.push_back('.');
    ans.push_back('.');
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
/*
                         ----------------------------
                              Ankur Kumar Singh    
                         ----------------------------
*/


#include <bits/stdc++.h>
using namespace std;
# define ll  long long  int
# define ld  long double
# define pb push_back
# define pp pop_back
# define ff first
# define ss second
# define mp make_pair
# define ac accumulate
# define mod 1000000007
# define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define trace1(x)                cerr << #x << ": " << x << "\n";
# define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
# define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
# define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";

int  main()
{

   IOS;
   ll n,k;
   cin>>n>>k;
   ll arr[n+2];
   for(ll i=1;i<=n;i++)
   {
      cin>>arr[i];
   }
    sort(arr+1,arr+1+n,greater<ll>());
    ll cnt=0;
    for(ll i=k+1;i<=n;i++)
    {
        cnt+=arr[i];
    }
    cout<<cnt;

}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        char[]s=sc.next().toCharArray();
        char[]t=sc.next().toCharArray();
        int sum=0;
        for(int i=0;i<s.length;i++){
            sum+=(s[i]==t[i])?0:1;
        }
        System.out.println(sum);
    }
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

void solve() {

}

int main() {
  int a,b;
  cin >> a >> b;
  for(int i=0;i<10000;++i) {
    int v1 = (double)i * 0.08;
    int v2 = (double)i * 0.1;
    if( v1 == a && v2 == b ) { cout << i << endl; return 0; }
  }
  puts("-1");
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    char[] S = scanner.next().toCharArray();
    for (int i = S.length - 1; i >= 0; i --) {
      if (isEven(S, 0, i)) {
        System.out.println(i);
        return;
      }
    }
  }

  private static boolean isEven(char[] s, int head, int tail) {
    if (head >= tail) return false;
    if ((tail - head) % 2 != 0) return false;
    int mid = (tail - head) / 2 + head;
    for (int i = 0; i < mid - head; i++) {
      if (s[head + i] != s[mid + i]) return false;
    }
    return true;
  }
}


Measured memory_bytes: 22612
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

const int N = 26, D = 365;

using namespace std;
int main() {
    int d;
    cin >> d;
    vector<int> c(N);
    vector<vector<int>> s(D, vector<int>(N));
    for (int i = 0; i < N; ++i)
        cin >> c[i];
    for (int i = 0; i < d; ++i)
        for (int j = 0; j < N; ++j)
            cin >> s[i][j];
    vector<int> ans;
    vector<int> last(N, 0);
    for (int i = 1; i <= d; ++i) {
        int maxt = 0, maxg = INT_MIN;
        int hi = *max_element(s[i - 1].begin(), s[i - 1].end());
        int maxloss = 0, maxlosst = 0;
        for (int j = 0; j < N; ++j) {
            int loss = (i - last[j]) * c[j];
            if (loss > maxloss) {
                maxloss = loss;
                maxlosst = j;
            }
        }
        if (hi < maxloss) {
            last[maxlosst] = i;
            ans.emplace_back(maxlosst + 1);
            continue;
        }
        for (int j = 0; j < N; ++j) {
            int gain = s[i - 1][j];
            for (int k = 0; k < N; ++k)
                if (k != j)
                    gain -= c[k] * (i - last[k]);
            if (gain > maxg) {
                maxg = gain;
                maxt = j;
            }
        }
        last[maxt] = i;
        ans.emplace_back(maxt + 1);
    }
    for (int i : ans)
        cout << i << endl;
}


Measured memory_bytes: 3684
IDENTIFICATION DIVISION.
      PROGRAM-ID. 101B.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01  INP PIC X(100).
      01  N   PIC 9(10).
      01  S.
      	03 SN PIC 9(1) OCCURS 10 TIMES.
      01 IDX  PIC 9(2).
      01 WA   PIC 9(10).
      01 SHO  PIC 9(10).
      01 AMA  PIC 9(10).
      
      PROCEDURE DIVISION.
      ACCEPT INP.
      MOVE INP TO N.
      MOVE INP TO S.
      
      PERFORM VARYING IDX FROM 1 BY 1 UNTIL (IDX > 10) OR (SN(IDX) = SPACE)
      ADD SN(IDX) TO WA
      END-PERFORM.
      
      DIVIDE N BY WA GIVING SHO REMAINDER AMA.
      
      IF AMA = 0
         DISPLAY "Yes"
      ELSE
      	 DISPLAY "No"
      END-IF.
      
      STOP RUN.

Measured memory_bytes: 384
#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>;

int main(){
	string s;
	cin >> s;
	set<char> values;
	rep(i,s.size()){
		values.insert(s[i]);
	}
	for(char c = 'a' ; c < 'z' +1; c++){
		if(values.count(c)) continue;
			else{
				cout << c << endl;
				return 0;
			}
	}
	cout << "None" << endl;
}


Measured memory_bytes: 3768
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,j,k,p;
	int max,len;
	char a[4001],b[4001];
	int la,lb;
	
	while(scanf("%s",a)!=EOF)	{
		scanf("%s",b);
//		printf("%s %s\n",a,b);
		la=strlen(a);
		lb=strlen(b);
		max=0;
		for(i=la-1;i>=0;i--)	{
//			printf("i=%d\n",i);
			
			len=0;
			p=i;
			for(j=0;j<lb;j++)	{

				if(p>=la)	break;
				if(a[p]==b[j])	{
					len++;	
//				printf("j=%d p=%d len=%d\n",j,p,len);		
				}
				else {
					if(len>max)	{
						max=len;
					}
					len=0;
				}
				p++;
			}
			if(len>=max)	{
				max=len;
			}
		}
		for(j=1;j<lb;j++)	{
			len=0;
			p=j;
			for(i=0;i<la;i++)	{
				if(p>=lb)	break;
				if(a[i]==b[p])	{
					len++;
				}
				else {
					if(len>max)	{
						max=len;
					}
					len=0;
				}
				p++;
			}
			if(len>=max)	{
				max=len;
			}
		}
		printf("%d\n",max);
	}
	return 0;
}


Measured memory_bytes: 552
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
ans=0

array=[True]*len(T)

for t in range(K,len(T)):
  if T[t-K] == T[t] and array[t-K]==True:
    array[t]=False
  

for t in range(len(T)):
  if T[t]=="r" and array[t]==True:
    ans += P
  elif T[t]=="s" and array[t]==True:
    ans += R
   
  elif T[t]=="p"and array[t]==True:
    ans += S

print(ans)

Measured memory_bytes: 4084
#include <iostream>
#include <cstdio>

using namespace std;

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

int ans = 0, K;

int main() {
	scanf("%d", &K);
	for (int a = 1; a <= K; a++) {
		for (int b = 1; b <= K; b++) {
			for (int c = 1; c <= K; c++) {
				ans += gcd(a, gcd(b, c));
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3228
#include <stdio.h>
#include <ctype.h>

static int
readMCXI (
  const char  * s
  )
{
  int prefix = 1;
  int res = 0;

  for ( ; *s != '\0'; ++s )
  {
    if ( isdigit ( *s ) )
    {
      prefix = *s - '0';
      continue ;
    }

    switch ( *s )
    {
      case 'm': res += prefix * 1000; break ;
      case 'c': res += prefix * 100;  break ;
      case 'x': res += prefix * 10;   break ;
      case 'i': res += prefix * 1;    break ;
    }
    prefix = 1;
  }

  return ( res );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int n;

  scanf ( "%d", &n );
  while ( n-- )
  {
    char s1[ 16 ], s2[ 16 ];
    int  res, m, c, x, i;

    scanf ( " %s %s", s1, s2 );
    res = readMCXI ( s1 ) + readMCXI ( s2 );
    i   = ( res        ) % 10;
    x   = ( res / 10   ) % 10;
    c   = ( res / 100  ) % 10;
    m   = ( res / 1000 ) % 10;

    if ( m ) printf ( m > 1 ? "%dm" : "m", m );
    if ( c ) printf ( c > 1 ? "%dc" : "c", c );
    if ( x ) printf ( x > 1 ? "%dx" : "x", x );
    if ( i ) printf ( i > 1 ? "%di" : "i", i );
    puts ( "" );
  }

  return ( 0 );
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	nums := scanIntSlice(n)
	for _, n := range nums {
		if n%2 == 0 && n%3 != 0 && n%5 != 0 {
			fmt.Println("DENIED")
			os.Exit(0)
		}
	}
	fmt.Println("APPROVED")
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


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

using namespace std;
typedef long long ll;
#define watch(x) cout << "["<<(#x) << " is " << (x) << "]" << endl

double choose(double n, double r){
	double top,second,third;
	if(r==0){
		return 1.0;
	}
	else{
		 top = 1.0;
		for(double x = 1; x <= n; ++x){
			top *= x;
		}
		 second= 1.0;
		for(double x = 1; x <= r; ++x){
			second *= x;
		}
		 third=1.0;
		for(double x = 1; x <= (n-r); ++x){
			third *= x;
		}
	}
	return (top/((second*third)));
}

double distance(double first,double second){
	double third = pow(first,2)+pow(second,2);
	return sqrt(third);
}


void solve(){
	int n;
	cin >> n;
	double dist;
	int counter = 0;
		cin >> dist;
	while(n--){
		double first,second;
		cin >> first >> second;
		if(distance(first,second)<=dist){
			++counter;
		}

	}
	cout << counter << endl;
}

int main(){
	// cout << choose(15,4) << endl;
	//freopen("input.txt", "r", stdin);
	solve();
	return 0;

}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	string s;
	cin >> s;

	int n = s.size();
	if(n % 2 == 1){
		cout << "No" << endl;
		return 0;
	}

	string t;
	rep(i, n){
		if(i % 2 == 0) t.push_back('h');
		else t.push_back('i');
	}

	if(s == t){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
	long long x,i,sum=0;
	scanf("%lld",&x);
	for(i=1;i<=x;i++){
		sum+=i;
		if(sum>=x)break;
	}
	printf("%d",i);
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	static int h;
	static int w;
	static Masu[][] masu;

	static int min;
	static LinkedList<Masu> queue=new LinkedList<Masu>();
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String rts = sc.nextLine();
			String[] rtssp = rts.split("\\s+");
			w = Integer.parseInt(rtssp[0]);
			h = Integer.parseInt(rtssp[1]);
			if (w == 0 && h == 0) break;

			masu = new Masu[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					masu[i][j] = new Masu(i, j);
				}
			}

			for (int i = 0; i < h; i++) {
				String str = sc.nextLine();
				String[] strsp = str.split("\\s+");
				for (int j = 0; j < w - 1; j++) {
					if (strsp[j + 1].equals("0")) {

						masu[i][j].r = 1;
						masu[i][j + 1].l = 1;
					}
				}
				if (i != h - 1) {
					String str2 = sc.nextLine();
					String[] strsp2 = str2.split("\\s+");

					for (int j = 0; j < w; j++) {
						if (strsp2[j].equals("0")) {

							masu[i][j].u = 1;
							if (i + 1 != h) masu[i + 1][j].t = 1;
						}
					}
				}
			}

			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++)
					masu[i][j].setarround(masu);
			}

			int herei = 0;
			int herej = 0;

			masu[herei][herej].my=1;
			int x=0;
			int y=0;
			queue.offer(masu[x][y]);
			while(!queue.isEmpty()){
				Masu sub=queue.poll();
		//		System.out.println(sub.tate+" "+sub.yoko);
			//	sub.pass=true;
				for(Masu e:sub.list){
					if(!e.pass){
						if(e.my>sub.my+1)e.my=sub.my+1;	
						e.pass=true;
						queue.offer(e);			
					}
				}	
			}	
	
			if(masu[h-1][w-1].my==10000)System.out.println("0");
			else System.out.println(masu[h-1][w-1].my);
		
		}
	}
}
class Masu {
	int t;
	int r;
	int l;
	int u;
	int tate;
	int yoko;
	int my=10000;
	boolean pass;
	ArrayList<Masu> list=new ArrayList<Masu>();
	public Masu(int tt, int yy) {
		t = -1;
		r = -1;
		l = -1;
		u = -1;
		tate = tt;
		yoko = yy;
		pass = false;
	}

	public void setarround(Masu[][] map){
		if (this.r == 1) list.add(map[tate][yoko + 1]);
		if (this.u == 1) list.add(map[tate + 1][yoko]);
		if (this.t == 1) list.add(map[tate - 1][yoko]);
		if (this.l == 1) list.add(map[tate][yoko - 1]);

	}
	
}

Measured memory_bytes: 69488
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define repe(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main()
{
    IO;

string S,T; cin>>S>>T;
ll a=S.size(), jj=0;
rep(i,a){
if(S[i]!=T[i]){++jj;}
}
cout<<jj<<endl;

}


Measured memory_bytes: 3416
#include <iostream>
#include <algorithm>
#include <tuple>
#include <stack>
#include <queue>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
using namespace std;

const int MAX_SIZE = 1000010;
const long long MOD = 1000000007;

long long inv[MAX_SIZE];
long long fact[MAX_SIZE];
long long factinv[MAX_SIZE];

void init() {
  inv[1] = 1;
  for (int i=2; i<MAX_SIZE; i++) {
    inv[i] = ((MOD - inv[MOD%i]) * (MOD/i))%MOD;
  }
  fact[0] = factinv[0] = 1;
  for (int i=1; i<MAX_SIZE; i++) {
    fact[i] = (i * fact[i-1])%MOD;
    factinv[i] = (inv[i] * factinv[i-1])%MOD;
  }
}

long long C(int n, int k) {
  if (n >=0 && k >= 0 && n-k >= 0) {
    return ((fact[n] * factinv[k])%MOD * factinv[n-k])%MOD;
  }
  return 0;
}

long long power(long long x, long long n) {
  if (n == 0) {
    return 1;
  } else if (n%2 == 1) {
    return (x * power(x, n-1)) % MOD;
  } else {
    long long half = power(x, n/2);
    return (half * half) % MOD;
  }
}

long long gcm(long long a, long long b) {
  if (a < b) {
    return gcm(b, a);
  }
  if (b == 0) return a;
  return gcm(b, a%b);
}

typedef long long ll;

int main() {
  init();
  ll H, W, A, B;
  cin >> H >> W >> A >> B;
  ll ans = 0;
  for (auto i = 1; i <= H-A; i++) {
    ll temp = C(B-1+i-1, i-1);
    //cerr << temp << endl;
    temp *= C(W-B-1 + H-i, H-i);
    //cerr << temp << endl;
    temp %= MOD;
    ans += temp;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 23680
import kotlin.math.min

fun main(args: Array<String>){

    var (H, W) = readLine()!!.split(" ").map{it.toInt()}
    var c = Array(10){IntArray(10)}
    var A = Array(H){IntArray(W)}
    var countNum= IntArray(10){0}
    var ans = 0L
    for(i in c.indices){
        c[i] = readLine()!!.split(" ").map{it.toInt()}.toIntArray()
    }
    for(i in A.indices){
        A[i] = readLine()!!.split(" ").map{it.toInt()}.toIntArray()
    }
    var minToOne = IntArray(10){1001}
    minToOne[1] = 0

    var minRoot = 1
    var checked = Array(10){false}
    checked[1] = true
    var allchecked = false
    while(!allchecked) {
        var min = 1001
        var minIndex = -1
        for (i in 0 until 10) {
            if (!checked[i]) {
                minToOne[i] = Math.min(c[i][minRoot] + minToOne[minRoot], minToOne[i])
                if (min > minToOne[i]) {
                    min = minToOne[i]
                    minIndex = i
                }
            }
        }
        if(minIndex == -1) break

        checked[minIndex] = true
        minRoot = minIndex
        allchecked = true
        for(i in checked.indices){
            if(!checked[i]){
                allchecked = false
            }
        }
    }

    for (i in 0 until H) {
            for (j in 0 until W) {
                if (A[i][j] != -1) {
                    countNum[A[i][j]]++
                }
            }
        }

    for(i in countNum.indices){
        ans += countNum[i] * minToOne[i]
    }

    println(ans)
}

Measured memory_bytes: 42464
import collections

n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


c = collections.Counter(prime_factorize(n))


for i in c.keys():
    n *= (i - 1)
for j in c.keys():
    n //= j
print(n)


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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cout << #x << " : " << x << '\n'

const int INF = 1e9;

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

  int ans;
  int X, Y, Z;
  cin >> X >> Y >> Z;

  int hoge = X / (Y + Z);
  int piyo = X - hoge * (Y + Z);

  if (piyo >= Z) {
    ans = hoge;
  } else {
    ans = hoge - 1;
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}




int main(){

  int n,min_=0,max_=0;
  vector<int> cnt(9,0);
  cin >> n;
  FOR(i,0,n){
    int a;
    cin >> a;
    FOR(i,1,9){
      if(a<400*i){
        cnt[i]++;
        if(cnt[i]==1)min_++;
        break;
      }else if(i==8){
        max_++;
      }
    }
  }
  
  if(min_==0 && n>0)min_=1,max_--;
  cout << min_ << " " << min_+max_ << endl;
}


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

int main(void){
  int x,y,z;
  cin>>x>>y>>z;
  int sum=z;
  int cnt=0;
  while(x>sum){
    sum=sum+y+z;
    if(x<sum) break;
    cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve (void)
{

  int N;cin>>N;
  vector<vector<pair<int,int> > > data (N);
  for (int i = 0; i < N; i++)
  {
    int num;cin>>num;
    for (int j = 0; j < num; j++)
    {
      int X,Y;cin>>X>>Y;
      X--;
      data[i].emplace_back(X,Y);
    }
    
  }
  int ANS = 0;
  for (int b = 0; b < (1<<N); b++)
  {
    vector<int> bit;
    for (int i = 0; i < N; i++)
    {
      if((b>>i)&1)bit.push_back(1);
      else bit.push_back(0);
    }
    // DEBUG(bit);
    //不親切な人の証言は当てにしない
    int check = 1;
    for (int i = 0; i < N; i++)
    {
      if(bit[i] == 1)
      {
        for (int j = 0; j < data[i].size(); j++)
        {
          if(bit[data[i][j].first] != data[i][j].second) check = 0;
        }
        
      }
    }
    if(check == 1)
    chmax(ANS,__builtin_popcount(b));
    
  }
  cout<<ANS<<endl;
  
    
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

int main(){
  long n;
  cin >> n;
  vector<long> a(n);
  rep(i,n)cin >> a[i];
  sort(a.begin(), a.end());
  long maxa = a[n-1];
  long hyo[maxa+10];
  rep(i,maxa+10)hyo[i] = 0;
  rep(i,n){
    if(i>0 && a[i]==a[i-1]){
      hyo[a[i]] = 1;
      continue;
    }
    int j = 2;
    while(a[i]*j<=maxa){
      hyo[a[i]*j] = 1;
      j++;
    }
  }
  long ans = 0;
  rep(i,n){
    if(hyo[a[i]] == 0)ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12732
using System;

public class p0075
{
	p0075(){
		string str;
		string[] st;
		
		while((str=Console.ReadLine())!=null){
			st = str.Split(',');
			if(calc(double.Parse(st[1]), double.Parse(st[2])))
				Console.WriteLine(st[0]);
		}
	}
	
	public bool calc(double s, double t){
		return (25.0 <= (s/(t*t)));
	}
	
	public static int Main(string[] args){
		new p0075();
		return 0;
	}
}

Measured memory_bytes: 5652
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int n,i,ok,d[100005],dp[100005],x,y,rt;
vector<int> s[100005];
void dfs(int p,int f)
{
	int i,v,sum=0;
	dp[p]=1;
	for(i=0;i<s[p].size();i++)
	{
		v=s[p][i];
		if(v==f)continue;
		dfs(v,p);
		if(dp[v]==1)sum++,dp[p]=0;
	}
	if(sum>1)
	{
		printf("First\n");
		exit(0);
	}
	if(p==rt&&dp[rt]==1)
	{
		printf("First\n");
		exit(0);
	}
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		s[x].push_back(y);
		s[y].push_back(x);
		d[x]++;d[y]++;
	}
	for(i=1;i<=n;i++)if(d[i]>1){dfs(rt=i,0);break;}
	printf("Second\n");
	return 0;
}

Measured memory_bytes: 6528
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


class Main {
    private static int cnt = 0;

    private static void insertionSort(int[] A, int n, int g){

        for (int i = g; i < n; i++) {
            int v = A[i];
            int j = i - g;

            while (j >= 0 && A[j] > v){
                A[j+g] = A[j];
                j -= g;
                cnt++;
            }
            A[j+g] = v;
        }
    }

    private static void shellSort(int[] A, int n){
        cnt = 0;

        List<Integer> G = new ArrayList<>();

        for (int i = 1; i <= n; i = 3 * i + 1)
            G.add(0, i);

        int m = G.size();
        System.out.println(m);

        for (int i = 0; i < m - 1; i++)
            System.out.print(G.get(i)+" ");
        System.out.print(G.get(m - 1) + "\n");

        for (int i = 0; i < m; i++)
            insertionSort(A, n, G.get(i));
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] A = new int[n];
        for (int i = 0; i < n; i++)
            A[i] = sc.nextInt();

        shellSort(A, n);
        System.out.println(cnt);

        for (int num: A)
            System.out.println(num);
    }
}



Measured memory_bytes: 299268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn= new Scanner(System.in);
		int n=scn.nextInt();
		int k =scn.nextInt();
		int c =scn.nextInt();
		String s=scn.next();
		int [] arr1 = new int[n];
		int [] arr2 =new int[n];
		for(int i=0;i<n;i++){
			if(s.charAt(i)!='x'){
				arr1[i]=i-c-1>=0?Math.max(arr1[i-1],arr1[i-c-1]+1):Math.max(i>0?arr1[i-1]:0, 1);
			}else{
			     arr1[i]=i>0?arr1[i-1]:0;
			}
		}
		for(int i=n-1;i>=0;i--){
			if(s.charAt(i)!='x'){
				arr2[i]=i+c+1<n?Math.max(arr2[i+1],arr2[i+c+1]+1):Math.max(i+1<n?arr2[i+1]:0,1);
			}else{
			     arr2[i]=i+1<n?arr2[i+1]:0;
			}
		}
		
		for(int i=0;i<n;i++){
			if(s.charAt(i)!='x'){
				int val = i>0?arr1[i-1]:0;
				int val2 =i+1<n?arr2[i+1]:0;
				
				if((val+val2+1)==k){
					System.out.println(i+1);
				}
			}
		}
		
		

	}

}

Measured memory_bytes: 54240
#include <stdio.h>

int main() {
  int N, M, i, j, MAX, compMAX;
  int compA[1000] = {0};
  int commB[1000] = {0};
  int cnt[1000] = {0};
  scanf( "%d", &N );
  scanf( "%d", &M );
  for( i = 0; i < N; i++ ) {
    scanf( "%d", &compA[i] );
  }
  for( i = 0; i < M; i++ ) {
    scanf( "%d", &commB[i] );
  }
  for( i = 0; i < N; i++ ) {
    for( j = 0; j < M; j++ ) {
      if( compA[j] <= commB[i] ) {
        cnt[j]++;
        break;
      }
    }
  }
  compMAX = 1;
  MAX = cnt[0];
  for( i = 0; i < M; i++ ) {
    if( MAX < cnt[i] ) {
      MAX = cnt[i];
      compMAX = i + 1;
    }
  }
  printf( "%d\n", compMAX );
  return 0;
}

Measured memory_bytes: 1036
using System;
using System.Collections;
using System.Collections.Generic;

class Program {

    static void Main (string[] args) {
        string[] S1 = Console.ReadLine ().Split (' ');
        int N = int.Parse (S1[0]);
        int K = int.Parse (S1[1]);
        var d = new int[K];
        var has = new bool[N];
        for (int i = 0; i < K; i++) {
            Console.ReadLine ();
            string[] particlarhas = Console.ReadLine ().Split (' ');
            foreach (string str in particlarhas) {
                has[int.Parse (str) - 1] = true;
            }
        }
        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (!has[i]) {
                ans++;
            }
        }
        Console.WriteLine (ans);
    }
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

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

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  deque<ll> ans;
  rep(i, n) {
    if(i%2==0) ans.push_back(a[i]);
    else ans.push_front(a[i]);
  }
  if(n%2==1) reverse(ALL(ans));
  vector<ll> res(n);
  rep(i, n) res[i] = ans[i];
  line_out(res);
}


Measured memory_bytes: 8576
#!/usr/bin/ruby
N=gets.to_i
r=1.step(N-2,2).flat_map{|i|[[0,i],[i,0]]}
r+=(N%2).step(N-1,2).flat_map{|i|[[N-1,i],[i,N-1]]}
1.step(N-2,3){|j|
	1.step(N-2){|i|
		r<<[i,j] if (i+j)%2==1
	}
}
p r.size
puts r.map{|e|e*' '}

Measured memory_bytes: 52604
#include <cstdio>
#include <algorithm>
int main() {
	for (int i = 0; i < 3000; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0) break;
        if (a > b) std::swap(a, b);
        printf("%d %d\n", a, b);
    }
}


Measured memory_bytes: 2612
def main():
    N=int(input())
    a=[]
    for i in range(N):
        a.append(list(map(int,input().split())))
    mod=10**9+7

    dp=[0]*(2**N)
    dp[0]=1
    for i in range(1,2**N):
        m=[j for j in range(N) if i>>j &1==1]
        for j in m:
            dp[i]+=dp[i-2**j]*a[len(m)-1][j]
        dp[i]%=mod
    
    print(dp[-1])

if __name__=="__main__":
    main()

Measured memory_bytes: 57836
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void) {
  int a;
  scanf("%d", &a);
  int a_2 = a * a, a_3 = a * a * a;
  printf("%d\n", a + a_2 + a_3);
  return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	string N;
	cin >> N;

	string N_rev = N;
	reverse(N_rev.begin(), N_rev.end());

	if (N == N_rev) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3620
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<f64>();
    let r = N.sqrt() as i32;
    println!("{}", r*r);

}


Measured memory_bytes: 4352
//ABC053B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	string s;
	cin >> s;
	int n = s.size();
	int r, l;
	for(int i=0;i<n;i++){
		if(s.at(i) == 'A'){
			l = i;
			break;
		}
	}
	for(int i=n-1;i>=0;i--){
		if(s.at(i) == 'Z'){
			r = i;
			break;
		}
	}
	int ans = r-l+1;
	cout << ans << endl;
	return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;

unordered_map<char, ll> cnt;

int main(void) {
  // Here your code !
  cin >> s;

  for (auto &e : s) {
    cnt[e] += 1L;
  }

  ll n = s.size();

  ll ans = 1L + n * (n - 1L) / 2L;

  for (auto &e : cnt) {
    ll subtract = e.second * (e.second - 1L) / 2L;
    ans -= subtract;
  }

  printf("%lld\n", ans);

  return 0;
}


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

n,a,b = map(int,input().split())

answer = 0

for i in range(n+1):
    nc = list(str(i))
    nc = list(map(int,nc))
    ncsum = sum(nc)
    nc = list(map(str,nc))
    nc = int("".join(nc))
    if a <= ncsum and b >= ncsum:
        answer += nc

print(answer)


Measured memory_bytes: 42972
#include <stdio.h>
int main(){
        int n,u,k,v;
        int i,j;
        int M[100][100];

        scanf("%d",&n);
        for(i=0; i<n; i++) {
                for(j=0; j<n; j++) {
                        M[i][j]=0;
                }
        }
        for(i=0; i<n; i++) {
                scanf("%d%d",&u,&k);
                u--;
                for(j=0; j<k; j++) {
                        scanf("%d",&v);
                        v--;
                        M[u][v]=1;
                }
        }
        for(i=0; i<n; i++) {
                for(j=0; j<n; j++) {
                        printf("%d",M[i][j]);
                        if(j==n-1)
                                printf("\n");
                        else
                                printf(" ");
                }

        }
        return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
using namespace std;
char map[1005][1005];
bool vis[1005][1005];
int dx[]={0,0,-1,1};
int dy[]={1,-1,0,0};
int sx,sy;
int h,w;
int bfs(int n){
	memset(vis,false,sizeof(vis));
	queue<pair<pair<int,int>,int> >que;
	que.push(make_pair(make_pair(sx,sy),0));
	while(!que.empty()){
		pair<int,int>now=que.front().first;
		int cnt=que.front().second;
		que.pop();
		if(map[now.first][now.second]==n+48){
			sx=now.first;
			sy=now.second;
			return cnt;
		}
		for(int i=0;i<4;i++){
			int _x=now.first+dx[i];
			int _y=now.second+dy[i];
			if(_x<0||_y<0||_x>=h||_y>=w||map[_x][_y]=='X'||vis[_x][_y]){
				continue;
			}
			vis[_x][_y]=true;
			que.push(make_pair(make_pair(_x,_y),cnt+1));
		}
	}
}
int main(){
	int n;
	while(cin>>h>>w>>n){
		memset(map,0,sizeof(map));
		for(int i=0;i<h;i++){
			scanf("%s",map[i]);
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(map[i][j]=='S'){
					sx=i;
					sy=j;
					map[i][j]=='.';
					break;
				}
			}
		}
		int count=0;
		for(int k=1;k<=n;k++){
			count+=bfs(k);
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int main(){
  int n,m;cin >> n >> m;
  vector<int> s(n),t(m);
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  for(int j=0;j<m;j++){
    cin >> t[j];
  }
  vector<vector<ll>> dp(n+1,vector<ll>(m+1)),sum(n+1,vector<ll>(m+1));
  dp[0][0]=1;
  sum[0][0]=1;
  for(int i=0;i<=n;i++){
    sum[i][0]=1;
  }
  for(int j=0;j<=m;j++){
    sum[0][j]=1;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(s[i]==t[j]){
        dp[i+1][j+1]=sum[i][j];
      }
      sum[i+1][j+1]=(sum[i+1][j]+sum[i][j+1]-sum[i][j]+mod+dp[i+1][j+1])%mod;
    }
  }
  cout << sum[n][m] << endl;
}

Measured memory_bytes: 62976
#include<stdio.h>
#define N 101
 
int main(){
  int n,u,k,v,i,j;
  int Adj[N][N];
  scanf("%d",&n);
  
  for(i = 1;i <= n;i++){
    for(j = 1;j <= n;j++){
      Adj[i][j] = 0;
    }
  }
  
  for(i = 0;i < n;i++){
    scanf("%d%d",&u,&k);
    for(j = 1;j <= k;j++){
      scanf("%d",&v);
      Adj[u][v] = 1;
    }
 }
  
 for(i = 1;i <= n;i++){
   for(j = 1;j <= n;j++){
     if(j != 1){
       printf(" ");
     }
     printf("%d",Adj[i][j]);
   }
   printf("\n");
 }
  
 return 0;
    
}

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

int main() {
    string S;
    cin >> S;

    string result = "AC";
    int cnt = 0;

    if(S[0] != 'A') {
        result = "WA";
    }
    for(int i = 1; i < S.length(); i++) {
        if(i >= 2 && i <= S.length() -1) {
            if(S[i] == 'C') cnt++;
        }
        if(S[i] >= 'A' && S[i] <= 'Z' && S[i] != 'C') {
            result = "WA";
        }
    }
    if(S[S.length() - 1] == 'C') {
        result = "WA";
    }
    if(cnt != 1) {
        result = "WA";
    }

    cout << result << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
typedef long long lld;
std::priority_queue<int> pq;
int A, M, N;

lld solve() {
  for (int i = 0; i < M; ++i) {
    if (pq.empty()) break;
    int v = pq.top();
    pq.pop();
    v /= 2;
    if (v) pq.push(v);
  }
  lld sum = 0LL;
  while (!pq.empty()) {
    sum += pq.top();
    pq.pop();
  }
  return sum;
}

int main() {
  scanf(" %d%d", &N, &M);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A);
    pq.push(A);
  }
  printf("%lld\n", solve());
  return 0;
}

Measured memory_bytes: 892
import java.util.*;
	 public class Main{
	   public static void main(String[]args){
	     Scanner in=new Scanner(System.in);
	     int D=in.nextInt();
	     int T=in.nextInt();
	     int S=in.nextInt();
         if(T * S >= D){
            System.out.println("Yes");
         }else
	     System.out.println("No");
	   }
	 }

Measured memory_bytes: 35696
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,l=n1()
L=[l+i-1 for i in range(1,n+1)]

if L.count(0)>0:
    print(sum(L))
elif L[-1]<0:
    print(sum(L[:-1]))
else:
    print(sum(L[1:]))

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  ll N;cin>>N;
  ll i,j,k,l;
  ll a[N],b[N];
  rep(i,N) cin>>a[i];
  rep(i,N) b[i]=a[i];
  rep(i,N) b[i]=abs(b[i]);
  sort(b,b+N);
  ll plus=0,minus=0,zero=0;
  ll ans=0;
  rep(i,N){
    if(a[i]>0) plus++;
    else if(a[i]<0) minus++;
    else zero++;
  }
  if(zero+plus==0 or zero+minus==0){
    rep(i,N){
      ans+=b[i];
    }
    ans-=b[0]*2;
    cout<<ans<<endl;
  }
  else{
    rep(i,N){
      ans+=abs(a[i]);
    }
    cout<<ans<<endl;
  }
  sort(a,a+N);
  ll M=N,S=0;
  for(i=0;i<N-1;i++){
    if(i==N-2){
      cout<<a[M-1]<<" "<<a[S]<<endl;
      return 0;
    }
    if(plus>minus){
      cout<<a[S]<<" "<<a[M-1]<<endl;
      a[S]=a[S]-a[M-1];
      M--;
      plus--;
    }
    else if(plus<minus){
      cout<<a[M-1]<<" "<<a[S]<<endl;
      a[M-1]=a[M-1]-a[S];
      S++;
      minus--;
    }
    else{
      cout<<a[M-1]<<" "<<a[S]<<endl;
      a[M-1]=a[M-1]-a[S];
      S++;
      minus--;
    }
  }

}


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

const int INF = 2e9;

int main(){
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> cnt(n,k);
    rep(i,q){
        int a;
        cin >> a;
        a--;
        cnt[a]++;
    }
    rep(i,n){
        cnt[i] -= q;
        if(cnt[i] > 0)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1024