akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
int main(){
    int i = 1,n, num =0,  margin;
    cin >> n;

    while( i <= n ){
        if(i < 10){
            num++;
            i++;
        }
        else if(i < 100){
            i = 100;
        }
        else if(i < 1000){
            num++;
            i++;
        }
        else if(i < 10000){
            i = 10000;
        }
        else if(i < 100000){
            num++;
            i++;
        }
        else {
            break;
        }
    }
    cout << num << endl;

    return 0;
}

Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    K = int(input())

    for i in range(K-1):
        if S[i] != "1":
            print(S[i])
            exit()
    print(S[K-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		final int h = scanner.nextInt();
		final int w = scanner.nextInt();

		boolean[][] cell = new boolean[h][w];
		List<int[]>[][] adj = new List[h][w];

		String s;
		for (int i = 0; i < h; i++) {
			s = scanner.next();
			for (int j = 0; j < w; j++) {
				if (s.charAt(j) == '.') {
					cell[i][j] = true;
					adj[i][j] = new ArrayList<int[]>();
				}
			}
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (cell[i][j]) {
					if (i + 1 < h && cell[i + 1][j]) {
						adj[i][j].add(new int[] { i + 1, j });
						adj[i + 1][j].add(new int[] { i, j });
					}
					if (j + 1 < w && cell[i][j + 1]) {
						adj[i][j].add(new int[] { i, j + 1 });
						adj[i][j + 1].add(new int[] { i, j });
					}
				}
			}

		}

		int result = 0;

		distances = new int[h][w];
		int d;
		int[] v;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (!cell[i][j])
					continue;
				reset();
				distances[i][j] = 0;
				queue.add(new int[] { i, j });
				while (!queue.isEmpty()) {
					v = queue.poll();
					d = distances[v[0]][v[1]];
					for (int[] nv : adj[v[0]][v[1]]) {
						if (distances[nv[0]][nv[1]] >= 0)
							continue;
						queue.add(nv);

						distances[nv[0]][nv[1]] = d + 1;
						if (result < d + 1)
							result = d + 1;
					}
					;
				}
			}
		}

		System.out.println(result);

	}

	static Queue<int[]> queue = new ArrayDeque<int[]>();
	static int[][] distances;

	static void reset() {
		queue.clear();
		for (int i = 0; i < distances.length; i++) {
			for (int j = 0; j < distances[i].length; j++) {
				distances[i][j] = -1;
			}
		}
	}

}


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

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

const long long MOD = 1000000007;

