akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline


def read():
    N, K = map(int, input().strip().split())
    P = [0] + list(map(int, input().strip().split()))
    C = [0] + list(map(int, input().strip().split()))
    return N, K, P, C


def solve(N, K, P, C):
    max_score = -10**9
    # スコアの累積和
    for i in range(1, N+1):
        # スコアの累積和
        D = [0 for i in range(N+1)]
        # 1周の長さ
        size = 0
        # 1周のスコアの最大値: D[size]
        j = i
        score = 0
        while True:
            size += 1
            j = P[j]
            D[size] = D[size-1] + C[P[j]]
            if i == j:
                break
        round_score = D[size]
        for i in range(1, min(K, size)+1):
            max_score = max(max_score, D[i])
        # 周回してみる
        if D[size] > 0 and K > size:
            base_score = round_score * ((K // size)-1)
            max_score = max(max_score, base_score)
            for i in range(1, size+1):
                max_score = max(max_score, base_score + D[i])
            base_score = round_score * (K // size)
            for i in range(1, min(K%size, size)+1):
                max_score = max(max_score, base_score + D[i])
    return max_score


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 91648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  for(ll i=1;i<n;i++) {
    a[i]+=a[i-1];
  }
  ll ans=inf;
  for(ll i=2;i<n-1;i++) {
    ll mx,mn;
    {// calc left
      ll l=0,r=i-1;
      while(r-l>1) {
        ll m=(l+r)>>1;
        if(abs(a[i-1]-2*a[m-1])>abs(a[i-1]-2*a[m])) {
          l=m;
        }
        else {
          r=m;
        }
      }
      mx=max(a[i-1]-a[r-1],a[r-1]);
      mn=min(a[i-1]-a[r-1],a[r-1]);
    }
    {// calc right
      ll l=i,r=n-1;
      while(r-l>1) {
        ll m=(l+r)>>1;
        if(abs(a[n-1]-a[m-1]-(a[m-1]-a[i-1]))>abs(a[n-1]-a[m]-(a[m]-a[i-1]))) {
          l=m;
        }
        else {
          r=m;
        }
      }
      mx=max({a[n-1]-a[r-1],a[r-1]-a[i-1],mx});
      mn=min({a[n-1]-a[r-1],a[r-1]-a[i-1],mn});
    }
    ans=min(ans,mx-mn);
  }
  cout << ans << endl;
}

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

int main(){
  int x,y,z;
  cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);
  cout<<x<<" "<<y<<" "<<z<<endl;
  
  return 0;
}

Measured memory_bytes: 3592
S=str(input())
 
if S.count('R')==0:
  print(0)
if S.count('R')==1 :
  print(1)
if S.count('R')==2 and not S.count('RR') ==1:
  print(1)
if S.count('RR')==1 and not S.count('RRR')==1:
  print(2)
if S.count('RRR')==1:
  print(3)

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

X_s = sorted(X)
dict_med = {}

if N == 2 :
    print(X[1])
    print(X[0])
else :
    med_l = N // 2 - 1
    med_r = N // 2
    
    for i in range(N) :
        if i == med_l :
            dict_med[X_s[i]] = X_s[med_r]
        elif i == med_r : 
            dict_med[X_s[i]] = X_s[med_l]
        elif i < med_l :
            dict_med[X_s[i]] = X_s[med_r]
        elif i > med_r:
            dict_med[X_s[i]] = X_s[med_l]
    
    for i in X :
        print(dict_med[i])

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n, max_w;
	cin >> n >> max_w;

	ll w[n], v[n];
	rep(i, n) cin >> w[i] >> v[i];

	ll INF = 1e13;
	ll max_v = 100000;
	ll dp[max_v+1];
	// dp[i] : 価値iを作れるときの重さの最小値
	for(int i = 0; i <= max_v; i++){
		dp[i] = INF;
	}

	dp[0] = 0;
	for(int i = 1; i <= n; i++){
		for(int j = max_v; j >= 0; j--){
			if(j - v[i-1] >= 0) dp[j] = min(dp[j], dp[j - v[i-1]] + w[i-1]);
		}
	}

	ll ans = 0;
	for(int i = 0; i <= max_v; i++){
		if(dp[i] <= max_w) ans = max(ans, (ll)i);
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
N = int(input())
a = list(map(int,input().split()))

sorted_a = sorted(a, reverse=True)

alice = 0
bob = 0
for i in range (N):
    #Aliceのターン
    if i % 2 == 0:
        alice += sorted_a[i]
    else:
        bob += sorted_a[i]

print(alice-bob)

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

int main(){
	int x,y;
	cin >> x >> y;
	string out = "No";
	for(int i=0;i<=x;i++){
		if((2*i + 4*(x-i))==y){
			out ="Yes";
			break;
		}
	}
	cout << out;
}

Measured memory_bytes: 3620
import collections

n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    src, dst = map(int, input().split())
    src -= 1
    dst -= 1
    g[src].append(dst)
    g[dst].append(src)


UNDEF = -1
components = [UNDEF] * n
ncomponent = 0


for i in range(n):
    if components[i] == UNDEF:
        q = collections.deque([])
        ncomponent += 1
        q.append(i)
        components[i] = ncomponent
        while q:
            node = q.popleft()
            for other in g[node]:
                if components[other] == UNDEF:
                    components[other] = ncomponent
                    q.append(other)


print(max(collections.Counter(components).values()))


Measured memory_bytes: 109588
#include<stdio.h>

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;


void merge(int A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;


  
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  L[n1]=R[n2]=SENTINEL;
  //printf("aaa\n");
  i=0;
  j=0;
  for(k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
 
}

void mergeSort(int A[],int n,int left,int right){
  //printf("bbbb\n");
  
  if(left+1 < right){
    int mid = (left + right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}


int main(){
  int A[MAX],n,i;
  cnt = 0;
  scanf("%d",&n);

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

  mergeSort(A,n,0,n);

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

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

  return 0;

}



Measured memory_bytes: 5704
# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import sys
import string


def find_text(line, pattern_id, pattern):
    correspond = []
    for i in range(len(line)):
        s = line[i:i+len(pattern)]
        if(s == pattern):
            correspond.append(pattern_id)
        else:
            correspond.append(None)
    return correspond

def main():
    lines = [x.replace("\n","") for x in sys.stdin.readlines()]

    n, m = [int(x) for x in string.split(lines[0])]
    image_a = lines[1:n+1]
    image_b = lines[n+1:n+1+m]
    
    corresponds = {}
    for line_index, image_line in enumerate(image_a):
        for next_line, next_image_line in enumerate(image_b):
            # {(lineid, patternid):startindex,...}
            corresponds[(line_index,next_line)] = find_text(image_line, next_line, next_image_line)
    for j in range(len(corresponds[(0,0)])):
        for i in range(n-(m-1)):
            array = []
            for k in range(m):
                if(corresponds[(i+k,k)][j] == k):
                    array.append(True)
                else:
                    array = []
            if(len(array)==m):
                print("Yes")
                sys.exit(0)
    print("No")

if __name__ == '__main__':
    main()  


Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
signed main() {
    int N, K;
    cin >> N >> K;
    vector<bool> JJ(N, false);
    rep(i, K) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            JJ[a - 1] = true;
        }
    }
    int sum = 0;
    rep(i, N) {
        if(!JJ[i]) sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int n,m,k,inp;
    cin >> n >> m;
    vector<int> a(m);
    rep(i,n){
        cin >> k;
        rep(j,k){
            cin >> inp;
            a[inp-1]++;
        }
    }
    int cnt = 0;
    rep(i,m){
        if (a[i] >= n)cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 256
use std::io::{self, BufRead};

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let mut x: i32 = lines.next().unwrap().unwrap().parse().unwrap();
  let q1 = x / 500;
  x %= 500;
  let q2 = x / 5;
  let h = q1 * 1000 + q2 * 5;
  println!("{}", h);
}

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

int main() {
	int N, A, B;
	cin >> N >> A >> B;
  
  	if ((N * A) <= B) {
    	cout << N * A << endl;
    }
  	else if ((N * A) > B){
    	cout << B << endl;
    }
}

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

using namespace std;

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

    string vowels = "aeiou";
    char c;
    cin >> c;
    if(find(vowels.begin(), vowels.end(), c) != vowels.end())
        cout << "vowel";
    else
        cout << "consonant";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

bool hantei(int k[], int l, int m, int n) {
	if (l == 0) {
		return true;
	} else {
		if (k[10-l] > m) {
			return hantei(k,l-1,k[10-l],n);
		} else if(k[10-l] > n) {
			return hantei(k,l-1,m,k[10-l]);
		} else {
			return false;
		}
	}
}


int main() {
	int n;
	int kazu[10];
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> kazu[j];
		}
		if (hantei(kazu,10,0,0)) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;


public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7);
	static long cf = 998244353;
    static final long MAX = (long) 1e15;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 32;
    public static int[] Bit;
    public static long[] dp;
    
	public static void main(String[] args) {
	
	
	FastReader sc = new FastReader();
	
	int n = sc.nextInt();
	int m = sc.nextInt();
	boolean[] ac = new boolean[n+1];
	int[] wa = new int[n+1];
	long score = 0,pen = 0;
	for(int i=0;i<m;++i) {
		int idx = sc.nextInt();
		String ver = sc.next();
		if(ver.compareTo("AC") == 0) {
			if(!ac[idx]) {
				ac[idx] = true;
				++score;
			}
		}else {
			if(!ac[idx]) ++wa[idx];
		}
	}
	
	for(int i=1;i<=n;++i) {
		if(ac[i]) { pen+=wa[i]; }
	}
	
	out.print(score + " "+pen);
      out.close();
	}

	
}

Measured memory_bytes: 42920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  int b=1;
  sort(vec.begin(), vec.end());
  for(int i=0;i<N-1;i++){
    if(vec.at(i)==vec.at(i+1)){
      b=0;
      break;
    }
  }
  if(b==1) cout << "YES";
  else cout << "NO";
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 200000;
ll mod = INF;
ll a[maxn+1],b[maxn+1],as[maxn+1],bs[maxn+1];
ll n,m,k;
ll ans=0;

int main(){
    cin >> n>>m>>k;
    for(int i=1;i<=n;i++)cin >> a[i];
    for(int i=1;i<=m;i++)cin >> b[i];
    as[0]=bs[0]=0;
    for(int i=1;i<=n;i++){
        as[i]=as[i-1]+a[i];
    }
    for(int i=1;i<=m;i++){
        bs[i]=bs[i-1]+b[i];
    }
    ll aidx=0;
    ll bidx=m;

    for(;aidx<=n;aidx++){
        while(as[aidx]+bs[bidx]>k){
            if(bidx==0)break;
            bidx--;
        }
        if(as[aidx]+bs[bidx]<=k)ans=max(ans,aidx+bidx);
    }

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

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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int ans = a + b + c;
	
	int max = 0;
	if(max <= a)	max = a;
	if(max <= b)	max = b;
	if(max <= c)	max = c;
	
	cout << ans-max << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int a = scan.nextInt();
        
        int b = scan.nextInt();
        
        int c = scan.nextInt();
       
        if(a<b&&b<c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }        
}        
        
    


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

static const int N = 100 + 1;

void trace(int* a, int n);
/* ???????????°????????? */
int bubbleSort(int* a, int n);
void swapInt(int& t1, int& t2);

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

  int c = bubbleSort(a, n);
  trace(a, n);
  cout << c << endl;
}

void trace(int* a, int n) {
  for (int i = 0; i < n; ++i) {
    if (i) { printf(" "); }
    printf("%d", a[i]);
  }
  printf("\n");
}

int bubbleSort(int* a, int n) {
  int count = 0;
  bool flag = 1;
  for (int i = 0; flag; ++i) {
    flag = 0;
    for (int j = n - 1; j >= i + 1; --j) {
      if (a[j] < a[j - 1]) {
        swap(a[j], a[j - 1]);
        flag = 1;
        count++;
      }
    }
  }
  return count;
}

void swapInt(int& t1, int& t2) {
  int temp = t1;
  t1 = t2;
  t2 = temp;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  string s;
  int count=0;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i] == '1') count++;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;



int main(void) {
	int num, i, h, m;
	double a, b, mr, hr, k, ans;
	cin >> a >> b >> h >> m;
	mr = 6.0 * m;
	hr = 30.0 * h;
	hr += 0.5 * m;
	k = max(hr, mr) - min(hr, mr);
	if (k > 180.0)
		k = 360.0 - k;
	ans = a * a + b * b;
	ans -= 2.0 * a * b * cos(PI * k / 180.0);
	ans = sqrt(ans);
	printf("%.10lf\n", ans);
	return 0;
}

Measured memory_bytes: 4260
import * as fs from "fs";
const input = fs.readFileSync("/dev/stdin", "utf-8");

const main = (input: string): void => {
  const [a, b, c] = input.split("\n").map((str) => str.split(""));
  let next: string | undefined;

  const term = (str: string) => {
    if (str === "a") next = a.shift();
    else if (str === "b") next = b.shift();
    else if (str === "c") next = c.shift();

    if (!next) console.log(str.toUpperCase());
    else term(next);
  };

  term(a[0]);
};

main(input);


Measured memory_bytes: 29620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int q;
    double x1,y1,x2,y2,x3,y3,x4,y4,x,y,a1,b1,c1,a2,b2,c2;
    cin>>q;
    while(q--)
    {
        cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
        a1=y2-y1;
        b1=-(x2-x1);
        c1=-((a1*x1)+(b1*y1));
        a2=y4-y3;
        b2=-(x4-x3);
        c2=-((a2*x3)+(b2*y3));
        if(b1==0 && b2==0 || a1==0 && a2==0)
        {
            if(c1!=c2)
            {
                cout<<"0"<<endl;
            }

            else if((x3>=min(x1,x2) && x3<=max(x1,x2) && y3>=min(y1,y2) && y3<=max(y1,y2))|| (x4>=min(x1,x2) && x4<=max(x1,x2) && y4>=min(y1,y2) && y4<=max(y1,y2))||(x1>=min(x3,x4) && x1<=max(x3,x4) && y1>=min(y3,y4) && y1<=max(y3,y4))||(x2>=min(x3,x4) && x2<=max(x3,x4) && y2>=min(y3,y4) && y2<=max(y3,y4)))
            {
                cout<<"1"<<endl;
            }
            else
            {
                cout<<"0"<<endl;
            }

        }
        else if(b1==0 && a2==0)
        {
            x=x2;
            y=y4;
            if(x>=min(x1,x2) && x<=max(x1,x2) && y>=min(y1,y2) && y<=max(y1,y2) && x>=min(x3,x4) && x<=max(x3,x4) && y>=min(y3,y4) && y<=max(y3,y4))
            {
                cout<<"1"<<endl;
            }
            else
            {
                cout<<"0"<<endl;
            }
        }
        else if(b2==0 && a1==0)
        {
            x=x4;
            y=y2;
            if(x>=min(x1,x2) && x<=max(x1,x2) && y>=min(y1,y2) && y<=max(y1,y2) && x>=min(x3,x4) && x<=max(x3,x4) && y>=min(y3,y4) && y<=max(y3,y4))
            {
                cout<<"1"<<endl;
            }
            else
            {
                cout<<"0"<<endl;
            }

        }
        else if(a1/-b1 ==a2/-b2)
        {
             if(c1!=c2)
            {
                cout<<"0"<<endl;
            }

            else if((x3>=min(x1,x2) && x3<=max(x1,x2) && y3>=min(y1,y2) && y3<=max(y1,y2))|| (x4>=min(x1,x2) && x4<=max(x1,x2) && y4>=min(y1,y2) && y4<=max(y1,y2))||(x1>=min(x3,x4) && x1<=max(x3,x4) && y1>=min(y3,y4) && y1<=max(y3,y4))||(x2>=min(x3,x4) && x2<=max(x3,x4) && y2>=min(y3,y4) && y2<=max(y3,y4)))
            {
                cout<<"1"<<endl;
            }
            else
            {
                cout<<"0"<<endl;
            }
        }
        else
        {

            x=((b1*c2)-(b2*c1))/((a1*b2)-(a2*b1));
            y=((a2*c1)-(a1*c2))/((a1*b2)-(a2*b1));
            if(x>=min(x1,x2) && x<=max(x1,x2) && y>=min(y1,y2) && y<=max(y1,y2) && x>=min(x3,x4) && x<=max(x3,x4) && y>=min(y3,y4) && y<=max(y3,y4))
            {
                cout<<"1"<<endl;
            }
            else
            {
                cout<<"0"<<endl;
            }
        }


    }

}



