akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():

    return

#B
def B():
    n = I()
    a = IR(n)
    ans = 0
    b = [0]*(n+1)
    for i in range(n):
        ans += (a[i]+b[i])>>1
        if (a[i]%2)^(b[i]%2) and a[i]:
            b[i+1] += 1
    print(ans)
    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 46556
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a,b,c,d;
int main ()
{
	for(int i=1;i<=3;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		switch(x)
		{
			case 1:a++;break;
			case 2:b++;break;
			case 3:c++;break;
			case 4:d++;break;
		}
		switch(y)
		{
			case 1:a++;break;
			case 2:b++;break;
			case 3:c++;break;
			case 4:d++;break;
		}
	}
	if(a==3||b==3||c==3||d==3) 
	{
		printf("NO");
		return 0;
	}
	int num=0;
	if(a==2) num++;
	if(b==2) num++;
	if(c==2) num++;
	if(d==2) num++;
	if(num==2) printf("YES");
	return 0;
}

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

using LL = long long;
using LD = long double;
 
LL mod = 1e9+7;


int main()
{
	LL x;
	cin >> x;
	LL A, B;
	bool found = false;
	for (LL i = 1; i*i <= x && !found; ++i) {
		if (x % i == 0) {
			LL diff = i;
			for (LL b = -200; b <= 200; ++b) {
				LL a = diff+b;
				if (log10(a) <= 3) {
					if (a*a*a*a*a -b*b*b*b*b == x) {
						found = true;
						A = a, B=b;
						break;
					}
				}
			}
			if (found) {
				break;
			}
		}
	}
	cout << A << " " << B << "\n";

}

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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

void initStrArray(char** p, int n, int len){
    for(int i=0; i<n; i++){
        *(p + i) = (char*)malloc(sizeof(char) * (len + 1));
    }
}

int main(){
    int n, m;
    scanf("%d", &n);
    int p[n], p_len = 0;
    char* s[n];
    initStrArray(s, n, 10);
    rep(i, 0, n){
        p[i] = 0;
    }
    rep(i, 0, n){
        char buf[11];
        scanf("%s", buf);
        int f=1;
        rep(j, 0, p_len){
            if(strcmp(s[j], buf) == 0){
                f = 0;
                p[j]++;
                break;
            }
        }
        if(f){
            strcpy(s[p_len], buf);
            p[p_len++] = 1;
        }
    }
    scanf("%d", &m);
    rep(i, 0, m){
        char buf[11];
        scanf("%s", buf);
        rep(j, 0, p_len){
            if(strcmp(s[j], buf) == 0){
                p[j]--;
                break;
            }
        }
    }
    int ans = 0;
    rep(i, 0, p_len){
        if(p[i] > ans){
            ans = p[i];
        }
    }
    printf("%d", ans);

    return 0;
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#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 SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

const int mod = 1e9+7;
const int inf = (1<<28);
const ll infl = (1LL<<60);

int main() {
  string s; cin >> s;
  cout << (regex_match(all(s),regex("(hi)+"))?"Yes":"No") << endl;
  return 0;
}


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

int main(int argc, char *argv[]) {
  int as[3], bs[3], cnts[4] = {};
  for (int i = 0; i < 3; i++) {
    scanf("%d %d", &as[i], &bs[i]);
    cnts[as[i] - 1]++;
    cnts[bs[i] - 1]++;
  }
  int num1 = 0, num2 = 0;
  for (int i = 0; i < 4; i++) {
    if (cnts[i] == 1) {
      num1++;
    } else if (cnts[i] == 2) {
      num2++;
    }
  }
  if (num1 == 2 && num2 == 2) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		int[] mountains = new int[10];
		int i = 0;
		while(true){
			String s = r.readLine();
			mountains[i++] = Integer.valueOf(s);
			if(i >= 10) break;
		}
		Arrays.sort(mountains);
		for(i = 9; i > 6; i--) {
			System.out.println(mountains[i]);
		}
	}
}

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

const ll MOD=1e9+7;
const double EPS=1e-9;
const double PI=acos(-1.0);
//const long double PI=acos(-1.0L);

struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}

    Point operator +(const Point &b) const {return Point(x+b.x,y+b.y);}
    Point operator -(const Point &b) const {return Point(x-b.x,y-b.y);}
    Point operator *(const double b) const {return Point(x*b,y*b);}
    Point operator /(const double b) const {return Point(x/b,y/b);}
};

struct Line{
    Point a,b;
    Line(){}
    Line(Point a,Point b):a(a),b(b){}
};

int sgn(double a) {return (a>EPS)-(a<-EPS);}
int sgn(double a,double b) {return sgn(a-b);}

double dot(const Point &a,const Point &b) {return (a.x*b.x+a.y*b.y);}
double cross(const Point &a,const Point &b) {return (a.x*b.y-a.y*b.x);}
double norm(const Point &p) {return dot(p,p);}
double abs(const Point &p) {return sqrt(norm(p));}