int main(){
  ll n,k;
  cin >> n >> k;
  ll ans = 0;
  for(ll i=k;i<n+2;i++){
    ll m = i*(i-1)/2;
    ll M = i*(n-i+1+n)/2;
    ans += (M - m + 1) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-06-13 16:41:08
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , A , m , B , T;

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

    cin >> n >> A >> m >> B >> T;
    ll D = A - B;
    if(abs(m - n) <= D * T)    cout << "YES" << endl;
    else    cout << "NO" << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 3628
#include <stdio.h>

int main(){
	int n, x;
	int c;
	int i,t,s;
	while(1){
		scanf("%d %d", &n, &x);
		if(n == 0 && x == 0)break;
		c = 0;
		for(i = 1;i <= n; i++){
			for(t = i+1;t <=n; t++){
				for(s = t + 1; s <= n; s++){
					if(i+t+s==x)c++;
				}
			}
		}
		printf("%d\n", c);
	}
	return 0;
}

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

int main() {
    long long n,a,b,c,d,e;
    cin >>n>>a>>b>>c>>d>>e;
    cout << max({(n-1)/a,(n-1)/b,(n-1)/c,(n-1)/d,(n-1)/e})+5<<endl;
}

Measured memory_bytes: 256
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll k,cnt=0;
  cin >> k;
  queue<ll> q;
  for(int i=1; i<=9; i++) {
    q.push(i);
  }
  for(int i=0; i<k-1; i++) {
    ll x=q.front();
    q.pop();
    if(x%10>0) {
      q.push(x*10+x%10-1);
    }
    q.push(x*10+x%10);
    if(x%10<9) {
      q.push(x*10+x%10+1);
    }
  }
  cout << q.front() << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
int main(){
  double a,b,x;
  double ans;
  scanf("%lf%lf%lf",&a,&b,&x);
  if(x>a*a*b/2){
    ans=180/M_PI*atan(2*b/a-2*x/a/a/a);
    printf("%lf",ans);
  }
  else {
    ans=90-180/M_PI*atan(2*x/a/b/b);
    printf("%lf",ans);
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;
	
  	if(n % 2 == 1)
		n *= 2;

	cout << n << endl;
    return 0;
}


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

using namespace std;

const int maxn=1e6+5;

typedef long long ll;

const ll mod=1e9+7;

ll a[maxn];

int num[maxn];

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

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",a+i);
	}
	for(int i=0;i<n;i++){
		int x=a[i];
		for(int j=2;j*j<=x;j++){
			if(x%j==0){
				int cnt=0;
				while(x%j==0){
					x/=j;
					cnt++;
				}
				num[j]=max(cnt,num[j]);
			}
		}
		if(x>1){
			num[x]=max(num[x],1);
		}
	}
	ll tmp=1;
	for(int i=0;i<maxn;i++){
		for(int j=0;j<num[i];j++){
			tmp=(tmp*i)%mod;
		}
	}
//	printf("%lld\n",tmp);
	ll ans=0;
	for(int i=0;i<n;i++){
		ans=(ans+tmp*qPow(a[i],mod-2))%mod;
	}
	printf("%lld",ans%mod);
	return 0;
} 

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
      int n,q,a,b;
      cin>>n>>q;
    string S;
    cin>>S;
    vector<int> A(S.size(),0);
    for(int i=1;i<S.size();i++)
    {
        if(S[i]=='C'&&S[i-1]=='A')
        A[i] = A[i-1]+1;
        else
        A[i] = A[i-1];
    }
    while(q--)
    {
        cin>>a>>b;
        a--;
        b--;
        cout<<A[b]-A[a]<<endl;
    }
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


const ll MOD = (1e9 + 7);

const int SZ = 2123456;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}
  mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;}
  mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;}
  mint operator+(const mint a) const {mint res(*this);return res+=a;}
  mint operator-(const mint a) const {mint res(*this);return res-=a;}
  mint operator*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // for prime MOD
  mint inv() const {return pow(MOD-2);}
  mint& operator/=(const mint a) {return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this);return res/=a;}
};


int main2() {
  int r1 = nextInt();
  int c1 = nextInt();
  int r2 = nextInt();
  int c2 = nextInt();

  mint ans = 0;

  r1--;
  c1--;

  ans += mint(choose(r2 + c2 + 2, r2 + 1) + MOD - 1);
  ans -= mint(choose(r2 + c1 + 2, r2 + 1) + MOD - 1);
  ans -= mint(choose(r1 + c2 + 2, r1 + 1) + MOD - 1);
  ans += mint(choose(r1 + c1 + 2, r1 + 1) + MOD - 1);
  cout << ans.x << endl;
  return 0;
}

