akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

using namespace std;

int main ()
{
  int N,K,b,cost;
  vector<int> h;

  cin >> N >> K;

  vector<int> costs(N);

  REPI (N)
  {
    cin >> b;
    h.push_back (b);
    costs[i] = INT_MAX;
  }

  costs[0] = 0;

  for (int i=1;i<N;i++)
  {
    cost = INT_MAX;
    
    for (int j=1;j<=K;j++)
    {
      if (i-j < 0)
        break;
      cost = min (cost, costs[i-j] + abs(h[i]-h[i-j]));
    }

    costs[i] = min(cost,costs[i]);
  }

  cout << costs[N-1] << endl;
  return 0;
}

Measured memory_bytes: 4300
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define N 112345
using namespace std;
int n,m,sum,res,flag;
int main()
{
    int i,j,k,T,cas,x,y,t;
    scanf("%d",&n);
        printf(n<1200?"ABC\n":"ARC\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
typedef priority_queue <int> pi;
typedef priority_queue <int, vector<int>, greater<int>> pg;
typedef unsigned long long int ulli;

int main()
{
    int ans = 0, N;
    cin >> N;
    char temp[N];
    REP(i,N)
    {
        cin >> temp[i];
    }
    bool P = false, W = false, G = false, Y = false;
    REP(i,N)
    {
        if (temp[i] == 'P' && P == false)
        {
            ++ans;
            P = true;
        }
        if (temp[i] == 'W' && W == false)
        {
            ++ans;
            W = true;
        }
        if (temp[i] == 'G' && G == false)
        {
            ++ans;
            G= true;
        }
        if (temp[i] == 'Y' && Y == false)
        {
            ++ans;
            Y = true;
        }
    }
    if(ans == 3)
    {
        cout << "Three" << endl;
    }
    else if(ans == 4)
    {
        cout << "Four" << endl;
    }
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin : StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin : StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main(){
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: usize = sc.read();
    let mut cnt = 0;
    for _ in 0..n {
        let s: String = sc.read();
        if s == "A" {
            cnt += 1;
        } else {
            if cnt == 0 {
                println!("NO");
                return;
            } else {
                cnt -= 1;
            }
        }
    }
    if cnt != 0 {
        println!("NO");
    } else {
        println!("YES");
    }
}



Measured memory_bytes: 5032
#include <bits/stdc++.h>
#include <numeric>
#define M 1000000007
#define inf 1e18+1
#define pb push_back
// #define mp make_pair
#define forz(i,s,n) for(lli i=s;i<n;i++)
#define fore(i,n,s) for(lli i=n;i>=s;i--)
#define binod ios_base ::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

typedef long long int lli;
//typedef pair<long long int, long long int> pll;
typedef unsigned long long int ull;
using namespace std;

lli recpow(lli x, lli n, lli mod)
{
    if (n == 0)
        return 1;
    else if (n % 2 == 0) //n is even
        return recpow((x * x) % mod, n / 2, mod);
    else //n is odd
        return (x * recpow((x * x) % mod, (n - 1) / 2, mod)) % mod;
}


//code begins here
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    binod
    //sieve();
    lli n,mw;
    cin>>n>>mw;
    lli v[n], w[n];
    forz(i,0,n)
    cin>>w[i]>>v[i];
    lli tv=0;
    forz(i,0,n)
    tv+=v[i];
    lli dp[tv+1];
    forz(i,1,tv+1)
    dp[i]=inf;
    dp[0]=0;
    forz(i,0,n)
    {
        fore(j,tv,v[i])
        if(dp[j-v[i]]<inf)
        dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
    }
    lli x=tv;
    while(x>=0 and dp[x]>mw)
    x--;
    cout<<x;
    return 0;
}

Measured memory_bytes: 4388
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/

 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n ,d;
    cin >> n>>d;
    int a[n][d];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<d;j++)
        cin >> a[i][j];
    }
    double dist=0;
    int c=0;
    for(int i=0;i<n;i++)
    {    
        for(int j=i+1;j<n;j++)
        {
            dist = 0;
            for(int k=0;k<d;k++)
            dist += (a[i][k] - a[j][k])*(a[i][k]-a[j][k]);
            dist = sqrt(dist);
            if(floor(dist)==dist)
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) begin(x),end(x)
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
//const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
int n, a, b;
int c, cn, cnt;
/*signed*/int main(void) {
    cin >> n >> a >> b;
    vector<int> vec(n);
    rep(i, n) {
        cin >> vec[i];
        if (vec[i] <= a) ++c;
        else if (vec[i] <= b) ++cn;
        else ++cnt;
    }
    cout << min({ c,cn,cnt }) << endl;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    if(a < c && c < b) cout << "Yes" << endl;
    else if(b < c && c < a) cout << "Yes" << endl;
    else  cout << "No" << endl;
    return 0;
}

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

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

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

const int N = 1e6 + 5;

/***************************************************************************/

vector<int> identity(int n) {
	vector<int> A(n);
	for(int i=0; i<n; i++) {
		A[i] = i;
	}
	return A;
}

vector<int> inverse(vector<int> A) {
	vector<int> B(A.size());
	for(int i=0; i<(int)B.size(); i++) {
		B[A[i]] = i;
	}
	return B;
}

vector<int> multiply(vector<int> A, vector<int> B) {
	vector<int> C(A.size());
	for(int i=0; i<(int)C.size(); i++) {
		C[i] = A[B[i]];
	}
	return C;
}

vector<int> power(vector<int> A, int n) {
	if(n == 0) return identity(A.size());
	vector<int> B = power(A, n >> 1);
	B = multiply(B, B);
	if(n & 1) B = multiply(B, A);
	return B;
}

int main() {

	boost;
	int n, k; cin>>n>>k; k--;
	vector<int> P(n), Q(n);
	for(int i=0; i<n; i++) {
		cin>>P[i]; P[i]--;
	}
	for(int i=0; i<n; i++) {
		cin>>Q[i]; Q[i]--;
	}

	vector<int> A = multiply(multiply(Q, inverse(P)), multiply(inverse(Q), P));
	A = power(A, k/6);
	k %= 6;
	if(k >= 3) A = multiply(A, Q);
	if(k > 3) A = multiply(A, inverse(P));

	vector<int> B = P;
	if(k == 1) B = Q;
	else if(k == 2) B = multiply(Q, inverse(P));
	else if(k == 3) B = inverse(P);
	else if(k == 4) B = inverse(Q);
	else if(k == 5) B = multiply(inverse(Q), P);

	vector<int> AK = multiply(A, multiply(B, inverse(A)));
	for(int i=0; i<n; i++) {
		cout<<AK[i]+1<<" ";
	}
	cout<<"\n";

	return 0;
}

Measured memory_bytes: 13696
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = stdIn.nextInt();
		}
		
		int m = stdIn.nextInt();
		int b[] = new int[m];
		for(int i = 0; i < m; i++){
		    b[i] = stdIn.nextInt();
		}
		
		int aindex = 0;
		int bindex = 0;
		
		while(true){
		    if(a[aindex] == b[bindex]){
		        aindex++;
		        bindex++;
		    }else if(a[aindex] > b[bindex]){
		        bindex++;
		    }else if(a[aindex] < b[bindex]){
		        System.out.println(a[aindex]);
		        aindex++;
		    }
		    
		    if(aindex == n){
		        break;
		    }
		    
		    if(bindex == m){
		        for(int i = aindex; i < n; i++){
		            System.out.println(a[i]);
		        }
		        break;
		    }
		}
        
		stdIn.close();
	}

}




