akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

struct Edge {
    int l, r, cost;
};

struct Elem {
    int x, y, idx;
};

bool operator<(const Edge &a, const Edge &b) {
    return a.cost > b.cost;
}

bool cmp_x(const Elem &a, const Elem &b) {
    return a.x < b.x;
}

bool cmp_y(const Elem &a, const Elem &b) {
    return a.y < b.y;
}

// Union-Find 木 (Verified: AtCoder Typical Contest 001 B)
struct UnionFind {
private:
    const int n;
    int __size;
    vector<int> uf;
public:
    // 初期化 UnionFind uni(n) のように宣言すれば良い
    UnionFind(int _n) : n(_n), __size(_n), uf(_n, -1) {}
    // find (木の根を求める)
    int find(int x) {return (uf[x] < 0) ? x : uf[x] = find(uf[x]);}
    // x と y が同じ集合に属するかどうか
    bool same(int x, int y) {return find(x) == find(y);}
    // x が属する集合の要素数
    int size(int x) {return -uf[find(x)];}
    // 集合はいくつあるか
    int size()      {return __size;}
    // x と y の属する集合を併合
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return;
        __size--;
        if(uf[y] < uf[x]) swap(x, y);
        uf[x] += uf[y]; uf[y] = x;
    }
};

signed main() {
    int N; cin >> N;
    vector<Elem> vp(N);
    rep(i,0,N) {
        int x, y;
        cin >> x >> y;
        vp[i] = Elem{x, y, i};
    }

    priority_queue<Edge> q;
    // x
    sort(vp.begin(), vp.end(), cmp_x);
    rep(i,1,N) {
        int l = vp[i-1].idx, r = vp[i].idx;
        int c = vp[i].x - vp[i-1].x;
        q.push(Edge{l, r, c});
    }

    // y
    sort(vp.begin(), vp.end(), cmp_y);
    rep(i,1,N) {
        int l = vp[i-1].idx, r = vp[i].idx;
        int c = vp[i].y - vp[i-1].y;
        q.push(Edge{l, r, c});
    }

    // MST
    int ans = 0;
    UnionFind uf(N);
    while(!q.empty()) {
        Edge cur = q.top(); q.pop();
        if(uf.same(cur.l, cur.r)) continue;
        uf.unite(cur.l, cur.r);
        ans += cur.cost;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10864
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L, R = [0] * (n1 + 1), [0] * (n2 + 1)
    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]

    L[n1] = float('INF')
    R[n2] = float('INF')

    i, j = 0, 0
    reverse_cnt = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            reverse_cnt += n1 - i
            A[k] = R[j]
            j += 1
    return reverse_cnt


def merge_sort(A, left, right):
    cnt = 0
    if left + 1 < right:
        mid = (left + right) // 2
        cnt += merge_sort(A, left, mid)
        cnt += merge_sort(A, mid, right)
        cnt += merge(A, left, mid, right)
    return cnt


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    q = merge_sort(A, 0, N)
    print(q)


if __name__ == '__main__':
    main()



Measured memory_bytes: 26984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vector<ll>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	ll ans = 0;
	for (int i = 0; i < n - 1; i++) {
		if (v[i + 1] > v[i]) {

		}
		else {
			ans += abs(v[i] - v[i + 1]);
			v[i + 1] = v[i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 4780
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    bool a = 0;
    for (int i = 0; i < n/7+1; i++){
        if ((n-7*i)%4 == 0){
            a = 1;
            break;
        }
    }
    if (a == 1){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# 約数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)

    return divisors

def f(a,b):
    return max(len(str(a)), len(str(b)))

n = int(input())
divisors = make_divisors(n)
ans = float('INF')
#print(divisors)
for i in divisors:
    tmp = f(i, n//i)
    if tmp < ans:
        ans = tmp
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}

int A,B;

signed main(){
	cin >> A >> B;
	FOR(i,2,100000){
		int sum = A * i;
		int b = sum/B;
		int a = (sum-b*B)/A;
		int hasuu = sum-b*B-a*A;
		if(i < b+a+hasuu){cout<<sum<<endl;return 0;} 
	}
	cout<<-1<<endl;
}


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

int main(){
   int A,B,C;
   cin>>A>>B>>C;
   int K;
   cin>>K;
   int count = 0;
   for(int i=0;i<=K;i++){
       if(A>=B){
       B=B*2;
       count++;
       }
       if(A<B){
           break;
       }
   }
   for(int i=0;i<=K;i++){
       if(C<=B){
       C=C*2;
       count++;
       }
       if(B<C){
           break;
       }
   }
   if(A<B&&B<C&&count<=K){
       cout<<"Yes"<<endl;
   }else{
       cout<<"No"<<endl;
   }
   //cout<<A<<" "<<B<<" "<<C<<endl;;
   //cout<<count<<endl;
}

Measured memory_bytes: 3624
s = input()
l=len(s)
ans=[1]*l
for i in range(l-1):
    if s[i]==s[i+1]=="R":
        ans[i+2]+=ans[i]
        ans[i]=0
for i in range(l-1,1,-1):
    if s[i]==s[i-1]=="L":
        ans[i-2]+=ans[i]
        ans[i]=0
print(*ans)

Measured memory_bytes: 6400
#include <iostream>

using namespace std;

const double EPS = 1e-12;

double abs_d(double x) {
    return (x < 0 ? -x : x);
}

int main() {
    double x[4], y[4];
    while(cin>>x[0]>>y[0]) {
        for(int i=1; i<4; i++)
            cin >> x[i] >> y[i];

        double ab1 = x[1] - x[0];
        double ab2 = y[1] - y[0];
        double cd1 = x[3] - x[2];
        double cd2 = y[3] - y[2];
        double naiseki = ab1*cd1 + ab2*cd2;

        if(abs_d(naiseki) < EPS)
            cout << "YES" << "\n";
        else
            cout << "NO" << "\n";
    }

    return 0;
}

Measured memory_bytes: 1188
t;main(a,b,c){
    long int k;
    scanf("%d%d%d%ld",&a,&b,&c,&k);
    
    if(k%2){
        t=b-a;
    }else{
        t=a-b;
    }
    
    if(abs(a-b)>pow(10,18)){
        printf("Unfair");
    }else{
        printf("%d",t);
    }
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
ll n,m;
ll BIT[200005];
void add(ll x,ll y){
    while(x<=n){
        BIT[x]+=y;
        x+=(x&-x);
    }
}
ll sum(ll x,ll y){
    m=0;
    x--;
    while(y>=1){
        m+=BIT[y];
        y-=(y&(-y));
    }
    while(x>=1){
        m-=BIT[x];
        x-=(x&(-x));
    }
    return m; 
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    memset(BIT,0,sizeof(BIT));
    ll k,a;
    cin>>n>>k;
    vector<pair<ll,ll> > v;
    v.push_back({0,1});
    for(int i=1;i<=n;i++){
    	cin>>a;a-=k;
    	v.push_back({v[i-1].first+a,i+1});
    }
    sort(be(v));
    ll ans=0;
    for(auto& i:v){
    	ans+=sum(1,i.second-1);
    	add(i.second,1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7792
def f(array):
    temp = 'abcdefghijklmnopqrstuvwxyz'
    res = [0] * len(temp)
    cnt = 0
    for x in array:
        res[temp.index(x)] += 1
        cnt += 1
        if cnt == 10:
            break
    return ''.join([str(i) for i in res])

N = int(input())
s = [''.join(f(input())) for i in range(N)]

dic = {}
for i in range(N):
    if s[i] in dic:
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1

cnt = 0
for v in dic.values():
    cnt += v * (v - 1) // 2

print(cnt)





Measured memory_bytes: 76248
#include <bits/stdc++.h>
using namespace std;
static const int INF=9;

int main(){
  int N,M;
  cin>>N>>M;
  int E[N][N];
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i==j){
        E[i][j]=0;
      }
      else E[i][j]=INF;
    }
  }
  vector <pair<int,int>>vec(M);
  for(int i=0;i<M;i++){
    cin>>vec[i].first>>vec[i].second;
    E[vec[i].first-1][vec[i].second-1]=0;
    E[vec[i].second-1][vec[i].first-1]=0;   
  }
  
  /*for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cout<<E[i][j];
    }
    cout<<endl;
  }
  cout<<endl;
  */
  
  int ans=0;

  for(int i=0;i<M;i++){
    //辺を取り除く
    E[vec[i].first-1][vec[i].second-1]=INF;
    E[vec[i].second-1][vec[i].first-1]=INF;
    //辺の両端の距離を計算する
    for(int k=0;k<N;k++){
      for(int j=0;j<N;j++){
        for(int l=0;l<N;l++){
          if(E[j][l]>E[j][k]+E[k][l]) E[j][l]=E[j][k]+E[k][l];
        }
      }
    }
    
    for(int p=0;p<N;p++){
      for(int q=0;q<N;q++){
        if(E[p][q]==0) E[q][p]=0;
      }
    }
   
    //cout<<"&&"<<E[3][4]<<" "<<E[5][4]<<E[4][5]<<endl;
    if(E[vec[i].first-1][vec[i].second-1]==INF){
      ans++;
      //cout<<"#"<<vec[i].first-1<<" "<<vec[i].second-1<<endl;
    }
    //もとに戻す
    for(int p=0;p<N;p++){
      for(int q=0;q<N;q++){
              if(p==q){
        E[p][q]=0;
      }
      else E[p][q]=INF;
      }
    }
    
    for(int p=0;p<M;p++){
      E[vec[p].first-1][vec[p].second-1]=0;
      E[vec[p].second-1][vec[p].first-1]=0; 
    }
  }

  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
/* ****revpro**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll m,d;
		cin>>m>>d;
		if(d<22){
			cout<<0;
		}
		else {
			ll ans=0;
			rep(i,22,d+1){
				if((i%10>=2)&&((i/10)%10>=2)&&(((i%10)*(i/10))<=m)&&((i%10)!=0))
					ans++;
			}
			cout<<ans;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;

int a[100002], b[100002];
int main(){
	int n, k, ans = inf;
	scanf("%d%d", &n, &k);
	for(int i = 1;i <= n;i++)scanf("%d", &a[i]);
	
	int l = 0, r = 0, sum = 0;
	while(r <= n){
		if(sum == k)ans = min(ans, r-l);
		if(sum < k){
			r++;
			if(a[r] <= k){
				if(b[a[r]] == 0)sum++;
				b[a[r]]++;
			}
		}else{
			l++;
			if(a[l] <= k){
				b[a[l]]--;
				if(b[a[l]] == 0)sum--;
			}
		}
	}
	
	if(ans == inf)printf("0\n");
	else printf("%d\n", ans);
	return 0;
}


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

int gcd(int i , int j){
	if(i > j) swap(i,j);
	while(i*j != 0){
		j = j%i;
		swap(i,j);
	}
	return max(i,j);
}

int main() {
	int n,b,c; cin >>n>>b;
	for (int i = 0 ; i < n -1 ; i++){
		cin >>c;
		if(b > c) swap(b,c);
		b = gcd(b,c);
	} 
	cout << gcd(b,c) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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() {
    int n; cin >> n;
    vector<ll> A(n); rep(i, n) cin >> A[i];

    sort(all(A));
    ll ans[2] = {A[n-1], -1};
    ll half = ans[0]/ 2;
    bool fg = false;
    rep(i, n){
        ll num = A[i];
        if(num <= half) chmax(ans[1], num);
        else{
            ll tmp = ans[0] - num;
            if(ans[1] < tmp){
                ans[1] = num;
            }
            break;
            }
    }

    cout << ans[0] << " " << ans[1] << ln;
}

    

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] ai = new int[M];
        int[] bi = new int[M];
        int[] ci = new int[M];
        for (int i = 0; i < M; i++) {

            ai[i] = Integer.parseInt(sc.next());
            bi[i] = Integer.parseInt(sc.next());
            ci[i] = Integer.parseInt(sc.next());

        }
        sc.close();

        int max = 100000;

        //最大の距離は1000*99なのでintで足りるはず
        int[][] memo      = new int[N][N];//最短距離を記録するメモ

        //3重のfor文を用いて2点間の最小の値を探していくダイクストラ法
        for (int i = 0; i < N; i++) {

            for (int j = 0; j < N; j++) {

                if (i == j) {

                    memo[i][j] = 0;
                } else {

                    memo[i][j] = max;
                }
            }
        }
        //既知の経路を代入
        for (int i = 0; i < M; i++) {

            memo[ai[i]-1][bi[i]-1] = ci[i];
            memo[bi[i]-1][ai[i]-1] = ci[i];
        }

        //頂点1,2,・・N-1と頂点1+1,1+2,・・N,・2+1,2+2・・・N,・・・を結ぶ全パターンをメモ
        
        for (int n = 0; n < N; n++) {
        
            for (int i = 0; i < N; i++) {

                for (int j = 0; j < N; j++) {

                    for (int k = 0; k < N; k++) {

                        if (memo[i][j] > memo[i][k] + memo[j][k]) {

                            memo[i][j] = memo[i][k] + memo[j][k];
                            memo[j][i] = memo[i][k] + memo[j][k];
                        }

                    }
                }
            }
        }
        

        //使われなかった経路の本数
        int ans = 0;

        for (int i = 0; i < M; i++) {

            if (ci[i] > memo[ai[i]-1][bi[i]-1]) {

                ans++;
            }
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 26044
S = input()
S_1 = int(S[:2])
S_2 = int(S[2:])

YM_Flag = False
MY_Flag = False

if S_1 >= 1 and S_1 <= 12:
    MY_Flag = True

if S_2 >= 1 and S_2 <= 12:
    YM_Flag = True

if MY_Flag and YM_Flag:
    print('AMBIGUOUS')
elif MY_Flag:
    print('MMYY')
elif YM_Flag:
    print('YYMM')
else:
    print('NA')



Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
int n,m,cnt;
map<ll,int> mp;
ll ans;
int main()
{
	int i,s,a,b,j;
	ll k;
	scanf("%d",&n);mp[0]=1;
	for(i=1,k=0;i<=n;i++)scanf("%d",&a),k+=a,ans+=mp[k],mp[k]++;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 12800
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N + 1];
		Arrays.setAll(A, i -> sc.nextInt());
		int[] B = new int[N];
		Arrays.setAll(B, i -> sc.nextInt());
		sc.close();

		long ans = 0;
		for (int i = N - 1; i >= 0; i--) {
			int buster = Math.min(B[i], A[i + 1] + A[i]);
			int rest = Math.max(0, A[i] - Math.max(0, B[i] - A[i + 1]));
			ans += buster;
			A[i] = rest;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 65820
//By Bibi
///                 .-~~~~~~~~~-._       _.-~~~~~~~~~-.
///             __.'              ~.   .~              `.__
///           .'//                  \./                  \\`.
///        .'//                     |                     \\`.
///       .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \\`.
///     .'//.-"                 `-.  |  .-'                 "-.\\`.
///   .'//______.============-..   \ | /   ..-============.______\\`.
/// .'______________________________\|/______________________________`.
#include<bits/stdc++.h> 
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define dep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
int read()
{
	int sum=0,flag=1;
	char c;
	for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0';
	return sum*flag;
}
int a,b;
void init()
{
	a=read();b=read();
}
int huiwenshu(int n)  
{  
    int num=0;  
    while(n)  
    {  
        num=num*10+n%10;  
        n=n/10;  
    }  
    return num;  
}  
int ans;
void work()
{
	rep(i,a,b)
	{
		int m=huiwenshu(i);
		if(m==i) ans++;
	}
}
int main()
{
	init();
	work();
	printf("%d",ans);
	return 0;
}

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

int main()
 {
 	int i,n,s,j,f=0;
 	string w;
 	cin>>w;
 	int l=w.length();
 	int v[200]={0};
 //	vector<int>v;
 //	v.assign(l,0);
 	for(i=0;i<l;i++)
 	{
 		for(j=97;j<=122;j++)
 			{
 				if(w[i]==j)
 					v[j]++;
			 }
	 }
	 for(i=97;i<123;i++)
	 	{
	 		if(v[i]%2!=0)
	 		{
	 			f=1;
	 			break;
			 }
		 }
		 if(f==0)
			 cout<<"Yes"<<endl;
		 else
		 	cout<<"No"<<endl;
 }

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int n,k,arr[55],sum;
int main(){
	cin>>n>>k;
	for(int i=0; i<n; i++) cin>>arr[i];
	sort(arr, arr+n);
	for(int i=0; i<k; i++) sum += arr[n-1-i];
	cout<<sum<<endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        ArrayList<String> name = new ArrayList<>();
        ArrayList<Integer> time = new ArrayList<>();

        int numberProc = inp.nextInt();
        int quantity = inp.nextInt();

        for (int i = 0; i < numberProc; i++) {
            name.add(inp.next());
            time.add(inp.nextInt());
        }

        int finalCount = 0;

        int finalplaceholder = 0;

        String[] finalName = new String[100005];
        int[] finalTime = new int[100005];

        while (!name.isEmpty()) {
            String tempholdName = name.get(0);
            int tempholdTime = time.get(0);

            name.remove(0);
            time.remove(0);

            if (tempholdTime <= quantity) {
                finalCount += tempholdTime;

                finalName[finalplaceholder] = tempholdName;
                finalTime[finalplaceholder] = finalCount;

                finalplaceholder++;
            } else {
                name.add(name.size(), tempholdName);
                time.add(time.size(), (tempholdTime-quantity));

                finalCount += quantity;
            }
        }

        for (int i = 0; i < finalName.length; i++) {
            if (finalName[i] != null) {
                System.out.println(finalName[i] + " " + finalTime[i]);
            } else {
                break;
            }
        }
    }
}



Measured memory_bytes: 75516
#include <stdio.h>
int main(void){   
    // Your code here!   
    int H,W;     
    while(1){         
        scanf("%d%d", &H, &W);     
        if(H == 0 && W == 0) return(0);       
        
        int i;   
        for(i=0; i < H; i++)   
        {    
            int j;   
            for(j=0; j < W; j++)   
            {   
                if((i+j) % 2 == 0)  
                putchar('#');   
                else   
                putchar('.');   
            }     
            if(i < H-1) putchar('\n');   
            else{   
            putchar('\n');   
            putchar('\n');    
                
            }    
            
        }    
    }   return 0;   
    
} 



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

using namespace std;

int main() {
int n , ans = 0 ; 
cin>>n ;  
string str ; 
cin>>str ; 

for (int i=2 ;  i<n  ; i++)
{
    if (str[i]== 'C')
         if ((str[i-2] =='A')&& (str[i-1] =='B' ) )
             ans++ ; 
   
}
cout<<ans<<endl ; 
}

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

int main() {
    
    int n,m;
    cin>>n>>m;
    vector<vector<int>> dp(n+1, vector<int> (m+1 , 100000));
    vector<string> str(n);
    for(int i=0;i<n;i++)
        cin>>str[i];

    dp[1][1] = (str[n-1][m-1] == '#') ? 1: 0;

    for(int i=1;i<=n;i++)
    {
        for(int j = 1; j<=m; j++)
        {
            if(i == 1 && j == 1)
                continue;
            else if( i == 1)
                dp[i][j] = dp[i][j-1] + (str[i-1][j-2] == '#' && str[i-1][j-1] == '.');
            else if( j == 1)
                dp[i][j] = dp[i-1][j] + (str[i-2][j-1] == '#' && str[i-1][j-1] == '.');
            else
            {
                dp[i][j] = min( dp[i][j], dp[i][j-1] + (str[i-1][j-2] == '#' && str[i-1][j-1] == '.'));
                dp[i][j] = min( dp[i][j], dp[i-1][j] + (str[i-2][j-1] == '#' && str[i-1][j-1] == '.'));
            }
        }
    }

    cout<<dp[n][m]<<endl;

    return 0;                          
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>

using namespace std;

int main() {
    int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    int n, s, sum, cnt;

    while (cin >> n >> s) {
        if (!n && !s) { break; }
        cnt = 0;
        for (int i = 0; i < (1 << 10); i++) {
            sum = 0;
            for (int j = 0; j < 10; j++) {
                if (i & (1 << j)) {
                    sum += a[j];
                }
            }
            if (sum == s && bitset<10>(i).count() == n) { cnt++; }
        }
        cout << cnt << endl;
    }
    return 0;
}

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

int main(){
  int n;
  while(cin>>n){
    int array[n];
    int sum=0,sum2=0;
    for(int i=0;i<n;i++)
      cin>>array[i];
    sort(array,array+n);
    for(int i=0;i<n;i++){
      sum+=array[i];
      sum2+=sum;
    }
    //   for(int i=0;i<n;i++)
    // cout<<array[i]<<endl;
    cout<<sum2<<endl;
  }

}

Measured memory_bytes: 1176
# history :: {int : (int, bool)}
n, m = [int(x) for x in input().split()]
history = { i+1 : [0, False] for i in range(n)}

for _ in range(m):
  pi, result = input().split()
  translated_pi = int(pi)
  if result == 'WA' and not history[translated_pi][1]:
    history[translated_pi][0] += 1
  else:
    history[translated_pi][1] = True

ac_count = 0
penalty_count = 0
for result in history.values():
  if result[1]:
    ac_count += 1
    penalty_count += result[0]

print("{} {}".format(ac_count, penalty_count))

Measured memory_bytes: 23204
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define maxn 200001
const ll inf=1e9+7;
#define pb push_back
#define PI 3.14159265
#define watch(x) cerr << (#x) << " is " << (x) << endl;
void solve();
void sieve();
int main()
{
	//sieve();
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<fixed;
	cout<<setprecision(10);
	
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}
ll pr[1001];
vector<ll> prime;
void sieve()
{
	pr[0]=-1;
	pr[1]=-1;
	ll i,j;
	for(i=2;i<1001;i++)
	{
		if(pr[i]!=-1)
		{
			pr[i]=1;
			for(j=2;j<1001/i+1;j++)
			{
				if(i*j<1001)
				pr[i*j]=-1;
			}
		}
	}
	for(i=2;i<1001;i++)
	{
		if(pr[i]==1)
		prime.pb(i);
	}
}
		
bool pal(string s)
{
	string t=s;
	reverse(s.begin(),s.end());
	return (t==s);
}
ll countdig(ll x)
{
	ll c=0;
	if(x==0)
	return 1;
	
	while(x!=0)
	{
		c++;
		x/=10;
	}
	return c;
}
bool isprime(ll x)
{
	bool flag=true;
	for(ll i=2;i<=sqrt(x)+1;i++)
	{
		if(x%i==0)
		{
			flag=false;
			break;
		}
	}
	if(x==1)
	flag=false;
	
	return flag;
}
void swap(ll& a,ll& b)
{
	ll t=a;
	a=b;
	b=t;
}
void solve()
{
	char x;
	cin>>x;
	if(x>='A'&&x<='Z')
	cout<<'A';
	else
	cout<<'a';
}
	


Measured memory_bytes: 3696
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10;

bool seen[N];
int l[N], r[N];
pii sm_r[N], lr_l[N];

ll solve(int n);
int dist(int& x, int l, int r);

int main() {
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> l[i] >> r[i];
	}
	ll ans = solve(n);
	for (int i = 1; i <= n; ++i) {
		tie(l[i], r[i]) = make_pair(-r[i], -l[i]);
	}
	cout << max(ans, solve(n));
}

ll solve(int n) {
	memset(seen, 0, sizeof(seen));
	for (int i = 1; i <= n; ++i) {
		lr_l[i] = {l[i], i};
		sm_r[i] = {r[i], i};
	}
	sort(lr_l + 1, lr_l + n + 1, greater<pii>());
	sort(sm_r + 1, sm_r + n + 1);
	int x = 0, p1 = 1, p2 = 1;
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (i & 1) {
			while (seen[lr_l[p1].second]) {
				++p1;
			}
			int ind = lr_l[p1].second;
			ans += dist(x, l[ind], r[ind]);
			seen[ind] = true;
		} else {
			while (seen[sm_r[p2].second]) {
				++p2;
			}
			int ind = sm_r[p2].second;
			ans += dist(x, l[ind], r[ind]);
			seen[ind] = true;
		}
	}
	return ans + abs(x);
}

int dist(int& x, int l, int r) {
	int ans = 0;
	if (x < l) {
		ans = l - x;
		x = l;
	} else if (x > r) {
		ans = x - r;
		x = r;
	}
	return ans;
}

Measured memory_bytes: 2688
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> X(M);
	REP(i, M) cin >> X[i];
	sort(X.begin(), X.end());

	vector<int> Y(M - 1);
	REP(i, M - 1) Y[i] = abs(X[i + 1] - X[i]);
	sort(Y.begin(), Y.end());

	int sum = 0;
	REP(i, M - N) sum += Y[i];
	cout << sum << endl;
	return 0;
}


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

int main(){
    string s,p;
    cin >> s >> p;
    s = s + s;
    if(s.find(p) != -1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3220
import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))

pay = [abs(a[0])]
dis = [a[0]]
for i in range(len(a) - 1):
    pay.append(abs(a[i + 1] - a[i]))
    dis.append(a[i + 1] - a[i])
pay.append(abs(0 - a[-1]))
dis.append(0 - a[-1])
summ = sum(pay)

for i in range(n):
    ans = summ - (pay[i] + pay[i + 1]) + abs(dis[i] + dis[i + 1])
    print(ans)


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

int main() {
    int n, k;
    cin >> n >> k;
    
    vector<int> p(n,0);
    rep(i,n) cin >> p[i];
    sort(p.begin(),p.end());
    long long ans = 0;
    rep(i,k) ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 120000;

vector<int> eds1[MAXN * 5];
vector<int> eds[MAXN * 5];
vector<pair<int, int> > ed[1001000];
int was[MAXN * 5];
int n;
int m;
int dd[MAXN * 5];

void dfs1(int v, int c) {
	eds[v].push_back(c);
	eds[c].push_back(v);
	was[v] = 1;
	for (int u: eds1[v]) {
		if (!was[u])
			dfs1(u, c);
	}
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		--a, --b, --c;
		ed[c].push_back(make_pair(a, b));
	}
	int cc = n;
	for (int i = 0; i < 1000010; ++i) {
		if (ed[i].empty())
			continue;
		vector<int> vv;
		for (auto p: ed[i]) {
			vv.push_back(p.first);
			vv.push_back(p.second);
		}
		sort(vv.begin(), vv.end());
		vv.resize(unique(vv.begin(), vv.end()) - vv.begin());
		for (int j: vv)
			eds1[j].clear(), was[j] = 0;
		for (auto p: ed[i]) {
			eds1[p.first].push_back(p.second);
			eds1[p.second].push_back(p.first);
		}
		for (int j: vv) {
			if (!was[j]) {
				dfs1(j, cc);
				++cc;
			}
		}
	}
	for (int i = 0; i < cc; ++i)
		dd[i] = MAXN * 10;
	dd[0] = 0;
	queue<int> qu;
	qu.push(0);
	while (!qu.empty()) {
		int x = qu.front();
		qu.pop();
		for (int y: eds[x]) {
			if (dd[y] > dd[x] + 1) {
				dd[y] = dd[x] + 1;
				qu.push(y);
			}
		}
	}
	if (dd[n - 1] == MAXN * 10)
		cout << -1 << "\n";
	else
		cout << dd[n - 1] / 2 << "\n";
	return 0;
}




Measured memory_bytes: 72576
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define double long double
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = 998244353 ;
#define MAX 300100

multiset<ll> all;
void deal(){
	ll l , r;
	cin>>l>>r;
	for(ll i = l ; i<=min(r, l + 5050); i++)
		all.insert(i%2019);
	auto it = all.begin();
	ll mn = inf;
	while(it!=all.end()){
		auto it1 = all.begin();
		while(it1!=all.end()){
			if(it == it1){
				++it1;
				continue;
			}
			mn = min(mn, ((*it1) * (*it)) % 2019);
			++it1;
		}
		++it;
	}
	cout<<mn;
}


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

Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifndef ONLINE_JUDGE
#define debug(a) cout<<#a<<" --> "<<(a)<<"\n";
#define debug2(a) cout<<#a<<" --> "<<(a)<<" ";
#define HERE cout<<"here - "<<__LINE__<<"\n";
#else
#define debug(a)
#define debug2(a)
#define HERE
#endif
const ll mod = 100000007;
const int N = 15;
typedef pair<int,int> pii;

void TEST_CASES(int cas)
{
    string s;
    cin>>s;
    if(s[0]>='A' && s[0]<='Z')
    {
        printf("A\n");
    }
    else{
        printf("a\n");
    }
}


/*
*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int n;
    cin >> n;

    for(int i = 0;i < n/7 + 1;i++){
        for(int j = 0;j < n/4 + 1;j++){
            if(7 * i + 4 * j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using lli = long long;

lli A, B, N;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> A >> B >> N;
	cout << (A * min(B - 1, N)) / B;
}

Measured memory_bytes: 3636
import java.util.Scanner;
 
public class Main {
    Scanner sc = new Scanner(System.in);
    void run(){
        for(;;){
            int n = sc.nextInt();
            if(n == 0){
                break;
            }
            int sum = 0;
            int min = 1000;
            int max = 0;
            for(int i =0 ; i< n ; i++){
                int x = sc.nextInt();
                max = Math.max(x,max);
                min = Math.min(x, min);
                sum += x;
            }
            System.out.println((sum-min-max)/(n-2));
        }
         
    }
    public static void main(String[] args) {
        Main m = new Main();
        m.run();
    }
}


Measured memory_bytes: 28992
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,q;
int a[110];
int main(){
	while(1){
		cin>>n>>q;
		if(n==0&&q==0)break;
		for(int i=0;i<110;i++){
			a[i]=0;
		}
		for(int i=0;i<n;i++){
			int m;
			cin>>m;
			for(int j=0;j<m;j++){
				int t;
				cin>>t;
				a[t]++;
			}
		}
		int ans=0;
		for(int i=1;i<110;i++){
			if(a[i]>=q&&a[i]>a[ans]){
				ans=i;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,t = 1;
  cin >> n >> k;
  for (int i = 0; i < n; i++){
    if (t*2 < t+k) {
      t = t*2;  
    } else {
      t = t+k;
    }
  }
  cout << t << endl;
}

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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

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

int main()
{

	int n, tt;
	cin >> n >> tt;

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

	int maxx = -1;
	int ans = 0;
	vector<int> d(n);
	int delta = 0;
	for (int i = n - 1; i >= 0; --i) {
		maxx = max(maxx, a[i]);
		d[i] = maxx - a[i];
		delta = max(delta, d[i]);
	}

	for (int i = 0; i < n; ++i) {
		if (d[i] == delta) {
			++ans;
		}
	}

	cout << ans << "\n";

}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int n,i;
    char s[101],t[101],ans[201];
    scanf("%d",&n);
    scanf("%s %s",s,t);
    for (i=0;i<n;i++){
        ans[2*i]=s[i];
        ans[2*i+1]=t[i];
    };
    ans[2*n]='\0';
    printf("%s",ans);
    return 0;
};


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

int main(){
  char T;
  cin>>T;
  if(T=='T'){
    cout<<"A"<<endl;
    return 0;
  }
  if(T=='A'){
    cout<<"T"<<endl;
    return 0;
  }
  if(T=='C'){
    cout<<"G"<<endl;
    return 0;
  }
  if(T=='G'){
    cout<<"C"<<endl;
    return 0;
  }
  
  
   return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B;
    cin >> A >> B;
    cout << A*B << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MaxN = 100003;
int n,m;
vector<int> e[MaxN];
int color[MaxN];
bool paint(int x,int c) {
    color[x]=c;
    int nxt=3-c;
    for (auto i:e[x]) {
        if (!color[i]) if (!paint(i,nxt)) return false;
        if (color[i]!=nxt) return false;
    }
    return true;
}
int main() {
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;++i) {
        int u,v;
        scanf("%d%d",&u,&v);
        e[u].push_back(v),e[v].push_back(u);
    }
    if (!paint(1,1)) printf("%lld\n",(LL)n*(n-1)/2-m);
    else {
        int cnt[3]={0,0,0};
        for (int i=1;i<=n;++i) cnt[color[i]]++;
        printf("%lld\n",(LL)cnt[1]*cnt[2]-m);
    }
    return 0;
}

Measured memory_bytes: 6528
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    int H[] = new int[N];
    for(int i=0; i<N; i++) H[i] = sc.nextInt();
    boolean check = true;
    for(int i=N-2; i>=0; i--){
      if(H[i] - H[i+1] > 1){
        check = false;
        break;
      }
      if(H[i] > H[i+1]) H[i]--;
    }
    if(check) out.println("Yes");
    else out.println("No");
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m ;
  cin >> n >> m ;
  if(m<=2*n){
    cout << m/2 <<endl ;
  }
  else{
    cout << n+(m-2*n)/4 <<endl ;
  }
  
  
  
  return 0 ;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	REP(i, n) {
		cin >> h[i];
	}
	h.push_back(INT_MAX);
	int res = 0, con = 1;
	REP(i, n) {
		if (h[i] >= h[i + 1]) {
			con++;
		} else {
			chmax(res, con);
			con = 1;
		}
	}
	put(res-1);
	return 0;
}

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

int main()
{
	int H=0 , W=0 ;
	while(true)
	{
		cin >> H >> W ;
		if(H==0&&W==0) break ;

		for(int i=0 ; i<H ; i++)
		{
			for(int ii=0 ; ii<W ; ii++)
			{
				if(i==0 || ii==0 || i==H-1 || ii==W-1)
				{
					cout << "#" ;
				}
				else
				{
					cout <<  "." ;
				}
			}
			cout << endl ;
		}
		cout << endl ;
	}
	return 0 ;
}



Measured memory_bytes: 3100
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
  vector<vector<bool>>d(5001,vector<bool>(5001));
int main(){
  string a;cin>>a;
  ll ans=0;
  for(ll i=0;i<a.size();i++){
    for(ll o=0;o<a.size()-i;o++){
      ll b=0;
      for(ll j=i;j<a.size()-o;j++){
        b++;
        if(a[j]!='A'&&a[j]!='T'&&a[j]!='C'&&a[j]!='G'){
          b=0;
          break;
        }
      }
      ans=max(ans,b);
    }
  }
  cout<<ans;
}



Measured memory_bytes: 30176