Measured memory_bytes: 3228
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N, C;
  std::cin >> N >> C;
  std::vector<i64> x, v;
  x.reserve(N);
  v.reserve(N);
  for (i64 i = 0; i < N; ++i) {
    i64 x_i, v_i;
    std::cin >> x_i >> v_i;
    x.push_back(x_i);
    v.push_back(v_i);
  }

  std::vector<i64> l_gains;
  l_gains.reserve(N);
  for (i64 i = 0; i < N; ++i) {
    l_gains.push_back(v[i] - (x[i] - (i == 0 ? 0 : x[i - 1])));
  }

  std::vector<i64> l_strategies;
  l_strategies.reserve(N);
  for (const i64& l_gain : l_gains) {
    l_strategies.push_back((l_strategies.empty() ? 0 : l_strategies.back()) + l_gain);
  }

  std::vector<i64> l_optimums;
  l_optimums.reserve(N);
  for (const i64& l_strategy : l_strategies) {
    l_optimums.push_back(std::max(l_strategy, l_optimums.empty() ? 0 : l_optimums.back()));
  }
  std::reverse(l_optimums.begin(), l_optimums.end());

  std::vector<i64> r_gains;
  r_gains.reserve(N);
  for (i64 i = 0; i < N; ++i) {
    r_gains.push_back(v[N - 1 - i] - ((i == 0 ? C : x[N - i]) - x[N - 1 - i]));
  }

  std::vector<i64> r_strategies;
  r_strategies.reserve(N);
  for (const i64& r_gain : r_gains) {
    r_strategies.push_back((r_strategies.empty() ? 0 : r_strategies.back()) + r_gain);
  }

  std::vector<i64> r_optimums;
  r_optimums.reserve(N);
  for (const i64& r_strategy : r_strategies) {
    r_optimums.push_back(std::max(r_strategy, r_optimums.empty() ? 0 : r_optimums.back()));
  }
  std::reverse(r_optimums.begin(), r_optimums.end());

  i64 answer = 0;
  for (const i64& l_strategy : l_strategies) {
    answer = std::max(answer, l_strategy);
  }
  for (const i64& r_strategy : r_strategies) {
    answer = std::max(answer, r_strategy);
  }
  for (i64 i = 0; i < N; ++i) {
    answer = std::max(answer, (i == 0 ? 0 : l_strategies[i - 1]) - (i == 0 ? 0 : x[i - 1]) + r_optimums[i]);
    answer = std::max(answer, (i == 0 ? 0 : r_strategies[i - 1]) - (i == 0 ? 0 : C - x[N - i]) + l_optimums[i]);
  }
  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 6528
