akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
#define INF 4000
typedef pair<int,int> p;
int xs[] = {0, 1, 0, -1}, ys[] = {1, 0, -1, 0};
int x, y;
int field[55][55];
bool dp[55][55][55][55];

int main(){
  int tx, ty, kx, ky;
  while(true){
    scanf("%d%d", &x, &y);
    memset(dp, false, sizeof(dp));
    memset(field, -1, sizeof(field));
    if(x == 0 && y == 0) return 0;
    scanf("%d%d", &tx, &ty);
    scanf("%d%d", &kx, &ky);
    for(int i = 1;i <= y;i++){
      for(int j = 1;j <= x;j++){
	scanf("%d", &field[j][i]);
      }
    }
    int ans = 0;
    bool fin = false;
    queue<pair<p, p> > q;
    q.push(make_pair(p(tx, ty), p(kx, ky)));
    dp[tx][ty][kx][ky] = true;
    while(!q.empty() && !fin && ans < 105){
      int len = q.size();
      ans++;
      while(len-- && !fin){
	pair<p, p> tmp;
	tmp = q.front();
	q.pop();
	for(int i = 0;i < 4;i++){
	  tx = tmp.first.first + xs[i];
	  ty = tmp.first.second + ys[i];
	  kx = tmp.second.first - xs[i];
	  ky = tmp.second.second - ys[i];
	  if(field[tx][ty] != 0){
	    tx = tmp.first.first;
	    ty = tmp.first.second;
	  }
	  if(field[kx][ky] != 0){
	    kx = tmp.second.first;
	    ky = tmp.second.second;
	  }
	  if(dp[tx][ty][kx][ky])continue;
	  dp[tx][ty][kx][ky] = true;
	  q.push(make_pair(p(tx, ty), p(kx, ky)));
	  if(tx == kx && ty == ky){
	    fin = true;
	    break;
	  }
	}
      }
    }
    if(!fin || ans >= 100)
      puts("NA");
    else
      printf("%d\n", ans);
  }
}

Measured memory_bytes: 10172
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String O = sc.next();
    	String E = sc.next();
    	StringBuilder sb = new StringBuilder();
    	for (int i = 0; i < E.length(); i++) {
    		sb.append(O.charAt(i)).append(E.charAt(i));
    	}
    	if (O.length() != E.length()) {
    		sb.append(O.charAt(O.length()-1));
    	}
    	System.out.println(sb);
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,e,z[4][13]={{1,2,3,4,5,6,7,8,9,10,11,12,13},{1,2,3,4,5,6,7,8,9,10,11,12,13},{1,2,3,4,5,6,7,8,9,10,11,12,13},{1,2,3,4,5,6,7,8,9,10,11,12,13}};
  // int s=0,h=0,c=0,d=0;
  string b;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b>>e;
    if(b=="S"){
      for(int j=0;j<13;j++){
	if(z[0][j]==e){
	  z[0][j]=z[0][j]-e;
	}
      }
    }
      if(b=="H"){
	for(int j=0;j<13;j++){
	  if(z[1][j]==e){
	    z[1][j]=z[1][j]-e;
	  }
	}
      }
	if(b=="C"){
	  for(int j=0;j<13;j++){
	    if(z[2][j]==e){
	      z[2][j]=z[2][j]-e;
	    }
	  }
	}
	  if(b=="D"){
	    for(int j=0;j<13;j++){
	      if(z[3][j]==e){
		z[3][j]=z[3][j]-e;
	      }
	    }
	  }
  }
  for(int i=0;i<4;i++){
    for(int j=0;j<13;j++){
      if(z[i][j]!=0){
	if(i==0){
	  cout<<"S "<<z[i][j]<<"\n";
	}
	if(i==1){
	  cout<<"H "<<z[i][j]<<"\n";
	}
	if(i==2){
	  cout<<"C "<<z[i][j]<<"\n";
	}
	if(i==3){
	  cout<<"D "<<z[i][j]<<"\n";
	}
      }
    }
  }
  return(0);
}


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

int gcd(int a,int b) {
  if (a>b) {
    swap(a,b);
  }
  if (b%a == 0) {
    return a;
  }
  return gcd(b%a,a);
}

