akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=2e5+5;



void solve()
{
    int n,x,t;
    cin>>n>>x>>t;
    int ans=(n+x-1)/x;
    cout<<ans*t;   
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t;
 t=1;
 for(int i=1;i<=t;i++)
 {
   solve();
 }


}

Measured memory_bytes: 3644
import heapq
def prim():
    used = [True]*n
    edgelist = []
    for e in edge[0]:
        heapq.heappush(edgelist, e)
        used[0] = False
    res = 0
    while len(edgelist) != 0:
        minedge = heapq.heappop(edgelist)
        if not  used[minedge[1]]:
            continue
        v = minedge[1]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist, e)
        res += minedge[0]
    return res
n = int(input())
P = []
for i in range(n):
    x, y = map(int, input().split())
    P.append((x, y, i))
P.sort()
edge = [[] for _ in range(n)]
for i in range(n-1):
    d = min(abs(P[i+1][0]-P[i][0]), abs(P[i+1][1]-P[i][1]))
    edge[P[i][2]].append((d, P[i+1][2]))
    edge[P[i+1][2]].append((d, P[i][2]))
P.sort(key = lambda x: x[1])
for i in range(n-1):
    d = min(abs(P[i+1][0]-P[i][0]), abs(P[i+1][1]-P[i][1]))
    edge[P[i][2]].append((d, P[i+1][2]))
    edge[P[i+1][2]].append((d, P[i][2]))
print(prim())

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

int main()
{
    int a[32]={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};

    int k;
    cin>>k;
    cout<<a[k-1];
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
	int N,A,B;
	double average={};
	ll pascal[55][55]={};
	ll ready[51][51]={};
	ll value[51]={};
	int COUNT[51]={};//value[]がなんかい使われたか
	int valueable[51]={};//元々その種類の荷物は何個あるのか。
	
	for(int i=0;i<51;i++){
		for(int j=0;j<51;j++){
			if(j==0||i==0){
				ready[i][j]=1;
			}else{
				ready[i][j]=ready[i-1][j]+ready[i][j-1];
			}
		}
	}
	
	for(int i=0;i<51;i++){
		for(int j=0;j<51;j++){
			if(i+j<=52){
				pascal[j+i][j]=ready[i][j];
			}
		}
	}
	
//	cout << pascal[4][3] << endl;
	
	cin >> N >> A >> B;
	for(int i=0;i<N;i++){
		cin >> value[i];
	}
	
	sort(value,value+N,[](const long long& x,const long long& y){return x > y;});
	
	ll memo=0;
	ll count=-1;//count+1個の荷物が選ばれた。
	for(int i=0;i<A;i++){
		average+=double(value[i]);
		if(memo!=value[i]){
			count++;
			memo=value[i];
		}
		COUNT[count]++;//COUNT[]は0~  COUNT[count]は、最終的に入れた荷物と同じ種類の荷物の個数
	}
	average = average/double(A);
	
	printf("%f\n",average);
	
//	A=N  COUNT[count] <= =< B-B-COUNT[count];//
	
	memo=0;
	ll count_2=-1;//count_2+1個の種類の荷物がある
	for(int i=0;i<51;i++){
		if(memo!=value[i]){
			count_2++;
			memo=value[i];
		}
		valueable[count_2]++;
	}
	
	ll answer=0;
//	cout << B-(A-COUNT[count]) << endl;
//	if()
	if(count==0&&A<=valueable[0]){//選んだ荷物が一種類しかなくて、さらにその荷物の数がAより多い
		for(int i=A;i<=min(B,valueable[0]);i++){
			answer+=pascal[valueable[0]][i];
		}
	}else{
		answer=pascal[valueable[count]][COUNT[count]];
	}

	/*
	for(int i=COUNT[count];i<=min(valueable[count],B-(A-COUNT[count]));i++){
		answer+=pascal[valueable[count]][i];
	}*/
	
	/*
	for(int i=0;i<=count;i++){//選ばれたのは何種類?
//		cout << valueable[i] << COUNT[i] << endl;
//		cout << valueable[i] << " " << COUNT[i] << endl;
//		cout << pascal[valueable[i]][COUNT[i]] << endl;
		answer*=pascal[valueable[i]][COUNT[i]];
	}
	
	if(count==0&&A<=valueable[0]){//選んだ荷物が一種類しかなくて、さらにその荷物の数がAより多い
		for(int i=A+1;i<=min(B,valueable[0]);i++){
			answer+=pascal[valueable[0]][i];
		}
	}
	
	*/
	cout << answer << endl;//A個だけ選ぶ場合。
	
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]

use std::thread;
use std::io::{ self, Read };
use std::fmt;
use std::iter::Iterator;
use std::cmp::*;
use std::collections::*;
use std::str::*;
use std::mem::*;
use std::cell::*;

struct Input {
    stdin: io::Stdin,
    buf: VecDeque<String>
}

impl Input {
    fn new() -> Input {
        Input { 
            stdin: io::stdin(),
            buf: VecDeque::new()
        }
    }

    fn read<T: FromStr>(&mut self) -> T 
    where <T as FromStr>::Err: fmt::Debug {
        self.next().unwrap().parse::<T>().unwrap()
    }