import sys;
lines = sys.stdin.readlines();

#配列の宣言
alfabet = {};

#値の格納
alfabet['A'] = 1;
alfabet['B'] = 2;
alfabet['C'] = 3;
alfabet['D'] = 4;
alfabet['E'] = 5;
alfabet['F'] = 6;

for i, line in enumerate(lines):
    #値を受け取り格納
    first,second = line.split();

if(alfabet[first]<alfabet[second]):
    print ("<");
elif(alfabet[first]>alfabet[second]):
    print (">");
else:
    print("=");


Measured memory_bytes: 3060
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
    

    return 0;
}

Measured memory_bytes: 256
//2019.9.15 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
#define ctz(x) __builtin_ctz(x)
//#define pc(x) __builtin_popcountll(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define lowbit(x) (x&-x)
#define gc getchar
#define kcz 1000000007
//template <class T>using Tree=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
//inline int read() {
//    res s=0,ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//char sr[1<<21],z[20];
//int C=-1,Z=0;
//inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
//inline void print(res x){
//    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
//    while(z[++Z]=x%10+48,x/=10);
//    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
//}
inline int read() {
    res s=0,ch=gc(),w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s*w;
}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
inline LL Read() {
    RG LL s=0;
    res ch=gc(),w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s*w;
}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
//inline void swap(res &x,res &y) {
//    x^=y^=x^=y;
//}
//inline void add(res &x,const res &y){
//    x+=y,x>=kcz?x-=kcz:(x<0?x+=kcz:1);
//}
//inline int Add(const res &x,const res &y){
//    return x+y>=kcz?x+y-kcz:(x+y<0?x+y+kcz:x+y);
//}
//inline int mul(const res &x,const res &y){
//    return int(1LL*x*y%kcz);
//}
//inline int mul(const res &x,const res &y,const res &d){
//    return int(1LL*x*y/d%kcz);
//}
//inline int qpow(res x,res y){
//    res ret=1;
//    while(y){
//        if(y&1)ret=mul(ret,x);
//        x=mul(x,x),y>>=1;
//    }
//    return ret;
//}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
namespace MAIN{
    char opt[10];
    inline void MAIN(){
        scanf("%s",opt+1);
        if(opt[1]=='S')puts("Cloudy");
        else if(opt[1]=='C')puts("Rainy");
        else puts("Sunny");
    }
}
int main(){
//    srand(19260817);
//    freopen("block.in","r",stdin);
//    freopen("block.out","w",stdout);
    MAIN::MAIN();
//    Ot();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int ax,ay,bx,by;cin>>ax>>ay>>bx>>by;
  int x = bx-ax;
  int y = by-ay;
  //一回目
  for(int i = 0; x > i; i++){
    cout << "R";
  }
  for(int i = 0; y > i; i++){
    cout << "U";
  }
  for(int i = 0; x > i; i++){
    cout << "L";
  }
  for(int i = 0; y+1 > i; i++){
    cout << "D";
  }
  for(int i = 0; x+1 > i; i++){
    cout << "R";
  }
  for(int i = 0; y+1 > i; i++){
    cout << "U";
  }
  cout << "LU";
  for(int i = 0; x+1 > i; i++){
    cout << "L";
  }
  for(int i = 0; y+1 > i; i++){
    cout << "D";
  }
  cout << "R" << endl;



}