Measured memory_bytes: 160392
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<bitset>
#include<vector>
#include<math.h>
#include<stack>
#include<map>
#include<queue>
#define ls(x) (x<<1)
#define rs(x) ((x<<1)|1)
#define eps 1e-9
using namespace std;
int n,x;
int a[105];
int main()
{
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int i;
	for(i=1;i<=n;i++)
	{
		if(x>=a[i])
		{
			x-=a[i];
		}
		else break;
	}
	i--;
	if(i==n&&x!=0)i--;
	printf("%d",i);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a, b, temp, i;
    for(i=1; i<=3000; i++)
    {
       cin >> a >> b;
        if( a==0 && b==0)
        break;
    if(a > b)
    {
    temp = a;
    a = b;
    b = temp;
    }
   cout << a << " " << b << endl;
}
}


Measured memory_bytes: 3016
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = [1 for _ in range(n)]

for i in range(m):
  a, b = map(int, input().split())
  if h[a-1] > h[b-1]:
    l[b - 1] = 0
  elif h[a-1] < h[b-1]:
    l[a - 1] = 0
  else:
    l[a - 1] = 0
    l[b - 1] = 0

cnt = 0
for i in l:
  if i == 1:
    cnt += 1

print(cnt)

Measured memory_bytes: 20064
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n; cin >> n;
  vector<int> vec(n);
  for (int& v: vec) cin >> v;
  sort(vec.begin(), vec.end());
  int m = unique(vec.begin(), vec.end()) - vec.begin();
  m = n - m;
  int ans = n - (m + (m & 1));
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
package main