//1:Counter_Clockwise -1:Clockwise
//2:a-b-c -2:c-a-b 0:a-c-b
int ccw(const Point &p,const Point &q){
    int s=sgn(cross(p,q));
    if(s!=0) return s;
    if(dot(p,q)<0) return -2;
    if(norm(p)<norm(q)) return 2;
    return 0;
}
int ccw(const Point &a,const Point &b,const Point &c){return ccw(b-a,c-a);}

bool isConvex(vector<Point> &g){
    int n=g.size();
    for(int i=0;i<n;i++){
        if(ccw(g[i],g[(i+1)%n],g[(i+2)%n])==-1) return false;
    }
    return true;
}

int main(){
    int N;
    cin>>N;
    vector<Point> g(N);
    rep(i,N) cin>>g[i].x>>g[i].y;

    if(isConvex(g)) cout<<"1"<<endl;
    else cout<<"0"<<endl;

    return 0;
}



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

typedef struct dice{
	int num[6];
	int i;
	
}Dice;

int main(int argc, const char * argv[]) {
	
	int i,j,n,s;
	char way[101];
	Dice a;
	int Dice[5] = {6 ,3 ,4 ,5 ,2 }; 

	
	scanf("%d",&a.num[0]);
	scanf("%d",&a.num[1]);
	scanf("%d",&a.num[2]);
	scanf("%d",&a.num[3]);
	scanf("%d",&a.num[4]);
	scanf("%d",&a.num[5]);
	
	scanf("%s",way);
	
	for(i = 0; way[i] != '\0' ; i++) {
		
		int tmp = 0;
		if(way[i] == 'N') { 
			tmp = Dice[3];
		    Dice[3] = 7 - Dice[0];
			Dice[4] = Dice[0];
			Dice[0] = tmp;
		} else if(way[i] == 'S') {
			tmp = Dice[4];
			Dice[4] = 7 - Dice[0];
			Dice[3] = Dice[0];
			Dice[0] = tmp;
		} else if(way[i] == 'W') {
			tmp = Dice[2];
			Dice[2] = 7 - Dice[0];
			Dice[1] = Dice[0];
			Dice[0] = tmp;
		} else if(way[i] == 'E') {
			tmp = Dice[1];
			Dice[1] = 7 - Dice[0];
			Dice[2] = Dice[0];
			Dice[0] = tmp;
		}
		

	}
	
	printf("%d\n",a.num[7-Dice[0] - 1]);
	return 0;
	
	
}


Measured memory_bytes: 2056
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
	while (1) {
		auto n = readln.chomp.to!int;
		if (!n) break;
		auto time = new int[](60 * 60 * 24);
		foreach (_; 0..n) {
			auto x = readln.chomp.split;
			auto s = x[0].split(":").map!(to!int);
			auto a = s[0]*60*60+s[1]*60+s[2];
			auto e = x[1].split(":").map!(to!int);
			auto b = e[0]*60*60+e[1]*60+e[2];
			time[a..b] += 1;
		}
		time.reduce!(max).writeln;
	}
}

Measured memory_bytes: 4496
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int k=sc.nextInt();
		long mod=1000000007;
		int a=Math.min(k,n-k+1);
		long ans=0;
		for(int i=1; i<=a; i++){
			ans=C(n-k+1,i,mod)*C(k-1,i-1,mod);
			ans%=mod;
			System.out.println(ans);
		}
		for(int i=0; i<k-a; i++){
			System.out.println(0);
		}
	}
	static long C(long left,long right,long mod){
		if(right==0){
			return 1;
		}
		long ans=1;
		right=Math.min(right,left-right);
		for(int i=0; i<right; i++){
			ans*=(left-i);
			ans%=mod;
		}
		for(int i=2; i<=right; i++){
			long tmp=mod-2;
			long mul=i;
			while(tmp>0){
				if((tmp&1)==1){
					ans*=mul;
				}
				tmp>>=1;
				mul*=mul;
				ans%=mod;
				mul%=mod;
			}
		}
		return ans;
	}
}




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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<bool Repeat = false> void replaceAll(string& str, const string& from, const string& to) {
  for (size_t pos = 0; (pos = str.find(from, pos)) != string::npos;) {
    str.replace(pos, from.size(), to);
    if (!Repeat) pos += to.size();
  }
}