Measured memory_bytes: 256
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-26 16:27:39
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-26 16:47:48
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> pii;
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
using namespace IO;
const int maxn=200000;
char s[maxn+10];
ll dp[maxn+10][3];
inline void update(ll& x,ll y)
{
    if(x<y) x=y;
    return ;
}
int main()
{
    scanf("%s",s);
    int len=strlen(s);
    dp[0][1]=1;
    dp[0][2]=0;
    dp[1][1]=(s[1]!=s[0])?2:1;
    dp[1][2]=1;
    for(int i=2;i<len;i++)
    {
        if(s[i]!=s[i-1]) update(dp[i][1],dp[i-1][1]+1);
        update(dp[i][1],dp[i-1][2]+1);
        update(dp[i][2],dp[i-2][1]+1);
        if(s[i]!=s[i-2]||s[i-1]!=s[i-3]&&i!=2) update(dp[i][2],dp[i-2][2]+1);
    }
    cout<<max(dp[len-1][1],dp[len][2]);
}

Measured memory_bytes: 5248
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int k = sc.nextInt();

      ArrayList<Integer>[] arr = new ArrayList[26];
      for(int i = 0; i < 26; i++)
        arr[i] = new ArrayList<>();

      for(int i = 0; i < s.length(); i++)
        arr[s.charAt(i)-'a'].add(i);

      for(int i = 0; i < 26; i++) 
        Collections.sort(arr[i], (a, b) -> s.substring(a).compareTo(s.substring(b)));

      for(int i = 0; i < 26; i++) {
        ArrayList<Integer> idxArr = arr[i];
        Set<String> substrs = new HashSet<>();
        for(int idx : idxArr) {
            for(int j = 0; j + idx < s.length(); j++) {
                String str = s.substring(idx, idx + j + 1);
                substrs.add(str);
                if(substrs.size() == k) {
                    System.out.println(str);
                    return;
                }
            }
        }
        
        k -= substrs.size();
      }
  }
}

