akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 500005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll i,j,k,l,x,d;
	cin>>x>>k>>d;
	if(x<0) x=-x;
	ll a=x/d,b=(x+d-1)/d;
	// cout<<a<<" "<<b<<endl;
	if(x%d==0) b++;
	if(k>=b){
		k=k-a;
		if(k%2) cout<<abs(x-d*b)<<endl;
		else cout<<abs(x-d*a)<<endl;
		// cout<<min(abs(x-d*a),abs(x-d*b))<<endl;
	}
	else if(k>=a){
		cout<<abs(x-d*a)<<endl;
	}
	else{
		cout<<abs(x-k*d)<<endl;
	}
	return 0;	
}

Measured memory_bytes: 3636
import java.io.*;
import java.util.*;

public class Main {
    static Deque<String> list = new ArrayDeque<>();

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());
        for (int i = 0; i < n; i++) {
            String sp = br.readLine();
            if (sp.startsWith("insert")) {
                list.addFirst(sp.substring(sp.indexOf(" ") + 1));
            }else if (sp.equals("deleteFirst")) {
                list.removeFirst();
            } else if (sp.equals("deleteLast")) {
                list.removeLast();
            } else if (sp.startsWith("delete")) {
                list.remove(sp.substring(sp.indexOf(" ") + 1));
            }
        }
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        StringBuilder ans = new StringBuilder();
        ans.append(list.poll());
        for (String s : list) {
            ans.append(" ");
            ans.append(s);
        }
        bw.write(ans.toString());
        bw.newLine();
        bw.close();
        br.close();
    }
}



Measured memory_bytes: 160108
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int res = findSumOfDigists(N);
        if(N % res == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static int findSumOfDigists(int n) {
        int sum = 0;
        while(n > 0) {
            sum += n % 10;
            n /= 10;
            
        }
        return sum;
    }
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;cin>>s;
	string test;cin>>test;
	int l = min(s.length(),test.length());
	int cnt = 0;
	for(int i=0;i<l;i++)
		if(s[i]==test[i]) cnt++;
	cout<<cnt<<endl;
    return 0;
} 

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n;
    cin >> n;
    int cont = 0;
    int menor = INFINITO;
    fo(i, n) {
        int p;
        cin >> p;
        if ( p <= menor ) {
            menor = p;
            cont++;
        }
    }

    cout << cont << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
using namespace std;

