akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

void add(vector<int> &nums, int i, int x, int n) {
  i += 1;
  while (i < n) {
    nums[i] += x;
    i += (i & -i);
  }
}

int sum(vector<int> &nums, int i) {
  int s = 0;
  i += 1;
  while (i != 0) {
    s += nums[i];
    i -= (i & -i);
  }
  return s;
}

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i<N; i++) {
    cin >> A[i];
  }

  for (int k = 0; k < K; k++) {
    vector<int> nums(N+3);
    for (int i = 0; i < N; i++) {
      int I = max(0, i-A[i]);
      int J = min(N, i+A[i]+1);
      add(nums, I, 1, N+1);
      add(nums, J, -1, N+1);
    }

    int flag = 1;
    for (int i = 0; i < N; i++) {
      A[i] = sum(nums, i);
      if (A[i] < N) {
        flag = 0;
      }
    }
    if (flag == 1) break;
  }
  for (int i = 0; i < N; i++) {
    cout << A[i] << ' ';
  }

  return 0;
}

Measured memory_bytes: 4796
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	rep(i,3) cout << s[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

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

		
		String s = sc.next();
		
		
		long ans = 0;
		int aCount = 0;
		int pos = 0;
		
		while(pos<s.length()) {
			
			if (s.charAt(pos) == 'A') {
				aCount++;
				pos++;
			} else if (s.charAt(pos) == 'B' && pos+1<s.length() && s.charAt(pos+1) == 'C') {
				ans += aCount;
				pos += 2;
			} else {
				aCount = 0;
				pos++;
			}
		}
		
		
		
		System.out.println(ans);
	}
}


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

using namespace std;

const long long int MOD = 1e9 + 7;

long long int mul(long long int A, long long int B){
  A %= MOD;
  B %= MOD;
  return (A * B) % MOD;
}

long long int add(long long int A, long long int B){
  A %= MOD;
  B %= MOD;
  return (A + B) % MOD;
}
int main(){
  int N;
  cin >> N;
  vector <long long int> V(N, 0);
  for(int i = 0; i  < N; i++){
    cin >> V[i];
  }
  long long int ret = 0;
  long long int pow2 = 1;
  for(int i = 0; i < 60; i++){
    long long int zero = 0, uno = 0;
    for(int j = 0; j < N; j++){
      if(V[j] & 1){
        uno++;
      }else{
        zero++;
      }
      V[j] /= 2;
    }
    ret = add(ret, mul(zero, mul(uno, pow2) ));
    pow2 = mul(pow2, 2);
  }
  cout << ret;
  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>
 
int main(void){
  char s[100010];
  int a[26] = {0};
  int i;
  scanf("%s", s);
  for(i = 0; i < strlen(s); i++){
    a[s[i] - 'a']++;
  }
  for(i = 0; i < 26; i++){
    if(a[i] == 0){
      printf("%c\n", 'a' + i);
      return 0;
    }
  }
  printf("None\n");
  return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second

typedef long long ll;
typedef pair<ll,int> P;
typedef pair<P,P> PP;

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

//-----------------------------------------------------------------------------

string s;

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

	cin>>s;
	if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3])) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