    fn read_2<T: FromStr, U: FromStr>(&mut self) -> (T, U)
    where <T as FromStr>::Err: fmt::Debug,
          <U as FromStr>::Err: fmt::Debug {
        (self.read(), self.read())
    }

    fn read_3<T: FromStr, U: FromStr, V: FromStr>(&mut self) -> (T, U, V)
    where <T as FromStr>::Err: fmt::Debug,
          <U as FromStr>::Err: fmt::Debug,
          <V as FromStr>::Err: fmt::Debug {
        (self.read(), self.read(), self.read())
    }

    fn read_bytes(&mut self) -> Vec<u8> {
        self.next().unwrap().into_bytes()
    }

    fn read_n<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where <T as FromStr>::Err: fmt::Debug {
        let mut v = Vec::new();
        for _ in 0..n { v.push(self.read::<T>()); }
        v
    }
}

impl Iterator for Input {
    type Item = String;
    fn next(&mut self) -> Option<String> {
        while self.buf.is_empty() {
            let mut s = String::new();
            let _res = self.stdin.read_line(&mut s);
            self.buf.extend(s.split_whitespace().map(|s| s.to_owned()));
        }
        self.buf.pop_front()
    }
}

fn popcnt(x: i64) -> i64 {
    let mut y = 0;
    let mut b = 1;
    while b <= x {
        if x & b > 0 { y += 1; }
        b <<= 1;
    }
    y
}

fn run() {
    let mut ip = Input::new();
    let n = ip.read();
    let a: Vec<i64> = ip.read_n(n);
    let mut ans = 1i64 << 50;
    for x in -100..101 {
        let mut s = 0;
        for &y in &a {
            s += (x - y) * (x - y);
        }
        ans = min(ans, s);
    }
    println!("{}", ans);
}

fn main() {
    let _ = thread::Builder::new()
        .stack_size(50 * 1024 * 1024)
        .spawn(run).unwrap()
        .join();
}

Measured memory_bytes: 8572
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int uint;

int popcount(uint x) {
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int tzcnt(uint x) {
    return popcount(~x & x - 1);
}

struct Point {
    int x, y;

    Point(int p, int q) : x(p), y(q) {}
};


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

    int A, B, X;
    cin >> A >> B >> X;

    out(A + B > X && A <= X ? "YES" : "NO");

    int aaa;
    cin >> aaa;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>

using namespace std;

int main()
{
	string s;
	cin >> s;
	
	int counter = 0;
	if(s[0] == '1') ++counter;
	if(s[1] == '1') ++counter;
	if(s[2] == '1') ++counter;

	cout << counter << endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n, x, t;
  cin >> n >> x >> t;
  int r = n%x;
  int q = n/x;
  if(r==0)
  {
    cout << t*q << "\n";
  }
  else
  {
    cout << t*(q+1) << "\n";
  }
}

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

G=[[] for _ in range(N+1)]

for i in range(M):
  a,b=map(int,input().split())
  G[a].append(b)
  G[b].append(a)
  
ans=0

def dfs(v,seen=None,h=[]):
    global ans
    if not seen:
      seen = [0]*(N+1)
    seen[v] = 1
    if len(h) == N:
        ans += 1
        return
    update=0
    for u in G[v]:
        if seen[u] == 0:
          seen[u] = 1
          h.append(u)
          update = 1
          dfs(u,seen,h)
          h.pop()
          seen[u] = 0
    if update==0:return

dfs(1,h=[1])
print(ans)

Measured memory_bytes: 9148
#include <stdio.h>
#include <stdlib.h>

void insertionSort(int *, int);

int main(){
  int i, N;
  int A[100];

  scanf("%d",&N);
  if(N < 1 || 100 < N) exit(1);
  
  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
    if(A[i] < 0 || 1000 < A[i]) exit(2);
  }

  insertionSort(A, N);

  return 0;
}