int main() {
  int N,M;
  cin >> N >> M;
  int ansl = 1;
  int ansr = N;
  int l,r;
  for (int i=0; i<M; i++) {
    cin >> l >> r;
    ansl = max(ansl,l);
    ansr = min(ansr,r);
  }
  if (ansl > ansr) {
    cout << 0 << endl;
    return 0;
  }
  cout << ansr-ansl+1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#include<ctype.h>
char ch[5];

int main(){
scanf("%[^\n]", &ch);
if((ch[0]==ch[1])&&(ch[1]!=ch[2])||((ch[1]==ch[2])&&ch[0]!=ch[1])||(ch[0]==ch[2]&&ch[0]!=ch[1]))
        printf("Yes");
else
    printf("No");

return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	s := Scanner()
	w := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		if string(s[i]) == "." {
			w[i] = 1
		} else {
			b[i] = 1
		}
	}
	for i := 1; i < n; i++ {
		b[i] = b[i-1] + b[i]
	}
	for i := n - 2; i >= 0; i-- {
		w[i] = w[i+1] + w[i]
	}
	ans := make([]int, n-1)
	for i := 0; i < n-1; i++ {
		ans[i] = b[i] + w[i+1]
	}
	ans = append(ans, w[0])
	ans = append(ans, b[n-1])
	fmt.Println(min(ans))
}
func min(x []int) int {
	ret := x[0]
	for _, v := range x {
		if v < ret {
			ret = v
		}
	}
	return ret
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	double a, b, x;
	cin >> a >> b >> x;
	double tha = atan2(b, a);

	double l = 0.0, r = M_PI / 2.0;
	rep(i, 0, 10000)
	{
		double mid = (l + r) / 2.0;
		double v;
		if (mid < tha)
		{
			v = a * a*b - a * a * a*tan(mid) / 2.0;
		}
		else
		{
			v = b * b*tan(M_PI / 2.0 - mid)*a / 2.0;
		}
		if (v > x)
		{
			l = mid;
		}
		else
		{
			r = mid;
		}
	}

	cout << fixed << setprecision(10) << l / M_PI * 180.0 << endl;

	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
A = list(map(int, input().split()))

import fractions
#import math
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
    #return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
    #return reduce(math.gcd, numbers)

g = gcd_list(A)
if k%g == 0 and max(A) >= k:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(){
  int64_t N, K;
  cin >> N >> K;
  int64_t ans = K;
  
  rep(i, N - 1) ans *= K - 1;
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

int main(){
    int n;
    cin >> n;
    vector<bool> f(1001000, false);
    vi a(n);
    int cnt_1 = 0;
    rep(i, n) {
        cin >> a[i];
        f[a[i]] = true;
        if(a[i] == 1) cnt_1++;
    }
    if(cnt_1 == 1) {
        cout << 1 << endl;
        return 0;
    }
    if(cnt_1 > 1) {
        cout << 0 << endl;
        return 0;
    }
    Sort(a);
    bool flag = true;
    int ans = 0;
    rep(i, n) {
        if(i != n-1)
        if(a[i] == a[i+1]) continue;
        if(i != 0) {
            if(a[i] == a[i-1]) continue;
        }
        const auto &ret = enum_div(a[i]);
        for(auto p : ret) {
            //cout << a[i] << p;
            if(f[p]) {
                flag = false;
                break;
            }
        }
        //cout << endl;
        if(flag) ans++;
        flag = true;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4248
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define size(s) s.size()
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	int n;
	pii a[100100];
	cin>>n;
	REP(i,n)
	{
		int x;
		cin>>x;
		a[i]=make_pair(x,i);
	}
	sort(a,a+n);
	/*REP(i,n)
	{
		cout<<a[i].X<<" "<<a[i].Y<<endl;
	}*/
	int cnt=0;
	REP(i,n)
	{
		if((abs(a[i].Y-i))%2==1)cnt++;
	}
	cout<<cnt/2<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    double n,a,t;
    cin >> n >> t >> a;

    vector<double> h(n);
    for(auto &x:h)cin >> x;

    double best=inf,bestpt=-1;
    for(int i=0;i<n;i++){
        double temp=t-h[i]*0.006;
        if(best>abs(a-temp)){
            best=abs(a-temp);
            bestpt=i;
        }
    }

    cout << bestpt+1 << endl;

    return 0;
}


Measured memory_bytes: 3720
#include<stdio.h>
#define N 100

int main () {
	int count, i, tmp, n, A[N], flag;

	count = 0;

	scanf("%d", &n);

	for ( i = 0;i < n; i++ ) {
		scanf("%d", &A[i]);
	}

	flag = 1;
	while ( flag ) {
		flag = 0;
		for ( i = 1;i < n; i++ ) {
			if ( A[i] < A[i - 1] ) {
				tmp = A[i];
				A[i] = A[i - 1];
				A[i - 1] = tmp;
				count++;
				flag = 1;
			}
		}
	}
	for ( i = 0; i < n; i++ ) {
		printf("%d", A[i]);
		if( i < n-1 )
			putchar(' ');
	}
	printf("\n");
	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 1968
N, X, M = map(int, input().split())

isUsed = [False] * M
isUsed[X] = True
S = [X]
st = X
while True:
    nx = X**2 % M
    if isUsed[nx]:
        st = nx
        break
    isUsed[nx] = True
    S.append(nx)
    X = nx

idx = S.index(st)
L, R = S[:idx], S[idx:]

ans = sum(L[:N])
N = max(0, N - len(L))

q, r = divmod(N, len(R))
ans += q * sum(R) + sum(R[:r])

print(ans)

Measured memory_bytes: 12432
#pragma GCC optimize("O3")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>ll(b);i--)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
#define INF 1000000000000 
#define MOD 1000000007 
#define MAXR 100000 
#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 
#define Umap unordered_map
#define Uset unordered_set


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

    ll N, Q;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    cin >> Q;

    ll sum = 0;
    vector<ll> kosu(2 + 10e+5, 0);
    FOR(i, 0, N) {
        kosu[A[i]]++;
        sum += A[i];
    }

    REP(i, Q) {
        ll B, C;
        cin >> B >> C;
        sum += (C-B) * kosu[B];
        cout << sum << endl;
        kosu[C] += kosu[B];
        kosu[B] = 0;
        
    }



    return 0;
}

Measured memory_bytes: 11888
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        if(A==B){
            System.out.println(C);
        }else if(A==C){
            System.out.println(B);    
        }else{
            System.out.println(A);    
    }         
}
}

Measured memory_bytes: 35736
//繝・Φ繝励Ξ
#include <bits/stdc++.h>
//#define int long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define FOR(i,a,b)  for(int i = (a); i <= (b); ++i)
#define ALL(v) (v).begin(),(v).end()
#define PAIR pair<int,int>
using namespace std;
//constexpr int MOD = 10e9+7;
//constexpr int INF = 1LL << 60;
template <class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}  
template <class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}  
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
//