int main(){
  int n; cin >> n;
  int a; cin >> a;
  int mx = a, mn = a;
  long long t = a;
  for(int i = 1; i < n; i++){
    cin >> a;
    mx = max(mx, a);
    mn = min(mn, a);
    t += a;
  }
  cout << mn << " " << mx << " " << t << endl;
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

const int MAX = 1000100;
ll fact[MAX], fact_inv[MAX];

ll power( ll a, ll b ){
	ll res = 1;
	while( b>0 ){
		if( b&1 ) res = res*a % MOD;
		a = a*a % MOD;
		b >>= 1;
	}
	return res;
}

ll comb( ll n, ll r ){
	return (fact[n]*fact_inv[r]) % MOD * fact_inv[n-r] % MOD;
}

int main(){
	fact[0] = 1;
	for( int i = 0; i < 1000050; ++i ){
		fact[i+1] = fact[i]*(i+1) % MOD;
	}
	fact_inv[1000050] = power( fact[1000050], MOD-2 );
	for( int i = 1000049; i >= 0; --i ){
		fact_inv[i] = fact_inv[i+1]*(i+1) % MOD;
	}
	ll x, y; cin >> x >> y;
	if( x < y ) swap(x, y);
	if( ( (2*x-y) % 3 != 0 ) || 2*x-y < 0 ){
		cout << 0 << endl;
		return 0;
	}
	ll a = (2*x-y)/3;
	ll b = x-2*a;
	ll p = a+b;
	ll q = a;
	if( p < q ){
		cout << 0 << endl;
		return 0;
	}
	cout << comb(p, q) % MOD << endl;	
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define rup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    
    int ans = rup(n, x) * t;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 0x3F3F3F3F;
const ll maxn = 2e5 + 555;
const ll MOD = 1e9 + 7;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
    ll n, m, k;
    cin >> n >> m >> k;
    deque<ll> a(n);
    deque<ll> b(m);
    for (ll &i : a)
        cin >> i;
    for (ll &i : b)
        cin >> i;
    for (ll i = 1; i < n; i++)
        a[i] += a[i - 1];
    for (ll i = 1; i < m; i++)
        b[i] += b[i - 1];
    ll ans = upper_bound(b.begin(), b.end(), k) - b.begin();
    for (ll i = 0; i < n; i++) {
        if (a[i] > k)
            break;
        ll idx = upper_bound(b.begin(), b.end(), k - a[i]) - b.begin();
        ans = max(ans, i + 1 + idx);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
   	public String lcs(String a, String b) {
        int n = a.length();
        int m = b.length();
        int[][] memo = new int[n + 1][m + 1];
        for (int[] row: memo) {
            Arrays.fill(row, -1);
        }
        lcs(a, n, b, m, memo);
        StringBuilder sb = new StringBuilder();
        reconstructSolution(a, b, memo, sb, n, m);
        return sb.reverse().toString();
    }
    private void reconstructSolution(String a, String b, int[][] memo, StringBuilder sb, int i, int j) {
        if (i <= 0 || j <= 0) {
            return;
        }
        if (a.charAt(i - 1) == b.charAt(j - 1)){
            sb.append(a.charAt(i - 1));
            reconstructSolution(a, b, memo, sb, i - 1, j - 1);
        } else if (memo[i - 1][j] > memo[i][j - 1]) {
           reconstructSolution(a, b, memo, sb, i - 1, j); 
        } else {
           reconstructSolution(a, b, memo, sb, i, j - 1); 
        }
    }
    private int lcs(String a, int i, String b, int j, int[][] memo) {
       if (i <= 0 || j <= 0) {
           return 0;
       }
       if (memo[i][j] != -1) {
           return memo[i][j];
       }
       if (a.charAt(i - 1) == b.charAt(j - 1)) {
           return memo[i][j] = 1 + lcs(a, i - 1, b, j - 1, memo);
       } else {
           int x = lcs(a, i - 1, b, j, memo);
           int y = lcs(a, i, b, j - 1, memo);
           return memo[i][j] = Math.max(x, y);
       }
    }
    public static void main(String[] args)  {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String a = br.readLine();
            String b = br.readLine();
          	Main app = new Main();
            String result = app.lcs(a, b);
            System.out.println(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 86048
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(n), c(m), d(m);
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	for (int i = 0; i < m; i++) cin >> c[i] >> d[i];
	for (int i = 0; i < n; i++) {
		int tmp = abs(a[i] - c[0]) + abs(b[i] - d[0]), tmp2 = 1;
		for (int j = 1; j < m; j++) {
			const int tmp3 = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (tmp > tmp3) {
				tmp = tmp3;
				tmp2 = j + 1;
			}
		}
		cout << tmp2 << endl;
	}	
	return 0;
}

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

int main() {
    int n;
    string s;

    cin >> n;
    cin >> s;

    long long rt = 0;
    long long gt = 0;
    long long bt = 0;

    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') {
            rt += 1;
        }
        if(s[i] == 'G') {
            gt += 1;
        }
        if(s[i] == 'B') {
            bt += 1;
        }
    
    }

    long long t = rt * gt * bt;
    for(int i = 0; i < n - 2; i++) {
        for(int j = i + 1; j < n - 1; j++) {
            int k = 2 * j - i;
            if(   k < n
               && s[i] != s[j]
               && s[i] != s[k]
               && s[j] != s[k] ) {
                   t--;
               }
        }
    }

    cout << t << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n;
    cin>>n;
    vector<int> A(n);
    rep(i,n) cin>>A[i];
    sort(A.begin(),A.end());
    if(A[n-1]-A[0]>1){
        cout<<"No";
    }
    if(A[n-1]-A[0]==1){
        int a=0;
        rep(i,n) if(A[i]==A[0]) a++;
        if(a<A[n-1]&&A[n-1]<=a+(n-a)/2) cout<<"Yes";
        else cout<<"No";
    }
    if(A[n-1]==A[0]){
        if(A[0]==n-1||A[0]<=n/2) cout<<"Yes";
        else cout<<"No";
    }
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
    
    int N,M,A[123],B[123][123];
    
    scanf("%d",&N);
    scanf("%d",&M);
    
    for(int i=0;i<M;i++) scanf("%d",&A[i]);
    for(int i=0;i<M;i++)for(int j=0;j<N;j++)scanf("%d",&B[i][j]);
    
    int score[123]={};
    
    for(int i=0;i<M;i++){
        for(int j=0;j<N;j++){
            if(B[i][j] == A[i]) score[j]++;
            else score[A[i]-1]++;
        }
    }
    
    for(int i=0;i<N;i++){
        printf("%d\n",score[i]);
    }
    
    return 0;
}

Measured memory_bytes: 2764
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int k;
    string s;
    cin >> k >> s;
    if (sz(s) <= k) cout << s << endl;
    else cout << s.substr(0, k) << "..." << endl;
}


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

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  return y != 0 ? gcd(y, x % y) : x;
}

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) {
    int tmp;
    cin >> tmp;
    a.at(i) = abs(x - tmp);
  }

  int ans = a.front();
  for (int i = 1; i < n; i ++) {
    ans = gcd(ans, a.at(i));
  }

  cout << ans << endl;
}


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