int main() {
    int k, s;
    cin >> k >> s;

    int ans = 0;
    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k && i + j <= s; ++j) {
            int t = s -(i + j);
            if(t <= k) {
                ++ans;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<char> vec(N);
  for(int i=0;i<N;i++) {
    cin>>vec.at(i);
  }
  int count=0;
  for(int i=0;i<N;i++) {
    if(vec.at(i)=='Y') count++;
  }
  if(count==0) cout<<"Three"<<endl;
  else cout<<"Four"<<endl;
}

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

int helper(int x, int y){
    if(y == 0){
        return x;
    }
    return helper(y, x%y);
}

int gcd(int a, int b, int c){
    if(a == b && b == c){
        return a;
    }
    else if(a != b && b != c && a != c){
        
        int x = helper(c, a);
        return helper(b,x);
    }
    else{
        if (a == b)
        {
            return helper(a, c);
        }
        if (a == c)
        {
            return helper(b, a);
        }
        if (c == b)
        {
            return helper(a, c);
        }
    }
}

int main()
{
    int k;
    cin >> k;
    long long int sum = 0;
    for(int a = 1; a <= k; a++){
        for (int b = 1; b <= k; b++){
            for (int c = 1; c <= k; c++){
                sum += gcd(a,b,c);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3184
#include <stdio.h>

long long	calc(long long a, long long b)
{
  	return (a - b) * (a*a*a*a + a*a*a*b + a*a*b*b + a*b*b*b + b*b*b*b);
}

int	main(void)
{
  	long long	x;
  	long long   a;
  	long long   b;

  	scanf("%lld", &x);
  
  	for (a = -64; a <= 64; a++)
      	for (b = -64; b <= 64; b++)
		  	if (calc(a, b) == x)
            {
                printf("%lld %lld", a, b);
                return (0);
            }
              	
  	for (a = -1024; a <= 1024; a++)
      	for (b = -1024; b <= 1024; b++)
		  	if (calc(a, b) == x)
            {
                printf("%lld %lld", a, b);
                return (0);
            }
              	
  	return (0);
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
int32_t main()
{
    IOS;
    int n;
    cin >> n;
    double p[n];
    for(int i = 0;i < n; i++)
        cin >> p[i];
    double dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    for(int i = 1;i <= n; i++){
        for(int j = 0;j <= i; j++){
            if(j==0)
                dp[i][j] = (1-p[i-1])*dp[i-1][j];
            else
                dp[i][j] = p[i-1]*dp[i-1][j-1] + (1-p[i-1])*dp[i-1][j];
        }
    }
    // for(int i = 0;i <= n; i++){
    //     for(int j = 0;j <= n; j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    
    double ans = 0;
    for(int i = n/2+1;i <= n; i++){
            ans += dp[n][i];
    }
    cout << fixed << setprecision(10) << ans << "\n";
    return 0;
}

Measured memory_bytes: 144412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin, (x).end()

int main(){
	ll x; cin>>x;
	ll z = 100;
	ll i=0;
	for(i=1; i<x; i++){
		z += (z*1)/100;
		if(z>=x)break;
	}
	cout<<i<<endl;
}

Measured memory_bytes: 3636
s = input()
a = [0] * (len(s) + 1)
for i in range(len(s)):
    if s[i] == '<':
        a[i+1] = a[i] + 1
    
for i in range(len(s))[::-1]:
    if s[i] == '>':
        a[i] = max(a[i+1] + 1,a[i])
print(sum(a))      

Measured memory_bytes: 29148
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define INF (1<<29)
int dp[10000][10000];
int main()
{
	fill(dp[0], dp[1000], INF);
	string s1, s2; cin >> s1 >> s2;
	int s1sz = s1.size(), s2sz = s2.size();
	for (int i = 0; i <= s1sz; ++i) {
		for (int j = 0; j <= s2sz; ++j) {
			if (i == 0) {
				dp[0][j] = j;
				continue;
			}
			else if (j == 0) {
				dp[i][0] = i;
				continue;
			}
			else {
				dp[i][j] = min(dp[i - 1][j - 1] + (s1[i - 1] != s2[j - 1]), min(dp[i - 1][j] + 1, dp[i][j - 1] + 1));
			}
		}
	}
	cout << dp[s1sz][s2sz] << endl;
}

Measured memory_bytes: 42140
#include <stdio.h>

int main(void){

	long long int N, A, B;

	scanf("%lld", &N);
	scanf("%lld", &A);
	scanf("%lld", &B);

	long long int count = 0;

	if(B - A < 0){
		return !printf("%lld\n", count);
	}else{

		if(N == 1 && A < B){
			return !printf("%lld\n", count);
		}else if((N == 1 && A == B) || (N == 2 && A < B)){
			count = 1;
			return !printf("%lld\n", count);	
		}

		count = 0;

		count = B * (N - 2) - A * (N - 2) + 1;

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

		return 0;

	}

}

Measured memory_bytes: 128
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;



public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	   	int n = sc.nextInt();
	   	int A[] = new int[n];
	   	for(int i = 0; i < n-1; i++) {
	   		int a = sc.nextInt();
	   		A[a-1]++;
	   	}
	   	for(int i = 0; i < n; i++) {
	   		System.out.println(A[i]);
	   	}
	}
}

Measured memory_bytes: 62396
#include <iostream>
    using namespace std;
     
    int main() {
    	int a,b,c,i,n=0;
    	cin >>a>>b>>c;
    	for(i = a;i <=b;i++){
    		if(c%i == 0)n++;
    	}
    	cout << n << endl;
    	return 0;
    }

Measured memory_bytes: 1160
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hassan El Desouky
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define el '\n'
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
#define all(v)  	((v).begin()),((v).end())
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<int>		vll;
typedef vector<pii>		vpii;
const double EPS = 1e-9;
const int N = 1e3+2, M = 3e5+5, OO = 0x3f3f3f3f;
int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
//int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


class A2FightingOverCandies {
public:
	void solve(std::istream& in, std::ostream& out) {
        int a, b, c;
        in >> a >> b >> c;
        if (a + b == c) out << "Yes\n";
        else if (b + c == a) out << "Yes\n";
        else if (c + a == b) out << "Yes\n";
        else out << "No\n";
	}
};


int main() {
	A2FightingOverCandies solver;
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)
bool board[22][22];
int dx[4] = {1,-1,0,0}, dy[4] = {0,0,1,-1};
int main(){
    int h, w;
    cin >> h >> w;
    rep(i,1,h+1){
        rep(j,1,w+1){
            char c;
            cin >> c;
            if(c=='.'){
                board[i][j] = true;
            }
        }
    }
    int ans = 0;
    rep(i,1,h+1){
        rep(j,1,w+1){
            if(!board[i][j]) continue;
            queue<pair<int, int>> q;
            q.push({i,j});
            vector<vector<int>> tmp(22, vector<int>(22, -1));
            tmp[i][j] = 0;
            while(!q.empty()){             
                pair<int, int> xy = q.front(); 
                q.pop();
                int x = xy.first;
                int y = xy.second;
                rep(k,0,4){
                    int nx = x + dx[k], ny = y + dy[k];
                    if(tmp[nx][ny] == -1 && board[nx][ny]){
                        tmp[nx][ny] = tmp[x][y] + 1;
                        q.push({nx, ny});
                    }
                }
                ans = max(ans, tmp[x][y]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N,K;cin >> N >> K;
    vector<int> A(N,0);
    for (int i = 0;i < K;i++){
        int d;cin >> d;
        for (int j = 0;j < d;j++){
            int a;cin >> a;
            A[a - 1]++;
        }
    }
    int ans = 0;
    for (int i = 0;i < N;i++){
        if (A[i] == 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
using namespace std;



int main()
{
	int n, m;
	cin >> n >> m;
	vector<pair<long long , int> > p(n);
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		p[i] = make_pair(a, b);

	}
	sort(p.begin(), p.end());
	long long  int ans = 0;
	long long int k = m;
	for (int i = 0; i < n; i++)
	{
		if (p[i].second <= k)
		{
			ans += p[i].first*p[i].second;
			
		}
		else
		{
			ans += p[i].first*k;
			
			break;
		}
		k -= p[i].second;
	}
	cout << ans << endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define N 100050
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define READ(f) freopen (f, "r", stdin)
#define WRITE(f) freopen (f, "w", stdout)
#define mapiter map<int, int>::iterator
#define pii pair<int, int>
#define forn(i, n) for(ll i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n) for(int i = n - 1; i >= 0; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define btw cout << "bad\n"
#define pf push_front
#define elif else if

const int inf = 1e9;
const ll modw = 1e8;
  
using namespace std;
using namespace __gnu_pbds;



int main()
{
	barnarnar
	string t;
	cin >> t;
	int p = t.si - 1;
	if(t[p] == '0' || t[p] == '1' || t[p] == '6' || t[p] == '8')
	{
		cout << "pon";
		r0;
	}
	elif(t[p] == '3')
	{
		cout << "bon";
		r0;
	}
	else
	{
		cout << "hon";
	}
	r0;
}










Measured memory_bytes: 3652
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
ll nCr(ll n, ll r){
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
  ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
  return ret;
}

int main(void){
  int a,b;cin>>a>>b;
  cout<<(b-1)/(a-1)+((b-1)%(a-1)>0?1:0)<<endl;
  return 0;
}


Measured memory_bytes: 256
pattern = {
           "12651":3,
           "15621":4,
           "13641":5,
           "14631":2,
           "23542":1,
           "24532":6,
          }

label = input().split()
l2d = {label[i]:str(i+1) for i in range(6)}

qn = int(input())
for i in range(qn):
    top, front = input().split()
    tf = l2d[top]+l2d[front]

    for p in pattern:
        if tf in p:
            print(label[pattern[p]-1])

Measured memory_bytes: 7724
#include <iostream>
        #include <string>
        using namespace std;
         
        int main(void)
        {
            long long int oni_Coord, oni_dist_persec;
          	long long int child_Coord, child_dist_persec;
            long long int time;
            
            cin >> oni_Coord >> oni_dist_persec;
            cin >> child_Coord >> child_dist_persec;
            cin >> time;
           
            long long int oni_max, oni_min;
            long long int child_max, child_min;
          
            oni_max = oni_Coord + oni_dist_persec * time;
            oni_min = oni_Coord - oni_dist_persec * time;
          
            child_max = child_Coord + child_dist_persec * time;
            child_min = child_Coord - child_dist_persec * time;
          
            if ( (oni_max < child_max) || (child_min < oni_min) )
            {
              cout << "NO" << endl;
            }
            else
            {
              cout << "YES" << endl;
            }
          
            return 0;
        }

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

int main(){
    char s[100001];
    char c[] = "CODEFESTIVAL2016";

    scanf("%s", s);

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

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

    return 0;
}


Measured memory_bytes: 1740
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 768
n = int(input())
a = sorted(list(map(int, input().split())))
s = a[::]
ans = 0
c = 0
for i in range(n-1):
    if i == 0:
        ans += s.pop()
    else:
        if c == 0:
            ans += s[-1]
            c += 1
        elif c == 1:
            ans += s.pop()
            c = 0

print(ans)

Measured memory_bytes: 31736
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		int count = 0;
		String str;
		Scanner sc = new Scanner(System.in);
		str = sc.next(); // ??????W
		while (true) {
			String tmp = sc.next();
			if (tmp.equals("END_OF_TEXT")) {
				break;
			}
			if (str.length() == tmp.length()) {
				if (str.equalsIgnoreCase(tmp)){
					++count;
				}
			}
		}
		System.out.println(count);
		sc.close();
	}

}

Measured memory_bytes: 26072
def lcs(s1,s2):
    l1=len(s1)
    work=[0]*(l1+1)

    #enumerateを使って文字列へのアクセスを極力避ける
    for x in s2:
        work_old=work[:]
        for j,y in enumerate(s1):
            if x==y :
                work[j+1]=work_old[j]+1
            elif work[j]>work_old[j+1]:
                work[j+1]=work[j]
                
    print(work[-1])


import sys
input=sys.stdin.readline


q=int(input())
for _ in range(q):
    lcs(input()[:-1],input()[:-1])


Measured memory_bytes: 5628
#include <iostream>

using namespace std;

long long gcd(long long a, long long b) {
    while (a && b) {
        a %= b;
        swap(a, b);
    }
    return a + b;
}

int main()
{
    long long n, t, g, d;
    cin >> n >> g;
    for (int j = 1; j < n; j++) {
        cin >> t;
        d = gcd(g, t);
        g = (g / d) * t;
    }
    cout << g;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;


int main() {
	int d, n;
	cin >> d >> n;
	int a = 1;
	for (int i = 0; i < d; i++) {
		a *= 100;
	}
	if (n == 100) {
		n++;
	}
	cout << a * n;
	return 0;

}

Measured memory_bytes: 256
import sys
import numpy as np

n = int(input())
aaa = list(map(int, sys.stdin))
MOD = 998244353

s = sum(aaa)
dp1 = np.zeros(s + 1, dtype=np.int64)
dp2 = np.zeros(s + 1, dtype=np.int64)
dp1[0] = 1
dp2[0] = 1
for a in aaa:
    dp1 = (dp1 * 2 + np.roll(dp1, a)) % MOD
    dp2 = (dp2 + np.roll(dp2, a)) % MOD

h = (s + 1) // 2
ans = (pow(3, n, MOD) - dp1[h:].sum() * 3) % MOD
if s % 2 == 0:
    ans = (ans + dp2[h] * 3) % MOD
print(ans)


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

int main()
{
  string S;
  int K;
  cin >> S >> K;
  vector<string> d;

  for(int i = 0; i < S.length(); i++) {
   for (int j = 0; j < K; j++) {
     string sub = S.substr(i, j+1);
     d.push_back(sub);
   } 
  }

  sort(d.begin(), d.end());
  unique(d.begin(), d.end());
  //d.erase(d.begin(), d.end());
  cout<<d[K-1]<<endl;
  return 0;
}


Measured memory_bytes: 1660
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio;
    int a,b;
    cin>>a>>b;
    if(a>=10 || b>=10){
        cout<<-1<<'\n';
    }
    else{
        cout<<a*b<<'\n';
        
    }
    return(0);
}

Measured memory_bytes: 256
import sys
H,W,M = map(int,input().split())

s = [[int(item) -1 for item in input().split()] for _ in range(M)]

# print(s)

col = [0 for _ in range(H)]
row = [0 for _ in range(W)]

bomb_set = set()

# 各列と行で個数を配列
for i,j in s:
    col[i] += 1
    row[j] += 1
    bomb_set.add((i,j))    # 爆弾のある位置

# print(col)
# print(row)
# print(bomb_set)

max_col = max(col)
max_row = max(row)

# 最大の行と列を配列
max_col_index = []
max_row_index = []

# 最大の行を探す
for i in range(H):
    if col[i] == max_col:
        max_col_index.append(i)

# 最大の列を探す
for j in range(W):
    if row[j] == max_row:
        max_row_index.append(j)

# 最大の行と列の組み合わせが爆弾の位置と被っているか確認
for r in max_row_index:
    for c in max_col_index:
        if (c,r) not in bomb_set:
            ans = max_col + max_row
            print(ans)
            sys.exit()

ans = max_col + max_row -1
print(ans)

Measured memory_bytes: 114360
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, c;
int d[33][33];
int a[555][555];
int cost[3][33];

int main()
{
	cin >> n >> c;
	for(int i=1;i<=c;i++)
		for (int j = 1;j <= c;j++) {
			cin >> d[i][j];
		}

	for (int i = 1;i <= n;i++)
		for (int j = 1;j <= n;j++) {
			cin >> a[i][j];
		}

	for (int i = 1;i <= n;i++)
		for (int j = 1;j <= n;j++) {
			int k = (i + j) % 3;
			for (int l = 1;l <= c;l++) {
				cost[k][l] += d[ a[i][j] ][l];
			}
		}

	int ans = INF;
	for (int i = 1;i <= c;i++)
		for (int j = 1;j <= c;j++)
			for (int k = 1;k <= c;k++) {
				if (i != j && j != k && i != k) {
					int temp = cost[0][i] + cost[1][j] + cost[2][k];
					ans = min(ans, temp);
				}
			}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 110
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> new_data_set; 

pii a[MAX];
ll N;
ll dp[MAX][100100];
ll f(ll index,ll V){
	if(V<0) return 1e10;
	if(V==0) return 0;
	if(index==N) return 1e10;
	if(dp[index][V]!=-1) return dp[index][V];
	ll first = f(index+1,V);
	ll second = f(index+1,V-a[index].se)+a[index].fi;
	dp[index][V]=min(first,second);
	return min(first,second);
}

int main(){
	ios_base::sync_with_stdio(false);
	memset(dp,-1,sizeof(dp));
	ll n,W;cin>>n>>W;N=n;
	For(i,0,n) cin>>a[i].fi>>a[i].se;

	ll ans=0;
	For(v,0,100100){
		ll w = f(0,v);
		if(w<=W) ans=v; 
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 86400
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let n = scan "%d" id
let ls = scan_list ~sep:' ' Int.of_string

let () =
  ListL.fold_left ls ~init:1 ~f:(fun pred v ->
      if v = 0 || pred = 0 then 0
      else if pred = -1 then -1
      else
      if log10 (Float.of_int pred) +. log10 (Float.of_int v) < 19.0 then
        if pred * v > 1_000_000_000_000_000_000 then -1
        else pred *v
      else -1)
  |> Printf.printf "%d\n"


Measured memory_bytes: 17220
using System;

namespace Test
{
    class MainClass
    {
        public static int cnt = 0;
        public static void Main(string[] args)
        {
            var num = int.Parse(Console.ReadLine());
            var nums = new int[num];
            for (int i = 0; i < nums.Length; i++)
            {
                nums[i] = int.Parse(Console.ReadLine());
            }

            ShellSort(nums);
            Array.ForEach(nums, x => Console.WriteLine(x));
            Console.Read();
        }

        private static void ShellSort(int[] nums)
        {
            var m = 0;

            if (nums.Length == 1) m = 1;
            else m = (int)Math.Log(nums.Length, 2);
            Console.WriteLine(m);

            var G = new int[m];
            for (int i = 0; i < G.Length; i++)
            {
                G[i] = (int)Math.Pow(2,G.Length-i) - 1;
            }
            Console.WriteLine(string.Join(" ", Array.ConvertAll(G,x=>x.ToString())));

            for (int i = 0; i < G.Length; i++)
            {
                insertionSort(nums, G[i]);
            }
            Console.WriteLine(cnt);

        }

        private static void insertionSort(int[] nums, int g)
        {
            for (int i = g; i < nums.Length; i++)
            {
                var v = nums[i];
                var j = i - g;
                while ((j >= 0) && (nums[j] > v))
                {
                    nums[j + g] = nums[j];
                    j = j - g;
                    cnt++;
                }
                nums[j + g] = v;
            }
        }

    }
}

Measured memory_bytes: 13096
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

const int INF = 1e9 + 7;

int main()
{


    int N;
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; ++i)
        cin >> v[i];

    vector<int> dp(N, INF);
    dp[0] = 0;
    for (int i = 0; i < N; ++i)
    {
        for (int j : {i + 1, i + 2})
        {
            if (j < N)
                dp[j] = min(dp[j], dp[i] + abs(v[i] - v[j]));
        }
    }
    cout << dp[N-1];
    return 0;
}

Measured memory_bytes: 4036
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#define MAX(a,b) ((a>b)?(a):(b))
#define MIN(a,b) ((a<b)?(a):(b))
using namespace std;
typedef pair<string,int> ps;
int main(void){
	queue<ps> q;
	string s;
	int a;
	int t=0;
	int n,qt;
	cin>>n>>qt;
	for(int i=0;i<n;i++){
		cin>>s>>a;
		q.push(ps(s,a));
	}

	while(n){
		ps temp=q.front();
		q.pop();
		t+=MIN(qt,temp.second);
		temp.second=MAX(temp.second-qt,0);
		if(temp.second>0)q.push(temp);
		else {
			cout<<temp.first<<" "<<t<<endl;
			n--;
		}
	}
	return 0;
}

Measured memory_bytes: 6196
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
using ll = long long;
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    ll ans = b;
    ans+=min(c,a+b+1);
    cout << ans << endl;
}

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

ll mpow(ll a, ll b, ll modn){
  ll ret = 1;
  while(b){
    if(b%2){
      ret = (ret * a)%modn;
    }
    b = b / 2;
    a = (a*a)%modn;
  }
  return ret%modn;
}

int main(){
  ll n;
  cin>>n;
  ll max_dist = 0;
  map<ll, ll> cnt;
  vector<ll> inp(n);
  for(int i = 0;i < n; i++){
    cin>>inp[i];
    cnt[inp[i]]++;
    max_dist = max(max_dist, inp[i]);
  }
  if((inp[0] != 0) || (cnt[0] != 1)){
    cout<<"0"<<endl;
    return 0;
  }
  vector<ll> dp(max_dist + 1, 0);
  ll res = 1;
  ll modn = 998244353;
  for(int i = 1; i <= max_dist; i++){
    res = (res * mpow(cnt[i-1], cnt[i], modn))%modn;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 8064
h,w,d= map(int, input().split())
a = {}
for y in range(h):
    line = list(map(int, input().split()))
    for x in range(len(line)):
        a[line[x]-1] = (y,x)

# 問題の考え方
# DP的な感じで解ける
# まずGridになっているが、1次元の配列として考える 3*3(=9マスある状態) なら
#   1,2,3,4,5,6,7,8,9
# このときに数値の低い方から高い方へいくとゴールにつく(Ri-LiがDの倍数であること)が保証されるので最後の数字へ向かうときにかかるコストを考える(以下、3*3の例)
#   D=2としたときに、9はこれ以上進めないので、コスト0, 8もそれ以上進めないので コスト0, 7は9に行けるので9のコスト+7から9へ向かうコストで算出可能
#   また、5~9へのコストは1~9へのコスト引く1~5までのコストとなるので累積和的に答えを算出することが可能

num = len(a)
dp = [0]*num
for i in range(num-1, -1, -1):
    if i+d <= num-1:
        x, y = a[i]
        px, py = a[i+d]
        dp[i] = dp[i+d] + abs(x-px) + abs(y-py)

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    print(dp[l]-dp[r])

Measured memory_bytes: 26480
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  const int ans = max({a * 10 + b + c, a + b * 10 + c, c * 10 + a + b});
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
s = input()

ans = 0
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        flag = True
        for t in s[i:j]:
            if t != 'A' and t != 'C' and t != 'G' and t != 'T':
                flag = False
                break
        if flag:
            ans = max(ans, len(s[i:j]))

print(ans)


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

// グローバル変数
ll s;
vector<ll> c;

// 関数プロトタイプ
void input();
void solve();
int dfs(ll, int);

int main(void)
{
    input();
    solve();  
}

// 標準入力
void input() {
    cin >> s;
}

void solve() {
    c.push_back(s);
    cout << dfs(s, 1) << endl;
}

int dfs(ll a, int i) {
    ll res = 0;
    i++;
    if(a%2 == 0) {
        res = a / 2;
    } else {
        res = 3 * a + 1;
    }
    if(find(c.begin(), c.end(), res) != c.end()) {
        return i;
    } else {
        c.push_back(res);
        return dfs(res, i);
    }
}

Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in) 
  sc.useDelimiter("\n")
  val n = sc.nextInt()
  val d = sc.next().split(" ").map(_.toDouble).toList.sorted
  val ans = d.foldLeft(d(0))((x, y) => (x + y) / 2)
  println(ans)
}

Measured memory_bytes: 55596
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

vector<vector<int>> to;
vector<int> dis;

void bfs(int v, int N){
    vector<int> check(N, -1);
    queue<int> q; q.push(v);
    check[v] = 0;
    while(q.size() != 0){
        int num = q.front(); q.pop();
        for(int u: to[num]){
            if(check[u] != -1) continue;
            q.push(u);
            check[u] = check[num]+1;
            if(u > v)dis[check[num]]++;
        }
    }
}

void dfs(int v, int p=-1, int min=0, int k=1){
    for(int u: to[v]){
        if(u == p || u < min) continue;
        dis[k-1]++;
        dfs(u,v, min,k+1);
    }
}

int main(){
    int N,X,Y; cin >> N >> X >> Y;
    X--; Y--;
    to.resize(N, vector<int>());
    dis.resize(N-1);
    to[X].push_back(Y);
    to[Y].push_back(X);
    rep(i,N-1){
        to[i].push_back(i+1);
        to[i+1].push_back(i);
    }
    
    rep(i,N-1) bfs(i, N);

    rep(i,N-1) cout << dis[i] << endl;
    return 0;
}


Measured memory_bytes: 384
n=int(input())
a=[0]+list(map(int,input().split()))
ball=[0]*(n+1)
for i in range(n,0,-1):
    c=1
    sum=0
    while c*i<=n:
        sum+=ball[c*i]
        c+=1
    ball[i]=(sum+a[i])%2
ans=[]
for i in range(1,n+1):
    if ball[i]!=0:
        ans.append(i)
print(len(ans))
"""if len(ans)==0:
    exit()"""
print(*ans)


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

using namespace std;

const int N = 22;
const int MOD = 1e9 + 7;

int n, a[N][N], dp[N][1 << N];

int Check(int mask, int pos) {
  return mask & (1 << pos);
}

int Set(int mask, int pos) {
  return mask | (1 << pos);
}

int fun(int p, int mask) {
  if (p == n) return 1;
  int &ret = dp[p][mask];
  if (ret != -1) return ret;
  ret = 0;
  for (int i = 0; i < n; i++) {
    if (!Check(mask, i) && a[p][i]) {
      ret += fun(p + 1, Set(mask, i));
      ret %= MOD;
    }
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  memset(dp, -1, sizeof dp);
  cout << fun(0, 0) << '\n';
  return 0;
}



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

#define ll long long int
#define vi vector<int>
#define ii pair< int , int >
#define vii vector<ii>
#define FOR(i, n) for(ll i = 0; i < (ll)n; i++)
int MAX(int a, int b){return (a > b) ? a:b;}
int MIN(int a, int b){return (a < b) ? a:b;}
int ABS(int x){return (x > 0) ? x:-x;}
int left(int x){return (x<<1);}
int right(int x){return (x<<1)+1;}
int lsone(int x){return (x&(-x));}

const int maxk = 1e5 + 5;

int n, k, a[200];
bool ans[maxk][2], found[maxk][2];

int main(){
	scanf("%d %d", &n, &k);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for(int rem = 0; rem <= k; rem++){
		for(int turn = 0; turn < 2; turn++){
			if(rem == 0) ans[rem][turn] = false;
			else{
				for(int i = 0; i < n; i++) if(a[i] <= rem){
					ans[rem][turn] |= !ans[rem-a[i]][1-turn];
				}
			}
		}
	}
	if(ans[k][0]) printf("First\n");
	else printf("Second\n");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

const int N = 11111;
int a[N], b[N];
int n;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 1, n) {
        cin >> a[i];
    }
    rep(i, 1, n) {
        cin >> b[i];
    }
    int op1 = 0;
    rep(i, 1, n) {
        if(a[i] > b[i]) {
            op1 += a[i] - b[i];
        }
    }
    rep(i, 1, n) {
        if(a[i] < b[i]) {
            int cnt = b[i] - a[i] >> 1;
            op1 -= cnt;
        }
    }
    cout << (op1 > 0 ? "No" : "Yes") << endl;
    return 0;
}


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

typedef long long ll;

ll n,k;
void input()
{
    cin>>n>>k;
}

void solve()
{
    n%=k;
    cout<<min(n,k-n)<<endl;
}

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

Measured memory_bytes: 3616
N, L = map(int, input().split())
aji = []
for i in range(N):
  aji.append(L + i)
min_aji = min(aji)
max_aji = max(aji)
if min_aji > 0:
  print(sum(aji) - min_aji)
elif max_aji < 0:
  print(sum(aji) - max_aji)
else:
  print(sum(aji))


Measured memory_bytes: 3060
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))
flag=0
c=[0 for i in range(n+1)]
b=0
a.append(-2)
c[0]=1
if(a[b]==1):
    c[1]=0
    b+=1
else:
    c[1]=1
for i in range(2,n+1):
    if (i==a[b]):
        c[i]=0
        b+=1
    else:
        c[i]=c[i-1]+c[i-2]
        c[i]=c[i] %1000000007
print('{0}'.format(c[n]))

Measured memory_bytes: 7832
#include <bits/stdc++.h>
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x, y) memset(x, y, sizeof(x))
#define Maxn 1000000 + 10
using namespace std;
int N;
int d[Maxn];
int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }
    ll sum = 0;
    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
	int x;
    cin>>x;
    int ans=0;
    
    int time=x/100;
    int amari=x%100;
    
    if(amari<=5*time) ans=1;
    
    cout<<ans<<endl;
    
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls(x) (x*2)
#define rs(x) (x*2+1)
using namespace std;

const int maxn=2e5+7,inf=1e9+7;

int n,m,ans=0;
struct Opt{int l,r;}p[maxn];
struct Node{int lazy,maxx;}node[maxn*4];

bool cmp(const Opt &A,const Opt &B){return A.l<B.l;}
void pushdown(int num,int nl,int nr){
  if(!node[num].lazy)return;
  int lz=node[num].lazy; node[num].lazy=0;
  node[ls(num)].maxx+=lz;node[ls(num)].lazy+=lz;
  node[rs(num)].maxx+=lz;node[rs(num)].lazy+=lz;    
}
void update(int num){node[num].maxx=max(node[ls(num)].maxx,node[rs(num)].maxx);}
void build(int num,int nl,int nr){
  node[num].lazy=0; if(nl==nr){node[num].maxx=nr-m-1;return;}
  int mid=(nl+nr)/2;
  build(ls(num),nl,mid);build(rs(num),mid+1,nr);
  update(num);
}
void add(int num,int nl,int nr,int ql,int qr,int ad){
  if(ql<=nl&&nr<=qr){node[num].maxx+=ad;node[num].lazy+=ad;return;}
  if(nr<ql||qr<nl)return;
  int mid=(nl+nr)/2;pushdown(num,nl,nr);
  add(ls(num),nl,mid,ql,qr,ad);add(rs(num),mid+1,nr,ql,qr,ad);
  update(num);return;
}
int quary(int num,int nl,int nr,int ql,int qr){
  if(ql<=nl&&nr<=qr)return node[num].maxx;
  if(nr<ql||qr<nl)return -inf;
  int mid=(nl+nr)/2;pushdown(num,nl,nr);
  return max(quary(ls(num),nl,mid,ql,qr),quary(rs(num),mid+1,nr,ql,qr));
}
int main(){
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++)scanf("%d%d",&p[i].l,&p[i].r);
  sort(p+1,p+n+1,cmp);p[n+1].l=inf;
  build(1,0,m+1);
  for(int i=1;i<=n;i++){
    add(1,0,m+1,0,p[i].r,1);
    if(p[i].l!=p[i+1].l&&p[i].l<=m-1)ans=max(ans,quary(1,0,m+1,p[i].l+2,m+1)-p[i].l);
  }ans=max(ans,n-m);printf("%d\n",ans);
  return 0;
}

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

void print_vec(vector<int> n){
    for(int x: n){
        cout << x << " ";
    }
    cout << endl;
}
    

int main(void){
    int n; cin >> n;
    vector<int> A(n+1);
    vector<int> B(n);
    
    for(int i = 0; i < n+1; i++){
        cin >> A.at(i);
    }
    for(int i = 0; i < n; i++){
        cin >> B.at(i);
    }
    
    long long cnt = 0;
    int defeat;
    for(int i = 0; i < n; i++){
        defeat = min(A.at(i), B.at(i));
        cnt += defeat;
        A.at(i) -= defeat;
        
        defeat = min(A.at(i+1), B.at(i) - defeat);
        cnt += defeat;
        A.at(i+1) -= defeat;
        
        
    }
    cout << cnt << endl;
        
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define SORT(x) sort(all(x))
#define RSORT(x) sort(all(x),greater<ll>())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
	
	ll A,B;
	cin >> A >> B;
	
	if(abs(A-B) % 2 == 0) print(abs(A-B) / 2 + min(A,B));
	else print("IMPOSSIBLE");
	
 return 0;
}


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

fn main() {
	input! {
		x: usize,
		y: usize,
		z: usize,
	}

	println!("{}", (x - z) / (y + z));
}



Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >>N >>K;
  vector<bool> D(10, true);
  for(int i=0; i<K; i++){
    int d;
    cin >>d;
    D[d]=false;
  }
  bool finish=false;
  for(N; N<1e5; N++){
    int j=N;
    for(j; j>0; j/=10){
      if(D[j%10]==false) break;
      if(j<10) finish=true;
    }
  if(finish) break;
  }
  cout << N << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
seen = [0 for _ in range(n)]
seen[0] = 1
now = 0
for i in range(n):
  now = a[now] - 1
  if seen[now]:
    gap = i + 2 - seen[now]
    break
  else:
    seen[now] = i + 2
if k <= seen[now] - 1:
  now = 0
  for i in range(k):
    now = a[now] - 1
  print(now+1)
  #print('#')
else:
  #print(now)
  k -= seen[now] - 1
  #print(1,k)
  k %= gap
  #print(2,k)
  for i in range(k):
    now = a[now] - 1
  print(now+1)
  #print(gap)
  #print(seen)

Measured memory_bytes: 99240
#include <iostream>
#include <vector>
#include <set>
using namespace std;
const string r = "qwertasdfgzxcvb";//1
const string l = "yuiophjklnm";//0
int main(){
  //  cout << l.size();
  string tmp;
  while(cin >> tmp,tmp != "#"){
    int cnt = 0;
    int flag = 0;
    set<char> l_s;
    for(int i =0;i < l.size();i++){
      l_s.insert(l[i]);
    }
    if(l_s.find(tmp[0]) == l_s.end()){
      flag = 1;
    }else{
      flag = 0;
    }
    for(int i = 1;i < tmp.size();i++){
      if(l_s.find(tmp[i]) == l_s.end()){
	if(flag == 0){
	  cnt++;
	}
	flag = 1;
      }else{
	if(flag == 1)cnt++;
	flag = 0;
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1192
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

use std::collections::BTreeSet;

fn main() {
    input! {
        n:usize,
        p:[usize;n]
    }
    let mut set = BTreeSet::new();
    let mut idx = vec![0; n + 1];
    for (i, &x) in p.iter().enumerate() {
        idx[x] = i;
    }
    let mut ans = 0_isize;
    for i in (1..=n).rev() {
        set.insert(idx[i] as isize);
        let mut left = set.range(0..idx[i] as isize);
        let mut right = set.range(idx[i] as isize + 1..);

        if let Some(t) = left.next_back() {
            let f = *left.next_back().unwrap_or(&-1);
            let k = *right.next().unwrap_or(&(n as isize));
            ans += i as isize * (*t - f) * (k - idx[i] as isize);
        }

        let mut left = set.range(0..idx[i] as isize);
        let mut right = set.range(idx[i] as isize + 1..);

        if let Some(f) = right.next() {
            let t = *right.next().unwrap_or(&(n as isize));
            let k = *left.next_back().unwrap_or(&-1);
            ans += i as isize * (t - *f) * (idx[i] as isize - k);
        }
    }
    println!("{}", ans);
}


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

int n,t; int frq[10][10];
string s;

int main()
{
	 
	
	cin>>n;
	
	for( int i=1;i<=n;i++)
	{
		s= to_string(i);
		
		int l= s.size();
		
		if( s[l-1]!='0')
		{
			int x= s[0]   -'0';
			int y= s[l-1] -'0';
			
			frq[x][y]++;
		}
	}
	
	
	  for(int i=1;i<=9;++i)
        {
            for(int j=1;j<=9;++j)
                
				t=t+frq[i][j]*frq[j][i];
        }
        cout<<t<<endl;
	

	
	
	
}
      

Measured memory_bytes: 3716