int main() {
  string s;
  cin >> s;
  replaceAll(s, ",", " ");
  cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define int long long 
typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())
int C[2*MAXN],N,K;

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>K;
	FOR(i,1,N){
		if ((2*i)%K==0) C[i%K]++;
	}
	int ans=0;
	FOR(i,0,K-1) ans+=C[i]*C[i]*C[i];
	cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define repr(i,n) for(int i=0, i##_len=(n); i<i##_len; --i)
#define REP(i,m,n) for(int i=int(m), i##_len=(n); i<i##_len; ++i)
#define VV(T) vector<vector<T>>
#define co(P) cout << P << endl
#define ci(P) cin >> P
#define pb push_back
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;;
typedef long long ll;
typedef double d;

int main(){
  int K;
  string S;
  ci(K >> S);
  if((int)S.size() <= K){
    co(S);
  }
  else{
    rep(i,K){
    cout << S.at(i);
    }
    co("...");
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;

int ans = 0;

int func(vector<int>& vec) {
    sort(ALL(vec));
    if (vec[0] == vec[1] && vec[1] == vec[2]) {
        return false;
    };
    if (vec[0] != vec[1]) vec[0] += 2;
    else if (vec[0] == vec[1]) {vec[0] += 1; vec[1] += 1;}
    ans += 1;
    return true;
}

int main() {
    vector<int> vec(3);
    rep(i, 3) cin >> vec[i];
    while (func(vec)) {}
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] times = new int[5];
		for(int i = 0; i < times.length; i++) 
			times[i] = sc.nextInt();
		
		int min = 0;
		for(int i = 1; i < times.length; i++) 
			if(mod(times[min]) > mod(times[i]))
				min = i;
		
		int sum = 0;
		for(int i =0; i < times.length; i++)
			if(i == min)
				sum += times[i];
			else
				sum += roundUp(times[i]);
		System.out.println(sum);
	}
	
	private static int roundUp(int i) {
		if(i % 10 == 0)
			return i;
		return (i / 10 + 1) * 10;
	}
	
	private static int mod(int i) {
		if(i % 10 == 0)
			return 10;
		else
			return i % 10;
	}
}

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


int main(){
int a;
  cin>>a;
  vector<int>op(a);
  for(int i=0;i<a;i++)
  {
  int x;
    cin>>x;
    op.at(i)=x;
  
  }
      
sort(op.begin(), op.end());
int s=0;
  for(int i=0;i<a-2;i++)
  {
  for(int j=i+1;j<a-1;j++)
  {
  for(int k=j+1;k<a;k++)
  {
  if(op.at(i)+op.at(j)>op.at(k)){
    s=s+1;
  
  }
    else break;
  }
  }
  }
  cout<<s;
  
  
  
  
  
  
  
  
  
  
  
  
  
}

Measured memory_bytes: 256
import math
a, b, n = map(int,input().split())
# N = int(input())
# al = list(map(int,input().split()))

lst = []
if b > n:
    x = n
else:
    x = b-1

ans =  math.floor(a * x / b) - a * math.floor(x / b)
print(ans)

Measured memory_bytes: 8968
import java.util.HashSet;
import java.util.Scanner;

/**
 * @author Personal
 *
 */
public class Main{

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		HashSet<Integer> numbers = new HashSet<Integer>();
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		for (int i = 0; i < n; i++) {
			numbers.add(scan.nextInt());
		}
		if (numbers.size() % 2 == 0) {
			System.out.println(numbers.size() - 1 );
		} else {
			System.out.println(numbers.size());
		}


	}

}


Measured memory_bytes: 62500
fn solve(r: usize) -> usize {
    3 * r * r
}

fn solve_test() {
    assert_eq!(solve(4), 48);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let r = parse_line!(usize);

    println!("{}", solve(r));
}


Measured memory_bytes: 4352
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int n, m; cin >> n >> m;
  int t = m * 1900 + (n-m) * 100;
  int b = 1;
  loop(i,0,m) b *= 2;
  cout << t * b << endl;
  return 0;
}


Measured memory_bytes: 3612
n,a,b = gets.chomp.split(' ').map(&:to_i)
cnt = []
1.step(n) do |i|
  i = i.to_s
  sum = 0
  i.length.times do |n|
    sum += i[n].to_i
  end
  cnt << i.to_i if (sum >= a && sum <= b)
end
puts cnt.inject(:+)

Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数list 1 <= x <= n
auto divv = [](ll n) {
  unordered_set<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
//   sort(ALL(v));
  return v;
};

auto isprime = [](auto n){
  bool isPrime = true;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return isPrime;
};

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


    unordered_set<ll> divn,divk;
    divn = divv(n);
    divk = divv(k);
    ll sum=0;
    for(auto it:divk) if(divn.count(it)) if(isprime(it)) sum++;
    pr(sum);
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  if(n >= 30) {
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  return 0;
}

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

const int NUM = 7;

void grooping(int y, int x, int w, int h, char** room, unsigned long*** group, unsigned long* next)
{
	if (room[y][x] != '#') {
		for (int i = y - 1; i <= y + 1; i++) {
			for (int j = x - 1; j <= x + 1; j++) {
				if (i < 0 || j < 0 || i >= h || j >= w) {
					continue;
				}
				if ((i == y && j != x) || (i != y && j == x)) {
					for (int k = 0; k < NUM; k++) {
						group[y][x][k] |= group[i][j][k];
					}
				}
			}
		}
		for (int i = 0; i < NUM; i++) {
			if (group[y][x][i] == 0UL && next[i] != 0UL) {
				group[y][x][i] |= next[i];
				next[i] <<= 1;
				break;
			}
		}
	}
}