int main() {
 inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 50048
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int main(){
	 int N, X, Y;
	cin >> N>>X>>Y;
	vector<int>B(N,0);
	int c = 0;
	For(i, N) {
		for (int j = i; j < N; j++) {
			c = j - i;
			if (i <= X - 1 && j >= Y - 1) {
				c = c - (Y - X - 1);
			}
			else if (i >= X - 1 && j >= Y - 1)
				c = min(c, 1+(i - (X - 1) + j - (Y - 1)));
			else if (i <= X - 1 && j <= Y - 1)
				c = min(c,1+ (X - 1) - i + (Y - 1) - j);
			else if (i >= X - 1 && j <= Y - 1)
				c = min(c,1+ i - (X - 1) + (Y - 1) - j);
			B[c]=B[c]+1;
		}
	}
	for (int i = 1; i < N; i++)
		cout << B[i]<<endl;
}

Measured memory_bytes: 256
n = gets.to_i
ans = 100
(1...n).each do |i|
  a = i
  b = n - i
  tmp = a.to_s.split("").map(&:to_i).inject(:+) + b.to_s.split("").map(&:to_i).inject(:+)
  ans = tmp if ans > tmp
end
puts ans


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	vector<ll> t(N), v(N);
	REP(i, N) cin >> t[i];
	REP(i, N) cin >> v[i];

	double T = 0;
	REP(i, N) T += t[i];
	vector<double> houra(2*T+1);

	REP(j, 2*T+1){
		ll tmp = 0;
		double mi = 1010101010;
		double place = ((1.0*j)/2);
		REP(i, N){
			double val;
			if(place<=tmp){
				val = v[i]+(tmp-place);
			}
			if(tmp<place && place<=tmp+t[i]){
				val = v[i];
			}
			if(place>tmp+t[i]){
				val = v[i]+(place-tmp-t[i]);
			}
			mi = min(mi, val);
			tmp += t[i];
		}
		double k = place;
		mi = min(mi, k);
		mi = min(mi, T-k);
		houra[j] = mi;
	}
	//vprint(houra);
	double res = 0.0;
	REP(i, 2*T){
		res += 1.0*(houra[i] + houra[i+1])/4.0;
	}
	printf("%.5f\n", res);
    return 0;
}

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

public class Main {

	public static void main(String[] args) {

		// ABC116_A();
		// ABC116_B();
		ABC116_C();
		// ABC116_D();
	}

	private static void ABC116_A() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();
			lineBC = scanner.nextInt();
			lineCA = scanner.nextInt();