signed main (){
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   int N;
   cin >> N;
   int C[N-1];
   int S[N-1];
   int F[N-1];
   REP(i,N-1)
   {
      cin >> C[i] >> S[i] >> F[i];
   }
   int t[N];

   REP(i,N)
   {
      int t=0;
      for(int j = i;j<N-1;j++)
      {
         if(S[j] > t)
         {
            t +=S[j]-t+C[j];
         } else if(t%F[j] == 0)
         {
            t+=C[j];  
         } else
         {
            t += F[j] -t%F[j] + C[j];
         }
         
      }
      cout << t << endl;      
   }
}



//驛ｨ蛻・・譛蟆丞､
//譖ｴ譁ｰ縺励↑縺・ｴ蜷遺・邏ｯ遨阪ｏ
//莠梧ｬ｡蜈・↓縺励◆縺・・縺・ｂ縺呎ｳ・
//荳邂・園繧剃ｽ募屓繧よ峩譁ｰ縺励◆縺・・Segment Tree(縺溘□縺怜叙蠕涌(logN))
//遽・峇繧剃ｽ募屓繧よ峩譁ｰ縺励◆縺・・Lazy Segment Tree


Measured memory_bytes: 256
#include <stdio.h>

void swap(int *, int *);

int main(void)
{
	int N, M, i, k;
	
	scanf("%d %d", &N, &M);
	int A[N];
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	for (k = 1; k <= M; k++) {
		for (i = 0; i < N-1; i++) {
			if (A[i] % k > A[i+1] % k) {
				swap(&A[i], &A[i+1]);
			}
		}
	}
	for (i = 0; i < N; i++) {
		printf("%d\n", A[i]);
	}
	
	return 0;
}

void swap(int *x, int *y)
{
	int tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
}

Measured memory_bytes: 596
import java.util.*;
import java.io.*;
class Item {
	int weight,val;
	public Item(int weight, int val) {
		this.weight = weight;
		this.val = val;
	}
}
public class Main {


	public static void main(String[] args) {
		Main ans = new Main();
		System.out.println(ans.solve());
	}