import (
	"fmt"
	"math"
)

func main() {
	var x float64
	fmt.Scan(&x)
	for a := -200.0; a <= 200; a++ {
		for b := -200.0; b <= 200; b++ {
			if math.Pow(a, 5)-math.Pow(b, 5) == x {
				fmt.Println(a, b)
				return
			}
		}
	}
}


Measured memory_bytes: 1840
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <complex>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef complex<double> base;
ll mod=1e9+7;
double eps=1e-9;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ll pexp(ll x, ll y){if(y<0) return 0; ll ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
int n, vv[211111], a[211111];
ll ps[211111], pxor[211111], ans;

ll gv(int cur)
{
	int lef, rig, mid, best;
	lef=cur; rig=n;
	while(lef<=rig)
	{
		mid=(lef+rig)/2;
		if((pxor[mid]^pxor[cur-1])==ps[mid]-ps[cur-1])
		{
			best=mid;
			lef=mid+1;
		}
		else
		{
			rig=mid-1;
		}
	}
	return best-cur+1;
}

int main(void)
{
	cin>>n; int i, j;
	for(i=1 ; i<=n ; i++) scanf("%d",&a[i]);
	for(i=1 ; i<=n ; i++) ps[i]=ps[i-1]+a[i];
	for(i=1 ; i<=n ; i++) pxor[i]=pxor[i-1]^a[i];
	for(i=1 ; i<=n ; i++) ans+=gv(i);
	cout<<ans; return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int k;
  cin >> k;
  int a = 7%k, i = 1;
  set<int> b;
  while(a!=0) {
    if(b.count(a)) {
      cout << -1 << endl;
      return 0;
    }
    b.insert(a);
    a = (a*10+7)%k;
    i++;
  }
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 50472
#include <iostream>
using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	ll N; cin >> N;
	char S[100]; cin >> S;
	ll max = 0;
	ll c = 0;
	rep(i, 0, N) {
		if (S[i] == 'I') c++;
		if (S[i] == 'D') c--;

		if (max < c) {
			max = c;
		}
	}
	cout << max << endl;

	return 0;
}

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

int n;
ll ans;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0) ans+=i;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3828
#52d
N,A,B = map(int, input().split())
X_list = [int(e) for e in input().split()]

diff_X_list = [X_list[i]-X_list[i-1] for i in range(1,N)]

ans = 0
for diff_X in diff_X_list:
    if diff_X * A >= B:
        ans += B
    else:
        ans += diff_X * A
        
print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;

int main(){
    string s,t;
    cin>>s>>t;
    int N=s.size(),M=t.size();
    for(int i=N-1;i>=0;--i){
        if(i+t.size()>s.size()) continue;
        bool ok=true;
        REP(j,t.size()){
            if(s[i+j]!='?'&&s[i+j]!=t[j]) ok=false;
        }
        if(ok){
            REP(j,t.size()) s[i+j]=t[j];
            REP(j,s.size()) if(s[j]=='?') s[j]='a';
            cout<<s<<endl;
            return 0;
        }
    }
    cout<<"UNRESTORABLE"<<endl;
}


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

int main() {
  int A, B, C, X, COMBI;
  cin >> A >> B >> C >> X;
  COMBI=0;
  
  for(int i=0; i<=A; i++) {
    for(int j=0; j<=B; j++) {
      for(int k=0; k<=C; k++) {
        if(X==500*i+100*j+50*k) {
          COMBI++;
        }
      }
    }
  }
  cout << COMBI <<endl;
}

        
    
    

Measured memory_bytes: 256
// AOJ ITP2_11_C Enumeration of Subsets III
// 2019.3.9 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (isdigit(c));
	return n;
}