void insertionSort(int *A, int N){
  int h, i, j, k, v;

  for(h=0; h<N; h++){
    if(h) printf(" ");
    printf("%d", A[h]);
  }
  printf("\n");
  for(i=1; i<=N-1; i++){
    v=A[i];
    j=i-1;
    while(j >= 0 && A[j] > v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for(k=0; k<N; k++){
      if(k) printf(" ");
      printf("%d", A[k]);
    }
    printf("\n");
  }
}

  
    
  
  



Measured memory_bytes: 2060
#include<iostream>
using namespace std;
int main()
{
	int n, x;
	while (cin >> n >> x, !(n == 0 && x == 0)) {
		int counter = 0;
		for (int i = 1; i <= n - 1; i++) {
			for (int j = i + 1; j <= n; j++) {
				int k = x - i - j;
				if (k >= 1 && k <= n && k > i && k > j) {
					//cout << i << " " << j << " " << k << " " << i + j + k << endl;
					counter++;
				}
			}
		}
		cout << counter << endl;
	}
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

int k, length, pointer;
string S, str[100005];

int main(){

    cin >> S >> k;
    length = S.size();

    for (int i = 1; i <= 5; i++){
        for (int j = 0; j <= length-i; j++){
            str[pointer++] = S.substr(j,i);
        }
    }

    sort(str, str+pointer);
    unique(str, str+pointer);

    cout << str[k-1] << endl;

    return 0;

}

Measured memory_bytes: 2176
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  int a[M],b[M];
  lint c[M];
  REP(i,M){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;b[i]--;
  }
  bool l[N];
  REP(i,N)l[i]=false;


  lint S[N];
  REP(i,N)S[i]=-1e13;
  S[0]=0;
  REP(i,N){
    REP(j,M){
      S[b[j]]=max(S[b[j]],S[a[j]]+c[j]);
    }
  }
  lint temp=S[N-1];
  REP(i,N){
    REP(j,M){
      S[b[j]]=max(S[b[j]],S[a[j]]+c[j]);
    }
  }
  if(S[N-1]>temp){
    cout<<"inf"<<endl;
    return 0;
  }
  cout<<S[N-1]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	string s;
	cin>>s;
	
	int a=(int)s.find("A");
	int z=(int)s.rfind("Z");
	cout<<z-a+1<<endl;
}

Measured memory_bytes: 640
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

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

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

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

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

signed main() {
	int x, a, b;
	cin >> x >> a >> b;
	cout << (x-a)%b << endl;

    return 0;
}


Measured memory_bytes: 256
H,W = map(int, input().split())
Grid = [list(input()) for i in range(H)]
mod = 10**9+7
dp = [[0]*W for _ in range(H)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if j+1 < W and Grid[i][j+1] == ".":
            dp[i][j+1] += dp[i][j]
            dp[i][j+1] %= mod
        if i+1 < H and Grid[i+1][j] == ".":
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= mod
print(dp[-1][-1])

Measured memory_bytes: 88688
#include <iostream>

using namespace std;

void showArray(int SIZE, int *a) {
	for (int i = 0; i < SIZE; i++) {
		
		if (i == SIZE - 1) cout << a[i] << endl;
		else cout << a[i] << ' ';
	}
	
}

int main()
{

	int SIZE = 3;
	int a[3];
	
	cin >> a[0] >> a[1] >> a[2];

	int temp;

	for (int i = 0; i < SIZE; i ++ ) {
		for (int j = SIZE - 1; j > i; j--) {
			if (a[j] < a[j - 1]) {
				temp = a[j-1];
				a[j - 1] = a[j];
				a[j] = temp;

			}
		}

	}

	showArray(SIZE,a);

    return 0;
}






Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> sunuke(n,0);
  
  for(int i=0; i<k;i++){
    int d;
    cin >> d;
    for(int j=0;j<d;j++){
     int k;
      cin >> k;
        sunuke.at(k-1)++ ;
    }
  }
  int answer;
  for(int i=0;i<n;i++){
    if(sunuke.at(i) == 0){answer++;}
  }
  
  cout << answer << endl;
}

      

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;

#define int long long
#pragma GCC optimize ("O3")
#define ll long long
#define vec vector <int>
#define rep(i,a,b) for (ll i=a;i<b;i++)
#define repD(i,a,b) for (ll i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define maa 1000000007
#define Eps 1e-9
#define PI 3.14159265359

typedef tree<pii,null_type,less <pii >,rb_tree_tag,tree_order_statistics_node_update>ind_set;
typedef gp_hash_table<int, int, hash<int> > ht1;   /// if clear is required
typedef cc_hash_table<int, int, hash<int> > ht2;

///*X.find_by_order("index")
///X.order_of_key("key")

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

string a,b;
int n,m;
int DP[5000][5000];
int fun(int i,int j)
{
    if (i>=n)return 0;
    if (j>=m)return 0;
    if (DP[i][j]!=0)return DP[i][j];

    DP[i][j]=max(fun(i+1,j),fun(i,j+1));
    if (a[i]==b[j])DP[i][j]=1+fun(i+1,j+1);
    return DP[i][j];
}
string ans;
string CDP[3002][3002];
string reconstruct(int i,int j)
{
    if (i>=n ||j>=m)return "";

    if (CDP[i][j]!="%")return CDP[i][j];

    if (DP[i+1][j+1]==DP[i][j]-1 &&DP[i][j]==DP[i+1][j]+1&&DP[i][j]==DP[i][j+1]+1)
        {return CDP[i][j]=a[i]+reconstruct(i+1,j+1);}
    else if (DP[i][j+1]>DP[i+1][j])return CDP[i][j]=reconstruct(i,j+1);
    else return CDP[i][j]=reconstruct(i+1,j);


}

void solve()
{
    cin>>a>>b;n=a.length();m=b.length();
rep(i,0,3002)rep(j,0,3002)DP[i][j]=0;
    ///int L=fun(0,0);return;
/*rep(i,0,n)
{
    cout<<"\n";rep(j,0,m)cout<<DP[i][j]<<" ";
}*/
//cout<<L<<"\n";

    repD(i,n-1,-1)
    {
        repD(j,m-1,-1)
        {
            if (a[i]==b[j])DP[i][j]=1+DP[i+1][j+1];
            else DP[i][j]=max(DP[i+1][j],DP[i][j+1]);
        }
    }
rep(i,0,n+2)rep(j,0,m+2)CDP[i][j]="%";
    ans=reconstruct(0,0);cout<<ans<<"\n";




}
signed main()
{

    srand(time(NULL));

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

///freopen("input.txt","r",stdin);
///freopen("output.txt","w",stdout);

    int t=1;
///cin>>t;
    rep(a,0,t)
    {
        ///cout<<"Case "<<a+1<<": ";
        solve();
    }
}


Measured memory_bytes: 618880
#include"bits/stdc++.h"
using namespace std;

#define ll long long int
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define sz(a) int((a).size())
#define mod 1000000007
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

template <typename T>
inline void seethis(vector<T>vect)
{
    for(T x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll n;
	 cin>>n;

	 vector<ll>vect(n+1);

	 for(int i=1;i*i<=n;i++)
	 {
	 	for(int j=i;j*j<=n;j++)
	 	{
	 		for(int z=j;z*z<=n;z++)
	 		{
	 			ll val= i*i + j*j + z*z + i*j + i*z + j*z;

	 			if(val<=n)
	 			{
	 				if(i!=j and i!=z and j!=z)
	 				{
	 					vect[val]+=6;
	 				}
	 				else if(i==j and i==z)
	 				{
	 					vect[val]+=1;
	 				}
	 				else
	 					vect[val]+=3;
	 			}
	 		}
	 	}
	 }

	 for(int i=1;i<=n;i++)
	 	cout<<vect[i]<<"\n";
	// cout<<"\n";
	
	return 0;
}

Measured memory_bytes: 3684
import java.io.IOException
import java.io.InputStream
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = sc.nextIntArray(n).sorted().toMutableList()
    while (a.size > 1 && a.first() > 1) {
        val second = a.removeAt(1)
        val first = second % a.first()
        if (first > 0) {
            a.add(0, first)
        }
    }
    println(a.first())
}

class Scanner(private val `in`: InputStream) {
    private val buffer = ByteArray(1024)
    private var ptr = 0
    private var buflen = 0

    companion object {
        private fun isPrintableChar(b: Byte): Boolean = b in 33..126
        private fun isNumericChar(b: Byte): Boolean = b in 48..57
        private fun digit(b: Byte): Int = b - 48
    }

    fun hasNextByte(): Boolean {
        if (ptr < buflen) return true
        ptr = 0
        try {
            buflen = `in`.read(buffer)
        } catch (e: IOException) {
            e.printStackTrace()
        }
        return 0 < buflen
    }

    private fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        return buildString {
            var b = readByte()
            while (isPrintableChar(b)) {
                appendCodePoint(b.toInt())
                b = readByte()
            }
        }
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextInts(n: Int): Array<Int> = Array(n) { nextInt() }

    fun nextIntArray(n: Int): IntArray = IntArray(n) { nextInt() }

    fun nextIntArrays(n: Int, m: Int): Array<IntArray> {
        val arrays = Array(m) { IntArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextInt() } }
        return arrays
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextLongs(n: Int): Array<Long> = Array(n) { nextLong() }

    fun nextLongArray(n: Int): LongArray = LongArray(n) { nextLong() }

    fun nextLongArrays(n: Int, m: Int): Array<LongArray> {
        val arrays = Array(m) { LongArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextLong() } }
        return arrays
    }

}

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