	private long solve() {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int maxWeight = sc.nextInt();
		Item [] array = new Item[N+1];
		for(int i=1;i<=N;i++) {
			array[i] = new Item(sc.nextInt(), sc.nextInt());
		}
		int maxValue = N*1000;
		long [][] dp = new long[N+1][maxValue+1];

		for(int val=0;val<=maxValue;val++) { 
			dp[1][val] = (int) (1e9+1);
		}

		dp[1][array[1].val] = array[1].weight;
		dp[1][0] = 0;

		for(int i=2;i<=N;i++){
			for(int val=0;val<=maxValue;val++) {
				dp[i][val] = dp[i-1][val];

				if (val<array[i].val) continue;
				dp[i][val] = Math.min(dp[i-1][val], array[i].weight+ dp[i-1][val-array[i].val]);
			}
		}

		long bestTotalValue=0;
		for(int val=0;val<=maxValue;val++) {
			if (dp[N][val]<=maxWeight) {
				bestTotalValue = Math.max(bestTotalValue, val);
			}
		}
		return bestTotalValue;
	}

}

Measured memory_bytes: 140040
import sys
readline = sys.stdin.buffer.readline


class SegmentTree:
    def __init__(self, N, func, I):
        self.N = N
        self.sz = 2**(N-1).bit_length()
        self.func = func
        self.I = I
        self.seg = [I] * (self.sz * 2)

    def assign(self, k, x):
        self.seg[k + self.sz] = x

    def build(self):
        for i in reversed(range(1, self.sz)):
            self.seg[i] = self.func(self.seg[i * 2], self.seg[i * 2 + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[k * 2], self.seg[k * 2 + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        if b == self.N:
            b = self.sz * 2
        else:
            b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)


def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(readline())
    L = map(int, readline().split())
    seg = SegmentTree(N, gcd, 0)
    for i, n in enumerate(L):
        seg.assign(i, n)
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N)))
    print(ans)


main()

Measured memory_bytes: 60528
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef LOCAL
    #define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define debug(...) 42
    #define eprintf(...) 42
#endif

#define PI 3.1415926535897932384626433832795
#define INF 2e9
#define SINV(t) greater<t>()
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()

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

typedef long long ll;
#define vv(t) vector< t > 

#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))

template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}

#pragma endregion

template<typename T>
void SV(vector<T> v){
    #ifdef LOCAL
        REP(i,v.size()){
                cout << i << " : " << v[i] << endl;
        }
    #endif
}

template<typename T>
void SV(map<int, T> v){
    #ifdef LOCAL
        FOREACH(i, v){
            cout << i.first << " : " << i.second << endl;
        }
    #endif
}
int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}