Measured memory_bytes: 131412
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

const int MOD = 1e9 + 7;

int main() {
  string S;
  cin >> S;
  
  ll a = 0, ab = 0, abc = 0, all = 1;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'A') {
      a += all;
    }
    if (S[i] == 'B') {
      ab += a;
    }
    if (S[i] == 'C') {
      abc += ab;
    }
    if (S[i] == '?') {
      abc = abc * 3 + ab;
      ab  = ab * 3 + a;
      a   = a * 3 + all;
      all *= 3;
    }
    abc %= MOD;
    ab  %= MOD;
    a   %= MOD;
    all %= MOD;
  }
  cout << abc << endl;
  return 0;
}


Measured memory_bytes: 512
use proconio::{input};
use std::collections::VecDeque;

#[derive(Clone, Eq, PartialEq)]
struct Node {
    x: i64,
    y: i64
}

// #[fastout]
#[allow(non_snake_case)]
#[allow(unused)]
fn main() {
    input! {
        H: i64,
        W: i64,
        CH: i64,
        CW: i64,
        DH: i64,
        DW: i64,
        S: [String; H],
    }

    let mut Q = VecDeque::new();
    Q.push_back(Node { x: CW - 1, y: CH - 1 });

    let inf = W * H;
    let mut C = vec![vec![inf; W as usize]; H as usize];
    C[(CH - 1) as usize][(CW - 1) as usize] = 0;

    let mut push = |q: &mut VecDeque<Node>, c: &mut Vec<Vec<i64>>, x, y, cost, extraCost| {
        if x < 0 || W <= x { return; }
        if y < 0 || H <= y { return; }
        if S[y as usize].as_bytes()[x as usize] == "#".as_bytes()[0] { return; }

        let yy = y as usize;
        let xx = x as usize;

        let newCost = cost + extraCost;
        if c[yy][xx] <= newCost { return; }
        c[yy][xx] = newCost;

        let node = Node { x: x, y: y };
        if extraCost == 0 { q.push_front(node); } else { q.push_back(node); }
    };

    let mut ans = -1;

    while let Some(Node { x, y }) = Q.pop_front() {
        let cost = C[y as usize][x as usize];
        if x == DW - 1 && y == DH - 1 { ans = cost; break; }

        push(&mut Q, &mut C, x - 1, y, cost, 0);
        push(&mut Q, &mut C, x + 1, y, cost, 0);
        push(&mut Q, &mut C, x, y - 1, cost, 0);
        push(&mut Q, &mut C, x, y + 1, cost, 0);

        for xx in x-2..x+3 {
            for yy in y-2..y+3 {
                push(&mut Q, &mut C, xx, yy, cost, 1);
            } 
        }
    }

    println!("{}", ans);
}

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