int main(){
	const int INF=1000000000;
	int n,c;
	static int dp[2][5000+2][2];
	for(int i=0;i<2;i++)for(int j=0;j<5002;j++){dp[i][j][0]=INF; dp[i][j][1]=INF;}
	dp[1][1][0]=0;
	dp[1][0][1]=0;
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		int s=i%2,t=1-s;
		scanf("%d",&c);
		int m=min(i,n/2);
		for(int j=0;j<=m;j++){
			if(j==0)dp[s][j][0]=INF;
			else dp[s][j][0]=min(dp[t][j-1][0],dp[t][j-1][1]+c);
			dp[s][j][1]=min(dp[t][j][0]+c,dp[t][j][1]);
		}
	}
	printf("%d\n",min(dp[0][n/2][0],dp[0][n/2][1]));
}

Measured memory_bytes: 1248
from itertools import product
n = int(input())
testimony = []
ans = 0

for _ in range(n):
    a = int(input())
    t = [list(map(int, input().split())) for _ in range(a)]
    testimony.append(t)

for bits in product(range(2), repeat=n):
    for num, bit in enumerate(bits):
        if bit:
            for x, y in testimony[num]:
                if bits[x-1] != y:
                    break
            else:
                continue
            break
    else:
        ans = max(ans, sum(bits))
print(ans)


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int loop,ball,hidari,migi;
int main(){
  cin>>loop;
  for(int i=0;i<loop;i++){
    hidari=migi=0;
    for(int j=0;j<10;j++){
      cin>>ball;
      if(ball<=migi&&ball<=hidari){
	cout<<"NO"<<endl;
	j++;
	for(;j<10;j++){cin>>ball;}
      }
      if(hidari>migi){
	if(ball>hidari)hidari=ball;
	else migi=ball;
      }
      else{
	if(ball>migi)migi=ball;
	else hidari=ball;
	}
      if(j==9){
	cout<<"YES"<<endl;
      }
    }
  }
}

Measured memory_bytes: 1152
N = gets.to_i
ary = gets.split.map(&:to_i)
cnt = 0
0.upto(N-3) do |i|
    (i+1).upto(N-2) do |j|
        (j+1).upto(N-1) do |k|
            if ary[i] < ary[j] + ary[k] && ary[j] < ary[k] + ary[i] && ary[k] < ary[i] + ary[j] && ary[k] != ary[i] + ary[j] && ary[i] != ary[j] && ary[j] != ary[k] && ary[k] != ary[i]
                cnt += 1
            end
        end
    end