int main()
{
	int w, h;
	while (true) {
		cin >> w >> h;
		if (w == 0 && h == 0) {
			break;
		}

		unsigned long next[NUM] = { 1UL, 1UL, 1UL, 1UL, 1UL, 1UL, 1UL };
		char** room = new char*[h];
		unsigned long*** group = new unsigned long**[h];
		int x, y;
		for (int i = 0; i < h; i++) {
			room[i] = new char[w];
			group[i] = new unsigned long*[w];
			for (int j = 0; j < w; j++) {
				cin >> room[i][j];
				if (room[i][j] == '@') {
					x = j;
					y = i;
				}
				group[i][j] = new unsigned long[NUM];
				for (int k = 0; k < NUM; k++) {
					group[i][j][k] = 0UL;
				}
			}
		}

		for (int k = 0; k < 2; k++) {
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					grooping(i, j, w, h, room, group, next);
				}
			}
			for (int i = h - 1; i >= 0; i--) {
				for (int j = w - 1; j >= 0; j--) {
					grooping(i, j, w, h, room, group, next);
				}
			}
			for (int j = 0; j < w; j++) {
				for (int i = 0; i < h; i++) {
					grooping(i, j, w, h, room, group, next);
				}
			}
			for (int j = w - 1; j >= 0; j--) {
				for (int i = h - 1; i >= 0; i--) {
					grooping(i, j, w, h, room, group, next);
				}
			}
		}

		int count = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				for (int k = 0; k < NUM; k++) {
					if ((group[i][j][k] & group[y][x][k]) != 0UL) {
						count++;
						break;
					}
				}
			}
		}

		cout << count << '\n';

		for (int i = 0; i < h; i++) {
			delete[] room[i];
			for (int j = 0; j < w; j++) {
				delete[] group[i][j];
			}
			delete[] group[i];
		}
		delete[] room;
		delete[] group;
	}

	return 0;
}

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

using namespace std;

const long double eps = 1.0e-12; // 許容される誤差
const long double PI = 3.1415926535897932384626433832795028841971693;


long double mysqrtl(long double x)
{
  long double a = sqrt((double)x); // 近似値
  do {
    a = (a + x/a) / 2.0L;
  } while (fabsl(x - a*a) > eps);
  return a;
}


int main(void){
    long double  A,B,H,M;
    long double ans,s_H,s_M,tmp;

    
    cin>>A>>B>>H>>M;

    s_H= H *30.0 + 0.50* M;
    s_M= M*6.0;

    if(s_H >= s_M){
        tmp=s_H-s_M;
    }else{
        tmp=s_M-s_H;
    }

    tmp=min(tmp,360.0-tmp);

    tmp=tmp/180.0*PI;

  
        ans = A*A+B*B-2*A*B*cos(tmp);
 

    

 
    // ans = mysqrtl(ans);
    ans = sqrt(ans);


    
    printf("%.14Lf\n",ans);




    return 0;
}



Measured memory_bytes: 4100
import math
n=int(input())
e=[]
for i in range(n):
    x,y=map(int,input().split())
    if (x,y)==(0,0):
        continue
    else:
        t=math.atan2(y,x)
        e.append((x,y,t))
e.sort(key=lambda x:x[2])
n=len(e)

e+=e
a=[(0,0)]
ans=0
for x,y,t in e:
    a+=[(a[-1][0]+x,a[-1][1]+y)]
#print(e,a)
for l in range(n*2):
    for r in range(l,n*2):
        if r-l>n:
            continue
        else:
            x,y=a[r]
            w,z=a[l]
            ans=max((x-w)**2+(y-z)**2,ans)
print(ans**0.5 if n>0 else 0)

Measured memory_bytes: 39152
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if (N % 10 == 3) {
            System.out.println("bon");
        } else if (N % 10 == 0 
        || N % 10 == 1
        || N % 10 == 6
        || N % 10 == 8) {
            System.out.println("pon");
        } else {
            System.out.println("hon");
        }
        sc.close();
    }
}

Measured memory_bytes: 35820
#include <cstdio>
#include <algorithm>

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

using namespace std;

const int inf = 1e9;

typedef long long ll;

int n;
int hp[100];
int ms, ma;
int mps[100];
int mpa[100];
int dmgs[100];
int dmga[100];
int dps[2][100001];
int dpa[2][100001];

void calc(int m, int mp[], int dmg[], int dp[][100001]){
	dp[0][0] = 0;
	fill_n(dp[0] + 1, 100000, inf);
	for(int i = 1; i <= m; ++i){
		rep(j, 100001){
			dp[i & 1][j] = dp[(i - 1) & 1][j];
			if(dmg[i - 1]){
				if(j < dmg[i - 1]){
					dp[i & 1][j] = min(mp[i - 1], dp[i & 1][j]);
				}
				else{
					dp[i & 1][j] = min(dp[i & 1][j - dmg[i - 1]] + mp[i - 1], dp[i & 1][j]);
				}
			}
		}
	}
}

