akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		double T = Double.parseDouble(sc.next());
		double A = Double.parseDouble(sc.next());
		double[] H = new double[N];
		for(int i = 0;i < N;i++) {
			H[i] = Double.parseDouble(sc.next());
		}
		sc.close();
		int index = 0;
		double dist = 1000;
		for(int i = 0;i < N;i++) {
			if(Math.abs(A - (T - H[i] * 0.006)) < dist) {
				dist =Math.abs(A - (T - H[i] * 0.006));
				index = i+1;
			}
		}
		System.out.println(index);
	}
}

Measured memory_bytes: 24020
n,m,k=map(int, input().split())
*a,=map(int, input().split())
*b,=map(int, input().split())
a=[0]+a
b=[0]+b
import numpy as np
a=np.cumsum(a)
b=np.cumsum(b)
bi=m
ans=0
for i in range(n+1):
    asm=a[i]
    while a[i]+b[bi]>k and bi:
        bi-=1
    if a[i]+b[bi]<=k:
        ans=max(ans,i+bi)
print(ans)

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

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

//     int max_cnt, cnt = 0;
//     int c_n;
//     int result = 1;
//     for (int i = 1; i <= N; i++)
//     {
//         cnt = 0;
//         c_n = i;
//         while (c_n % 2 == 0) {
//             c_n /= 2;
//             cnt++;
//         }
//         // max_cnt = max(cnt, max_cnt);
//         if (cnt > max_cnt) {
//             max_cnt = cnt;
//             result = i;
//         }
//     }
//     cout << result << endl;
// }

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

    int max_i=1;
    for (int i = 1; i <= N; i++)
    {
        if (i % 2 != 0)
            A[i] = 0;
        else
        {
            A[i] = A[i / 2] + 1;
        }

        if (A[i] > A[max_i])
            max_i = i;
    }

    cout << max_i << endl;
}

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


int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int count = 1;
    for (int i = min(a, b); i >= 1; i--) {
        if (a % i == 0 && b % i == 0) {
            if (count == k) {
                cout << i << endl;
                return 0;
            } else count++;
        }
    }
}


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

typedef long long ll;
#define pii pair<pii , pii>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 200005

ll n , s;
ll a[MAXX];
ll p[MAXX];

int main()
{
    _FastIO;

    cin >> n;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        s += a[i];
        if(!i)
            p[0] = a[0];
        else
            p[i] = p[i - 1] + a[i];
    }
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        ans += (a[i] * ((s - p[i]) % 1000000007));
        ans %= 1000000007;
    }
    cout << ans << endl;
    return 0;
}


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

using tsii = tuple<string, int, int>;
bool cmpr(tsii t1, tsii t2) {
  string s1, s2;
  int p1, p2;
  tie(s1, p1, ignore) = t1;
  tie(s2, p2, ignore) = t2;
  
  if (s1 == s2) return p1 > p2;
  return s1 < s2;
}