int main() {
	ll n,a,b;
  	cin>>n>>a>>b;
  
  	ll ans=0;
  
	ll waru=n/(a+b);
  	ll amari=n%(a+b);
  
  	ans+=waru*a;

  
      
      if(amari>=a){
      	ans+=a;
      }
      
      else{
      	ans+=amari;
      }
    
 
  
  cout<<ans<<endl;
  
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

signed main(){
  int n,k,l;cin>>n>>k>>l;
  vector<int> road = init(n), train = init(n);
  rep(i,k){
    int p,q;cin>>p>>q;p--;q--;unite(p,q,road);
  }
  rep(i,l){
    int p,q;cin>>p>>q;p--;q--;unite(p,q,train);
  }
  map<pair<int,int>,int> m;
  rep(i,n){
    m[make_pair(root(i,road), root(i,train))]++;
  }
  rep(i,n){
    cout << m[make_pair(root(i,road), root(i,train))] << (i == n-1 ? "\n" : " ");
  }
}


Measured memory_bytes: 13568
#include<stdio.h>
#include<algorithm>
int main() {
	
	//freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int N;

	scanf("%d", &N);
	if (N < 1200) {
		printf("ABC");
	}
	else if (N < 2800) {
		printf("ARC");
	}
	else {
		printf("AGC");
	}
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        s: [chars],
    }
    let mut s = s;
    s.sort();
    s.dedup();
    puts!("{}\n", s.len());
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 22948
from collections import deque
import math


k = int(input())


def equal_num(dq):
    equal_sum = -1
    dq_len = len(dq)

    for _ in range(dq_len):
        if dq[0] != dq[1]:
            equal_sum += 1
        dq.rotate()

    equal_sum *= 3

    if equal_sum <= 0:
        equal_sum = 1

    # print(dq, equal_sum)
    return equal_sum


gcd_sum = 0
for h in range(1, k + 1):
    for i in range(h, k + 1):
        for j in range(i, k + 1):
            gcd_tmp = math.gcd(j, math.gcd(h, i))
            gcd_sum += gcd_tmp * equal_num(deque([h, i, j]))

print(gcd_sum)

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<ll> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}


bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;

// b-=a, a = 0としていい
// プラスマイナス対称なので、正の場合だけ考えればいい

// n >= c * 2 / (d - c) なら、くっつくから最大値と最小値だけ考えればいい

// d * n < b なら絶対ムリ

// bを超える (c + d)の倍数の中で一番小さいものは
// (b + (c+d) - 1) / (c+b) * (c+b)
// 上から上ー（d-c）* 上ならok


bool solve() {
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;


    b -= a;
    a = 0;
    b = abs(b);
    if (d * n < b) {
        return false;
    }
    if (d == c) {
        if (b % d != 0) return false;
        ll p = b / d;
        if (p > n) return false;
        return p % 2 == n % 2;
    }

    if (n >= c * 2 / (d - c)) {
        return true;
    }
/*
    vector<set<P>> k;

    k.push_back({{a, a}});

    rep(i, n) {
        set<P> next;
        for (P p : k.back()) {
            next.insert({p.first + c, p.second + d});
            next.insert({p.first - d, p.second - c});
        }
        k.push_back(next);
    }

    rep(i, n + 1) {
        ll up = i * d;
        for (P p : k[i]) {
            printf("%lld %lld %lld %lld\n", p.first, p.second, up + p.first, up + p.second);
        }
        cout << endl;
    }
*/

    b += d * (n - 1);

    ll cd = c + d;

    ll floor = b / cd * cd;
    ll ceil = floor + (d - c) * (n - 1);

    return floor <= b && b <= ceil;


    __throw_runtime_error("mada");

}

int main() {

    string ans = solve() ? "YES" : "NO";
    cout << ans << endl;


/*
    vector<set<P>> k;

    k.push_back({{a, a}});

    rep(i, n) {
        set<P> next;
        for (P p : k.back()) {
            next.insert({p.first + c, p.second + d});
            next.insert({p.first - d, p.second - c});
        }
        k.push_back(next);
    }

    rep(i, n + 1) {
        ll up = i * d;
        for (P p : k[i]) {
            printf("%lld %lld %lld %lld\n", p.first, p.second, up + p.first, up + p.second);
        }
        cout << endl;
    }

*/


}

Measured memory_bytes: 3636
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
 	ios::sync_with_stdio(false);
 	int N,i;
 	scanf("%d %d",&N,&i);
 	printf("%d\n",N-i+1);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long X;
    cin >> X;

    long long cnt = 0;
    long long tmp = 0;
    for (long long i = 1; i < 1000000000; i++){
        cnt += i;
        tmp = i;
        if (cnt >= X){
            break;
        }
    }

    cout << tmp << endl;
}

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

using namespace std;

int main(void)
{
  unsigned long a,b;
  unsigned long long ab;
  
  cin >> a >> b;
  
  ab = (unsigned long long) a + b;
  if ( ab & 1 ) cout << "IMPOSSIBLE" << endl;
  else cout << ab / 2 << endl;
  
  return 0;
}

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