int main(){
	while(scanf("%d", &n), n){
		rep(i, n){
			scanf("%d", &hp[i]);
		}
		int m;
		scanf("%d", &m);
		ms = ma = 0;
		rep(i, m){
			char nm[17];
			int mp;
			char trgt[7];
			int dmg;
			scanf("%s%d%s%d", nm, &mp, trgt, &dmg);
			if(trgt[0] == 'S'){
				mps[ms] = mp;
				dmgs[ms++] = dmg;
			}
			else{
				mpa[ma] = mp;
				dmga[ma++] = dmg;
			}
		}

		calc(ms, mps, dmgs, dps);
		calc(ma, mpa, dmga, dpa);
		
		ll ans = inf;
		rep(i, 100001){
			ll p = dpa[ma & 1][i];
			rep(j, n){
				if(hp[j] > i){
					p += dps[ms & 1][hp[j] - i];
				}
			}
			ans = min(p, ans);
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(int, a);
    Cin(int, b);
    Cin(int, x);
    Cout((a <= x && x <= a+b) ? "YES" : "NO");
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<lint,int> plint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint inf=123456789012345678LL,mo=1000000007;
lint dp[2][100100];//最短路の距離
lint d2[2][100100];//最短路が何通りあるか
bool used[100100];
int u[200200],v[200200],d[200200];
vector<pint> gr[100100];
priority_queue<plint> q;
void aedge(int x,int y,lint z,lint w){
	if(dp[x][y]<z) return;
	if(dp[x][y]==z){
		d2[x][y]+=w;d2[x][y]%=mo;
	}
	else d2[x][y]=w;
	dp[x][y]=z;q.push(mp(-z,y));
}
void cal(int it,int s){
	memset(used,false,sizeof(used));
	memset(d2[it],0,sizeof(d2[it]));
	rep(i,100100) dp[it][i]=inf;
	aedge(it,s,0,1);
	while(!q.empty()){
		plint p=q.top();q.pop();
		int y=p.se;lint z=-p.fi;
		if(used[y]) continue;used[y]=true;
		//cout<<y<<' '<<z<<' '<<d2[it][y]<<endl;
		rep(i,gr[y].size()) aedge(it,gr[y][i].fi,z+gr[y][i].se,d2[it][y]);
	}
}
int main()
{
	int n,m,s,t;
	cin>>n>>m;cin>>s>>t;
	rep(i,m){
		cin>>u[i]>>v[i]>>d[i];
		gr[u[i]].pb(mp(v[i],d[i]));gr[v[i]].pb(mp(u[i],d[i]));//ed.pb(mp(u,v))
	}
	cal(0,s);cal(1,t);
	//REP(i,1,n+1) cout<<i<<' '<<dp[0][i]<<' '<<d2[0][i]<<' '<<dp[1][i]<<' '<<d2[1][i]<<endl;
	lint out=d2[0][t]*d2[0][t];out%=mo;
	REP(i,1,n+1){
		if(dp[0][i]==dp[1][i]){
			out-=(d2[0][i]*d2[0][i])%mo*d2[1][i]%mo*d2[1][i];
			out%=mo;
		}
	}
	rep(i,m){
		if(dp[0][u[i]]+d[i]+dp[1][v[i]]==dp[0][t] && dp[0][u[i]]*2<dp[0][t] && dp[0][v[i]]*2>dp[0][t]){
			out-=(d2[0][u[i]]*d2[0][u[i]])%mo*d2[1][v[i]]%mo*d2[1][v[i]];
			out%=mo;
		}
		else if(dp[0][v[i]]+d[i]+dp[1][u[i]]==dp[0][t] && dp[0][v[i]]*2<dp[0][t] && dp[0][u[i]]*2>dp[0][t]){
			out-=(d2[0][v[i]]*d2[0][v[i]])%mo*d2[1][u[i]]%mo*d2[1][u[i]];
			out%=mo;
		}
	}
	cout<<(out%mo+mo)%mo<<endl;
}


Measured memory_bytes: 15728
#include <iostream>

using namespace std;

int main()
{
    int tong = 0;
   string s;
   cin >> s;
   while (s.length()>0)
   {
       tong  = tong + s[0] - 48;
       s.erase(0,1);
   }
   if ( tong %9 == 0 ) cout <<"Yes";
   else cout << "No";
   return 0;

}


Measured memory_bytes: 3672
N = int(input())
L = list(map(int, input().split()))
 
ans = 0
for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1, N):
      if(L[i] != L[j] and L[i] != L[k] and L[j] != L[k] and abs(L[j]-L[k]) < L[i] and L[i] < L[j]+L[k]):
        ans +=1
          
print(ans)

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long N;
	cin >> N;
	long long A[N], B[N], C[N];
	for (long long i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (long long i = 0; i < N; i++) {
		cin >> B[i];
	}
	for (long long i = 0; i< N; i++) {
		C[i] = A[i] - B[i];
	}
	long long demand = 0, supply = 0;
	long long cnt = 0;
	for (long long i = 0; i< N; i++) {
		if (C[i] < 0) {
			cnt++;
			demand += -C[i];
		}
	}
	sort(C, C + N);
	if (C[0] >= 0) {
		cout << "0" << endl;
		return 0;
	}
	long long i = N - 1;
	bool flg = false;
	while (true) {
		if (C[i] > 0) {
			supply += C[i];
			cnt++;
			if (supply >= demand) flg = true;
		}
		else {
			break;
		}
      if(flg) break;
		i--;
	}
	if (flg) cout << cnt << endl;
	else cout << "-1" << endl;
	return 0;
}

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

int main(void) {
  int N, cnt=0;
  cin >> N;
  int p[N], t[N];
  
  for(int i=0; i<N; i++){
    cin >> p[i];
    t[i] = i+1;
  }
  
  for(int i=0; i<N; i++){
    if(p[i] != t[i])
      cnt++;
  }
  
  if(cnt == 2 || cnt == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC169B()
{
	ll x = 1;
	int N;
	cin >> N;
	ll y = 1000000000000000000;
	bool of = false;
	for (int i = 0; i < N; ++i)
	{
		ll A;
		cin >> A;
		if (A == 0)
		{
			cout << 0 << endl;
			return;
		}
		if(x > y / A)
		{
			of = true;
		}
		x *= A;

	}
	if (of)
	{
		cout << "-1" << endl;
		return;
	}
	cout << x << endl;
}

int main()
{
	ABC169B();
	return 0;
}


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main() {
  int a,b;
  cin>>a>>b;
  if(b%2==0){
      if(a>=13)
          cout<<b;
      else if (a<=12 &&a>=6)
          cout<<(b/2);
      else if (a<=5)
          cout<<'0';
  }
  else
      return 0;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

bool has_divisor(int N, int i) {
    if(i==N)return false;
    if(N%i==0)return true;
    return has_divisor(N,i+1);
}

bool is_prime(int N) {
    if(N==1)return false;
    else if(N==2)return true;
    else return !has_divisor(N,2);//約数見つからなかったらfalseなのでその逆
}

ll gcd(ll p,ll q){
    ll tmp;
    if(p<q){tmp=p;p=q;q=tmp;}
    if(p%q==0)return q; 
    return gcd(q,p%q);
}

int main(){
    ll A,B;
    cin>>A>>B;
    ll G=gcd(A,B);
    ll L=(A*B)/G;
    cout<<L<<endl;
}

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define int ll

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

  int N,T;
  cin>>N>>T;
  vector<pii>A(N);
  T--;
  for(int i=0;i<N;i++)cin>>A[i].second>>A[i].first;
  vector<vector<vector<ll>>>dp(N+1,vector<vector<ll>>(T+1,vector<ll>(2,0)));
  for(int i=1;i<=N;i++){
    for(int j=0;j<=T;j++){
      for(int k=0;k<2;k++){
        if(k==1)dp[i][j][k]=max(dp[i-1][j][0]+A[i-1].first,dp[i][j][k]);
        if(j+A[i-1].second<=T)dp[i][j][k]=max(dp[i-1][j+A[i-1].second][k]+A[i-1].first,dp[i][j][k]);
        dp[i][j][k]=max(dp[i-1][j][k],dp[i][j][k]);
      }
    }
  }
  ll ans=-INF;
  for(int j=0;j<=T;j++){
    for(int k=0;k<2;k++){
      ans=max(dp[N][j][k],ans);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 492928
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

bool is_prime(int N){
    if(N == 1) return false;
    for(int i = 2; i * i <= N; i++){
        if(N % i == 0) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int Q;
    cin >> Q;
    vector<int> A(100010);
    rep(i, 1, 100010){
        A[i] = is_prime(i) && is_prime((i + 1) / 2);
    }
    
    vector<int> S(100010);
    rep(i, 1, 100010){
        S[i] = S[i - 1] + A[i];
    }
    
    rep(i, Q){
        int l, r;
        cin >> l >> r;
        output(S[r] - S[l - 1]);
    }
    return 0;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
main(){
  while(1){
    int a[6];
    scanf("%d",&a[0]);
    if(!a[0]) break;
    for(int i=1;i<5;i++) scanf("%d",&a[i]);
    for(int i=0;i<5;i++){
      int d,w,l;
      d=w=l=0;
      for(int j=0;j<5;j++){
	if(i==j) continue;
	if(a[i]==a[j]%3+1){
	  ++w;
	}else if(a[i]==a[j]){
	  ++d;
	}else{
	  ++l;
	}
      }
      if((w && l) || (!l && !w)) puts("3");
      else if(!w) puts("1");
      else if(!l) puts("2");
    }
  }
}

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

bool isA( int a, int b, int c )
{
    if ( a == 100 || b == 100 || c == 100 ) return true;
    if ( ( a + b ) / 2 >= 90 || ( a + b + c ) / 3 >= 90 ) return true;
    if ( ( a + b + c ) / 3 >= 80 ) return true;
    return false;
}

bool isB( int a, int b, int c )
{
    if ( ( a + b + c ) / 3 >= 70 ) return true;
    if ( ( a + b + c ) / 3 >= 50 && ( a >= 80 || b >= 80 ) ) return true;
    return false;
}

void printClass( int a, int b, int c )
{
    if ( isA( a, b, c ) ) cout << "A" << endl;
    else if ( isB( a, b, c ) ) cout << "B" << endl;
    else cout << "C" << endl;
}

int main( void )
{
    int n;

    while ( cin >> n && n )
    {
        int a, b, c;
        for ( int i = 0; i < n; i++ )
        {
            cin >> a >> b >> c;
            printClass( a, b, c );
        }
    }

    return 0;
}

Measured memory_bytes: 0
N, K, C = map(int, input().split())
S = input()

L = []
R = []
i = 0
while len(L) < K:
    if S[i] == 'o':
        L.append(i)
        i += C + 1
    else:
        i += 1

i = N - 1
while len(R) < K:
    if S[i] == 'o':
        R.append(i)
        i -= C + 1
    else:
        i -= 1

R = R[::-1]
for i in range(len(L)):
    if R[i] == L[i]:
        print(L[i] + 1)

Measured memory_bytes: 20904
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  while(1) {
    c-=b;
    if(c<=0) {
      pr("Yes");
      return;
    }
    a-=d;
    if(a<=0) {
      pr("No");
      return;
    }
  }
}

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


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

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
vector<int>E[100000];
int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;
bool b[200000], ok[100000];
queue<int>que;

void bfs(int u, int t) {
	que.push(u);
	while (!que.empty()) {
		int p = que.front(); que.pop(); for (int v : E[p]) {
			if (t) {
				if (d[v] > d[p] && !ok[v]) {
					ok[v] = 1; cnt++; que.push(v);
				}
			}
			else if (!~d[v]) {
				d[v] = d[p] + 1; que.push(v);
			}
		}
	}
}
int main() {
	int n, m, q; reader(&n); reader(&m); reader(&q);
	rep(i, m) {
		reader(&u[i]); reader(&v[i]);
		u[i]--; v[i]--;
		E[u[i]].emplace_back(v[i]); E[v[i]].emplace_back(u[i]);
	}
	queue<int>que;
	memset(d, -1, sizeof(d));
	d[0] = 0; bfs(0, 0);
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		reader(&r[i]); r[i]--;
		b[r[i]] = true;
	}
	ok[0] = true;
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] - d[u[i]] == 1) {
				E[u[i]].emplace_back(v[i]);
			}
		}
	}
	bfs(0, 1);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] - d[u[r[i]]] == 1 && !ok[v[r[i]]]) {
			E[u[r[i]]].emplace_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = true;
				bfs(v[r[i]], 1);
			}
		}
	}
	rep(i, q)printf("%d\n", ans[i]);
}