void out(int n)
{
	int i;
	char ob[30];

	if (!n) pc('0');
	else {
		i = 0; while (n) ob[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(ob[i]);
	}
}

void outs(char *s) { while (*s) pc(*s++); }

int main()
{
	int i, j, k, n, max, mask;

	n = in(), max = 1 << n;
	k = in(), mask = 0;
	while (k--) mask |= 1 << in();
	outs("0:\n");
	for (i = 0; i <= mask; i++) {
		if ((i | mask) != mask) continue;
		if (i == 0) continue;
		out(i), pc(':');
		k = i; for (j = 0; k; j++) {
			if (k & 1) pc(' '), out(j);
			k >>= 1;
		}
		pc('\n');
	}
	return 0;
}


Measured memory_bytes: 2048
N=int(input())
A=list(map(int,input().split()))
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
def gcd_reduce(T):
    result=T[0]
    for i in range(1,len(T)):
        result=gcd(result,T[i])
    return result
print(gcd_reduce(A))

Measured memory_bytes: 14252
character(4) S
logical check
read*,S

check=.false.
if(S(1:1)==S(2:2))then
  if(S(3:3)==S(4:4).and.S(1:1)/=S(3:3))check=.true.
else if(S(1:1)==S(3:3))then
  if(S(2:2)==S(4:4).and.S(1:1)/=S(2:2))check=.true.
else if(S(1:1)==S(4:4))then
  if(S(2:2)==S(3:3).and.S(1:1)/=S(3:3))check=.true.
endif

print"(A)",merge("Yes"," No",check)

end

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int n;

void solve()
{
    cin >> n;
    nout(n*n*n);
}

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

Measured memory_bytes: 256
// Given an array of integers of size ‘n’.
// Our aim is to calculate the maximum sum of ‘k’
// consecutive elements in the array.

/*{{{*/
#include<bits/stdc++.h>
#define sz(X) ((int)(X).size())
#define all(X) (X).begin(), (X).end()
#define rep(I, A, B) for (int I = (A); I <= (B); ++I)
#define repr(I, A, B) for (int I = (A); I >= (B); --I)
#define fors(I, S) for (int I = 0; S[I]; ++I)
#define get_pos(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define mp make_pair
#define pb emplace_back
#define ms0(X) memset((X), 0, sizeof((X)))
#define ms1(X) memset((X), -1, sizeof((X)))
#define len(X) strlen(X)
#define in insert
#define cn count
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef set<int> si;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T, class U> void _W(const pair<T, U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
#define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
#define DEBUG(...)
#endif
int MOD = 1e9 + 7;
/*}}}*/

const int SIZE = 1e6 + 10;

void solve() {
	int n;
	string s, t;
	R(n, s, t);
	rep(i, 0, n - 1)
	cout << s[i] << t[i];
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

#define MULTITEST 0
#if MULTITEST
	CASET {
		solve();
	}
#else
	solve();
#endif
	return 0;
}


Measured memory_bytes: 3660
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  static int h, w, k, ans;
  static char[][] c;
  static String res;

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

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

    String[] in = br.readLine().split(" ");
    h = Integer.parseInt(in[0]);
    w = Integer.parseInt(in[1]);
    k = Integer.parseInt(in[2]);

    c = new char[h][w];

    for (int i = 0; i < h; i++) {
      in = br.readLine().split(" ");
      for (int j = 0; j < w; j++) {
        c[i][j] = in[0].charAt(j);
      }
    }

    br.close();

    for (int i = 0; i < (1 << h); i++) {
      for (int j = 0; j < (1 << w); j++) {
        int black = 0;
        for (int l = 0; l < h; l++) {
          if(((i >> l) & 1) == 1) continue;
          for (int m = 0; m < w; m++) {
            if(((j >> m) & 1) == 1) continue;
            if(c[l][m] == '#') black++;
          }
        }
        if(black == k) ans++;
      }
    }

    out.println(ans);

    out.flush();

  }
}

Measured memory_bytes: 33164
package main

import "fmt"

type dice struct {
	top, bottom, right, left, up, down int
}