int main() {
  int N;
  cin >> N;
  
  vector<tuple<string, int, int>> v(N);
  for (int i = 0; i < N; ++i) {
    string S;
    int P;
    cin >> S >> P;
    
    v.at(i) = make_tuple(S, P, i+1);
  }
  
  sort(v.begin(), v.end(), cmpr);
  
  for (auto e : v) {
    int i;
    tie(ignore, ignore, i) = e;
    
    cout << i << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var array = new int[N][];
            var si = -1;

            for (var i = 0; i < N; i++)
            {
                array[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (array[i][2] > 0) si = i;
            }
            
            for (var x = 0; x < 101; x++)
            {
                for (var y = 0; y < 101; y++)
                {
                    var H = Math.Abs(array[si][0] - x) + Math.Abs(array[si][1] - y) + array[si][2];
                    var isTrue = true;
                    for (var k = 0; k < N; k++)
                    {
                        if (array[k][2] > 0 && H - array[k][2] != Math.Abs(x - array[k][0]) + Math.Abs(y - array[k][1]))
                            isTrue = false;
                        if (array[k][2] == 0 && H > Math.Abs(x - array[k][0]) + Math.Abs(y - array[k][1]))
                            isTrue = false;
                    }

                    if (isTrue)
                    {
                        Console.WriteLine($"{x} {y} {H}");
                        return;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ll long long
#define rep(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, m;

int main() {
	io(); cin >> n >> m;
	cout << n * (n - 1ll) / 2ll + m * (m - 1ll) / 2ll;
}

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

int main() {
  long long N;
  cin >> N;
  vector<long long> A(N), B(N);
  for (long long i = 0; i < N; i++) cin >> A[i] >> B[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  if (N % 2 == 1) {
    long long result = B[N/2]-A[N/2]+1;
    cout << result << endl;
  } else {
    long long result =  (B[N/2-1]+B[N/2])-(A[N/2-1]+A[N/2])+1;
    cout << result << endl;
  }
}

Measured memory_bytes: 6428
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		ArrayList<Integer> a = new ArrayList<Integer>();
		for(int i = 0; i < N; i ++) {
			a.add(stdIn.nextInt());
		}
		
		Collections.sort(a);
		
		int ans = 0;
		for(int i = a.size() - 1; 0 <= i; i --) {
			ans += a.get(i);
			if(0 <= i - 1) {
				i --;
				ans -= a.get(i);
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 20688
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=pow(10,9)+7;
bool cmp(pair<long double ,int > x, pair<long double , int> y){ return x.F<y.F; }
const ll MAXN=1e3+5;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
 
int main(){ 
    
//    #ifndef ONLINE_JUDGE
//  		freopen("input.txt", "r", stdin);
//    #endif
    
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	ll a,b;
	cin>>a>>b;
	if (a==b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}


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

int temp;
float  n;
float p;

int main()
{
	cin>>temp;
    n=float(temp);
    if(temp&1)
    {
        p=(ceil(n/2))/n;
        cout<<setprecision(10)<<p;
    }
    else
        cout<<setprecision(10)<<0.5;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
#define treap_pair pair<treap*, treap*>
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 2e3 + 2;
const int M = 1e5 + 2;
const int mod = 998244353;
const int inf = 1e9;
const ll INF = 1e16;

void data() {
	#ifdef PC
		freopen("main.in", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
}

int h, w, k, mat[20][N], pr[20][N], ans = inf;
string s[20];

int main() {
	data();
	scanf("%d %d %d", &h, &w, &k);
	for (int i = 1; i <= h; ++i)
		cin >> s[i];
	for (int i = 1; i <= h; ++i)
		for (int j = 0; j < w; ++j)
			mat[i][j + 1] = (s[i][j] - '0');
	for (int i = 1; i <= h + 1; ++i)
		for (int j = 1; j <= w; ++j)
			pr[i][j] = pr[i][j - 1] + mat[i][j];
	for (int mask = 0; mask < (1 << (h - 1)); ++mask) {
		int cnt = __builtin_popcount(mask);
		int last = 0;
		for (int i = 1; i <= w + 1; ++i) {
			int col = 0;			
			for (int j = 1; j <= h; ++j) {
				col += pr[j][i] - pr[j][last];
				if (mask & (1<<(j - 1))) {
					if (col > k && i - last == 1)
						cnt += 10000;
					if (col > k) {
						last = i - 1;
						cnt++;
					}
					col = 0;
				}
			}
			if (col > k && i - last == 1)
				cnt += 10000;
			if (col > k) {
				last = i - 1;
				cnt++;
			}
			col = 0;
		}
		ans = min(ans, cnt);
	}
	printf("%d", ans);
}

/*
	Timus: 288481RF
	CodeForces: fractal
*/


Measured memory_bytes: 384
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		a1: [usize; n],
		a2: [usize; n],
	}

	let mut s1 = vec![0usize; n];
	s1[0] = a1[0];
	for i in 1..n {
		s1[i] = s1[i-1] + a1[i];
	}

	let mut s2 = vec![0usize; n];
	s2[0] = a2[n-1];
	for i in 1..n {
		s2[i] = s2[i-1] + a2[n-1-i];
	}

	let mut ans = 0;
	for i in 0..n {
		ans = max(ans, s1[i]+s2[n-1-i]);
	}
	println!("{}", ans);
}



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

using namespace std;

int main() {
	long long n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	for(long long i = 0; i < n; i++) {
		long long lo = a + i * c - (n - i - 1) * d;
		long long hi = a - (n - i - 1) * c + i * d;
		assert(lo <= hi);
		if(lo <= b && b <= hi)
			return cout << "YES", 0;
	}
	cout << "NO";
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc106/tasks/abc106_d
n, m, q = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(m)]
Q = [list(map(int, input().split())) for _ in range(q)]

A = [[0 for _ in range(n+1)] for _ in range(n+1)]
for x in X:
    l, r = x
    A[l][r] += 1

B = [[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(1, n+1):
    for j in range(1, n+1):
        B[i][j] += B[i][j-1] + A[i][j]
    for j in range(1, n+1):
        B[i][j] += B[i-1][j]

for q in Q:
    a, b = q
    result = B[b][b] - B[b][a-1] - B[a-1][b] + B[a-1][a-1]
    print(result)


Measured memory_bytes: 127396
using System;

namespace abc061_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ABCs = Console.ReadLine().Split(' ');

            int A = Convert.ToInt32(ABCs[0]);
            int B = Convert.ToInt32(ABCs[1]);
            int C = Convert.ToInt32(ABCs[2]);

            if (A<=C && B>=C)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

bool isprime(int n);

int main()
{
	int k;
	while(1){
		cin >> k;
		if(k == 0) break;
		int ans;
		if(isprime(k)) ans = 0;
		else {
			int i = 1, j = 1;
			while(1){
				if(isprime(k - i)) break;
				else i++;
			}
			while(1){
				if(isprime(k + j)) break;
				else j++;
			}
			ans = i + j;
		}
		cout << ans << endl;
	}
	return 0;
}

bool isprime(int n)
{
	if(n == 1 || n == 0) return false;
	else if(n == 2) return true;
	else {
		for(int i = 2; i * i <= n; i++){
			if(n % i == 0) return false; 
		}
	}
	return true;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    set<string>S;
    for(int i=0; i<n; i++)
    {
        string s;
        cin>>s;
        S.insert(s);
    }
    cout<<S.size()<<endl;
}


Measured memory_bytes: 19232
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int x,y;
    cin>>x>>y;
    int ans;
    if(x<y)ans=min(y-x,abs(y+x)+1);
    else ans=min(1+x-y,abs(x+y))+1;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

#define TST 0
int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
#if TST==1
#endif
}


Measured memory_bytes: 3612
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


# --------------------------------------------

dp = None


def main():
    S = input()

    print(S[0] + str(len(S) - 2) + S[-1])


main()


Measured memory_bytes: 5068
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

struct Edge {
	ll to;
	string lab;
};

ll n,a,s,g;
string INFSTR="";

string solve() {
	vector<vector<Edge>> grp(n);
	REP(i,a) {
		ll x,y;
		string lab;
		cin>>x>>y>>lab;
		grp[x].pb(Edge{y,lab});
	}
	vector<vector<string>> dir(n,vector<string>(601,INFSTR));
	dir[s][0]="";
	priority_queue<pair<string,ll>,vector<pair<string,ll>>,greater<pair<string,ll>>> q;
	q.push(make_pair("",s));
	while(!q.empty()) {
		string str=q.top().first;
		ll p=q.top().second;
		q.pop();
		if(dir[p][(ll)str.size()]!=str) continue;
		REP(i,grp[p].size()) {
			string cost=grp[p][i].lab;
			ll np=grp[p][i].to;
			if((str+cost).size()>600) continue;
			if(str+cost<dir[np][(str+cost).size()]) {
				dir[np][(str+cost).size()]=str+cost;
				q.push(make_pair(str+cost,np));
			}
		}
	}
	string ret=INFSTR;
	REP(i,601) ret=min(ret,dir[g][i]);
	if(ret==INFSTR||(ll)ret.size()>250) return "NO";
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	REP(i,600) INFSTR+='z';
	while(1) {
		cin>>n>>a>>s>>g;
		if(n==0) break;
		cout<<solve()<<endl;
	}
}



Measured memory_bytes: 37768
//標準解答
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;

int main(){
  char ch;
  int cnt[26] = {};
  
  while( cin >> ch ){
    ch = tolower(ch);
    if ( isalpha(ch) ){
      cnt[ch-'a']++;
    }
  }
  
  for ( int i = 0; i < 26; i++ ){
    printf("%c : %d\n", i+'a', cnt[i]);
  }
  
  return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int q = 700,c=0;

	for (int i = 0; i < s.length(); i++){
		if (s[i] == 'o')
			c++;
		
	}
	q += c * 100;
	cout << q;
	
}

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

#define rep(i, a, b) for ((i)=(a); (i) < (b); (i)++)
#define reps(i, a, b, s) for ((i)=(a); (i) < (b); (i)+=(s))
#define repe(i, a, b) for ((i)=(a); (i) <= (b); (i)++)
#define mod(n, M) ((((n) % (M)) + (M)) % (M))
#define pb push_back
#define MP make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define prnt(arr) for (auto i : (arr)) cout << i << " "; cout << endl;
#define eps 1e-11
#define len(x) x.size()
#define FIN freopen("input.txt", "r", stdin);
#define FOUT freopen("output.txt", "w", stdout);
#define nl "\n"

using namespace std;

typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

// double max = numer_limits<double>::max()
// double INFINITY = numeric_limits<double>::infinity();

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

	int a, b;
	cin >> a >> b;
	if (a == 1) a = INT_MAX;
	if (b == 1) b = INT_MAX;
	if ( a > b ) cout << "Alice\n";
	else if (a < b) cout << "Bob\n";
	else cout << "Draw\n";

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	ans := 0
	for i := 0; i < len(s); i++ {
		switch string(s[i]) {
		case "+":
			ans++
		case "-":
			ans--
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long x,k,d;
    long long mini;
    cin >> x >> k >> d;
    x = abs(x);
    mini = x % d;

    if(x / d >= k){
       mini = x - d * k;
    }
    else {
         if((k - (x / d)) % 2 == 1)mini = min(abs(mini + d),abs(mini - d));
    }
    cout << abs(mini) << endl;
    
}

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

#define ll long long

int main(){
	string s;
	cin>>s;
	reverse(s.begin(),s.end());
	ll a[200005];
	map<ll,ll> mp;
	ll x=1;
	for (int i=0;i<s.size();i++){
		if (i!=0) a[i]=((s[i]-'0')*x+a[i-1])%2019;
		else a[i]=s[i]-'0';
		x*=10;
		x%=2019;
	}
	for (int i=0;i<s.size();i++) mp[a[i]]++;
	ll res=0;
	for (int i=0;i<2019;i++) res+=mp[i]*(mp[i]-1)/2;
	res+=mp[0];
	//res+=mp[0]+mp[0]*(mp[0]-1)/2;
	cout<<res<<endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    int n;cin>>n;
    vector<tuple<string,int,int>> ans;
    for(int i=1;i<=n;i++){
        string s;int m;cin>>s>>m;
        m*=-1;//sは昇順でsortされる．sが同じ時にmも昇順でsortされてしまうので-1倍かけて降順に直す．．．
        ans.PB(tie(s,m,i));
    }
    sort(ALL(ans));
    rep(i,n){
        cout<<get<2>(ans[i])<<endl;
    }
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  string akiba = "KIHBR";
  int idx = 0;
  int cnt = 0;
  rep(i, s.size()) {
    if(s[i] == 'A') {
      cnt++;
      if(cnt > 1) {
	idx = -1;
	break;
      }
    } else if(idx < (int)akiba.size() && s[i] == akiba[idx]) {
      if(idx == 0) {
	if(s.substr(i, 3) != "KIH") {
	  break;
	}
	i+=2;
	idx+=3;
	cnt = 0;
      } else {
	idx++, cnt=0;
      }
    } else {
      idx = -1;
      break;
    }
  }
  cout << (idx == (int)akiba.size() ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 2e5+5;
const int mod = 1e9+7;

ll a , b;

bool isprime(ll x){
    if(x == 2)
        return 1;
    if(x == 1)
        return 0;
    for(ll v = 2; v*v <= x; v++){
        if(x % v == 0)
            return 0;
    }
    return 1;
}

int main(){
    scanf("%lld%lld" , &a , &b);
    vector < ll > common;
    for(ll i = 1; i*i <= a; i++){
        if(a % i == 0 && b % i == 0){
            common.push_back(i);
        }
        if(a / i == i)
            continue;
        if( (a % (a/i)) == 0 && (b % (a / i)) == 0){
            common.push_back(a/i);
        }
    }
    int ans = 1;
    sort(common.begin() , common.end());
    for(auto v : common){
        if(isprime(v)){
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main()
{
    string str;
    int index;
    int C[26];
    char c;
    for (int i = 0; i != 26; ++i)
    {
        C[i] = 0;
    }
    while (cin >> str)
    {
        for (int i = 0; i != str.size(); ++i)
        {
            if (isalpha(str[i]))
            {
                index = tolower(str[i]) - 'a';
                ++C[index];
            }
        }
    }
    for (int i = 0; i != 26; ++i)
    {
        c = 'a' + i;
        cout << c << " : " << C[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3160
# 入力１
Vn, En = map(int, input().split())

# 初期化
# INF = 10**2 * 10**7  # INF 以外で取りうる値は 10**2 * -10**47< < 10**2 * 10**7
INF = float("inf")
# 入力２：各頂点から別の頂点へ移動する辺とコスト
E = [[INF]*Vn for _ in range(Vn)]
for _ in range(En):
    s, t, c = map(int, input().split())
    E[s][t] = c

for i in range(Vn):
    E[i][i] = 0

for k in range(Vn):
    for i in range(Vn):
        for j in range(Vn):
            E[i][j] = min(E[i][j], E[i][k]+E[k][j])
f = False
for i in range(Vn):
    if E[i][i] < 0:
        f = True
        break
    
if f:
    print("NEGATIVE CYCLE")
else:
    for i in range(Vn):
        for j in range(Vn):
            if E[i][j] == INF:
                E[i][j] = "INF"
        print(" ".join(map(str,E[i])))


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

int main() {
    int n; cin>>n;
    double count;
    for(int i=1;i<=n;i++) {
        if(i%2==1)
        count++;
    }
    cout<<count/n<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x,a,b;
    
    cin >> x >> a >> b;
    
    if(a >= b){
        cout << "delicious" << endl;
    }else if( x >= b - a ){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }
    
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	int n;
	cin >> n;
	cout << (n+1)*n/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string s[100];
char c[]={'#','*','@'};
int a,b,p,dx[]={0,1,0,-1},dy[]={1,0,-1,0};
void dfs(int y,int x){
  s[y][x]='.';
  r(i,4)
    if(x+dx[i]>=0&&dx[i]+x<b)
      if(y+dy[i]>=0&&dy[i]+y<a)
        if(s[y+dy[i]][x+dx[i]]==c[p])
        dfs(y+dy[i],x+dx[i]);
}
main(){
  while(cin>>a>>b,a){
    r(i,a)cin>>s[i];
    int su=0;
    r(i,a)r(j,b){
      if(s[i][j]!='.'){
        if(s[i][j]=='@'){p=2;dfs(i,j);};
        if(s[i][j]=='*'){p=1;dfs(i,j);};
        if(s[i][j]=='#'){p=0;dfs(i,j);};
        su++;
      }
    }
    cout<<su<<endl;
  }
}

Measured memory_bytes: 3484
import java.util.Scanner


object Main {


  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val w = IndexedSeq.fill(n)(sc.nextInt())
    (n, w)
  }

  def solve(n: Int, w: IndexedSeq[Int]): Long = {
    // [0, i), [i, n)
    (1 until n).map { i =>
      val s1 = (0 until i).map(w).sum
      val s2 = (i until n).map(w).sum
      math.abs(s1 - s2)
    }.min
  }

  def main(args: Array[String]): Unit = {
    val (n, w) = read()
    println(solve(n, w))
  }
}

Measured memory_bytes: 25908
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(int i=vv;i<n;i++)
#define FORR(i,n,vv) for(int i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)

int maxn=10000000+1;
ve <int> v(maxn);

void fun(){
	v[1]=1;
	for(ll i=2;i<maxn;i++){
		if(v[i]==0){
			for(ll j=i*i;j<maxn;j+=i)
				v[j]=i;
		v[i]=i;

		}
	}

}


int main(){



    FAST
//	PRECISE

ll ans=0;ll n;
cin>>n;
fun();
FOR(i,1,n+1){
	unordered_map <ll,ll> m;
	ll x=i;
	while(x!=1){
		m[v[x]]++;
		x/=v[x];
	}
	ll co=1;
	for(auto i:m)
		co*=(i.S+1);
	ans+=co*i;
}
cout<<ans;

return 0;
 }

Measured memory_bytes: 42148
N=int(input())
nums=input().split()
r1=0
r2=0
r3=0
r4=0
r5=0
r6=0
r7=0
r8=0
r9=0
for n in range(0,N):
    if 1<=int(nums[n])<=399:
        r1=1
    if 400<=int(nums[n])<=799:
        r2=1
    if 800<=int(nums[n])<=1199:
        r3=1
    if 1200<=int(nums[n])<=1599:
        r4=1
    if 1600<=int(nums[n])<=1999:
        r5=1
    if 2000<=int(nums[n])<=2399:
        r6=1
    if 2400<=int(nums[n])<=2799:
        r7=1
    if 2800<=int(nums[n])<=3199:
        r8=1
    if 3200<=int(nums[n]):
        r9=r9+1

if r1==r2==r3==r4==r5==r6==r7==r8==0 :
    if 1<=r9<=8:
        p1=r9
        p2=1
    else:
        p1=8
        p2=1
else:
    p1=r1+r2+r3+r4+r5+r6+r7+r8+r9
    p2=r1+r2+r3+r4+r5+r6+r7+r8

print(p2,p1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mpp make_pair
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    fast;
    string s;
    cin>>s;
    if(s[0]>='A' && s[0]<='Z')
    {
        cout<<"A"<<endl;
    }
    else
    {
        cout<<"a"<<endl;
    }
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    int N, K, Q;
    cin >> N >> K >> Q;
    int tmp;
    vector<int> A;
    int cnt[100000] = {0};
    for (int i = 0; i < Q; i++)
    {
        cin >> tmp;
        A.emplace_back(tmp);
        cnt[tmp - 1] += 1;
    }

    int pnt;
    for (int i = 0; i < N; i++)
    {
        pnt = K - Q + cnt[i];
        if (pnt > 0)
        {
            cout << "Yes" << endl;
        }else
        {
            cout << "No" << endl;
        }
        
    }
    
    return 0;
}


Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;

const int MAX_V = 1000;

int V;
bool G[MAX_V][MAX_V];
int match[MAX_V];
bool used[MAX_V];

bool dfs(int v) {
	used[v] = true;
	for(int i = 0; i < V; i++) {
		if(!G[v][i]) continue;
		int u = i, w = match[u];
		if(w < 0 || (!used[w] && dfs(w))) {
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int bipartite_matching() {
	int res = 0;
	memset(match, -1, sizeof(match));
	for(int v = 0; v < V; v++) {
		if(match[v] < 0) {
			memset(used, 0, sizeof(used));
			if(dfs(v)) {
				res++;
			}
		}
	}
	return res;
}

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

	int N, M;
	while(cin >> N >> M) {
		memset(G, 0, sizeof G);
		V = N + M;
		for(int i = 0; i < N; i++) {
			int K, b;
			cin >> K;
			for(int j = 0; j < K; j++) {
				cin >> b;
				b = b - 1 + N;
				G[i][b] = G[b][i] = true;
			}
		}

		if(bipartite_matching() == M) {
			cout << "Bob" << endl;
		}
		else {
			cout << "Alice" << endl;
		}
	}
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> A(N), B(M), C(M);
    using P = pair<ll, int>;
    priority_queue<P> q;
    REP(i, N) {
        cin >> A[i];
        q.push(mp(A[i], 1));
    }
    REP(i, M) {
        cin >> B[i] >> C[i];
        q.push(mp(C[i], B[i]));
    }
    ll result = 0;
    REP(i, N) {
        ll x;
        int k;
        tie(x, k) = q.top();
        PRINT(x);
        q.pop();
        result += x;
        if (k - 1 > 0) {
            q.push(mp(x, k - 1));
        }
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 8688
X, Y = list(map(int, input().split()))

#x + y = X
#2* x + 4*y = Y
#x = (4*X - Y) / 2
#y = (Y - 2*X) / 2

if (
  	(Y - 2*X) >= 0 and Y % 2 == 0 and 
  	(4*X - Y) >= 0):
  print("Yes")
else:
  print("No")


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/11  Problem: ARC 091 A / Link: http://arc091.contest.atcoder.jp/tasks/arc091_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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


	LL M;
	cin >> N>>M;
	if (N == 1 && M == 1)ans = 1;
	else if (N == 1) {
		ans = 0;
		if (M > 2)ans = M - 2;
	}
	else if (N == 2) {
		ans = 0;
	}
	else if (M == 1) {
		ans = 0;
		if (N > 2)ans = N - 2;
	}
	else if (M == 2) {
		ans = 0;
	}
	else {
		N -= 2;
		M -= 2;
		ans = N*M;
	}

	cout << ans << "\n";

	return 0;
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;

char b(int x) { return x ? '#' : '.'; }

bool query(string& x, string& y) {
  cout << x << endl << y << endl;
  fflush(stdout);
  string res;
  cin >> res;
  if (res == "end") {
    exit(0);
  }
  return res == "T";
}

void Main() {
  int N;
  cin >> N;

  string s1, s2;

  rep(i, 4) {
    s1 = b(i & 1);
    s2 = b(i & 2);
    if (query(s1, s2)) {
      break;
    }
  }

  while (1) {
    bool ok = 0;
    rep(i, 4) {
      string q1 = s1 + b(i & 1);
      string q2 = s2 + b(i & 2);
      if (query(q1, q2)) {
        ok = 1;
        s1 = q1;
        s2 = q2;
        break;
      }
    }
    if (!ok) break;
  }

  while (1) {
    bool ok = 0;
    rep(i, 4) {
      string q1 = b(i & 1) + s1;
      string q2 = b(i & 2) + s2;
      if (query(q1, q2)) {
        ok = 1;
        s1 = q1;
        s2 = q2;
        break;
      }
    }
    if (!ok) break;
  }
}

int main() {
  //cin.tie(0); ios::sync_with_stdio(false);
  Main();
  return 0;
}


Measured memory_bytes: 596
def main():
    N,M = map(int,input().split())
    heights = list(map(int,input().split()))
    graph = [[] for _ in range(N)]

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

    counter = 0

    for i in range(N):
        ok = True
        now_height = heights[i]
        for d in graph[i]:
            if heights[d] >= now_height:
                ok = False
                break
        if ok:
            counter += 1

    print(counter)






if __name__ == '__main__':
    main()


Measured memory_bytes: 29436
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(12)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    double ans;
    for(int i=1;i<=n;i++){
        int maki=i;
        double niko=1;
        while(maki<k){
            maki*=2;
            niko/=2;
        }
        ans+=niko/n;
    }
    doublecout(ans);
    return 0;
}



Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#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 FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

ll w[111];
ll v[111];
ll dp[111][111111];

signed main()
{
	int N, W;
	cin >> N >> W;
	REP(i, N){
		cin >> w[i] >> v[i];
	}
	REP(i, N+1){
		REP(k, 100001){
			dp[i][k] = INF;
		}
	}
	dp[0][0] = 0;
	FOR(i, 1, N){
		REP(k, 100001){
			if(k-v[i-1]>=0){
				dp[i][k] = min(dp[i-1][k], dp[i-1][k-v[i-1]]+w[i-1]);
			}else{
				dp[i][k] = dp[i-1][k];
			}
		}
	}
	int ans=100000;
	while(dp[N][ans]>W)ans--;
	cout << ans << endl;
}


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

int main() {
  string C1, C2;
  cin >> C1 >> C2;
  if(C1.at(0) == C2.at(2) && C1.at(1) == C2.at(1) &&  C1.at(2) == C2.at(0)) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=5100;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int del(int x) { return x>=P?x-P:x; }
void add(int &x,int y) { x=del(x+y); }
int n,f[N][N][2],g[N],h[N][2],siz[N];
#define pb push_back
vector <int> G[N];
void dfs (int u,int fa)
{
	siz[u]=f[u][1][0]=1;
	for (int v:G[u]) if (v!=fa)
	{
		dfs (v,u);
		for (int i=0; i<=siz[u]; i++)
			for (int j=0; j<=siz[v]; j++)
				for (int x=0; x<=1; x++)
					for (int y=0; y<=1; y++)
					{
						add(h[i][x^y^1],(LL)f[u][i][x]*f[v][j][y]%P*g[j]%P);
						add(h[i+j][x^y],(LL)f[u][i][x]*f[v][j][y]%P);
					}
		siz[u]+=siz[v];
		for (int i=0; i<=siz[u]; i++)
			for (int x=0; x<=1; x++)
				f[u][i][x]=h[i][x],h[i][x]=0;
	}
}

int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(n);
	for (int i=1; i< n; i++)
	{
		int x,y; sc(x),sc(y);
		G[x].pb (y),G[y].pb (x);
	}
	g[0]=1;
	for (int i=2; i<=n; i+=2)
		g[i]=(LL)g[i-2]*(i-1)%P;
	dfs (1,0);
	int ans=0;
	for (int i=1; i<=n; i++)
		add(ans,(LL)del(f[1][i][0]-f[1][i][1]+P)*g[i]%P);
	pr(ans);

    return 0;
}

Measured memory_bytes: 200832
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	char e,f,g;
	e='A';
	f='B';
	g='C';
	cin>>a;
	b=a/1000;
	c=b/26;
	b=b%26;
	d=c/26;
	e=e+d;
	f=f+c;
	g=g+b;
	putchar(e);
	putchar(f);
	putchar(g);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
s = 0
for i in range(n+1):
  s += abs(a[i]-a[i+1])
for i in range(1,n+1):
  print(s-abs(a[i]-a[i+1])-abs(a[i]-a[i-1])+abs(a[i-1]-a[i+1]))

Measured memory_bytes: 14048
def main():
    N,M = map(int, input().split())
    inf = 10**9
    p = 2**N
    dp = [inf] * p
    dp[0] = 0
    
    for i in range(M):
        a,b = map(int, input().split())
        c = sum([2**(int(j)-1) for j in list(input().split())])
        for k in range(p):
            if dp[k|c] > dp[k] + a:
                dp[k|c] = dp[k] + a
    if dp[-1] == inf:
        print(-1)
    else:
        print(dp[-1])

if __name__ == "__main__":
    main()



Measured memory_bytes: 46296
import Control.Applicative

a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

bel :: Int -> Char
bel n 
  | n `elem` a = 'a'
  | n `elem` b = 'b'
  | n `elem` c = 'c'

answer :: Eq a => a -> a -> String
answer x y
  | x == y = "Yes"
  | otherwise = "No"
  
main = do
  [x, y] <- map (read :: String -> Int) . words <$> getLine
  putStrLn $ answer (bel x) (bel y)


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<typename T>
struct Max_Flow{
    struct edge{
        int to; T cap; int rev;
        edge(int to, T cap, int rev) : to(to), cap(cap), rev(rev) {}
    };

    vector<vector<edge>> es;
    vector<bool> used;
    const T INF_T;

    Max_Flow(int n) : INF_T(numeric_limits<T>::max()){
        es.resize(n), used.resize(n);
    }

    void add_edge(int from, int to, T cap){
        es[from].eb(to, cap, sz(es[to]));
        es[to].eb(from, cap, sz(es[from])-1);
    }

    T dfs(int now, int t, T flow){
        if(now == t) return flow;
        used[now] = true;
        for(auto &e: es[now]){
            if(!used[e.to] && e.cap > 0){
                T f = dfs(e.to, t, min(flow, e.cap));
                if(f > 0){
                    e.cap -= f;
                    es[e.to][e.rev].cap += f;
                    return f;
                }
            }
        }
        return 0;
    }

    T max_flow(int s, int t){
        T flow = 0;
        for(;;){
            fill(all(used), false);
            T f = dfs(s, t, INF_T);
            if(f == 0) return flow;
            flow += f;
        }
    }
};

int main(){
    int H, W;
    cin >> H >> W;
    Max_Flow<int> G(H+W+2);
    int s = H+W, t = H+W+1;
    string S[H];
    rep(i, H){
        cin >> S[i];
        rep(j, W){
            if(S[i][j] == 'S') G.add_edge(s, i, inf), G.add_edge(s, H+j, inf);
            if(S[i][j] == 'T') G.add_edge(i, t, inf), G.add_edge(H+j, t, inf);
            if(S[i][j] == 'o') G.add_edge(i, H+j, 1);
        }
    }
    int ans = G.max_flow(s, t);
    cout << (ans < inf? ans : -1) << endl;
}

Measured memory_bytes: 3928
n = int(input())
h = list(map(int, input().split()))

ans = 0
now = 0
before = h[0]
for i in range(1, n):
    if h[i] <= before:
        now += 1
    else:
        ans = max(ans, now)
        now = 0
    before = h[i]
print(max(ans, now))


Measured memory_bytes: 14252
import java.util.*;

public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int[] st = new int[3];
      st[0] = sc.nextInt();
      st[1] = sc.nextInt();
      st[2] = sc.nextInt();
      
      if(st[0] == st[1] + st[2] || st[1] == st[0] + st[2] || st[2] == st[0] + st[1]){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}

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

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

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

    cout << lcm(a, b) << endl;
    
    return 0;
}

Measured memory_bytes: 256