void solve() {
	long long sum = 0;
	string arr;
	cin >> arr;
	for (int i = 0; i < arr.size(); ++i) 
		sum += (arr[i] - '0');
	(sum % 9 == 0) ? cout << "Yes" << endl : cout << "No" << endl;
}

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

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	string s;
	cin >> s;
	ll n,i,j,k,c,h,g,l;
	n = s.length();
	l = (n-1)/2;
	i=0;j=n-1;c=0;
	char a,b;
	while(i<l && j>l)
	{
		a = s[i];
		b = s[j];
		if(a!=b)
		{
			c=1;
			break;
		}
		i++;j--;
	}
	if(c==1)
	{
		cout << "No" << endl;
	}
	else
	{
		i=0;j=l-1;c=0;k=(l-1)/2;
		while(i<=k && j>k)
		{
			a = s[i];
			b = s[j];
			if(a!=b)
			{
				c=1;
				break;
			}
			i++;j--;
		}
		if(c==1)
		{
			cout << "No" << endl;
		}
		else
		{
			i=l+1;j=n-1;c=0;k=(l+n)/2;
			while(i<k && j>=k)
			{
				a = s[i];
				b = s[j];
				if(a!=b)
				{
					c=1;
					break;
				}
				i++;j--;
			}
			if(c==1)
			{
				cout << "No" << endl;
			}
			else
			{
				cout << "Yes" << endl;
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string s;
  cin >> s;
  ll rcnt = 0,lcnt = 0;
  ll ans = 0;
  for (int i = 0; i < (int)s.length(); ++i) {
    if (s[i] == '<') rcnt++;
    else if (s[i] == '>') lcnt++;
    if (i == (int)s.length()-1 || (s[i] == '>' && s[i+1] == '<')) {
      debug(rcnt, lcnt);
      if (rcnt < lcnt) swap(rcnt, lcnt); //処理を共通にするためにrcnt>=lcntにする
      ans += rcnt*(rcnt+1)/2 + (lcnt-1)*lcnt/2;
      rcnt = 0; //initialize
      lcnt = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

bool is_atgc(string s){
    for (int i = 0; i < s.size(); ++i){
        if(string("ATGC").find(s[i]) == string::npos){
            return false;
        }
    }
    return true;
}


int main(){

    string b;
    cin >> b;

    int ans = 0;

    for (int i = 0; i < b.size(); ++i){
        for(int j = 0; j  <= i; ++j){
            if(is_atgc(b.substr(j, i-j+1))){
                ans = max(ans, i-j+1);
            }
        }
    }
    
    cout << ans << endl;

}


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

using namespace std;

const int Nmax = 105;
typedef long long ll;

struct
{
    int weight;
    ll cost;
} a[Nmax];

int N,W;

static inline ll Max(ll a, ll b)
{
    return (a > b) ? a : b;
}

int main()
{
    cin >> N >> W;
    for(int i = 1; i <= N; ++i)
        cin >> a[i].weight >> a[i].cost;

    vector<ll> dp(W + 1,0),dp0(W + 1,0);

    for(int i = 1; i <= N; ++i)
    {
        if(a[i].weight > W)
            continue;
        for(int j = a[i].weight; j <= W; ++j)
            dp[j] = Max(dp0[j],dp0[j - a[i].weight] + a[i].cost);
        dp0 = dp;
    }
    cout << dp0[W];
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9, mod = 1e9+7;
#define endl     '\n'
int a[200005];
void solve(){

}


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

    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n-k; i++){
        cout <<(a[i] < a[i+k] ? "Yes\n" : "No\n");
    }
    return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};




int main(){
  
  int n,k;
  ll res = 0;
  cin >> n >> k;
  deque<int> dque;
  REP(i,n){
    int x;cin >> x;
    dque.push_back(x);
  }
  for(int i = 0;i <= min(n,k);i++){
    for(int j = 0;j+i <= min(n,k);j++){
      priority_queue<int,vector<int>,greater<int>> que;
      deque<int> de = dque;
      REP(l,i)que.push(de.front()),de.pop_front();
      REP(l,j)que.push(de.back()),de.pop_back();
      REP(l,k-i-j)if(!que.empty())if(que.top() < 0)que.pop();
      ll sub = 0;
      while(!que.empty()){
        sub += que.top();
        que.pop();
      }
      res = max(res,sub);
    }
  }
  cout << res << endl;



  


  return 0;
}


Measured memory_bytes: 256
S = list(input())
n = len(S)-1
ans = 0
for i in range(2**n):
    equation = '' + str(S[0])
    for j in range(n):
        if (i>>j)&1:
            equation+='+'+str(S[j+1])
        else:
            equation+=str(S[j+1])
    ans += eval(equation)
print(ans)

Measured memory_bytes: 3064
N = int(input())
S_dict = {}
for i in range(N):
    s = input()
    if s not in S_dict:
        S_dict[s] = 1
    else:
        S_dict[s] += 1
        
max_poll = max(S_dict.values())
ans_list = []
for key, poll in S_dict.items():
    if poll == max_poll:
        ans_list.append(key)

for ans in sorted(ans_list):
    print(ans)

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

int main() {
  long long A,B,K;
  cin >> A >> B >> K;
  
  if (A > K) 
    cout << A - K << " " << B << endl;
  else if (A + B > K)
    cout << 0 << " " << A + B - K << endl;
  else
    cout << 0 << " " << 0 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, W; cin >> N >> W;
    vector<int> v(N), w(N);
    for (int i = 0; i < N; i++) cin >> v[i] >> w[i];
    
    vector<vector<int>> dp(N + 1, vector<int>(W + 1, 0));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            if (w[i] > j) dp[i + 1][j] = dp[i][j];
            else dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
        }
    }
    
    cout << dp[N][W] << endl;
  
    return 0;
}



Measured memory_bytes: 6840
#include <bits/stdc++.h>
using namespace std;
 
long long t,x,z;
 
int main() {
	double y = 100;
	cin >> x;
	while (++z) {
		if (y >= x) {
			cout << z-1 << "\n";
			exit(0);
		}
		y *= 1.01;
		y = floor(y);
	}
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL N;cin >> N;
    LL K;cin >> K;
    vector<LL> A(N);
    rep(i,N)cin >> A[i];

    LL lb = 0;
    LL ub = 1000000001;

    while(ub - lb > 1){
        LL mid = (lb + ub)/2;
        LL ct = 0;
        rep(i,N){
            ct += ((A[i]+mid-1)/mid)-1;
        }
        
        if(ct <= K){
            ub = mid;
        }
        else{
            lb = mid;
        }
    }   

    cout << ub << endl;


}

Measured memory_bytes: 4624
n,m = map(int,input().split())
n_p = list()
m_p = list()
ans = 1


for i in range(n):
    n_p.append(list(map(int,input().split()))    )
for j in range(m):
    m_p.append(list(map(int,input().split())))
    
for i in range(n):
    ans = 1
    d=abs(n_p[i][0]-m_p[0][0])+abs(n_p[i][1]-m_p[0][1])
    for j in range(m):
        if d != min(d,abs(n_p[i][0]-m_p[j][0])+abs(n_p[i][1]-m_p[j][1])):
            d = min(d,abs(n_p[i][0]-m_p[j][0])+abs(n_p[i][1]-m_p[j][1]))
            ans = j+1
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;

ll modpow(ll a, ll n, ll mod)
{
    ll res = 1;
    while (n)
    {
        if (n & 1)
        {
            res = (res * a) % mod;
        }
        a = (a * a) % mod;
        n /= 2;
    }
    return res;
}

ll modinv(ll a, ll mod)
{
    return modpow(a, mod - 2, mod);
}

// ll comb(ll n, ll k, ll mod)
// {
//     ll a = 1;
//     ll b = 1;
//     ll c = 1;
//     rep(i, n) a = a * (n - i) % mod;
//     rep(i, k) b = b * (k - i) % mod;
//     rep(i, n - k) c = c * (n - k - i) % mod;
//     ll bc = (b * c) % mod;
//     return a * modinv(bc, mod) % mod;
// }
ll comb(ll n, ll k, ll mod)
{
    ll a = 1;
    ll b = 1;
    rep(i, k) a = a * (n - i) % mod;
    rep(i, k) b = b * (i+1) % mod;
    return a * modinv(b, mod) % mod;
}
int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = modpow(2, n, MOD);
    ll ss = comb(n, a, MOD);
    ss = comb(n, b, MOD);
    ll sub = (comb(n, a, MOD) + comb(n, b, MOD)) % MOD;
    ans = (ans - sub) % MOD;
    if (ans < 0)
    {
        ans += MOD;
    }
    cout << ans - 1 << endl;
    //system("pause");
    return 0;
}

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

typedef long long int ll;
ll n, k, a[200007];

bool check(ll x) {
    ll cuts = 0;
    for(ll i = 0; i < n; ++i) {
        cuts += (a[i] + x - 1)/x - 1;
    }

    return cuts <= k;    
}

int main() {
    scanf("%lld %lld", &n, &k);
    for(ll i = 0; i < n; ++i) {
        scanf("%lld", &a[i]);
    }

    sort(a, a + n);

    ll l = 1, r = a[n - 1];
    while(l < r) {
        ll mid = (l + r)/2;
        if(check(mid)) {
            r = mid;
        } else l = mid + 1;
    }

    printf("%lld\n", l);
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int INF = 1e9;
const int MAX = 1e5;

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

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問の有無

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

int n; // 変数
int h[MAX];
int dp[MAX]; // 足場iまでの最小コスト

int rec(int i) {
    if (dp[i] != INF) return dp[i];
    if (i == 0) return dp[i] = 0;
    if (i == 1) return dp[i] = abs(h[i] - h[i-1]);
    int x = rec(i-1) + abs(h[i]-h[i-1]);
    int y = rec(i-2) + abs(h[i]-h[i-2]);
    return dp[i] = min(x, y);
}

int main() {
// input
    cin >> n;
    rep(i, n) {
        cin >> h[i];
    }
// solve
    rep(i, n) {
        dp[i] = INF;
    }
    int ans = rec(n-1);
// output
    cout << ans << "\n";
}

Measured memory_bytes: 9000
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
//#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
const int MAXN=1e5;
int n_pnt,n_edg;
struct NODE{
	int p,val;//val+p*x>0
	NODE(){}
	NODE(int a,int b){p=a;val=b;}
};
struct QUEUE{
	int u,p;//val+p*x>0
	long long val;
	QUEUE(){}
	QUEUE(int a,int b,long long c){u=a;p=b;val=c;}
};
vector<pair<int,int> > lnk[MAXN+5];
long long vis[2][MAXN+5];//vis[0][i]-x>0 && vis[1][i]+x>0 -> x<vis[0] && x>-vis[1]
inline int G(int p){return p==1;}
long long MIN=-1e15,MAX=1e15;
int main()
{
	fill(vis[0],vis[0]+MAXN+5,1e15);
	fill(vis[1],vis[1]+MAXN+5,1e15);
	scanf("%d%d",&n_pnt,&n_edg);
	for(int i=0,u,v,l;i<n_edg;i++)
		scanf("%d%d%d",&u,&v,&l),
		lnk[u].push_back(make_pair(v,l)),lnk[v].push_back(make_pair(u,l));
	queue<QUEUE> que;
	que.push(QUEUE(1,1,0));
	while(!que.empty())
	{
		QUEUE fro=que.front();que.pop();
		for(int i=0;i<lnk[fro.u].size();i++)
		{
			int v=lnk[fro.u][i].first,l=lnk[fro.u][i].second;
			long long val=l-fro.val;int p=fro.p==1? -1:1;
			if(vis[G(p)][v]!=1e15)
			{
				if(val!=vis[G(p)][v])
				{
					printf("%d\n",0);
					return 0;
				}
				else
					continue;
			}
			vis[G(p)][v]=val;
			if(G(p))
				MIN=max(MIN,max((long long)0,-vis[1][v]));
			else
				MAX=min(MAX,vis[0][v]);
			que.push(QUEUE(v,p,val));
		}
	}
	long long ans=-1;
	for(int i=1;i<=n_pnt;i++)
		if(vis[0][i]!=1e15 && vis[1][i]!=1e15)
		{
			int res=(vis[0][i]-vis[1][i])/2;
			if(res<0) {printf("0\n");return 0;}
			if(ans==-1) ans=res;
			if(ans!=res) {printf("0\n");return 0;}
		}
	if(ans!=-1)
	{
		if(MIN<ans && ans<MAX)
			printf("%d\n",1);
		else
			printf("%d\n",0);
		return 0;
	}
	if(MAX-MIN-1<0) printf("%d\n",0);
	else printf("%lld\n",MAX-MIN-1);
	return 0;
}
/*
2 1
1 2 3
*/

Measured memory_bytes: 9716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  vector<vector<int>> d(3,vector<int>(n));
  d[0][0]=a[0];
  d[1][0]=b[0];
  d[2][0]=c[0];
  for(int i=1;i<n;i++){
    d[0][i]=max(d[1][i-1],d[2][i-1])+a[i];
    d[1][i]=max(d[2][i-1],d[0][i-1])+b[i];
    d[2][i]=max(d[0][i-1],d[1][i-1])+c[i];
  }
  cout << max(max(d[0][n-1],d[1][n-1]),d[2][n-1]) << endl;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define INF 1000000000000
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
int r;
cin>>r;
if(r>=400&&r<=599)
{
	cout<<"8\n";
}
else if(r>=600&&r<=799)
{
	cout<<"7\n";
}
else if(r>=800&&r<=999)
{
	cout<<"6\n";
}
else if(r>=1000&&r<=1199)
{
	cout<<"5\n";
}
else if(r>=1200&&r<=1399)
{
	cout<<"4\n";
}
else if(r>=1400&&r<=1599)
{
	cout<<"3\n";
}
else if(r>=1600&&r<=1799)
{
	cout<<"2\n";
}
else 
{
	cout<<"1\n";
}

return  0;
}






Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 1e9+7;

vector<ll> fact,ifact,inv,pow2;
ll add(ll a, ll b)
{
	a+=b; a%=MOD;
	if(a<0) a+=MOD;
	return a;
}
ll mult(ll a, ll b)
{
	if(a>MOD) a%=MOD;
	if(b>MOD) b%=MOD;
	ll ans=(a*b)%MOD;
	if(ans<0) ans+=MOD;
	return ans;
}
ll pw(ll a, ll b)
{
	ll r=1;
	while(b){
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

const bool DEBUG = 0;
const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	ll a[n];
	forn(i,0,n) cin>>a[i];
	
	ll pre[n]{};
	forn(i,0,n)
	{
		pre[i]=a[i];
		if(i) pre[i]=add(pre[i],pre[i-1]);
	}
	
	ll ans=0;
	forn(i,1,n)
	{
		ans=add(ans, mult(pre[i-1],a[i]));
	}
	
	cout<<ans<<'\n';
	
	return 0;
}


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

int main()
{
	while(1){
		string s;
		getline(cin,s);
		int l = s.length();
		if(l == 1 && s[0] == '0') break;
		int sum = 0;
		for(int i=0; i<l; i++){
			sum += s[i] - '0';
		}
		cout << sum << endl;
	}
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;
  while(cin >> n >> k && n && k){
    vary(ll,v,k,0);
    rep(i,k){
      cin >> v[i];
    }
    sort(all(v));
    vector<pair<int,int>> vp;
    int cnt = 1,M = 0,st = v[0];
    rep(i,k-1){
      if(v[i] == 0){
        ++i;
        st = v[i];
      }
      if(v[i] == v[i+1] - 1){
        ++cnt;
      }
      else{
        vp.push_back(make_pair(st,cnt));
        M = max(M,cnt);
        cnt = 1;
        st = v[i+1];
      }
    }
    vp.push_back(make_pair(st,cnt));
    M = max(M,cnt);
    cnt = 0;
    if(n == k){
      cout << k << endl;
    }
    else if(v[0] != 0){
      cout << M << endl;
    }
    else{
      M++;
      rep(i,vp.size()-1){
        if(vp[i].fi + vp[i].se + 1 == vp[i+1].fi){
          M = max(M,vp[i].se + vp[i+1].se + 1);
        }
      }
      cout << M << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3768
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var A, B int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &A, &B)

	if B%A == 0 {
		fmt.Println(A + B)
	} else {
		fmt.Println(B - A)
	}
}


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

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  char maze[h+2][w+2];
  for(int i=0; i<h+2; i++)
    for(int j=0; j<w+2; j++)
      maze[i][j] = '#';
  for(int i=1; i<h+1; i++)
    for(int j=1; j<w+1; j++)
      cin >> maze[i][j];
  for(int i=0; i<h+2; i++){
    for(int j=0; j<w+2; j++){
      cout << maze[i][j];
    }
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = input().split()
intA = [int(s) for s in A]

def warizan():
    for i in range(N):
        intA[i] = int(intA[i] / 2)

count=0
flg = False
while True:
    for i in range(N):
        #print(intA[i])
        if(intA[i]%2 != 0):
            flg = True
            break
    if flg:
        break
        
    warizan()
    count += 1
        
print(count)

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>

using ll = long long;
using ull = unsigned long long;

using std::cout;
using std::cerr;
using std::cin;
using std::endl;
using std::string;
using std::vector;
using std::array;

int main()
{
    ll n;
    cin >> n;
    ll min_cnt = n;
    bool flag = false;
    for (ll i = 2; i <= std::sqrt(n); i++)
    {
        if (n % i == 0)
        {
            min_cnt = std::min(min_cnt, i + n / i);
            flag = true;
        }
    }
    
    if (flag)
    {
        cout << min_cnt - 2 << endl;
    }
    else
    {
        cout << min_cnt - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 384
N = input()
X = list( map(int, input().split()))
X.sort()

min_a = X[0]
max_a = X[-1]

sum_min = 0
sum_max = 0
    
def calc(x, min, max):
    mid = (min + max) // 2
    sum_min = 0
    sum_max = 0
    for value in x:
        sum_min += (value - min) ** 2
        sum_max += (value - max) ** 2
    
    if abs(min - max) <= 1:
        if sum_min < sum_max:
            return int(sum_min)
        else:
            return int(sum_max)
    elif sum_min < sum_max:
        return calc(x, min, mid)
    else:
        return calc(x, mid, max)
    
    return -1
    
ans = calc(X, min_a, max_a)
print(ans)

Measured memory_bytes: 3064
n=int(input())
s1=input()
s2=input()
g=["c"]
i=0
while i<n:
    if s1[i]==s2[i]:
        g.append("a")
        i+=1
    else:
        g.append("b")
        i+=2
ans=1
mod=10**9+7
for i in range(len(g)-1):
    if g[i]=="c":
        if g[i+1]=="a":
            ans=(ans*3)%mod
        else:
            ans=(ans*6)%mod
    elif g[i]=="a":
        ans=(ans*2)%mod
    else:
        if g[i+1]=="b":
            ans=(ans*3)%mod
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static long solve(int x) {
        long [] arr = new long[x+1];
        arr[0] = 2;
        arr[1] = 1;
        for (int i = 2; i <= x; i++){
            arr[i] = arr[i-2] + arr[i-1];
        }
        return arr[x];
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int s = in.nextInt();
        System.out.println(solve(s));
    }
}

Measured memory_bytes: 23124
using System;
class Program
{
    static void Main()
    {
        var x = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var dir = new char[12] { 'U', 'R', 'D', 'L', 'L', 'U', 'R', 'D', 'R', 'D', 'L', 'U' };
        var len = new int[12]
        {
          x[3] - x[1], x[2] - x[0],
          x[3] - x[1], x[2] - x[0],
          1, x[3] - x[1] + 1, x[2] - x[0] + 1,1,
          1, x[3] - x[1] + 1, x[2] - x[0] + 1,1
        };
        for (int i = 0; i < 12; i++)
        {
            for (int j = 0; j < len[i]; j++) Console.Write(dir[i]);
        }
        Console.WriteLine();
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

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

    bool even_is_man = false;
    int ok, ng;
    for (int i = 0; ; ++i) {
        if (i == 0) {
            cout << 0 << endl;
            fflush(stdout);
            string s;
            cin >> s;
            if (s == "Vacant") {
                return 0;
            }
            if (s == "Male") even_is_man = true;
            ok = -1;
            ng = n;
        } else {
            int mid = (ok + ng) / 2;
            cout << mid << endl;
            fflush(stdout);
            string s;
            cin >> s;
            if (s == "Vacant") {
                return 0;
            }
            if (s == "Male") {
                if (even_is_man) {
                    if (mid % 2 == 0) {
                        ok = mid;
                    } else {
                        ng = mid;
                    }
                } else {
                    if (mid % 2 == 0) {
                        ng = mid;
                    } else {
                        ok = mid;
                    }
                }
            } else {
                if (even_is_man) {
                    if (mid % 2 == 0) {
                        ng = mid;
                    } else {
                        ok = mid;
                    }
                } else {
                    if (mid % 2 == 0) {
                        ok = mid;
                    } else {
                        ng = mid;
                    }
                }
            }     
        } 
    }
}

Measured memory_bytes: 852
#include<iostream>
using namespace std ;
int main()
{
	int n=0 , m=0 , l=0 , a=0 ;
	cin >> n >> m ;
	int Al[n][m] , bl[m] ;
	for(int i=0;i<n;i++)
	{
		for(int ia=0;ia<m;ia++)
		{
			cin >> l ;
			Al[i][ia]=l ;
		}
	}
	for(int ib=0;ib<m;ib++)
	{
		cin >> l ;
		bl[ib]=l ;
	}

	for(int i=0;i<n;i++)
	{
		for(int ia=0;ia<m;ia++)
		{
			a=a+bl[ia]*Al[i][ia] ;
			if(ia==m-1) cout << a << endl ;
		}
		a=0 ;
	}
	return 0 ;
}


Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		String op = scanner.next();
		int B = scanner.nextInt();
		int result = 0;

		if (op.equals("+")) {
			result = A + B;
		} else if (op.equals("-")) {
			result = A - B;
		}
		System.out.println(result);
	}

}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;

void solve()
{
	int a,b,k;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			cout<<"OK";return;
		}
	}
	cout<<"NG";
}
 
int main()
{
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-12
#define MOD 998244353ll
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;

inline void solve()
{
	int n;
	cin >> n;
	ll sum = 0;
	fore(i, 1, n + 1)
	{
		if (i % 3 != 0 && i % 5 != 0)
			sum += i;
	}
	cout << sum;
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	while (q--)
	{
		solve();
		cout << '\n';
	}

}

Measured memory_bytes: 3652
n=int(input())

if n==2:
  print(-1)
elif n==3:
  print('aab')
  print('d.b')
  print('dcc')
elif n%4==0:
  for i in range(n//4):
    temp=['.'*n]*4
    temp[0]=temp[0][:4*i]+'aabd'+temp[0][(i+1)*4:]
    temp[1]=temp[1][:4*i]+'ccbd'+temp[1][(i+1)*4:]
    temp[2]=temp[2][:4*i]+'efgg'+temp[2][(i+1)*4:]
    temp[3]=temp[3][:4*i]+'efhh'+temp[3][(i+1)*4:]
    print(temp[0])
    print(temp[1])
    print(temp[2])
    print(temp[3])
elif n%4==1:
  temp=['']*5
  temp[0]='aabbc'+'.'*(n-5)
  temp[1]='fg..c'+'.'*(n-5)
  temp[2]='fg..d'+'.'*(n-5)
  temp[3]='h.jjd'+'.'*(n-5)
  temp[4]='hiiee'+'.'*(n-5)
  print(temp[0])
  print(temp[1])
  print(temp[2])
  print(temp[3])
  print(temp[4])
  for i in range(n//4-1):
    temp=['.'*n]*4
    temp[0]=temp[0][:4*i+5]+'aabd'+temp[0][(i+1)*4+5:]
    temp[1]=temp[1][:4*i+5]+'ccbd'+temp[1][(i+1)*4+5:]
    temp[2]=temp[2][:4*i+5]+'efgg'+temp[2][(i+1)*4+5:]
    temp[3]=temp[3][:4*i+5]+'efhh'+temp[3][(i+1)*4+5:]
    print(temp[0])
    print(temp[1])
    print(temp[2])
    print(temp[3])
elif n%4==2:
  temp=['']*6
  temp[0]='a.ccaa'+'.'*(n-6)
  temp[1]='ab.bb.'+'.'*(n-6)
  temp[2]='cb...c'+'.'*(n-6)
  temp[3]='c...bc'+'.'*(n-6)
  temp[4]='.bb.ba'+'.'*(n-6)
  temp[5]='aacc.a'+'.'*(n-6)
  print(temp[0])
  print(temp[1])
  print(temp[2])
  print(temp[3])
  print(temp[4])
  print(temp[5])
  for i in range(n//4-1):
    temp=['.'*n]*4
    temp[0]=temp[0][:4*i+6]+'aabd'+temp[0][(i+1)*4+6:]
    temp[1]=temp[1][:4*i+6]+'ccbd'+temp[1][(i+1)*4+6:]
    temp[2]=temp[2][:4*i+6]+'efgg'+temp[2][(i+1)*4+6:]
    temp[3]=temp[3][:4*i+6]+'efhh'+temp[3][(i+1)*4+6:]
    print(temp[0])
    print(temp[1])
    print(temp[2])
    print(temp[3])
else:
  temp=['']*7
  temp[0]='a.aa.aa'+'.'*(n-7)
  temp[1]='a...bc.'+'.'*(n-7)
  temp[2]='....bcd'+'.'*(n-7)
  temp[3]='a..ee.d'+'.'*(n-7)
  temp[4]='abb..a.'+'.'*(n-7)
  temp[5]='.cc..ab'+'.'*(n-7)
  temp[6]='dd.aa.b'+'.'*(n-7)
  print(temp[0])
  print(temp[1])
  print(temp[2])
  print(temp[3])
  print(temp[4])
  print(temp[5])
  print(temp[6])
  for i in range(n//4-1):
    temp=['.'*n]*4
    temp[0]=temp[0][:4*i+7]+'aabd'+temp[0][(i+1)*4+7:]
    temp[1]=temp[1][:4*i+7]+'ccbd'+temp[1][(i+1)*4+7:]
    temp[2]=temp[2][:4*i+7]+'efgg'+temp[2][(i+1)*4+7:]
    temp[3]=temp[3][:4*i+7]+'efhh'+temp[3][(i+1)*4+7:]
    print(temp[0])
    print(temp[1])
    print(temp[2])
    print(temp[3])

Measured memory_bytes: 4468
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int> > vpii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;

map <string,int> ans;
int l=0;
int k=0;

int main(){
    string str;
    string a,b;
    while(cin>>str){
        if(str.size()>=l){
            b = str;
            l=str.size();
        }
        ans[str]++;
        if(ans[str]>=k){
            k=ans[str];
            a=str;
        }
    }
    cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 3168
def gcd(a,b):
    a,b=max(a,b),min(a,b)
    if b==0:
        return a
    c = a//b
    d = a%b
    if d==0:
        return b
    else:
        return gcd(b,d)


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


l = [0 for _ in range(n)]
l[0]=0
for i in range(1,n):#nums[i]左側の最大公約数を求める
    l[i]=gcd(l[i-1],nums[i-1])

r=[0 for _ in range(n)]
r[-1]=0
for i in reversed(range(0,n-1)):#nums[i]の右側の最大公約数を求める
    r[i]=(gcd(nums[i+1],r[i+1]))

ans=0
for i in range(n):
    saidaikouyakusu_except_for_ni=gcd(l[i],r[i])
    if ans < saidaikouyakusu_except_for_ni:
        ans = saidaikouyakusu_except_for_ni
    else:pass

print(ans)

Measured memory_bytes: 14436
#include "bits/stdc++.h"

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

int n;
vector<ll> A, B, C;

ll solve() {
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	ll ans = 0;
	for (int i = 0; i < n; i++) {
		auto a_ite = lower_bound(A.begin(), A.end(), B[i]);
		auto c_ite = upper_bound(C.begin(), C.end(), B[i]);

		ll cnt_a = 0, cnt_c = 0;
		cnt_a = distance(A.begin(), a_ite);
		cnt_c = distance(c_ite, C.end());
		ans += cnt_a * cnt_c;
	}

	return ans;
}

int main(void){
	cin>>n;
	A.resize(n); B.resize(n), C.resize(n);
	for (int i = 0; i < n; i++) cin>>A[i];
	for (int i = 0; i < n; i++) cin>>B[i];
	for (int i = 0; i < n; i++) cin>>C[i];

	cout<< solve() <<endl;
	
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

using namespace std;

int main() {
	
int n ;    
cin >> n ;
int x[n],y[n] ;
int ind[n]  ;

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

  double ans = 0 ; 
  int count = 0 ;
  do{
      ++count ;
    for(int i=0; i<(n-1); i++){
         //   cout<<ind[i];
         double tmp = 0;
         double tmp2 = (x[ind[i+1]]-x[ind[i]])*(x[ind[i+1]]-x[ind[i]])+(y[ind[i+1]]-y[ind[i]])*(y[ind[i+1]]-y[ind[i]]) ;
         tmp += sqrt(tmp2) ; 
        ans += tmp ;
        }
       // cout<<endl;
    }while(next_permutation(ind,ind+n));

   cout << setprecision(10) << fixed << (double) ans/count << endl ;
  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  cout << (n - 1) * (m - 1) << endl;
  return 0;
}

Measured memory_bytes: 256