func move(d *dice, dir byte) {
	now := d.top
	switch dir {
	case 'N':
		d.top = d.down
		d.down = d.bottom
		d.bottom = d.up
		d.up = now
	case 'S':
		d.top = d.up
		d.up = d.bottom
		d.bottom = d.down
		d.down = now
	case 'W':
		d.top = d.right
		d.right = d.bottom
		d.bottom = d.left
		d.left = now
	case 'E':
		d.top = d.left
		d.left = d.bottom
		d.bottom = d.right
		d.right = now
	}
}

func roll(d *dice) {
	// topとbottomは変えない
	now := d.up
	d.up = d.right
	d.right = d.down
	d.down = d.left
	d.left = now
}

func main() {
	var d dice
	fmt.Scan(&d.top, &d.down, &d.right, &d.left, &d.up, &d.bottom)
	var q int
	fmt.Scan(&q)
	ans := make([]int, 0)
	for i := 0; i < q; i++ {
		var top, down int
		fmt.Scan(&top, &down)
		// 転がす操作をして当てはまるパターンを探す
		// まず上面を固定する。NNNEEEの操作を行ってチェックすれば十分
		if top != d.top { // 上面が合ってないので操作が必要
			ops := "NNNEEE"
			for i := 0; i < len(ops); i++ {
				move(&d, ops[i])
				if top == d.top {
					break
				}
			}
		}
		if top != d.top {
			// あり得ないクエリなので、-1を入れておく
			ans = append(ans, -1)
			continue
		} else if down != d.down { // 前面が合ってない
			for i := 0; i < 3; i++ {
				roll(&d)
				if down == d.down {
					break
				}
			}
		}
		if down != d.down {
			// あり得ないクエリなので、-1を入れておく
			ans = append(ans, -1)
		} else {
			ans = append(ans, d.right)
		}

	}
	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i])
	}
}



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

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

    int n;
    cin >> n;

    int v1, v2, v3;

    int arr[n][3];

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

        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    }

    v1 = arr[0][0];
    v2 = arr[0][1];
    v3 = arr[0][2];

    for(int i = 1; i<n; i++){

        int temp1 = v1;
        int temp2 = v2;
        int temp3 = v3;

        v1 = arr[i][0] + max(temp2,temp3);
        v2 = arr[i][1] + max(temp1,temp3);
        v3 = arr[i][2] + max(temp1,temp2);
    }

    cout << max( max(v1,v2), v3 ) <<endl;

    return 0;
}

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

int n,cnt,ans;