Measured memory_bytes: 13708
/**
 *   @FileName	f.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.01 01:02:16
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

constexpr int MOD = 998244353;
struct mint {
private:
    long long x;
public:
    mint(long long x = 0) :x((MOD+x)%MOD) {}
    mint(std::string &s) {
        long long z = 0;
        for (int i = 0; i < s.size(); i++) {
            z *= 10;
            z += s[i] - '0';
            z %= MOD;
        }
        this->x = z;
    }
    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) {
        long long n = MOD - 2;
        mint u = 1, b = a;
        while (n > 0) {
            if (n & 1) {
                u *= b;
            }
            b *= b;
            n >>= 1;
        }
        return *this *= u;
    }
    mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint &a) const {
        mint res(*this);
        return res /= a;
    }
    friend std::ostream& operator<<(std::ostream &os, const mint &n) {
        return os << n.x;
    }
    bool operator==(const mint &a) const {
        return this->x == a.x;
    }
};
//pow
template<typename T, typename U>
T pow(T k, U n, T unity = 1) {
    while (n > 0) {
        if (n & 1) {
            unity *= k;
        }
        k *= k;
        n >>= 1;
    }
    return unity;
}
int main() {
    int n,s;cin >> n >> s;
    vector<vector<mint>> dp(n + 1,vector<mint>(s + 1,0));
    dp[0][0] = pow(mint(2),n);
    mint p = mint(1) / 2;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        for (int j = 0; j < s + 1; j++) {
            dp[i + 1][j] += dp[i][j];
            if (j - a >= 0) dp[i + 1][j] += dp[i][j - a] * p;
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 73728
MOD = 10**9+7

def mod_pow(x, n):
  if x==0: return 1
  res = 1
  while n > 0:
    if n&1:
      res = (res*x)%MOD
    x = (x*x)%MOD
    n >>= 1
  return res

fact, invfact = [0]*(10**5+2), [0]*(10**5+2)
fact[0], invfact[0] = 1, 1
for i in range(1, 10**5+2):
  fact[i] = (fact[i-1]*i)%MOD
  invfact[i] = mod_pow(fact[i], MOD-2)%MOD

def comb(n, r):
  if n<r or n==0 or r==0: return 0
  return (((fact[n]*invfact[r])%MOD)*invfact[n-r])%MOD

from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for i, ele in enumerate(a):
  if d[ele] == 0:
    d[ele]= i+1
  else:
    l = d[ele]
    r = i+1

print(n)
for k in range(2, n+2):
  print((comb(n+1, k)-comb(l-1+n-r+1, k-1))%MOD)

Measured memory_bytes: 28880
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <set>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int typea = a * x + b * y, typeb, typec;
    if(x>=y){
        typeb = c * 2 * y + a * (x - y);
        typec = c * 2 * x;
    }
    if(x<y){
        typeb = c * 2 * x + b * (y - x);
        typec = c * 2 * y;
    }
    cout << min(typea, min(typeb, typec)) << endl;
    return 0;
}

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

int main(void){
  int a,b,t; cin >> a >> b >> t;
  int ans = (t+0.5)/a;
  cout << ans* b << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
l = [0] * (n + 110)
m = [100, 101, 102, 103, 104, 105]

for x in range(100, 106):
    l[x] = 1

for x in range(100, n + 1):
    if l[x] == 1:
        for y in m:
            l[x + y] = 1

print(1 if l[n] == 1 else 0)

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main(){
	int sx,sy,tx,ty,k=1,x,y;
	cin>>sx>>sy>>tx>>ty;
	for(int i=1;i<=ty-sy;i++) cout<<"U"; 
	for(int i=1;i<=tx-sx;i++) cout<<"R"; 
	for(int i=1;i<=ty-sy;i++) cout<<"D"; 
	for(int i=1;i<=tx-sx;i++) cout<<"L"; 
	cout<<"L";
	for(int i=1;i<=ty-sy+1;i++) cout<<"U"; 
	for(int i=1;i<=tx-sx+1;i++) cout<<"R"; 
	cout<<"DR";
	for(int i=1;i<=ty-sy+1;i++) cout<<"D"; 
	for(int i=1;i<=tx-sx+1;i++) cout<<"L";
	cout<<"U"; 
	return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,a=0,b=0,t1=0,x,y,t; cin>>n; 
    bool ok=true;
    while (n--){
        cin >> t >> x >> y ; 
        int d=abs(a-x)+abs(b-y); 
        int td=t-t1; 
        t1 = t,a = x,b = y; 
        if ((td<d) or (d%2 != td%2))  ok=false; 
    }
    if (ok==true) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}
  

Measured memory_bytes: 3616
#include <iostream>
#include <math.h>
using namespace std;


int main(){
	int N,M;
	cin>>N>>M;
	int sum = 0;
	for(int i=0; i<M; ++i) {int x; cin>>x; sum+=x;}
	if(sum<=N) cout<<N-sum<<'\n';
	else cout<<-1<<'\n';
}

Measured memory_bytes: 3632
#include <bits/stdc++.h> 
using namespace std;
 
int main(){
  
  int n,k;
  cin>>n>>k;
  int sum=0;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  for(int i=0;i<k;i++){
    sum+=vec.at(i);
  }
  cout<<sum<<endl;

  
}

Measured memory_bytes: 3628
#include <iostream>  
#include <string.h> 
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    int c = a + b;
    if (c < 24)
        cout << c ;
    else if (c==24)
        cout << 0;
    else {
        c -= 24;
        cout<<c;
    }

    return 0;
}

Measured memory_bytes: 3620
#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 n, a;
  cin >> n >> a;
  int s = n%500;
  if (s <= a) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
A=[0]*N
B=[0]*N
pen=0
for i in range(M):
  p,S=input().split()
  if S=="AC":
    A[int(p)-1]=1
  elif S == "WA" and A[int(p)-1] == 0:
    B[int(p)-1] += 1
penalty=[A[i]*B[i] for i in range(N)]
print(sum(A),sum(penalty))

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

using namespace std;

typedef long long ll;

const int INF = (int) 1e9 + 1e6 + 123;
const ll LINF = (ll) 1e18 + 1e9 + 123;

#define rep(i, s, t) for (auto i = s; i < (t); ++i)
#define per(i, s, t) for (auto i = s; i >= (t); --i)
#define sz(x) ((int) (x).size())
#define mp make_pair
#define pb push_back

template<typename A, typename B> bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return 1;
    }
    return 0;
}

template<typename A, typename B> bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return 1;
    }
    return 0;
}

void run();

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    run();
    return 0;
}

const int N = 10000 + 123;

int n;
ll a[N], b[N];

void run() {
    cin >> n;
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, n) a[i] -= b[i];
    ll can_decr = 0, need_decr = 0;
    rep(i, 0, n) {
        if (a[i] > 0) need_decr += a[i];
        else if (a[i] < 0) can_decr += (-a[i]) / 2;
    }
    cout << (need_decr <= can_decr ? "Yes\n" : "No\n");
}


Measured memory_bytes: 384
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 red = new int[N][];
            var blue = new int[N][];

            for (var i = 0; i < N; i++)
                red[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (var i = 0; i < N; i++)
                blue[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();

            red = red.OrderByDescending(z => z[0]).ThenByDescending(x => x[1]).ToArray();
            blue = blue.OrderBy(z => z[0]).ThenBy(x => x[1]).ToArray();

            var useRed = new bool[N];
            var useBlue = new bool[N];
            var total = 0;
            for (var i = 0; i < N; i++)
            {
                var min = int.MaxValue;
                var minInd = int.MaxValue;
                if (useRed[i]) continue;
                for (var j = 0; j < N; j++)
                {
                    if (useBlue[j]) continue;
                    if (red[i][0] < blue[j][0] && red[i][1] < blue[j][1])
                    {
                        if (blue[j][1] - red[i][1] < min)
                        {
                            min = blue[j][1] - red[i][1];
                            minInd = j;
                        }
                    }
                }
                if (min != int.MaxValue)
                {
                    useRed[i] = true;
                    useBlue[minInd] = true;
                    total++;
                }
            }
            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 13524