int main(void){
    int N, M;
    cin >> N >> M;
    string s;
    vv(ll) img(N), tpl(M);
    REP(i, N){
        cin >> s;
        REP(j, N){
            if(s[j]=='#'){
                img[i]|=1ll<<j;
            }
        }
    }
    REP(i, M){
        cin >> s;
        REP(j, M){
            if(s[j]=='#'){
                tpl[i]|=1ll<<j;
            }
        }
    }
    ll mask=~0ll;
    mask<<=M;
    mask=~mask;
    debug(mask);
    bool flg=false;
    REP(i,N-M+1){
        REP(j, N-M+1){
            bool fff=true;
            REP(k, M){
                if(((img[i+k]>>j)&mask)==tpl[k]){}
                else{
                    fff=false;
                    break;
                }
            }
            if(fff){
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}


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

int a[3], k;

int main() {
        scanf("%d%d%d%d", &a[0], &a[1], &a[2], &k);
        sort(a, a + 3); a[2] *= pow(2, k);
        printf("%d\n", a[0] + a[1] + a[2]);
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <unordered_map>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<long long int> L(N + 1);
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i <= N; i++) {
    L[i] = L[i - 2] + L[i - 1];
  }
  cout << L[N] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


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

    int count = 0;
    ll tmp = K;
    while(tmp > 0){
        tmp /= 2;
        count++;
    }
    vector<int> C(100, 0);
    for(auto a : A){
        tmp = a;
        for(int i = 0; tmp > 0; i++){
            if(tmp % 2 == 1) C[i]++;
            tmp /= 2;
        }
    }
    ll ans = 0;
    
    for(int i = count - 1; i >= 0; i--){
        if (2 * C[i] < N && ans + pow(2, i) <= K) ans += pow(2, i); 
    }
    //cout << count << endl;
    //cout << ans << endl;
    ll ans1 = 0;
    REP(i, N) ans1 += ans ^ A[i];
    cout << ans1 << endl;


    return 0;
}

Measured memory_bytes: 1024
class UnionFind:
  def __init__(self, N):
    self.par=[i for i in range(N)]
    self.rank=[0 for _ in range(N)]
    self.size=[1 for _ in range(N)]
    
  def unite(self, x, y):
    x=self.getroot(x)
    y=self.getroot(y)
    if x!=y:
      if self.rank[x]<self.rank[y]:
        x, y=y, x
      if self.rank[x]==self.rank[y]:
        self.rank[x]+=1
      self.par[y]=x
      self.size[x]+=self.size[y]
      
  def united(self, x, y):
    return self.getroot(x)==self.getroot(y)
      
  def getroot(self, x):
    if self.par[x]==x:
      return x
    else:
      self.par[x]=self.getroot(self.par[x])
      return self.par[x]

  def getsize(self, x):
    return self.size[self.getroot(x)]
  

N, M=map(int, input().split())
UF=UnionFind(N+1)
p=[0]+list(map(int, input().split()))
for _ in range(M):
  x, y=map(int, input().split())
  UF.unite(x, y)
  
print(sum([1 for i in range(1, N+1) if UF.getroot(i)==UF.getroot(p[i])]))

Measured memory_bytes: 25928
n,k = map(int,input().split())
p = list(map(int,input().split()))
c = tuple(map(int,input().split()))
for i in range(n):
  p[i] -= 1

ans = -float('inf')
v = [False for _ in range(n)]
for i in range(n):
  j = i
  if v[j]:
    continue
  r = []
  while(v[j] == False):
    r.append(j)
    v[j] = True
    j = p[j]
  cr = []
  for ri in r:
    cr.append(c[ri])
  k1 = k%len(cr)
  k2 = k//len(cr)
  if k2 > 0:
    k1 += len(cr)
    k2 = max(k2-1,0)
  cr2 = cr+cr+cr
  #print(k1,k2,cr)
  now = -float('inf')
  csum = [0 for _ in range(len(cr2)+1)]
  for i0 in range(len(cr2)):
    csum[i0+1] = csum[i0]+cr2[i0]
  for i0 in range(len(cr)):
    for i1 in range(k1):
      now = max(csum[i0+i1+1]-csum[i0],now)
  if sum(cr) > 0:
    now += sum(cr)*k2
  ans = max(ans,now)
print(ans)

Measured memory_bytes: 75000
#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=0;



void solve(){
	string s,t;
	cin>>s>>t;
	if(sz(t) == sz(s)+1){
		rep(i,0,sz(s)){
			if(s[i]!=t[i]){
				cout<<"No";
				return;
			}
		}
		cout<<"Yes";
		return;
	}
	cout<<"No";
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 3652
#!/usr/bin/env python3
import sys


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    N = IS(int)
    A = IL(int)
    LIMIT = 10**18
    A.sort()
    ans = 1
    for a in A:
        ans *= a
        if ans > LIMIT:
            print(-1)
            exit()
    print(ans)

solve()


Measured memory_bytes: 21792
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n,k; cin>>n>>k;
  string s; cin>>s;
  rep(i,n) s.PB(s[n-i-1]);
	vector<string> candidate;
	rep(i,n) candidate.PB(s.substr(i,n));
	sort(ALL(candidate));

  string opt = candidate[0];
	int i = 0;
	int l = 0;
	while(opt[i]==opt[0]){
		l++; i++;
	}
	int r = pow(2,min(k-1,15))*l;
	string ans;
	i = 0;
	while((ans.size()<n)&&(i<r)){
		ans.PB(opt[0]); i++;
	}
	i = 0;
	while(ans.size()<n){
		ans.PB(opt[l+i]); i++;
	}
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 40320
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int a[10][1000], b[10][1000];
int h, w, k;
string st;

inline void work() {
    cin >> h >> w >> k;
    for (int i = 0; i < h; ++i) {
        cin >> st;
        for (int j = 0; j < w; ++j) {
            a[i][j] = st[j] - 48;
        }
    }
    int ans = h * w;
    for (int mask = 0; mask < (1 << (h - 1)); ++mask) {
        memset(b, 0, sizeof(b));
        int rows = 0;
        bool flag = true;
        for (int i = 0; i < h; ++i) {
            if (i > 0 && (((mask >> i) & 1) != ((mask >> (i - 1)) & 1))) {
                ++rows;
            }
            for (int j = 0; j < w; ++j) {
                b[rows][j] += a[i][j];
                if (b[rows][j] > k) {
                    flag = false;
                    break;
                }
            }
            if (!flag) {
                break;
            }
        }
        if (flag) {
            int cnt = rows;
            for (int j = 1; j < w; ++j) {
                bool split = false;
                for (int i = 0; i <= rows; ++i) {
                    if (b[i][j - 1] + b[i][j] > k) {
                        split = true;
                        break;
                    }
                }
                if (split) {
                    ++cnt;
                }
                else {
                    for (int i = 0; i <= rows; ++i) {
                        b[i][j] += b[i][j - 1];
                    }
                }
            }
            ans = min(ans, cnt);
        }
    }
    cout << ans << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

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

int main(){
	int k;cin>>k;
	int c=0;int x=7;int f=0;
	while(c<1e6){
		c++;
		if(x%k==0){
			f=1;
			break;
		} 
		x=x*10+7;x%=k;
	}
	if(f) cout<<c;
	else cout<<-1;
	return 0;
}

Measured memory_bytes: 3224
n = gets.chomp.to_i
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

puts(a[n-1])

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int s,w;
    cin >> s >> w;
    if(w>=s){
        cout << "unsafe" << endl;
    }else{
        cout << "safe"  << endl;
    }
    return 0;
}

Measured memory_bytes: 3612
#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>>;

// 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 );
}

int main()
{
    int N, M;
    cin >> N >> M;

    vector<int> p(M);
    vector<string> S(M);

    REP(i, M){
        cin >> p[i] >> S[i];
    }

    vector<bool> AC(N, false);
    vector<int> P(N, 0);

    REP(i, M){
        // cout << i << endl;
        if(AC[p[i]-1] == true) continue;
        
        if(S[i] == "AC"){
            AC[p[i]-1] =true;
            // cout << "AC[p[i]-1]:" << AC[p[i]-1] << endl;
        }
        else{
            P[p[i]-1]++;
            // cout << "P[p[i]-1]:" << P[p[i]-1] << endl;
        }
    }
    int ac_count = 0;
    int wa_count = 0;
    REP(i, N){
        if(AC[i] == true){
            ac_count++;
            wa_count += P[i];
        }
    }

    cout << ac_count << " " << wa_count << endl;
    return 0;
}

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

li = [list(map(int,input().split())) for _ in range(n)]
li.sort(key = lambda x : x[1])

s = 0

for i in range(n):
    s += li[i][0]
    if li[i][1] < s:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 53596
import queue
 
H, W = map(int,input().split())
MAP = []
INF = 10 ** 8
x = 0
y = 1
dx = [1,0,-1,0]
dy = [0,1,0,-1]
 
 
for _ in range(H):
    MAP.append(list(input()))
 
def bfs(S):
    que = queue.Queue()
    d = [[INF for i in range(W)] for j in range(H)]
    que.put(S)
    d[S[x]][S[y]] = 0
    
    while not que.empty():
        p = que.get()
        for i in range(4):
            nx = p[x] + dx[i]
            ny = p[y] + dy[i]
            if 0 <= nx < H and 0 <= ny < W and MAP[nx][ny] != "#" and d[nx][ny] == INF:
                que.put([nx,ny])
                d[nx][ny] = d[p[x]][p[y]] + 1
    
    MAX = -1
    for i in range(H):
        for j in range(W):
            if d[i][j] != INF and MAX < d[i][j]:
                MAX = d[i][j]
    return MAX

ans = -1

for i in range(H):
    for j in range(W):
        if MAP[i][j] != "#":
            tmp = bfs([i,j])
            if ans < tmp:
                ans = tmp

print(ans)

Measured memory_bytes: 3940
// g++ temp.cpp
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <string>
#include <climits>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
const unsigned long long MOD = 100000000000000000;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 50
ll dp[MAX_N+1][MAX_N+1][MAX_N*MAX_N+1]={0};
void solve(){
  ll N,A;
  ll x[MAX_N+1];
  cin>>N>>A;
  ll max_cost=0;
  for(ll i=1;i<=N;i++){
    cin>>x[i];
    //数列の数の合計を更新する
    max_cost+=x[i];
  }
  ll ans=0;
  //何も取らなくても数の平均は0に成るというのが1通りあるのでそれを更新する
  dp[0][0][0]=1;
  for(ll j=1;j<=N;j++){
    for(ll k=0;k<=N;k++){
      for(ll s=0;s<=max_cost;s++){
        //取れる範囲が1つ増えたとしても、前の状態のものを引き継ぐことができるのでこの処理が可能
          dp[j][k][s]+=dp[j-1][k][s];
         if(k>0&&s>=x[j]){
          //もしカードを選び、取る予定のカードの大きさが総計よりも小さければ
          //総計から取るカードの大きさを引いた時に取れた回数を引き継ぐことができるので、この処理が可能
          dp[j][k][s]+=dp[j-1][k-1][s-x[j]];
         }
      }
    }
  }
  for(ll i=1;i<=N;i++){
    //更新できるまでansに加算し続ける
    if((i*A)>max_cost) break;
    ans+=dp[N][i][i*A];
    //if(i>max_cost) break;
   // cout<<ans<<endl;
  }
  //出力
  cout<<ans<<endl;
}
int main(){
  solve();
  return 0;
}

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

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

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

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

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

  vector<vector<vector<int>>>dp(N+1,vector<vector<int>>(N*A+1,vector<int>(N+1,0)));
  dp[0][0][0]=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<=A*N;j++){
      for(int k=0;k<N;k++){
        if(j+x[i]<=N*A)dp[i+1][j+x[i]][k+1]+=dp[i][j][k];
        dp[i+1][j][k]+=dp[i][j][k];
      }
    }
  }

  int ans=0;
  for(int i=1;i<=N;i++)ans+=dp[N][A*i][i];
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 56192
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] str;
		int[][] points = new int[n][3];
		for(int i=0; i<n; i++) {
			str = br.readLine().split(" ");
			points[i][0] = Integer.parseInt(str[0]);
			points[i][1] = Integer.parseInt(str[1]);
			points[i][2] = Integer.parseInt(str[2]);
		}
		int[][] cost = new int[n+1][3];
		for(int i=1; i<=n; i++) {
			for(int j=0; j<3; j++) {
				for(int p=0; p<3; p++) {
					for(int q=0; q<3; q++) {
						if(p!=q) cost[i][p] = Math.max(cost[i][p], points[i-1][p]+cost[i-1][q]);
					}
				}
				//System.out.print(cost[i][j][0]+"|"+cost[i][j][1]+"|"+cost[i][j][2]+" ");
			}
			//System.out.println();
		}
		int ans = -1;
		for(int j=0; j<3; j++) {
			ans = Math.max(cost[n][j], ans);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 48204
def fact(n):
    fact = 1
    for i in range(1,n+1):
        fact *= i
    return fact

def combinations_count(n,r):
    return fact(n) // (fact(n - r) * fact(r))

def main():
    N, M = map(int, input().split())
    ans = 0
    if N >= 2:
        ans += combinations_count(N, 2)
    if M >= 2:
        ans += combinations_count(M, 2)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long>a(n);
  vector<long>b(n);
  vector<long>c(n);
  int i,j;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  for(i=0;i<n;i++){
    cin >> b[i];
  }
  for(i=0;i<n;i++){
    cin >> c[i];
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());

  vector<long>sumC(n);
  long ans = 0;

  int tmp = n-1;
  for(i=n-1;i>=0;i--){
    if(i!=n-1)sumC[i] = sumC[i+1];
    for(j=tmp;j>=0;j--){
      if(b[i]<c[j])tmp--;
      else break;
    }
    sumC[i] += n-1-tmp;
  }
  tmp = n-1;
  for(i=n-1;i>=0;i--){
    for(j=tmp;j>=0;j--){
      if(a[i]<b[j])tmp--;
      else break;
    }
    if(tmp!=n-1)ans += sumC[tmp+1];
  }
  cout << ans << endl;


}


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