end
puts cnt

Measured memory_bytes: 14316
import bisect
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)

left=b[int(n/2)-1]
right=b[int(n/2)]
for i in a:
    pos=bisect.bisect_left(b, i)+1
    if 2*pos<=n:
        print(right)
    else:
        print(left)

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

typedef pair<double, double> P;

double dist(P a, P b) {
    double x = a.first - b.first;
    double y = a.second - b.second;
    return sqrt(x * x + y * y);
}

double dist2(P a, P b) {
    double x = a.first - b.first;
    double y = a.second - b.second;
    return x * x + y * y;
}

bool j(P A, P B, P C) {
    double a = dist2(A, B), b = dist2(B, C), c = dist2(C, A);
    vector<double> D = {a, b, c};
    sort(D.begin(), D.end());
    return D[2] < D[0] + D[1];
}

double R(P A, P B, P C) {
    double a = dist(A, B), b = dist(B, C), c = dist(C, A);
    vector<double> D = {a, b, c};
    sort(D.begin(), D.end());
    if(j(A, B, C)) {
        double u = a * b * c;
        double d = sqrt((a+b+c) * (-a+b+c) * (a-b+c) * (a+b-c));
        return u / d;
    } else {
        return D[2] / 2;
    }
}

int main() {
    int N; cin >> N;
    vector<P> p(N);
    rep(i, N) {
        double a, b;
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }
    if(N == 2) {
        double ans = dist(p[0], p[1]) / 2;
        printf("%.10lf\n", ans);
        return 0;
    }
    double ans = 0.0;
    for(int i = 0; i < N; ++i) {
        for(int j = i + 1; j < N; ++j) {
            for(int k = j + 1; k < N; ++k) {
                double r = R(p[i], p[j], p[k]);
                ans = max(ans, r);
            }
        }
    }
    printf("%.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iterator>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vector<int> > 
#define vl vector<long long>
#define vc vector<char> 
#define vvc vector<vector<char> > 
#define vpi vector<pair<int,int> >
#define ll long long 
#define sz(a) int(a.size())
#define forn(i,n) for(int i = 0 ; i < int(n) ; i++)
#define all(x) x.begin(),x.end()
#define vpl vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pci pair<char,int>
#define len(s) s.length()
#define un unsigned
# define M_PI           3.14159265358979323846  /* pi */
#define modulo 998244353ll
#define mod 1000000007ll
#define MAXN  1000001 
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


void solve()
{
    int n,m;
    cin>>n>>m;
    vi row[n];
    vi col[m];
    vvc path(n,vc (m,'.'));
    forn(i,n)
    {
        forn(j,m)
        {
            cin>>path[i][j];
            if(path[i][j] == '#')
            {
                row[i].pb(j);
                col[j].pb(i);
            }
        }
    }
    int ans = 0;
    forn(i,n)
    {
        forn(j,m)
        {
            if(path[i][j] == '.')
            {
                int temp = 0;
                int ind = upper_bound(all(row[i]),j)-row[i].begin();
                if(ind == row[i].size())
                {
                    temp += m-1;
                }
                else
                {
                    temp += row[i][ind]-1;
                }
                if(ind-1 >= 0)
                temp -= row[i][ind-1];
                else
                {
                    temp -= -1;
                }
                ind = upper_bound(all(col[j]),i) - col[j].begin();
                if(ind == col[j].size())
                {
                    temp += n-1;
                }
                else
                {
                    temp += col[j][ind]-1;
                }
                if(ind-1 >= 0)
                {
                    temp -= col[j][ind-1];
                }
                else
                {
                    temp -= -1;
                }
                ans = max(ans,temp-1);
            }
        }
    }
    cout<<ans<<endl;
}



int main()
{
    fast();
    int t;
    // cin>>t;
    t = 1;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 41704
#include <stdio.h>
int main(){
    int a[100],i,n;
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=n-1;0<=i;i--){
        if(i==0) {
            printf("%d",a[i]); 
            break;
        }
        printf("%d ",a[i]);
        
    }
    printf("\n");
    return 0;
}

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

int main(void)
{
	int k, p, n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> k >> p;
		if (k % p == 0)
		{
			cout << p << endl;
		}
		else
		{
			cout << k % p << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3080
#include <list>
#include <set>
#include <cassert>
#include <iostream>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

#define f first
#define s second
#define mp make_pair

using namespace std;

struct Sectors{
  int start;
  int end;
  int id;
  Sectors() : start(0), end(1000000010), id(-1){}
  Sectors(int s, int e, int i) : start(s), end(e), id(i){}

  int size(){ return end - start + 1; }
  bool isEmpty(){ return id == -1; }
  bool isIn(int sec){ return start <= sec && sec <= end; }
};

int main(){
  int n;
  while(scanf("%d", &n), n){
    list<Sectors> ss;
    int emp = 0;

    ss.push_back(Sectors());
 
    REP(cc, n){
      char buff[2];
      scanf("%s", buff);
      if(buff[0] == 'W'){
	int l, s;
	scanf("%d%d", &l, &s);

	if(emp == 0){
	  list<Sectors>::iterator it = ss.end(); --it;
	  int start = it->start;
	  int end   = start + s - 1;
	  it->start = end + 1;
	  it = ss.insert(it, Sectors(start, end, l));
	}else{
	  list<Sectors>::iterator it = ss.begin();
	  while(s > 0){
	    if(it->isEmpty()){
	      int sz = it->size();
	      if(sz > s){
		int start = it->start;
		int end   = start + s - 1;
		it->start = end + 1;
		it = ss.insert(it, Sectors(start, end, l));
		break;
	      }else{
		s -= sz;
		it->id = l;
		emp--;
	      }
	    }

	    assert(it != ss.end());
	    ++it;
	  }
	}
      }else if(buff[0] == 'D'){
	int l;
	scanf("%d", &l);
	FOR(it, ss){
	  if(it->id == l){
	    it->id = -1;
	    emp++;
	  }
	}
      }else{
	int sec;
	scanf("%d", &sec);

	FOR(it, ss){
	  if(it->isIn(sec)){
	    printf("%d\n", it->id);
	    break;
	  }
	}
      }

      // FOR(it, ss)printf("[%d,%d]:%d ", it->start, it->end, it->id);puts("");
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 1044
#include<stdio.h>
#include<math.h>

int main() {

   int n, d, i, j, x;
   int c = 0;

   scanf("%d", &n);

   for (i = 0; i <= n - 1; i++) {
      scanf("%d", &x);
      for(d = 2; d <= sqrt(x); d++) {
         if (x != 2 && x % d == 0) {
            c--;
            break;
         }
      }
      c++;
   }

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

   return 0;
}



Measured memory_bytes: 2080
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll inf=1e18;
const int N=1e5+3;
struct oy{
	int x,y,id;
}a[N],b[N];
struct dio{
	int u,v,w;
}e[N<<1];
bool cmp1(oy a,oy b){return a.x<b.x;}
bool cmp2(oy a,oy b){return a.y<b.y;}
bool cmp3(dio a,dio b){return a.w<b.w;}
int pre[N],n,cnt;
int find(int x){
	return pre[x]==x?x:pre[x]=find(pre[x]);
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) pre[i]=i;
    for(int i=1;i<=n;i++){
    	cin>>a[i].x>>a[i].y;
    	a[i].id=b[i].id=i;
    	b[i].x=a[i].x;b[i].y=a[i].y;
    }
    sort(a+1,a+1+n,cmp1);
    sort(b+1,b+1+n,cmp2);
    for(int i=2;i<=n;i++){
    	e[cnt].u=a[i-1].id;
    	e[cnt].v=a[i].id;
    	e[cnt].w=a[i].x-a[i-1].x;
    	cnt++;
    }
    for(int i=2;i<=n;i++){
    	e[cnt].u=b[i-1].id;
    	e[cnt].v=b[i].id;
    	e[cnt].w=b[i].y-b[i-1].y;
    	cnt++;
    }
    int num=0;
    ll ans=0;
    sort(e,e+cnt,cmp3);
    for(int i=0;i<cnt;i++){
    	int x=find(e[i].u),y=find(e[i].v);
    	if(x!=y){
    		pre[x]=y;
    		ans+=e[i].w;
    		num++;
    	}
    	if(num==n-1) break;
    }
    cout<<ans<<endl;
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    while(true){
      cin >> n;
      bool flag = false;
      if(n == 0) break;
      VVI day(31);
      VI cntNum(n,1);
      vector<vector<bool>> cnt(n,vector<bool>(n,false));
      rep(i,n) cnt[i][i] = true;

      rep(i,n){
        int x;
        cin >> x;
        rep(j,x){
          int m;
          cin >> m;
          day[m].push_back(i);
        }
      }


      rep(i,31){
        if(day[i].size() == 0) continue;

        vector<bool> current(n,false);
        rep(j,day[i].size()){
          rep(k,n){
            if(cnt[day[i][j]][k]) current[k] = true;
          }
        }
        rep(j,day[i].size()){
          rep(k,n){
            if(cnt[day[i][j]][k] == false && current[k]){
              cnt[day[i][j]][k] = true;
              cntNum[day[i][j]]++;
              if(cntNum[day[i][j]] == n) flag = true;
            }
          }
        }
        current.clear();
        if(flag){
          cout << i << endl;
          break;
        }
      }
      if(flag == false){
        cout << -1 << endl;
      }
      cnt.clear();
      cntNum.clear();
      day.clear();
    }
    return 0;
}



Measured memory_bytes: 3144
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

int ans[1 << 21];

int adj[] = {-6, -1, 1, 6};
int pos[] = {7, 8, 9, 10, 13, 14, 15, 16};

int encode(const vector<int> &v){
	int r = 0;
	for(int i = 0; i < 8; ++i){
		r |= v[pos[i]] << (3 * i);
	}
	return r;
}

void decode(int r, vector<int> &ret){
	ret.assign(24, -1);
	for(int i = 0; i < 8; ++i){
		ret[pos[i]] = r & 7;
		r >>= 3;
	}
}

int main(){
	const int mask = 07777777;

	for(int i = 0; i < (1 << 21); ++i){
		ans[i] = -1;
	}

	vector<int> v(24, -1), w;
	for(int i = 0; i < 8; ++i){
		v[pos[i]] = i;
	}
	int c = encode(v);
	ans[c & mask] = 0;
	queue<int> q;
	q.push(c);
	q.push(-1);
	int tm = 1;
	while(q.size() > 1){
		c = q.front();
		q.pop();
		if(c == -1){
			++tm;
			q.push(-1);
		}
		else{
			decode(c, v);
			int x;
			for(x = 7; v[x]; ++x);
			for(int i = 0; i < 4; ++i){
				int y = x + adj[i];
				if(v[y] > 0){
					swap(v[x], v[y]);
					c = encode(v);
					if(ans[c & mask] == -1){
						ans[c & mask] = tm;
						q.push(c);
					}
					swap(v[x], v[y]);
				}
			}
		}
	}

	while(1){
		for(int i = 0; i < 8; ++i){
			if(scanf("%d", &v[pos[i]]) == EOF){
				return 0;
			}
		}
		printf("%d\n", ans[encode(v) & mask]);
	}
}

Measured memory_bytes: 9256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef  long long  ll;
typedef vector<ll> vll;
#define meme(s) memset(s,0,sizeof(s))
#define rall(s) s.rbegin(),s.rend()
#define i(x) scanf("%lld",&(x))
typedef unordered_map<ll,ll> mll;
#define pb push_back
#define in2(x,y) i(x),i(y)
#define EL cout<<'\n'
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define all(s) s.begin(),s.end()
typedef unordered_map<ll,vll>circuit;
typedef unordered_map<ll,bool>is;
const ll MOD=1e9+7;
#define no cout<<"NO\n"
#define yes cout<<"YES\n"
#define fr(n,x) for(int n=0;n<x;n++)
#define pf(x) printf("%lld\n",(x))
const  ll mx=2e6;
const int N = 1e6+6;
#define segtree ll L=2*node,R=L+1,mid=(l+r)/2
#define cs(n) printf("Case %lld: ",(n))
typedef pair<ll,ll> pll;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")




int main()
{

   mll s;
   ll x;
   i(x);
   ll d;
   fr(n,x-1)
   {
       i(d);
       s[d]++;
   }
   for(ll n=1;n<=x;n++)pf(s[n]);
}

Measured memory_bytes: 11548
N = int(input())
XY = []
for _ in range(N):
    A = int(input())
    xy = []
    for _ in range(A):
        x, y = map(int, input().split())
        x -= 1
        xy.append((x, y))
    XY.append(xy)
ans = 0
for s in range(1<<N):
    for i in range(N):
        if s>>i&1:
            for x, y in XY[i]:
                if s>>x&1 != y:
                    break
            else:
                continue
            break
    else:
        ans = max(ans, bin(s).count("1"))
print(ans)


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

using namespace std;

typedef pair<int, int> p;
typedef long long ll;
const int inf = 1000000007;

int main() {
  int n;
  cin >> n;
  set<int> s;
  rep(i, n) {
    int d;
    cin >> d;
    s.insert(d);
  }
  cout << s.size() << endl;
  return 0;
}

Measured memory_bytes: 3592
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> Ais(N);
    rep(i,0,N) {
        cin >> Ais[i];
    }
//    ll N, K;
//    N = 100000;
//    K = 1000000000000;
//    vector<ll> Ais(N);
//    random_device rng;
//    rep(i,0,N) {
//        Ais[i] = rng() % (2 * 100000 - 1) + 1;
//    }
    auto table = make_vec_nd((ll)numeric_limits<ll>::max(), 64, N);
    unordered_map<ll, ll> last_appear;
    rep(i,0,2*N) {
        ll Ai = Ais[i%N];
        if (last_appear.find(Ai) != last_appear.end()) {
            table[0][last_appear[Ai]%N] = i - last_appear[Ai] + 1;
        }
        last_appear[Ai] = i;
    }
    rep(p,1,64) {
        rep(i,0,N) {
            ll next_i = (i + table[p-1][i]) % N;
            table[p][i] = table[p-1][i] + table[p-1][next_i];
            if (table[p][i] > N * K) {
                table[p][i] = N * K;
            }
        }
    }
    ll start_idx = 0;
    while (true) {
        if (start_idx + table[0][start_idx%N] >= N * K) {
            break;
        }
        ll p = 0;
        while (start_idx + table[p][start_idx%N] < N * K) {
            p++;
        }
        p--;
        start_idx += table[p][start_idx%N];
    }
    unordered_map<ll, ll> values_cnt;
    vector<ll> ans;
    rep(i,start_idx,N*K) {
        ll Ai = Ais[i%N];
        if (values_cnt[Ai] == 0) {
            ans.push_back(Ai);
            values_cnt[Ai]++;
        } else {
            while (values_cnt[Ai] > 0) {
                values_cnt[ans.back()]--;
                ans.pop_back();
            }
        }
    }
    rep(i,0,ans.size()) {
        cout << ans[i];
        if (i < ans.size()-1) {
            cout << " ";
        }
    }
    cout << endl;
}



Measured memory_bytes: 126692
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000
#define EMPTY -10
#define mp(a, b) make_pair(a,b)

bool resuelveCaso() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	if (!cin) return false;
	
	int difx = x2 - x1, dify = y2 - y1;

	int rdifx = -dify, rdify = difx;

	cout << x2 + rdifx << ' ' << y2 + rdify << ' ' << x1 + rdifx << ' ' << y1 + rdify << '\n';

	/*
	if (x1 < x2) {
		cout << x2 << ' ' << y2 + (x2 - x1) << ' ' << x1 << ' ' << y2 + (x2 - x1) << '\n';
	}

	else if (x1 == x2 && y1 < y2) {
		cout << x1 - (y2 - y1) << ' ' << y2 << ' ' << x1 - (y2 - y1) << ' ' << y1 << '\n';
	}
	else if (x1 > x2) {
		cout << x2 << ' ' << y1 - (x2 - x1) << ' ' << x1 << ' '  << y1 - (x2 - x1) << '\n';
	}
	else {
		cout << x2 + (y1 - y2) << ' ' << y2 << ' ' << x1 + (y1 - y2) << ' ' << y1 << '\n';
	}
	*/


	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

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

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

const int MAX_N = 1e5 + 5;
int n, ans;
int Arr[MAX_N];

int _gcd (int a, int b) {
	return !b? a: _gcd(b, a % b);
}

void calc (int d) {
	int cnt = 0;
	for (int i = 0; i < n; i++)
		cnt += (Arr[i] % d != 0);

	if (cnt <= 1)
		ans = max(ans, d);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> Arr[i];

	ans = 0;
	for (int i = 1; i < n; i++)
		ans = _gcd(ans, Arr[i]);

	for (int i = 1; i * i <= Arr[0]; i++)
		if (Arr[0] % i == 0) {
			calc(i);
			calc(Arr[0] / i);
		}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 640
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
  for j in range(W+1):
    if j>=w[i]:
      dp[i+1][j]=max(dp[i][j] ,dp[i][j-w[i]] +v[i] )
    else:
      dp[i+1][j]=dp[i][j]
print(dp[N][W])

Measured memory_bytes: 120300
#include<stdio.h>

int A[100000], n;

int binarySearch(int key){
  int left = 0, right = n, mid;

  while(left < right){
    mid = (left + right) / 2;
    if(key == A[mid]) return 1;
    if(key > A[mid]) left = mid + 1;
    else if(key < A[mid]) right = mid;
  }
  return 0;
}


int main(){

  int i, q, k, sum = 0;

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

  scanf("%d", &q);
  for(i = 0 ; i < q ; i++){
    scanf("%d", &k);
    if(binarySearch(k)) sum++;
  }

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

  return 0;
}


Measured memory_bytes: 2184
def f(n):
    s = (n + 1) // 2
    if s & 1 == 1:
        if (n + 1)& 1 == 1:
            return 1 ^ n
        else:
            return 1
    else:
        if (n + 1) & 1 == 1:
            return 0 ^ n
        else:
            return 0

def main():
    a, b = map(int, input().split())
    if a == 0:
        print(f(b))
    elif a == b:
        print(a)
    else:
        print(f(a - 1) ^ f(b))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38404
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		string s;
		cin >> s;
		ll ans = 0;
		for (char c : s) {
			ans += (c - '0');
		}
		if (ans % 9 == 0) cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int cou(int x)
{
    if(x == 0) return 0;
    return cou(x>>1) + (x & 1);
}
int A[20],x[20][20],y[20][20];
int main()
{
    int n;cin>>n;
    for(int i = 1; i <= n; i++){
            cin>>A[i];
     for(int j = 1; j <= A[i]; j++)
        cin >> x[i][j] >> y[i][j];
    }
    int ans=0;
    for(int bi =1; bi < (1 << n); bi++){
         bool ok=true;
         for(int i = 1; i <=n; i++){
            if(!(bi & (1 << (i-1)))) continue;
            for(int j = 1; j <= A[i]; j++){
                if(((bi >> (x[i][j]-1)) & 1)^ y[i][j]) ok=false;
            }
         }
        if(ok) ans = max(ans , cou(bi));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    ll X, K, D;
    in3(X, K, D);

    X = abs(X);

    ll L = X / D;

    if (L >= K)
    {
        X -= K * D;
    }
    else
    {
        X -= L * D;
        K -= L;

        if (K % 2 == 1) X = abs(X - D);
    }

    outl(X);

    return 0;
}

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

int main(){
  ll x;
  cin >> x;
  ll y = x / 11;
  ll z = x % 11;
  y *= 2;
  if (z < 7 && z != 0) y++;
  else if (z > 6) y += 2;
  cout << y << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
long long int arr[100009],crr[100009];
int main()
{
    long long int n,k, temp;

    cin>>n>>k;

    for(int i=1; i<=n; i++)
    {
        cin>>crr[i];
    }
    arr[1] = 0;
    arr[2] = abs(crr[1]-crr[2]);
    if(n==2){cout<<abs(crr[1]-crr[2])<<endl;return 0;}

    for(int i=3; i<=n; i++)
    {
        arr[i] = 1e18;
        for(int j=1; j<=k; j++)
        {
            if( i-j>=1 )
            {
                //arr[i] = arr[i] + arr[i-j];
                temp = abs(crr[i] - crr[i-j])+arr[i-j];
                arr[i] = min(arr[i],temp);
            }else
            {
                break;
            }
        }
    }
//    for(int i=1; i<=n; i++)
//    {
//        cout<<arr[i]<<" ";
//    }
    cout<<arr[n]<<endl;
    return 0;
}


Measured memory_bytes: 1792