			int result = lineAB * lineBC / 2;
			System.out.println(result);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC116_B() {
		Scanner scanner = null;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numS = scanner.nextInt();

			int wkResult = 0;

			List<Integer> wkList = new ArrayList<Integer>();
			int cnt = 0;
			while (true) {
				if (cnt != 0) {
					wkResult = isResultNum(wkList.get(cnt - 1));
					if (wkList.contains(wkResult)) {
						cnt++;
						break;
					}
					wkList.add(wkResult);
				} else {
					wkResult = numS;
					wkList.add(numS);
				}
				cnt++;
			}
			System.out.println(cnt);
		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static int isResultNum(int numS) {
		if (numS % 2 == 0) {
			return numS / 2;
		} else {
			return 3 * numS + 1;
		}
	}

	private static boolean isNotExit(int[] arrayH) {
		for (int i = 0; i < arrayH.length; i++) {
			if (arrayH[i] != 0) {
				return true;
			}
		}
		return false;
	}

	private static void ABC116_C() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			int[] arrayH = new int[numN];
			for (int i = 0; i < arrayH.length; i++) {
				arrayH[i] = scanner.nextInt();
			}

			int cnt = 0;
			while (isNotExit(arrayH)) {
				cnt++;
				boolean notZAeroCnt = false;
				for (int i = 0; i < arrayH.length; i++) {
					if (arrayH[i] != 0) {
						arrayH[i]--;
						notZAeroCnt = true;
					} else {
						if (notZAeroCnt) {
							break;
						}
					}

				}
			}
			System.out.println(cnt);
		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC116_D() {
		Scanner scanner = null;
		String numT = "";
		String numX = "";

		try {
			scanner = new Scanner(System.in);
			numT = scanner.next();
			numX = scanner.next();

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

// I'm trying to ~~~
int main(){
    int A,B; cin >> A >> B;
    if(A%B==0) cout << 0 << endl;
    else cout << 1 << endl;

}


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

bool check(vector<int> &arr, int mid, int k){
    long long temp = 0;
    vector<int> tarr = arr;
    int i = 0;
    for(i = 0; i < tarr.size(); i++){
        if(temp > k) break;
        int x = tarr[i]/mid;
        if(tarr[i]%mid == 0) x--;
        if(temp + x > k) break;
        temp += x;
        tarr[i] %= mid;
    }
   
    for(;i < arr.size(); i++){
        if(tarr[i] > mid) return false;
    }
    //  cout<<mid<<" "<<temp<<endl;
    return true;
}

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> arr(n);
    int low = 1, high = 0;
    for(auto &x : arr){
        cin>>x;
        high = max(high,x);
    }
    int ans;
    while(low < high){
        int mid = (low + high)/2;
        if(check(arr,mid,k)){
            // ans = mid;
            high = mid;
        } else {
            low = mid + 1;
        }
    }
    cout<<high;
}

Measured memory_bytes: 4720
sentence = input()

def check_kaibun(strings):
    result = 0
    compare_strings = strings[::-1]
    
    if strings == compare_strings:
        return True
    else:
        return False


first_half = int((len(sentence) - 1) / 2)
second_half = int((len(sentence) + 1) / 2)
last_char = len(sentence)


if check_kaibun(sentence) == True and check_kaibun(sentence[0:first_half]) == True and check_kaibun(sentence[second_half:last_char]) == True:
    print("Yes")
else:
    print("No")

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

int n,t,a,h[1010];


int main()
{
    cin>>n>>t>>a;

    for (int i = 0; i < n; i++)
    {
        cin>>h[i];
    }

    
    int ans = 0;
    double min_diff = 1<<30;

    for (int i = 0; i < n; i++)
    {
        double temp = t - h[i] * 0.006;
        double difftemp = abs(a-temp);

        if(min_diff > difftemp){
            min_diff = difftemp;
            ans = i+1;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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


long tmp[10];

int main(){
	long T,N,A,B,C,D;
	char s[10];
	scanf("%s",s);
	
	if(s[0]<'a'){
		printf("%c\n",'A');
	}
	else {
		printf("%c\n",'a');
	}


	return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const int N = 200005;
ll inf = 1e16;
ll mod = 1e9 + 7;

char en = '\n';
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;
  ll res = 0;
  for (ll i = 1, la; i <= n; i = la + 1) {
    la = n / (n / i);

    ll x = la;
    if (n % x != 0)
      continue;

    ll m = n / x - 1;
    if (x < m) {
      res += m;
    }

    // n / x yields the same value for i <= x <= la.
  }

  cout << res << en;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n[] = new int[3];
		for(int i = 0;i<3;i++){
			n[i] = saori.saori_hayami();
		}
		Arrays.sort(n);
		int a = n[2] * 10 + n[1] + n[0];
		System.out.println(a);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22996
A,B,C,D = map(int,list(input()))
result = 0


def getOp(i,a,b,c,d):
    if i == 0:
        return ["+","+","+",a+b+c+d]
    elif i == 1:
        return ["+","+","-",a+b+c-d]
    elif i == 2:
        return ["+","-","+",a+b-c+d]
    elif i == 3:
        return ["+","-","-",a+b-c-d]
    elif i == 4:
        return ["-","+","+",a-b+c+d]
    elif i == 5:
        return ["-","+","-",a-b+c-d]
    elif i == 6:
        return ["-","-","+",a-b-c+d]
    elif i == 7:
        return ["-","-","-",a-b-c-d]
    else:
        return


for n in range(7):
    ls = getOp(n,A,B,C,D)
    if ls[3] == 7:
        result = n;

l = getOp(result,A,B,C,D)
print(str(A)+l[0]+str(B)+l[1]+str(C)+l[2]+str(D)+"=7")



Measured memory_bytes: 3064
n, m, c = map(int, input().split())
b_list = list(map(int,input().split()))
a_list = []
d_list = []
for i in range(n):
    d_list = list(map(int,input().split()))
    a_list.append(d_list)

ans_count = 0
for i in range(n):
    const = 0
    for j in range(m):
        const = const + a_list[i][j] * b_list[j]
    const = const + c
    if const > 0:
        ans_count = ans_count + 1

print(ans_count)


Measured memory_bytes: 3064
import sys
from collections import defaultdict
dic1 = defaultdict(int)
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n = int(readline())
"""素因数分解"""
def factrize(n):
    b = 2
    fct = []
    while b*b <= n:
        while n % b == 0:
            n //= b
            #もし素因数を重複させたくないならここを加えてfct.append(b)を消す
            """
            if not b in fct:
                fct.append(b)
            """
            fct.append(b)
        b = b+1
    if n > 1:
        fct.append(n)
    return fct #リストが帰る

lst1 = factrize(n)

for i in lst1:
    dic1[i] += 1
ans = 0
for i in dic1.values():
    ct = 1
    while i:
        i -= ct
        if i < 0:
            break
        ans += 1
        ct += 1

print(ans)

Measured memory_bytes: 65948
#include<stdio.h>
int main()
{
	unsigned long long int n, a, b;
	scanf("%lld %lld %lld", &n, &a, &b);
	if (a > b)
		printf("0\n");
	else if (n == 1 && a < b)
		printf("0\n");
	else if (n == 1 && a == b)
		printf("1\n");
	else
		printf("%lld\n", (n - 2) * (b - a) + 1);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	// 点A(a,b)と点B(c,d)を結ぶ直線と点C(e,f)と点D(g,h)を結ぶ線分が交差するか判定
	public static boolean isIntersect (double a, double b, double c, double d,
										double e, double f, double g, double h) {
		double ta = (f - b) * (a - c) + (a - e) * (b - d);
		double tb = (h - b) * (a - c) + (a - g) * (b - d);
		return ta * tb < 0;
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (sc.hasNextLine()) {
			double[] nums = new double[8];
			String[] str = sc.nextLine().split(",");
			for (int i = 0; i < nums.length; i++)
				nums[i] = Double.parseDouble(str[i]);
			boolean b = isIntersect(nums[0],nums[1],nums[4],nums[5],nums[2],nums[3],nums[6],nums[7]) &&
						isIntersect(nums[2],nums[3],nums[6],nums[7],nums[0],nums[1],nums[4],nums[5]);
			System.out.println(b ? "YES" : "NO");
		}

	}

}

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

int main(){
  int h,w;
  cin>>h>>w;
  char a[h+2][w+2];
  rep(i,0,w+2){
    a[0][i]='#';
    a[h+1][i]='#';
  }
  rep(i,0,h+2){
    a[i][0]='#';
    a[i][w+1]='#';
  }
  rep(i,0,h){
    rep(j,0,w){
      cin>>a[i+1][j+1];
    }
  }
  rep(i,0,h+2){
    rep(j,0,w+2){
      cout<<a[i][j];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main() 
{
  ll n; cin >> n;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  string ans = "Yes";
  h[0] -= 1;
  rep(i, n-1){
    if (h[i] < h[i+1]) h[i+1] -= 1;
    if (h[i] > h[i+1]){
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var s = cin.nextInt();
            var w = cin.nextInt();

            
            Console.WriteLine(s <= w?"unsafe":"safe");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 27480
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
ll dp[2010][2010];

//union-find木について
ll par[101010];
ll rank2[101010];
ll usize[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
		usize[i] = 1;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (usize[x] < usize[y]) {
		par[x] = y;
		usize[y] += usize[x];
	}
	else {
		par[y] = x;
		usize[x] += usize[y];
	}
}


//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, m;
	cin >> n >> m;
	priority_queue<ll>q;
	rep(i, n) {
		ll a;
		cin >> a;
		q.push(a);
	}
	rep(i, m) {
		ll x = q.top();
		q.pop();
		q.push(x / 2);
	}
	ll ans = 0;
	rep(i, n) {
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int X,Y;
  	int ans = 0;
  	cin >> X >> Y;
  	if (X==1){
    	ans = ans + 300000;
    }
  	if (X==2){
    	ans = ans + 200000;
    }
  	if (X==3){
    	ans = ans + 100000;
    }
  	if (Y==1){
    	ans = ans + 300000;
    }
  	if (Y==2){
    	ans = ans + 200000;
    }
  	if (Y==3){
    	ans = ans + 100000;
    }
  	if (X==1 && Y==1){
    	ans = 1000000;
    }
  
  	cout << ans << endl;
  	
  	
}

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

using namespace std;

int n;
int a[100000][3];
int dp[100001][3];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	dp[0][0] = dp[0][1] = dp[0][2] = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 3; k++)
			{
				if (k != j)
					dp[i][j] = max(dp[i][j], a[i - 1][j] + dp[i - 1][k]);
			}
		}
	}
	int ans = max(max(dp[n][0], dp[n][1]), dp[n][2]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

int main(){
	int a[5] ; 
	int diff = 0 ;
	int ans = 0 ;  
	for(int i=0;i<5;i++){
		cin >> a[i] ; 
		if ( a[i] % 10 == 0 ) {
			ans += a[i] ; 
			continue ; 
		}
		diff = max(diff,10-a[i]%10);
		ans += (10-a[i]%10+a[i]);
	}
	cout << ans - diff << endl;
    return 0 ;
}


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

int main() {
  double n, m, x; cin >> n >> m >> x;
  double val = n*n*m;
  double pi = acos(-1);
  if(x >= val-x) {
    x = (val-x);
    double h = x / (n*n) * 2.0;
    printf("%.9f\n", atan(h/n) * 180 / pi);
  } else {
    double h = x / (m*n) * 2.0;
    printf("%.9f\n", 45 - (atan(h/m) * 180 / pi) + 45.0);
  }
}

Measured memory_bytes: 512
def dfs(i, cost, skills):
    if i == N:
        if min(skills) < X:
            return INF
        else:
            return cost
    new_skills = [a + s for a, s in zip(contents[i], skills)]
    return min(dfs(i + 1, cost, skills), dfs(i + 1, cost + prices[i], new_skills))


INF = float('inf')
N, M, X = map(int, input().split())
prices = []
contents = []
for _ in range(N):
    C, *A = map(int, input().split())
    prices.append(C)
    contents.append(A)
ans = dfs(0, 0, [0] * M)
if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;

struct Comb {
    const ll mod;
    vector<ll> fact, ifact;
    ll mod_pow(ll x, ll n, const ll mod){
    ll ans = 1;
    while(n){
            if(n & 1) ans = ans*x%mod;
            x = x*x%mod;
            n >>= 1;
        }
        return ans;
    }
    Comb(int n, ll mod) : fact(n+1), ifact(n+1), mod(mod) {
        fact[0] = 1;
        for(int i=1;i<n+1;++i) fact[i] = fact[i-1] * i % mod;
        ifact[n] = mod_pow(fact[n], mod-2, mod);
        for(int i=n;i>=1;--i) ifact[i-1] = ifact[i] * i % mod;
    }
    ll operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]%mod*ifact[n-k]%mod;
    }
};

int main(){
  ll N,K;cin>>N>>K;
  vll A(N);rep(i,N)cin>>A[i];
  ll sum_max=0,sum_min=0;

  Comb comb = Comb(N, mod);

  sort(all(A));
  rep(i,N){
    sum_max += A[i]*comb(i,K-1)%mod;
    sum_max %= mod;
  }
  sort(all(A),greater<ll>());
  rep(i,N){
    sum_min += A[i]*comb(i,K-1)%mod;
    sum_min %= mod;
  }
  cout << (sum_max - sum_min + mod)%mod << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cmath>
#include <chrono>

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)



using namespace std;
using namespace std::chrono;

char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const int MOD = 1000000007;
char alphs[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

int all[101], lessd[101];

void solve() {

    int n, m;
    cin>>n>>m;
    cout<<(n*(n-1)/2)+(m*(m-1))/2<<endl;
}


int main() {

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

    
        solve();


    return 0;
}

Measured memory_bytes: 3604
// AOJ CGL_1_C Counter-Clockwise
// 2018.5.2 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct { double x, y; } PP;
typedef struct { PP s, e; } SEG, LINE;

#define INF			1e8
#define EPS			1e-8
#define EQ(a,b)		(fabs((a)-(b))<EPS)
#define PPeQ(a,b)	(EQ(a.x,b.x)&&EQ(a.y,b.y))

int dcmp(double x) { if (fabs(x) < EPS) return 0; return x <= 0 ? -1 : 1; }
PP vset(double x, double y) { PP r; r.x = x, r.y = y; return r; }
PP vadd(PP p1, PP p2) { PP r; r.x = p1.x + p2.x, r.y = p1.y + p2.y; return r; }
PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
PP vsmul(PP p, double k) { PP r; r.x = p.x * k, r.y = p.y * k; return r; }
PP vmul(PP p1, PP p2) { PP r;
	r.x = p1.x * p2.x - p1.y * p2.y, r.y = p1.x * p2.y + p1.y * p2.x; return r; }
double vabs(PP a) { return hypot(a.x, a.y); }
double dist(PP p1, PP p2) {	return hypot(p1.x-p2.x, p1.y-p2.y); };
double cross(PP a, PP b) { return a.x * b.y - a.y * b.x; }
double dot(PP a, PP b) { return a.x * b.x + a.y * b.y; }
double norm(PP a) { return a.x * a.x + a.y * a.y; }

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define COUNTER_CLOCKWISE
int ccw(PP p0, PP p1, PP p2)
{
	PP a, b;
	double t;

	a = vsub(p1, p0), b = vsub(p2, p0), t = cross(a, b);
	if (t >  EPS) return 1;	if (t < -EPS) return -1;
	if (dot(a, b) < -EPS) return 2;	if (norm(a) < norm(b)) return -2;
	return 0;
}

char *msg[5] = { "ONLINE_FRONT", "CLOCKWISE", "ON_SEGMENT", 
                 "COUNTER_CLOCKWISE", "ONLINE_BACK" };

int main()
{
	int q, x, y, ans;
	PP p0, p1, p2;

	x = in(), y = in(), p0 = vset(x, y);
	x = in(), y = in(), p1 = vset(x, y);

	q = in(); while (q--) {
		x = in(), y = in(), p2 = vset(x, y);
		ans = ccw(p0, p1, p2);
		puts(msg[2+ans]);
	}
	return 0;
}



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

using namespace std;


int main()
{

    int N;
    vector<int> xv;
    vector<int> yv;
    vector<int> hv;
    int cx, cy, ch;
    int tmpch;
    bool check;

    cin>>N;

    xv.resize(N);
    yv.resize(N);
    hv.resize(N);

    for(int i=0; i<N; ++i)
    {
        int x, y, z;
        cin >> x >> y >> z;
        xv[i]=x;
        yv[i]=y;
        hv[i]=z;
    }



        for (int i = 0; i <= 100; ++i)
        {
            for (int j = 0; j <= 100; ++j)
            {
                check = true;

                for (int k = 0; k < N; ++k)
                {
                    if(hv[k])
                    {
                        tmpch = hv[k] + abs(xv[k] - i) + abs(yv[k] - j);
                        break;
                    }
                }

                for(int k=0; k<N; ++k)
                {
                    check&=(hv[k]==max(tmpch-abs(xv[k]-i)-abs(yv[k]-j), 0));
                }

                if(check)
                {
                    cout<<i<<" "<<j<<" "<<tmpch<<endl;
                    return 0;

                }

            }
        }


    return 0;
}

Measured memory_bytes: 256
import bisect

n = int(input())
l = list(map(int, input().split()))

l.sort()
ans = 0
for i in range(n):
    a = l[i]
    for j in range(i+1, n):
        b = l[j]
        ans += bisect.bisect_left(l, a+b)-j-1

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define rev(x) x.rbegin(), x.rend()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pi 3.141592653589793238
#define mp make_pair
#define pb push_back
#define precise cout<<fixed<<setprecision(20)
#define ff first
#define ss second
#define T int t;cin>>t;rep(mmm,0,t)
#define watch(x) cerr<<(#x)<<" is "<<(x)<<endl;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;

const int N=100001;
int mod=1000000007;
//mod=998244353;

int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
int mul(int a,int b){return ((a%mod)*(b%mod))%mod;}
int sub(int a,int b){return (((a-b)%mod)+mod)%mod;}

void solve()
{
	int n;
	cin>>n;
	int sum=0;
	int sq=0;
	rep(i,0,n)
	{
		int a;
		cin>>a;
		sum+=a;
		sum%=mod;
		sq+=mul(a,a);
	}
	cout<<mul(sub(mul(sum,sum),sq),power(2,mod-2));
}

signed main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0);cout.tie(0);
    solve();
    return 0;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(int i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(int i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(int i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n;
    cin>>n;
    ll a[n+1],b[n+1],c[n+1];
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    ll dp[n+1][3];
    fill(dp);
    dp[1][0]=a[1];
    dp[1][1]=b[1];
    dp[1][2]=c[1];
    for(ll i=2;i<=n;i++)
    {
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
    }
    ll ans=max(dp[n][0],max(dp[n][1],dp[n][2]));
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 4992
/*------------------------------------
........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   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std; 

int h[20]; 
int dp[20][160][2];

int getsum(int idx,int n,int sum,int flag){
    if (idx>n) return sum;
    if (dp[idx][sum][flag] != -1)  return dp[idx][sum][flag];
    int limit=9,res=0;
    if (!flag) limit=h[idx];
    for (int i=0;i<=limit;i++){
        if (i<limit or flag) 
            res = max(res,getsum(idx+1,n,sum+i,1));
        else 
            res = max(res,getsum(idx+1,n,sum+i,0));
    }
    dp[idx][sum][flag]=res;
    return res;
}

inline void solve(){
    string  s; 
    cin >> s ; 
    for (int i=0;i<sz(s);i++) h[i+1]=s[i]-'0';
    memset(dp,-1,sizeof(dp));
    cout << getsum(1,sz(s),0,0) << endl;
    
}

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



Measured memory_bytes: 3684
#include<iostream>

using namespace std;

const string end_of_text = "END_OF_TEXT";

string to_lower(string word) {
  string lower = "";

  for(int i = 0; i < word.size(); i++) {
    lower += tolower(word[i]);
  }

  return lower;
}


int main() {
  string target;
  int count = 0;

  cin >> target;
  target = to_lower(target);

  while(true) {
    string word;
    cin >> word;

    if(to_lower(word)== target) {
      count++;
    }

    if(word == end_of_text) {
      break;
    }
  }

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



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

#define mod 1000000007;

using namespace std;

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

    for(int i = 0 ; i + 1 < S.size(); i++)
    {
        if(S[i] == S[i+1])
        {
            cout << i + 1 << " " << i + 2;
            return 0;
        }

        if(i + 2 < S.size() && S[i] == S[i+2])
        {
            cout << i + 1 << " " << i +3;
            return 0;
        }


    }
    cout << "-1 -1";
}

Measured memory_bytes: 512
import itertools

MOD = 10**9 + 7


def main():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N)]
    dp = [[0] * (1 << N) for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        pairs = []
        for j in range(N):
            if A[i][j] == 1:
                pairs.append(1 << j)
        for combi in itertools.combinations(range(N), r=i):
            x = 0
            for c in combi:
                x += 1 << c
            for p in pairs:
                if x & p == 0:
                    dp[i+1][x | p] = (dp[i+1][x | p] + dp[i][x]) % MOD

    print(dp[N][(1 << N) - 1])


if __name__ == "__main__":
    main()


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

#define DEBUG(x) cout << #x << " = " << x << endl
typedef long long ll;
const int N = 5e3 + 5;
int a[N];
bitset<N> dp;
int n, k;
ll sum;

bool check(int m) {
    if (a[m] >= k) return true;
    dp.reset();
    dp.set(0);
    for (int i=1; i<=n; ++i) if (i != m) {
        dp |= (dp << a[i]);
    }
    for (int i=k-a[m]; i<k; ++i) {
        if (dp[i]) return true;
    }
    return false;
}

int solve() {
    if (sum < k) return n;  //所有数之和小于k 
    sort(a+1, a+n+1);
    if (check(0)) return 0;
    int low = 1, high = n, ret = 0;
    while (low <= high) {
        int mid = low + high >> 1;
        if (check(mid)) high = mid-1;
        else { ret = mid; low = mid+1; }
    }
    return ret;
}

int main() {
    cin >> n >> k;
    for (int i=1; i<=n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    cout << solve() << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        KEYENCE2019_B solver = new KEYENCE2019_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class KEYENCE2019_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String keyence = "keyence";
            String str = in.next();

            int i = 0;
            for (i = 0; i < str.length(); i++) {
                if (str.charAt(i) != keyence.charAt(i)) {
                    keyence = keyence.substring(i);
                    break;
                }
            }

            if (str.endsWith(keyence)) {
                out.print("YES");
            } else {
                out.print("NO");
            }
        }

    }
}



Measured memory_bytes: 23124