class Main{
    public static void main(String[] args){
       BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
       in.lines().map(Integer:: valueOf).sorted(Comparator.reverseOrder()).limit(3).parallel().forEachOrdered(System.out::println);
    }
}

Measured memory_bytes: 31924
#include <iostream>

using namespace std;

int main(void) {
    int64_t x;
    cin >> x;
    int64_t ans = (x+10)/11 * 2;
    if(0 < x%11 && x%11 <= 6) {
        ans--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>//小数点以下表示
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n;
    cin>>n;
    vector<int> x(n);
    rep(i,n){
        cin>>x.at(i);
    }
    sort(x.begin(),x.end());
    int mini=10000000;
    for(int i=x.at(0);i<=x.at(n-1);i++){
        int sum=0;
        rep(j,n){
            sum+=(x.at(j)-i)*(x.at(j)-i);
        }
        mini=min(mini,sum);
    }
    cout<<mini<<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int H, W;
int A[85][85], B[85][85];
int res[85][85][160*80+10];

int dp(int i, int j, int x) {
    if (~res[i][j][x]) return res[i][j][x];
    int diff = abs(A[i][j] - B[i][j]);
    if (i == H-1 && j == W-1) return res[i][j][x] = abs(x-diff);
    else {
        res[i][j][x] = 1e9;
        if (i < H-1) res[i][j][x] = min(res[i][j][x], min(dp(i+1,j,x+diff), dp(i+1,j,abs(x-diff))));
        if (j < W-1) res[i][j][x] = min(res[i][j][x], min(dp(i,j+1,x+diff), dp(i,j+1,abs(x-diff))));
        return res[i][j][x];
    }
}

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> H >> W;
    FOR(i,0,H-1){
        FOR(j,0,W-1){ cin >> A[i][j]; }
    }
    FOR(i,0,H-1){
        FOR(j,0,W-1){ cin >> B[i][j]; }
    }

    memset(res,-1,sizeof res);
    cout << dp(0,0,0) << '\n';
}



Measured memory_bytes: 361856
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

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

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  string s,t;
  int ans = 0;
  cin >> s >> t;
  for(int i=0;i<s.size();i++){
    if(s[i]==t[i]) ans++;
  }
  cout<< ans <<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

int N,M;
int s,e;
scanf("%d%d",&N,&M);

int L[M],R[M];

scanf("%d%d",&s,&e);

for (int i = 0; i < M-1; i++){
    scanf("%d%d",&L[i],&R[i]);
}

for (int i = 0; i < M-1; i++){
  if (L[i]<=s && R[i]<e){e = R[i];}
  else if (s<L[i] && R[i]<e){s = L[i]; e = R[i];}
  else if (s<L[i] && e<=R[i]){s = L[i];}
}

(e+1 - s > 0)? printf("%d",e+1 - s) : printf("0");

return 0;

}