int main(){
    vector<int> vec(3);
    cin >> vec.at(0);
    cin >> vec.at(1);
    cin >> vec.at(2);

    cout << vec.at(2) << " " << vec.at(0) << " " << vec.at(1) <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    for (int i = n-1; i >= 0; --i) {
        if (i == n-1) continue;
        if (a[i] > a[i+1]) a[i]--;
        if (a[i] > a[i+1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 640
h, w, k = map(int, input().split())
l = []
total = 0

for _ in range(h):
    c = list(input())
    total += c.count('#')
    l.append(c)
    
ans = 0
for i in range(2**h):
    count1 = 0
    li = []
    for j in range(h):
        if ((i>>j)&1):
            li.append(j)
            count1 += l[j].count('#')
    for a in range(2**w):
        count2 = 0
        for b in range(w):
            if ((a>>b)&1):
                for z in li:
                    if l[z][b] == "#":
                        count2 -= 1
                for c in range(h):
                    if l[c][b] == "#":
                        count2 += 1
        if total - count1 - count2 == k:
          ans += 1
print(ans)

Measured memory_bytes: 9236
#include <stdio.h>
int main(void)
{
	int n;
	scanf("%d",&n);
	int a = 1;
	int b = 1;
	while (a<=9)
	{
		b = 1;
		while (b <=9)
		{
			if(a*b == n)
			{
				printf("Yes\n");
				return(0);
			}
			b++;
		}
		a++;
	}
	printf("No\n");
	return(0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<vector<pair<int,ll>>> edge;
    vector<ll> length;

    rep(i,n + 1){
        vector<pair<int,ll>> tmpv;

        edge.pback(tmpv);
        length.pback(LLONG_MAX);
    }

    rep(i,n - 1){
        int u,v;
        ll w;
        cin >> u >> v >> w;

        edge[u].pback(mpair(v,w));
        edge[v].pback(mpair(u,w));
    }

    function<void(int, ll)> dfs = [&](int node, ll l) -> void{

        if(length[node] > l){
            length[node] = l;

            rep(i,edge[node].size()){
                int to  = edge[node][i].first;
                ll tmpl = edge[node][i].second;

                dfs(to, l + tmpl);
            }
        }

    };

    dfs(1,0);

    for(int i = 1; i <= n; i++){
        cout << length[i] % 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 10800
n, k = gets.split.map &:to_i

arr = gets[0..-2].chars.map{|c| c=="1"}
s = []
s[0] = arr[0] ? 1 : -1

arr[1..-1].each{|a|
  if a
    if s[-1] > 0
      s[-1] += 1
    else
      s << 1
    end
  else
    if s[-1] < 0
      s[-1] -= 1
    else
      s << -1
    end
  end
}


tmp = 0
max = 0

# p s
s.each_with_index do |v, i|
  if v > 0
    tmp += v
    # print "Add #{v}"
  else
    prev = i - k * 2

    # print "Add #{v}"
    if prev >= 0
      # print "M#{s[prev]}"
      tmp -= s[prev].abs
    end
    if prev - 1 >= 0
      # print "M#{s[prev-1]}"
      tmp -= s[prev-1].abs
    end
    tmp += v.abs
  end
  # puts "\t--- TMP #{tmp}"
  max = [max, tmp].max
end
puts max


Measured memory_bytes: 11256
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int h,w;
int m;
set<pair<int, int>> t;
set<int> vt;
set<int> hr;
map<int, int> vn;
map<int, int> hn;
multimap<int, int> rvn;
multimap<int, int> rhn;

int main()
{
  ll ans=0;

  cin >> h >> w >> m;
  for (int i=0; i<m; i++) {
    int hi, wi;
    cin >> hi >> wi;
    t.insert(make_pair(hi, wi));
    vt.insert(hi);
    hr.insert(wi);
    if (vn.count(hi) > 0) {
      vn[hi]++;
    } else {
      vn[hi]=1;
    }
    if (hn.count(wi) > 0) {
      hn[wi]++;
    } else {
      hn[wi]=1;
    }
  }
  /*
  for (auto hit=hr.begin(); hit!=hr.end(); hit++) {
    for (auto vit=vt.begin(); vit!=vt.end(); vit++) {
      auto fit=t.find(make_pair(*vit, *hit));
      if (fit != t.end()) {
        if (vn.count(*vit) > 0) {
          vn[*vit]++;
        } else {
          vn[*vit]=1;
        }
        if (hn.count(*hit) > 0) {
          hn[*hit]++;
        } else {
          hn[*hit]=1;
        }
//printf("(%d %d)\n", *vit, *hit);
      }
    }
  }
    */

  for (auto vit=vn.begin(); vit!=vn.end(); vit++) {
//    printf("vn[%d] = %d\n", vit->first, vit->second);
    rvn.emplace(vit->second, vit->first);
  }
  for (auto hit=hn.begin(); hit!=hn.end(); hit++) {
//    printf("hn[%d] = %d\n", hit->first, hit->second);
    rhn.emplace(hit->second, hit->first);
  }
  /*
  for (auto vit=rvn.rbegin(); vit!=rvn.rend(); vit++) {
    printf("rvn[%d] = %d\n", vit->first, vit->second);
  }
  for (auto hit=rhn.rbegin(); hit!=rhn.rend(); hit++) {
    printf("rhn[%d] = %d\n", hit->first, hit->second);
  }
*/

  ans = rvn.rbegin()->first + rhn.rbegin()->first - 1;
  for (auto vit=rvn.rbegin(); vit != rvn.rend() && vit->first == rvn.rbegin()->first; vit++) {
    for (auto hit=rhn.rbegin(); hit != rhn.rend() && hit->first == rhn.rbegin()->first; hit++) {
      auto fit=t.find(make_pair(vit->second, hit->second));
      if (fit == t.end()) {
        ans++;
        cout << ans << endl;
        return 0;
      }
    }
  }

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


Measured memory_bytes: 102004
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
long long int a[100005];
int main()
{
    long long int n,num=0,i,num2=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]%4==0)
        num++;
        if(a[i]%2==0&&a[i]%4!=0)
        num2++;
    }
    if(num>=(n/2))
    printf("Yes\n");
    else if(n-num*2-num2<=0)
    printf("Yes\n");
    else
    printf("No\n");
}


Measured memory_bytes: 1024