int main(){
    cin >> n;
    map<int,int> mp;
    for(int i = 0;i < n;i ++){
        int a;
        cin >> a;
        mp[a] = i;
    }
    for(auto ite = mp.begin();ite != mp.end();++ite){
        int sub = abs(ite->second-cnt);
        if(sub%2) ans ++;
        cnt ++;
    }
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int n;
int main(){
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(map<int, int>::iterator it = mp.begin();  it != mp.end(); it++){
        if(it->second & 1) ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <stdlib.h>
#define int long long

signed main(){
	int N, i, ans = 0;
	scanf("%lld", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
	}
	for(i = 0; i < N; i++){
		ans += A[i] / 2;
		if(i == N - 1){
			break;
		}
		if(A[i] % 2 == 1 && A[i + 1] > 0){
			ans++;
			A[i + 1]--;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 896
def main():
    N = int(input())
    S = [input() for _ in range(N)]

    AC = 0
    WA = 0
    TLE = 0
    RE = 0
    for i in range(N):
        if S[i] == 'AC':
            AC += 1
        elif S[i] == 'WA':
            WA += 1
        elif S[i] == 'TLE':
            TLE += 1
        else:
            RE += 1

    print('AC x ' + str(AC))
    print('WA x ' + str(WA))
    print('TLE x ' + str(TLE))
    print('RE x ' + str(RE))

main()


Measured memory_bytes: 16244
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, M, D;
  cin >> N >> M >> D;
  if (D != 0)
    cout << SP(20) << ((long double)2 * POW(N - D, 1)) * (M - 1) / POW(N, 2)
         << endl;
  else
    cout << SP(20) << ((long double)POW(N, 1)) * (M - 1) / POW(N, 2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) 
{
    int debt = 100000;
    int weeks, i;

    scanf("%d", &weeks);
    for (i=0; i<weeks; i++) {
        debt = debt * 1.05;
        debt += 999;
        debt = debt / 1000 * 1000;
    }

    printf("%d\n", debt);
    return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;

public class Main{
	public static boolean solve(int n){
		if(n<100){
			return false;
			}
		if(n>=100&&n<=105){
			return true;
			}
		if(n>105 && n<200){
			return false;
			}
		boolean[] dp = new boolean[n+1];
		dp[100] = true;dp[101] = true;dp[102] = true;dp[103] = true;dp[104] = true;dp[105] = true;
		for(int i = 200;i<n+1;i++){
			dp[i] = (dp[i-100]||dp[i-101]||dp[i-102]||dp[i-103]||dp[i-104]||dp[i-105]);}
		return dp[n];
			}
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		if(solve(n)){
			System.out.println(1);
			}
		else{
			System.out.println(0);
			}
		}
	}

Measured memory_bytes: 22604
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  string s;
  int w;
  cin >> s >> w;
  
  int c = s.length()/w;
  if(s.length()%w!=0)
    c++;
  r(i,c){
    cout << s[w*i];
  }
  return 0;
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector <int> Ai(N+5);
	for (int i = 0; i < N; i++) {
		cin >> Ai.at(i);
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (Ai[Ai[i] - 1] == i + 1) {
			ans++;
		}
	}
	cout << ans / 2 << endl;
    return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

"""
参考：https://qiita.com/drken/items/03c7db44ccd27820ea0d
・最長共通部分列問題
・i側とj側の両方向に配るDP
・復元
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

s = input()
t = input()

dp = [[0] * (len(t)+1) for i in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        # 下から右に送る
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
        # 右から下に送る
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])
        # 今回増やす文字が一致するなら、LCSが1文字増える
        if s[i] == t[j]:
            # 左上から右下に送る
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)

# 復元(DPテーブルを遡る)
i = len(s)
j = len(t)
ans = ''
while i > 0 and j > 0:
    # 上が同じ値なら上に移動
    if dp[i-1][j] == dp[i][j]:
        i -= 1
    # 左が同じ値なら左に移動
    elif dp[i][j-1] == dp[i][j]:
        j -= 1
    # 上も左も値が異なれば、そこが更新箇所なので、該当位置の文字を取得
    else:
        ans = s[i-1] + ans
        i -= 1
        j -= 1
print(ans)


Measured memory_bytes: 136664
#include <algorithm>
#include <iostream>
#include <cstdint>
#include <cmath>
#include <vector>
#include <utility>
#include <limits>
#include <map>

using namespace std;

int main() {
  int64_t N, D, A;
  cin >> N >> D >> A;
  
  vector<pair<int64_t, int64_t>> monsters;
  monsters.reserve(N);
  
  int64_t farthest = 0;
  for (size_t n = 0; n < N; ++n) {
    int64_t X, H;
    cin >> X >> H;
    monsters.push_back(make_pair(X, H));
    if (X > farthest) farthest = X;
  }
  sort(monsters.begin(), monsters.end());

  int64_t cnt = 0, valid_damage = 0;
  map<int64_t, int64_t> damages;
  for (int n = 0; n < N; ++n) {
    for (auto it = damages.begin(), end = damages.end(); it != end;) {
      if ((*it).first < monsters[n].first) {
        valid_damage -= (*it).second;
        it = damages.erase(it);
      } else {
        break;
      }
    }
    if (monsters[n].second > valid_damage) {
      int64_t magic = (monsters[n].second - valid_damage + A - 1) / A;
      int64_t damage = magic * A;
      damages[monsters[n].first + 2 * D] = damage;    
      valid_damage += damage;
      cnt += magic;
    }
  }
  cout << cnt << endl;
  
  return 0;
}


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

int N;
int d_i[100];

int cmpnum(const void *n1,const void *n2){
    if(*(int *)n1<*(int *)n2)
	return -1;
    else if(*(int *)n1>*(int *)n2)
	return 1;
    else
	return 0;
}

int main(){
    int tmp=0,count=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
	scanf("%d",&d_i[i]);

    qsort(d_i,N,sizeof(int),cmpnum);

    for(int i=0;i<N;i++){
	if(tmp!=d_i[i]){
	    count++;
	    tmp=d_i[i];
	}
    }

    printf("%d\n",count);
}



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

int main(){
  int a,b; cin>>a>>b;
  if(a<b){
    for(int i=0;i<b;i++){
      cout<<a;
    }
  }
  else{
    for(int i=0;i<a;i++){
      cout<<b;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#define llint long long

using namespace std;
typedef pair< llint, pair<int, int> > P;

llint N, M, K;
llint c[100005];
vector<P> vec;
int used[100005];

int parent[200005];
void init(){
	for(int i = 1; i <= 200005; i++){
		parent[i] = i;
	}
}
int root(int i)
{
	if(parent[i] == i) return i;
	return parent[i] = root(parent[i]);
}
bool same(int i, int j)
{
	return root(i) == root(j);
}
void unite(int i, int j)
{
	int root_i = root(i), root_j = root(j);
	if(root_i == root_j) return;
	parent[root_i] = root_j;
}

int main(void)
{
	cin >> N >> M >> K;
	for(int i = 1; i <= N; i++) cin >> c[i];
	init();
	
	for(int i = 1; i <= N; i++){
		if(c[i]) unite(i, 100000 + c[i]);
	}
	
	int a, b, w;
	for(int i = 0; i < M; i++){
		cin >> a >> b >> w;
		vec.push_back( make_pair(w, make_pair(a, b)) );
	}
	sort(vec.begin(), vec.end());
	
	llint ans = 0, cnt = 0;
	for(int i = 0; i < vec.size(); i++){
		a = vec[i].second.first;
		b = vec[i].second.second;
		w = vec[i].first;
		
		if(same(a, b)) continue;
		unite(a, b);
		ans += w;
		cnt++;
		if(cnt >= K-1) break;
	}
	
	if(cnt < K-1) ans = -1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3956
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var a = -1; var z = -1;
        for (int i = 0; i < s.Length; i++)
            if (s[i] == 'A' && a == -1) a = i;
            else if (s[i] == 'Z') z = i;
        Console.WriteLine(z - a + 1);
    }
}

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

const ll mod=1e9+7;

int main(){
    ll n;
    cin>>n;
    string s1,s2;
    cin>>s1>>s2;
    ll ans=1;
    bool flag=0;
    rep(i,n){
        if(s1[i]==s2[i]){
            if(i==0) ans*=3;
            else if(flag==0) ans*=2;
            flag=0;
        }else{
            if(i==0) ans*=6;
            else if(flag==0) ans*=2;
            else ans*=3;
            flag=1;
            i++;
        }
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int i,j;
  for(i=0;i<s.size();i++){
    if(s[i]=='A'){
      break;
    }
  }
  for(j=0;j<s.size();j++){
    if(s[s.size()-1-j]=='Z'){
      break;
    }
  }	
  cout << s.size()-j-i <<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int u;
struct tup
{
    u value;
    u weight;
    char type;
    u data;
    string name;
};

bool cmp(const tup x,const tup y)
{
    if(x.value<y.value)
    {
        return true;
    }
    else if(x.value==y.value)
    {
        if(x.weight<y.weight)
        {
            return true;
        }
        else if(x.weight==y.weight)
        {
            if(x.type<y.type)
            {
                return true;
            }
            else if(x.type==y.type)
            {
                if(x.data<y.data)
                {
                    return true;
                }
                else if(x.data==y.data)
                {
                    if(x.name<y.name)
                        return true;

                }
            }
        }
    }
    return false;
}

int main()
{
    int n;
    cin>>n;
    struct tup a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i].value>>a[i].weight>>a[i].type>>a[i].data>>a[i].name;
    }
    sort(a,a+n,cmp);
    for(int i=0;i<n;i++)
    {
      cout<<a[i].value<<" "<<a[i].weight<<" "<<a[i].type<<" "<<a[i].data<<" "<<a[i].name<<endl;
    }

}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> x(N), y(N);
    rep(i, N) cin >> x[i] >> y[i];

    map<pair<int, int>, int> pq;
    rep(i, N) {
        rep(j, N) {
            if (i == j) continue;
            pair<int, int> p = make_pair(x[i] - x[j], y[i] - y[j]);
            pq[p]++;
        }
    }

    int max_pq = 0;
    for (auto i : pq) {
        // auto a = i.first;
        // printf("[%d, %d]: %d\n", a.first, a.second, i.second);
        max_pq = max(max_pq, i.second);
    }
    cout << N - max_pq << endl;
    return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
a = abs
z = [list(map(int, input().split())) for _ in range(int(input()))]
z.sort(key = lambda x: x[2])
x, y, h = z[-1]
r = range(101)
for c in r:
    for d in r:
        H = h + a(c-x) + a(d-y)
        if all(u == max(H - a(s-c) - a(t-d), 0) for s, t, u in z):
            print(c, d, H)
            exit()


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  char buf[1024];
  int N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d", &N);

  int *A=(int *)malloc(sizeof(int)*N);
  rep(i,N){
    scanf("%d",&A[i]);
  }
  rep(i,N){
    A[i]=A[i]*2;
  }

  long *X=(long *)malloc(sizeof(long)*N);
  long sum=0;
  rep(i,N){
    sum+=A[i];
  }
  sum=sum/2;

  long ssum=0;
  for(int i=1; i<N; i=i+2){
    ssum+=A[i];
  }

  X[0]=sum-ssum;
  srep(i,1,N){
    X[i]=A[i-1]-X[i-1];
  }

  rep(i,N){
    printf("%ld ", X[i]);
  }
  printf("\n");


  return 0;
}


Measured memory_bytes: 2432
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 17;

const int mod = 1e9+7;


int n;
int a[N][N];
// dp[mask] = max score when you distirbute rabbits in mask no matter where they are
long long dp[1 << N];
long long pre[1 << N];

void go(int idx , const vector < int > & not_chosen , int taken , int a_taken , long long before_adding){
    //cout << idx << " " << taken << " " << a_taken << endl;
    if(idx == (int)not_chosen.size()){
        dp[a_taken] = max(dp[a_taken] , before_adding + pre[taken]);
        return;
    }
    go(idx + 1 , not_chosen , taken , a_taken , before_adding);
    taken |= (1 << not_chosen[idx]);
    a_taken |= (1 << not_chosen[idx]);
    go(idx + 1 , not_chosen , taken , a_taken , before_adding);
}

int main(){
    scanf("%d" , &n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            scanf("%d" , &a[i][j]);
        }
    }
    for(int msk = 0; msk < (1 << n); msk++){
        for(int i = 0; i < n; i++){
            if(!(msk & (1 << i)))
                continue;
            for(int j = i+1; j < n; j++){
                if(msk & (1 << j)){
                    pre[msk] += a[i][j];
                }
            }
        }
    }

    for(int msk = 0; msk < (1 << n); msk++){
        vector < int > not_chosen;
        for(int i = 0; i < n; i++){
            if(!(msk & (1 << i)))
                not_chosen.push_back(i);
        }
        go(0 , not_chosen , 0 , msk , dp[msk]);
    }
    printf("%lld\n" , dp[ (1 << n) - 1]);
}


Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
    int w,h;
    while(cin>>h>>w,h) 
    {
        string f[h];
        for(int i = 0; i < h; ++i)
        {
            cin>>f[i];
        }
 
        bool used[h][w];
        memset(used,0,sizeof(used));
 
        int x=0,y=0;
        while(1) 
        {
            if(used[y][x])
            {
                cout<<"LOOP"<<endl;
                break;
            }
            if(f[y][x]=='.')
            {
                cout<<x<<" "<<y<<endl;
                break;
            }
            used[y][x]=true;
 
            if(f[y][x]=='>') x+=1;
            if(f[y][x]=='<') x-=1;
            if(f[y][x]=='^') y-=1;
            if(f[y][x]=='v') y+=1;
        }
    }
  return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;

    if(a+b == 15) {
        cout << '+';
    }
    else if(a*b == 15) {
        cout << '*';
    }
    else {
        cout << 'x';
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
ans = [0] * n
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            a = x * x + y * y + z * z + x * y + x * z + y * z
            if a > n: continue
            ans[a-1] += 1
for i in ans: print(i)

Measured memory_bytes: 9192
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
double a[11];
int main()
{
  while(cin>>a[1]){
    a[0] = 0;
    double sum = 0;
    for(int i = 2;i <=10;i++){
      a[i] = 0;
    }
    sum = a[1];
    for(int i = 2;i <= 10;i++){
      if(i%2){
	a[i] =a[i-1]/3;
      }else{
	a[i] =a[i-1]*2;
      }
      sum +=a[i];
    }
    printf("%.8lf\n",sum);
  }
  return 0;
}

Measured memory_bytes: 1236