Measured memory_bytes: 2512
#include<iostream>
//#include<string>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  bool ans = false;
  for(int i = 0; i < s.size(); ++i){
    if(s == t){
      ans = true;
      break;
    }
    s = s . back() + s . substr(0,s.size() - 1);
  }
  if(ans){
    cout << " Yes "  << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define show(x) cout<<#x<<" = "<<(x)<<" "
#define ENA cout<<endl;
#define ENAA cout<<endl<<endl;

int MAX = 1e+6+5;
int BIG = 1e+9;
int MOD = 1e+9+7;

signed main()
{
    IOS;
    char n; cin>>n;
    cout<<(char)(n+1)<<endl;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;
int dp[gf];
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, k;
	cin >> n >> k;
	int h[n + 1];
	rep(i, 1, n)
	{
		cin >> h[i];
	}
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	rep(i, 3, n)
	{
		int mx = INF;
		zip(j, max(i - k, 1ll), i)
		{
			mx = min(mx, dp[j] + abs(h[j] - h[i]));
			if (mx > 100)
			{
				debug(j, dp[j]);
			}
		}
		dp[i] = mx;
		debug(dp[i]);
	}
	cout << dp[n] << en;


	return 0;
}




Measured memory_bytes: 5220
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
//#include <Windows.h>
//#include "Library.h"
//#include "Math.h"
using namespace std;
typedef long long int ll; typedef pair <int, int> P; typedef vector <int> vecint;
//const int INF = 2000000000;
const double EPS = 10e-9;
const int mvm = 1000001;
int v[100], w[100], m[100];
int dp[10001];
int main()
{
	int n, W; cin >> n >> W;
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < n; i++)
		cin >> v[i] >> w[i] >> m[i];
	for (int i = 0; i < n; i++)
	{
		int k = (int)log2(m[i]) - 1;
		int num = 1;
		//cout << "i " << i << endl;
		if (k == -1)
		{
			for (int t = W; t >= 0; t--)
			{
				if (t >= w[i] * num)
					dp[t] = max(dp[t], dp[t - w[i] * num] + v[i] * num);
			}
		}
		else
		{
			int sum = 0;
			for (int j = 0; j <= k + 1; j++)
			{
				if (j == k + 1) num = m[i] - sum;
				else if (j != 0) num *= 2;
				sum += num;
				//cout << "num " << num << endl;
				for (int t = W; t >= 0; t--)
				{
					if (t >= w[i] * num)
						dp[t] = max(dp[t], dp[t - w[i] * num] + v[i] * num);
				}
			}
		}
		/*for (int i = 0; i <= W; i++)
		{
			cout << dp[i];
			i == W ? cout << endl : cout << " ";
		}*/

	}
	cout << dp[W] << endl;
	return 0;
}

Measured memory_bytes: 3304