akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair 
#define INF 1000000000
#define MOD 1000000007 
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint()
{
	int x=0,p=1;char c;
	c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//
const int maxn=1e5+5;
int n,par[maxn];
ll res;
vector<pii >Sx,Sy;
set<iiii >E;
//
void finit()
{
	rep(i,n)par[i]=i;
}
int fF(int x)
{
	if(par[x]==x)return x;
	return par[x]=fF(par[x]);
}
bool fU(int x,int y)
{
	x=fF(x);y=fF(y);
	if(x==y)return false;
	par[x]=y;
	return true;
}
int main()
{
	n=getint();
	rep(i,n)
	{
		int x=getint(),y=getint();
		Sx.push_back(mp(x,i));
		Sy.push_back(mp(y,i));
	}
	sort(Sx.begin(),Sx.end());
	sort(Sy.begin(),Sy.end());
	rep(i,n-1)
	{
		E.insert(mp(abs(Sy[i+1].first-Sy[i].first),mp(Sy[i].second,Sy[i+1].second)));
		E.insert(mp(abs(Sx[i+1].first-Sx[i].first),mp(Sx[i].second,Sx[i+1].second)));
	}
	finit();
	set<iiii >::iterator it;
	for(it=E.begin();it!=E.end();it++)
	{
		ll len=1ll*it->first;
		int x=it->second.first,y=it->second.second;
		if(fU(x,y))res+=len;
	}
	printf("%lld\n",res);
	return 0;	
} 

Measured memory_bytes: 15468
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<vector>
#include<string>
using namespace std;
const int inf=0x3f3f3f3f;
typedef long long ll;
int main()
{
    long double a,b;
    cin>>a>>b;
   cout<<(ll)(a*b)<<endl;
    return 0;
}


Measured memory_bytes: 3732
#include <iostream>

using namespace std;

int main()
{
	string N;
	cin >> N;

	if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}





Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int h, w, ans;
vector<vector<int>> mp(100,vector<int>(100,-1));
vector<string> in_str(100);

void re_set(){
    for(int i = 0;i<100;i++){
        in_str[i] = "";
        for(int j = 0;j<100;j++){
            mp[i][j] = -1;
        }
    }
    return;
}

int zentan(int x, int y, int num, char pre_num){
    if(x<0 || y < 0 || x >= h || y >= w || mp[x][y]!=-1 || in_str[x][y] != pre_num) return 0;
    mp[x][y] = num;
    int temp;
    temp = zentan(x+1,y,num,in_str[x][y]);
    temp = zentan(x,y+1,num,in_str[x][y]);
    temp = zentan(x-1,y,num,in_str[x][y]);
    temp = zentan(x,y-1,num,in_str[x][y]);
    return 1;
}

int main(){
    while(cin >> h >> w){
        if(!h && !w) return 0;
        re_set();
        ans = 0;
        for(int i = 0;i<h;i++){
            string tmp;
            cin >> tmp;
            in_str[i] = tmp;
        }
        for(int i = 0;i<h;i++){
            for(int j = 0;j<w;j++){
                ans += zentan(i,j,ans,in_str[i][j]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4016
import java.util.*;

public class Main {

	private void doit(){
		Scanner sc = new Scanner(System.in);
		long mod = 1000000007;
		while(sc.hasNext()){
			int n = sc.nextInt();
			int [] data = new int[n];
			int sum = 0;
			for(int i = 0; i < data.length; i++){
				data[i] = sc.nextInt();
				sum += data[i];
			}
			
			double ave = (double)sum / n;
			
			int ans = Integer.MAX_VALUE;
			int [] comp = {(int) Math.ceil(ave), (int) Math.floor(ave)};
			
			for(int i =0 ;i < comp.length; i++){
				int now = 0;
				for(int j = 0; j < data.length; j++){
					now += (data[j] - comp[i]) * (data[j] - comp[i]);
				}
				ans = Math.min(now, ans);
			}
			
			System.out.println(ans);
		}

	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 9680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{
    ll h;
    int n; cin >> h >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++){
        h -= a[i];
        if(h <= 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}
    

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);


int d;
int s[365][26];
int c[26];


int calc(vector<int> &v) {
	int sum = 0;
	int las[26]; rep(i, 26)las[i] = 0;
	

	int dec = 0;
	rep(j, 26)dec += c[j];

	int aldec = 0;

	rep(i, d) {
		aldec -= c[v[i]] * (i - las[v[i]]);

		sum += s[i][v[i]];
		las[v[i]] = i;

		sum -= aldec;
		aldec += dec;
	}
	return max(sum, 0);
}

void query(vector<int> v) {
	rep(i, d) {
		cout << v[i] + 1 << "\n";
	}
}
void solve() {
	cin >> d;
	rep(i, 26)cin >> c[i];
	rep(i, d)rep(j, 26)cin >> s[i][j];

	//init_answer
	vector<int> v;
	int las[26]; rep(j, 26)las[j] = 0;
	int sum = 0;

	rep(i, d) {
		int ma = -mod;
		int chk = -1;
		rep(j, 26) {
			int ad = s[i][j];
			ad += c[j] * (i - las[j]);
			if (ma < ad) {
				ma = ad;
				chk = j;
			}
		}
		v.push_back(chk);
		las[chk] = i;

		sum += s[i][chk];
		rep(j, 26){
			sum -= c[j] * (i - las[j]);
		}
	}

	random_device rnd;
	mt19937 mt(rnd());
	uniform_int_distribution<> ud(0, d - 1);
	uniform_real_distribution<> rd(0.0,1.0);
	vector<int> alt = v;


	int cur=sum;

	rep(i, 30000) {
		int id = ud(mt);
		rep(j, 26) {
			if (j == v[id])continue;
			alt[id] = j;
			int val = calc(alt);
			if (cur < val) {
				v=alt;
				cur = val;
            }
		}
		alt=v;
	}

	query(v);
}


signed main() {
	solve();
		return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int index,biggest=0;
  for(int i=0;i<N;i++){
    int t;
    cin>>t;
    if(abs(t)>abs(biggest)){biggest=t;index=i;}
  }
  index++;//convert to 1-started
  cout<<2*N-1<<endl;
  for(int i=1;i<N+1;i++)cout<<index<<" "<<i<<endl;
  if (biggest>0){
    for(int i=1;i<N;i++)cout<<i<<" "<<i+1<<endl;
  }else{
    for(int i=N;i>=2;i--)cout<<i<<" "<<i-1<<endl;
  }
  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int x;
    double p;
    cin>>x>>p;
    p/=100;
    double ans;
    if(x&1){
        ans=(1-p)*(x+1)/2/p+p*1.0*(x-1)/2/p+1;
    }
    else{
        ans=x/2/p;
    }
    printf("%.20f\n",ans);
    return 0;
}


Measured memory_bytes: 256
import itertools
n = int(input())
seq = [i for i in range(n)]
steps = list(itertools.permutations(seq))
xy = [list(map(int,input().split())) for _ in range(n)]
sumlen = 0
for j in range(len(steps)):
    leng = 0
    step = steps[j]
    for k in range(n-1):
        x_1 = int(xy[step[k]][0])
        x_2 = int(xy[step[k+1]][0])
        y_1 = int(xy[step[k]][1])
        y_2 = int(xy[step[k+1]][1])
        leng += ((x_1 - x_2)**2  + (y_1 - y_2)**2)**0.5
    sumlen += leng
print((sumlen/len(steps)))

Measured memory_bytes: 13976
N,K=map(int,input().split())
p=list(map(int,input().split()))

total=0
for i in range(K):
   total+=(p[i]+1)/2

result=0
result+=total
for i in range(1,N-K+1):
   total=total-(p[i-1]+1)/2+(p[i+K-1]+1)/2
   result=max(result,total)

print(result)

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(105, 0);
    
    for(int i = 0; i < m; i++){
        int v;
        cin >> v;
        a[v] = 1;
    }

    int cost1, cost2;
    cost1 = cost2 = 0;
    for(int i = 0; i < x; i++){
        cost1 += a[i];
    }
    for(int i = x; i < n; i++){
        cost2 += a[i];
    }
    cout << min(cost1, cost2) << endl;

    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = list(input())
if s[k-1] == 'A':
  s[k-1] = 'a'
elif s[k-1] == 'B':
  s[k-1] = 'b'
else:
  s[k-1] = 'c'
print(''.join(s))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W,K;cin>>H>>W>>K;
  int cnt=0;
  vector<vector<bool>> c(H,vector<bool>(W));
  for(int i=0;i<H;i++){
    string S;cin>>S;
    for(int j=0;j<W;j++){
      c[i][j]=(S[j]=='#'?true:false);
    }
  }
  for(int i=0;i<(1<<(H+W));i++){
    vector<vector<bool>> d(H,vector<bool>(W));
    for(int a=0;a<H;a++){
      for(int j=0;j<W;j++){
      	d[a][j]=c[a][j];
      }
  	}
    for(int j=0;j<H;j++){
      if(i&(1<<j)){
        for(int z=0;z<W;z++){
          d[j][z]=false;
        }
      }
    }
    for(int j=0;j<W;j++){
      if(i&(1<<H+j)){
        for(int z=0;z<H;z++){
          d[z][j]=false;
        }
      }
    }
    int count=0;
    for(int a=0;a<H;a++){
      for(int j=0;j<W;j++){
      	if(d[a][j])count++;
        //cout<<(d[a][j]?"#":".");
      }
      //cout<<endl;
  	}
    //cout<<i<<endl;
    if(count==K){
      cnt++;
    }
    //cout<<endl;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3632
import java.util.*;
 
public class Main {
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] Nmap = new int[100000];
		for (int i = 0; i < N; i++) {
			Nmap[sc.nextInt()]++;
		}
		int max = 0;
		for (int i = 0; i < 100000-2; i++) {
			int sum = Nmap[i] + Nmap[i+1] + Nmap[i+2];
			if (max < sum) {
				max = sum;
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 50516
#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>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    string pat = "";
    for(int i=0; i<26; i++){
        pat += ('a' + i);
    }
    for(int i=0; i<26; i++){
        pat += ('A' + i);
    }

    while(1){
        int n; cin>>n;
        if(n == 0) return 0;
        vector<int> k(n);
        for(int i=0; i<n; i++) cin>>k[i];
        string s; cin>>s;

        int cnt = 0;
        string ans = "";
        for(int i=0; i<s.size(); i++){
            for(int j=0; j<52; j++){
                if(s[i] == pat[j]){
                    ans += pat[(j - k[(cnt++) % n] + 52) % 52];
                    break;
                }
            }
        }

        cout << ans << endl;
    }
}


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

int main(){
    int A,B;
    cin >> A >> B;
    int x = B+(A-B%A);
    int ans1 = x/B+(x%B)/A+(x%B%A),ans2 = x/A;
    if(ans2<ans1) cout << x << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 3136
package main

import "fmt"

type Card struct {
	suit byte
	rank int
}

func main() {
	var (
		n, r int
		s    string
	)
	fmt.Scanln(&n)
	dict := make(map[Card]bool)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s %d", &s, &r)
		dict[Card{s[0], r}] = true
	}
	suits := "SHCD"
	for i := 0; i < len(suits); i++ {
		b := suits[i]
		for j := 1; j <= 13; j++ {
			if !dict[Card{b, j}] {
				fmt.Printf("%s %d\n", string([]byte{b}), j)
			}
		}
	}
}


Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int n,sum=0;
    cin >>n;
    for(int i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0)sum+=i;
    }
    cout << sum << endl;
   return 0;
}


Measured memory_bytes: 3600
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::vec::Vec;
use std::{vec, cmp, num};


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()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: String = sc.read();
    let n = to_chars(n);
    if n[1] == n[2] && (n[0] == n[1] || n[2] == n[3]) {
        println!("Yes");
    } else {
        println!("No");
    }
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> l(51);
    int sum = 0;
    for(int i=0;i<n;i++) cin >> l.at(i);
    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    for(int i=0;i<k;i++){
        sum += l.at(i);
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> t;
    if(s[0]=='E') t.push_back(0);
    int cnt=1;
    for(int i=1; i<n; i++) {
        if(s[i-1]==s[i]) {
            cnt++;
        } else {
            t.push_back(cnt);
            cnt=1;
        }
    }
    t.push_back(cnt);
    if(t.size()%2) t.push_back(0);
    int tl = t.size();

    // || W E || W E W E W E

    int west=0, east=0, ans;
    for(int i=0; i<tl; i+=2) east+=t[i+1];
    ans = west + east;

    for(int i=0; i+1<tl; i+=2) {
        west += t[i];
        east -= t[i+1];
        if(ans>west+east) ans = west+east;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#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 n;
    cin >> n;

    vector<ll> v(n);  // v[i] : a[i] - (i+1);
    rep(i, n) {
        ll a;
        cin >> a;
        v[i] = a - (i+1);
    }
    sort(v.begin(), v.end());

    int mid = n/2;
    ll ans = 0;
    rep(i, n) {
        ans += abs(v[i] - v[mid]);
    }

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

Measured memory_bytes: 1792
/*
問題文
すぬけ君は 1,2,3の番号がついた 3 つのマスからなるマス目を持っています。
各マスには 0 か 1 が書かれており、マス i には siが書かれています。
すぬけ君は 1 が書かれたマスにビー玉を置きます。 ビー玉が置かれるマスがいくつあるか求めてください。
制約
s1,s2,s3は 1 あるいは 0
*/
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s, s1, s2, s3;
  cin >> s;
  s1 = s / 100;
  s2 = (s - s1*100) / 10;
  s3 = (s - s1*100 - s2*10);
  cout << s1 + s2 + s3 << endl;
}

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

#define rep(loop, N) for (int loop = 0; loop < N; loop++)
using namespace std;

struct Node {
	Node* parent = NULL;
	vector<Node*> child;
	long long value = 0;
};
struct Edge {
	int parent = 0;
	int child = 0;
	bool operator <(const Edge& right) const { return parent < right.parent; }
};
struct Tree {
	vector<Node> node;
	Tree(int, vector<Edge>);
};
Tree::Tree(int nodeNum, vector<Edge> edge) {
	node.resize(nodeNum);
	for (Edge& it : edge) {
		node[it.child].parent = &node[it.parent];
		node[it.parent].child.push_back(&node[it.child]);
	}
}

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	long long m_module = 1000000007;
	vector<struct Memo> memo;
public:
	long long calculate(int, int);
	Combination1(int, long long);
};
long long Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, long long module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_November_30(void) {

	int M1, D1, M2, D2; cin >> M1 >> D1 >> M2 >> D2;

	cout << (M1 != M2 ? 1 : 0) << endl;
	return;
}

void B_Tax_Rate(void) {

	int N; cin >> N;

	for (int X = int(N / 1.08); X <= N; X++) {
		if (int(X * 1.08) == N) {
			cout << X << endl;
			return;
		}
	}
	cout << ":(" << endl;
	return;
}

int main(void) {

	//A_November_30();
	B_Tax_Rate();
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main() {
    char op = '\0';
    int a = 0, b = 0, i = 0, j;
    int ans[256] = {0};
    
    while(1) {
        scanf("%d %c %d", &a, &op, &b);
        if(op == '?') {
            break;
        }
        if(op == '+') {
            ans[i] = a+b;
            i++;
        }
        if(op == '-') {
            ans[i] = a-b;
            i++;
        }
        if(op == '/') {
            ans[i] = a/b;
            i++;
        }
        if(op == '*') {
            ans[i] = a*b;
            i++;
        }
    }
    
    for(j = 0; j < i; j++) {
        printf("%d\n", ans[j]);
    }
    return 0;
}


Measured memory_bytes: 2148
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string szLine = Console.ReadLine();
            string[] szArr = szLine.Split(' ');
            int nTotal = szArr.Length;
            long[] arr = new long[nTotal];

            for (int i = 0; i < szArr.Length; ++i)
            {
                arr[i] = long.Parse(szArr[i]);
            }

            long a = arr[0];
            long b = arr[1];
            long c = arr[2];
            long sum = a + b + c;

            long max = 0;
            for (int i = 0; i < arr.Length; ++i)
            {
                if (arr[i] > max)
                {
                    max = arr[i];
                }
            }

            if ((max * 3) % 2 == sum % 2)
            {
                Console.WriteLine((max * 3 - sum) / 2);

            }
            else
            {
                Console.WriteLine(((max + 1) * 3 - sum) / 2);

            }

        }
    }
}


Measured memory_bytes: 13140
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp = input[1].split(" ");
    //文字列から10進数に変換するときはparseIntを使います
    var COLUMN_NUM = parseInt(input[0], 10);
    var height = [];
    for (var i = 0; i < COLUMN_NUM; i++) {
        height[i] = parseInt(tmp[i], 10);
    }

    var moveCount=0;
    var moveCountMax = 0;
    var startPos;

    for (var posi = 0; posi < COLUMN_NUM-1; posi++) {
        if (height[posi] >= height[posi + 1]) {
            moveCount++;
        } else {
            moveCount = 0;
        }
        if (moveCount > moveCountMax) {
            moveCountMax = moveCount;
        }
    }

    //出力
    console.log('%d', moveCountMax);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
    int n,C;
    cin>>n>>C;
    vector<int> s(n),t(n),c(n);
    for(int i=0;i<n;i++){
        cin>>s[i]>>t[i]>>c[i];
        c[i]--;
    }
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> sque;
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> tque;
    for(int i=0;i<n;i++){
        sque.push({s[i],c[i]});
        tque.push({t[i],c[i]});
    }
    int res=0;
    
    vector<int> tv(C+1);
    for(int i=0;i<=1e5+1;i++){
        vector<int> swi;
        while(!sque.empty()){
            auto buf=sque.top();
            if(buf.first==i){
                sque.pop();
                swi.push_back(buf.second);
                tv[buf.second]=true;
            }
            else{
                break;
            }
         }   
         res=max(res,accumulate(tv.begin(),tv.end(),0));
         while(!tque.empty()){
            auto buf=tque.top();
            if(buf.first==i){
                tque.pop();
                tv[buf.second]=false;
            }
            else{
                break;
            }
         }   
         for(int j=0;j<swi.size();j++){
             tv[swi[j]]=true;
         }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int p[100];

    for(int i=0;i<n;i++)
    {
       cin>>p[i];
    }
    int c=0;
    for(int i=0;i<n;i++)
    {
        if(p[i]!=i+1)
        {
            c++;
        }
    }

    if(c<=2)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3524
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int n;
long long a[111111];

int main(){
  ios_base::sync_with_stdio(false);
  
  int ans = 0;

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

  sort(a, a+n);
  
  for(int i=0;i<n-1;i++){
    if(a[i]*2 < a[i+1]){
      ans = 0;
      a[i+1] += a[i];
      continue;
    }
    a[i+1] += a[i];
    ans++;
  } 
  
  if(a[n-2]*2 >= a[n-1])ans++;
  cout << ans << endl;  

  return 0;
}



Measured memory_bytes: 1024
def culc(a, b, op):
    if op == '+':
        return a + b
    elif op == '-':
        return a - b
    elif op == '*':
        return a * b
    else:
        try:
            return a // b
        except:
            return 'error:zerodivision'


while True:
    data = input().split()
    a = int(data[0])
    b = int(data[2])
    if '?' in data:
        break
    print(culc(a, b, data[1]))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int a[200000];
int b[200000];

int main() {
  int n;
  while(cin>>n) {
    inputs(a,n+1);
    inputs(b,n);
    ll ans = 0;
    REP(i,n) {
      int x = min(a[i], b[i]);
      ans += x;
      int y = min(a[i+1], b[i] - x);
      ans += y;
      a[i+1] -= y;
    }
    cout << ans << endl;
  }
}


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

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

    if(a >= b)
        cout << "delicious" << endl;
    if(a < b && (x+a) >= b)
        cout << "safe" << endl;
    if((x+a) < b)
        cout << "dangerous" << endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n,A,B = [int(i) for i in readline().split()]
abc = [[int(i) for i in readline().split()] for j in range(n)]


res1 = []
res2 = []
eq = 10**9

"""
def dfs(s,g,amari,yen,List):
    global eq
    if s != g:
        a,b,c = abc[s]
        if a*B == A*b:
            eq = min(eq,c)
            dfs(s+1,g,amari,yen,List)
        else: 
            dfs(s+1,g,amari+a*B-b*A,yen+c,List)
            dfs(s+1,g,amari        ,yen,List)
    else:
        if amari != 0:
            List.append((amari,yen))
        else:
            if yen != 0:
                eq = min(eq,yen)
        

dfs(0,n//2,0,0,res1)
dfs(n//2,n,0,0,res2)
"""

def dp(s,g):
    global eq
    d = {0:0}
    for i in range(s,g):
        nd = {}
        a,b,c = abc[i]
#        if a*B == A*b:
#            eq = min(eq,c)
#        else:
        for amari,yen in d.items():
            if amari in nd:
                nd[amari] = min(nd[amari],yen)
            else:
                nd[amari] = yen
            yen += c
            amari += a*B-b*A
            if amari == 0 and yen != 0:
                eq = min(eq,yen)
            elif amari in nd:
                nd[amari] = min(nd[amari],yen)
            else:
                nd[amari] = yen
        d = nd
#        print(d,nd)
    
    return list(d.items())


res1 = dp(0,n//2)
res2 = dp(n//2,n)


#res1.sort()
res2.sort()
#print(res1)
#print(res2)
#print(eq)

from bisect import *

ans = min(10**9,eq)

L = len(res2)
for amari,yen in res1:
    i = bisect(res2,(-amari,-10000000))
    if i < L and res2[i][0] == -amari:
        if 0 < yen+res2[i][1] < ans:
            ans = yen+res2[i][1]


if ans == 10**9:
    print(-1)
else:
    print(ans)






Measured memory_bytes: 43120
n = gets.to_i
a = gets.chomp.split(' ').map(&:to_i)
num = 0
n.times do |i|
  (n-1).downto(i+1) do |j|
    if a[j] < a[j-1]
      a[j], a[j-1] = a[j-1], a[j]
      num += 1
    end
  end
end
puts a.join(' ')
puts num

Measured memory_bytes: 8716
#!/usr/bin/env python3
import collections

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def solve(N,M,A,B,C):
    dp = [float('Inf') for _ in range(2**N)]
    dp[0] = 0

    def f(C):
        return(sum(map(lambda x:2**(x-1),C)))

    for i in range(1,M+1):
        c = f(C[i-1])
        for d in range(0,2**N):
            dp[d | c] = min(dp[d | c], dp[d] + A[i-1])

    print(dp[-1] if dp[-1] != float("inf") else -1)





def main():
    # Failed to predict input format
    N,M = map(int,input().split())
    A = []
    B = []
    C = []
    CA = set()

    for _ in range(M): 
        a,b = map(int,input().split())
        A.append(a)
        B.append(b)
        c = list(map(int,input().split()))
        C.append(set(c))

    solve(N,M,A,B,C)



if __name__ == '__main__':
    main()


Measured memory_bytes: 4280
#include <stdio.h>
#include <algorithm>

using namespace std;

int n;
int m;
bool check[7368792];
int go;
int x;

void reset(){
	for(x=0;x<=7368791;x++) check[x] = 0;	
}
int i;

int main(){
	while(1){
		scanf("%d%d",&m,&n);
		if(n==0 && m==0) break;
		reset();
		go = m;
		while(n--){
			for(i=1;go*i<=7368791;i++){
				check[go*i] = 1;
			}
			while(check[go]) go++;
		}
		printf("%d\n",go);
	}	
	return 0;
}


Measured memory_bytes: 9912
/***************************************************************\
 * soi --
 *
 * Author: Cobalt Sato
 *
 * Purpose:
 *
 * Usage:
 *
 * Repository:
 *
 * Reference:
 *
 * File formats:
 *
 * Restrictions:
 *
 * Error handling:
 *
 * Warning:
 *
 * Notes:
 *
\***************************************************************/
#include <iostream>
#include <cassert>
#include <string>

using namespace std;
int main()
{
  char* s = new char[3];
  cin >> s;
  int sum = 700;
  for (int i = 0; i < 3; ++i){
    if (s[i] == 'o'){
      sum += 100;
    }
  }
  cout << sum << endl;
  return (0);
}



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

mod = 10**9 + 7

A.sort(key = lambda x:abs(x),reverse = True)
ans = 1
last = -1
lastp = -1
cnt = 0
for a in A:
    if a >= 0:break
else:
    if k&1:
        for i in range(k):
            ans *= A[n-i-1]
            ans %= mod
    else:
        for i in range(k):
            ans *= A[i]
            ans %= mod
    print(ans)
    exit()
for i in range(k):
    ans *= A[i]
    ans %= mod
    if A[i] < 0:
        last = i
        cnt += 1
    if A[i] > 0:
        lastp = i
if n == k:
    print(ans%mod)
    exit()
if cnt&1:
    first = 0
    firstp = 0
    for a in A[k:]:
        if a > 0 and firstp == 0:
            firstp = a
        if a < 0 and first == 0:
            first = a
    if first == 0 and firstp == 0:
        ans = 0
    elif first == 0 or lastp == -1:
        ans *= pow(A[last],mod-2,mod)*firstp%mod
        ans %= mod
    elif firstp == 0:
        ans *= pow(A[lastp],mod-2,mod)*first%mod
        ans %= mod
    else:
        if A[lastp]*firstp <= A[last]*first:
            ans *= pow(A[lastp],mod-2,mod)*first%mod
            ans %= mod
        else:
            ans *= pow(A[last],mod-2,mod)*firstp%mod
            ans %= mod
print(ans%mod)


Measured memory_bytes: 31532
import sys
from collections import deque
from collections import defaultdict
from collections import Counter

def conn(n,m,e):
    d=dict(zip(range(1,n+1),range(-1,(-1)*n-1,-1)))
    td=defaultdict(lambda:deque([])) #tdは同値類がキーで中の元が値
    c=1
    for edge in e:
        a=edge[0]
        b=edge[1]
        da=d[a] #da,dbはa,bの含まれる同値流のラベル
        db=d[b]
        if da<0 and db<0:
            d[a]=c
            d[b]=c
            td[c].append(a)
            td[c].append(b)
            c+=1
        elif da>0 and db<0:
            d[b]=da
            td[d[a]].append(b)
        elif da<0 and db>0:
            d[a]=db
            td[d[b]].append(a)
        elif da>0 and db>0 and da!=db:
            for x in td[db]:
                d[x]=da
                td[da].append(x)

    return list(d.values())

def components(n,k,e):
    ed=defaultdict(lambda:deque())
    for edge in e:
        ed[edge[0]].append(edge[1])
    c=0
    s=[0]*n
    label=[0]*n
    for i in range(1,n+1):
        if s[i-1]==0:
            c+=1
            label[c-1]=c
            stack=deque([i])
            while stack:
                w=stack.pop()
                s[w-1]=c
                while ed[w]:
                    wn=ed[w].pop()
                    if s[wn-1]==0:
                        s[wn-1]=c
                        if ed[wn]:
                            stack.append(w)
                            w=wn
                    elif s[wn-1]<c:
                        label[s[wn-1]-1]=c
    return [label[s[i]-1] for i in range(n)] 
           
def components2(n,k,e):
    ed=defaultdict(lambda:deque())
    for edge in e:
        ed[edge[0]].append(edge[1])
        ed[edge[1]].append(edge[0])
    c=0
    s=[0]*n
    for i in range(1,n+1):
        if s[i-1]==0:
            c+=1
            stack=deque([i])
            while stack:
                w=stack.pop()
                s[w-1]=c
                while ed[w]:
                    wn=ed[w].pop()
                    if s[wn-1]==0:
                        s[wn-1]=c
                        if ed[wn]:
                            stack.append(w)
                            w=wn
    return [s[i] for i in range(n)] 
def main(n,k,l,e1,e2):
    d1=components2(n,k,e1)
    d2=components2(n,l,e2)
    p=tuple(zip(iter(d1),iter(d2)))
    d=Counter(p)
    # print(d1,d2,d,p)
    print(' '.join([str(d[x]) for x in p])) 

if __name__=='__main__':
    ssr=sys.stdin.readline
    n,k,l=map(int,ssr().strip().split())
    e1=[]
    e2=[]
    for _ in range(k):
        e1.append(tuple(map(int,ssr().strip().split())))
    for _ in range(l):
        e2.append(tuple(map(int,ssr().strip().split())))
    main(n,k,l,e1,e2)


Measured memory_bytes: 191796
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b, c, k, sum = 0;
    cin >> a >> b >> c >> k;
    
    while (k) {
        if (a >= k) {
            cout << k;
            return 0;
        } else {
            sum += a;
            k -= a;
        }

        if (b >= k) k = 0;
        else k -= b;

        if (c >= k) {
            sum -= k;
            k = 0;
        }
    }

    cout << sum;

    return 0;
}


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

int main()
{
    string n;
    int flag = 0;
    cin >> n;
    for(int i = 0; i < n.length(); i++)
    {
        if(n[i] == '7')
            flag = 1;
    }
    if(flag == 1)
        cout << "Yes\n";
    else
        cout << "No\n";

    }


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
	int64_t N,K,start,now=0,roop=0,cnt=0,r;
    cin>>N>>K;
    vector<int>A(N);
    vector<int>check(N);
    for(int i=0;i<N;i++){
    	cin>>A.at(i);
        check.at(i)=0;
    }
    
    for(int i=0;i<N;i++){
    	if(check.at(now)==0){
        check.at(now)=1;
        now=A.at(now)-1;
        
        cnt++;
        continue;
        }else{
        break;
          
        }
      }
    for(int i=0;i<N;i++){
    	if(check.at(now)<=1){
        check.at(now)=10;
        now=A.at(now)-1;
        roop++;
        continue;
        }else{
          start=now;
          break;   
        }
    }
  if(K<=roop+cnt){
  r=K;
  start=0;
  }else{
  r=(K-cnt)%roop;
  }  
  now=start;
  for(int i=0;i<r;i++){
  	now=A.at(now)-1;
  }
  cout<<now+1<<endl;
}

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

class Main {
    public static void main(String [] args) {
        Reader in = new Reader ();
        Writer out = new Writer ();
        int n = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        if(a > b) {
            System.out.println(0);
            System.exit(0);
        }
        if(n == 1) {
            if(a == b) System.out.println(1);
            else System.out.println(0);
            System.exit(0);
        }
        long min = 1L * (n - 1) * a + b;
        long max = 1L * (n - 1) * b + a;
        System.out.println(Math.max(0, max - min + 1));
    }
    static class Reader {
        private StringTokenizer a;
        private BufferedReader b;
        Reader () {
            a = null;
            b = new BufferedReader (new InputStreamReader (System.in));
        }
        public String next () {
            while(a == null || !a.hasMoreTokens()) {
                try {
                    a = new StringTokenizer (b.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return a.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(this.next());
        }
        public long nextLong () {
            return Long.parseLong(this.next());
        }
        public double nextDouble () {
            return Double.parseDouble(this.next());
        }
        public String nextLine() {
            try {
                return b.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return "";
        }
    }
    static class Writer {
        private PrintWriter a;
        private StringBuffer b;
        Writer () {
            a = new PrintWriter (System.out);
            b = new StringBuffer ("");
        }
        public void write (Object s) {
            b.append(s);
        }
        public void writeln(Object s) {
            b.append(s).append('\n');
        }
        public void flush () {
            a.print(b);
            a.flush();
            a.close();
        }
    }
    static class Pair implements Comparator <Pair> {
        int first;
        int second;
        Pair  (int a, int b) {
            this.first = a;
            this.second = b;
        }
        Pair (Pair a) {
            this.first = a.first;
            this.second = a.second;
        } 
        Pair () {}
        public String toString () {
            return "[" + first + ", " + second + "]";
        }
        public int compare (Pair a, Pair b) {
            if(a.first == b.first) {
                return a.second - b.second;
            } else {
                return a.first - b.first;
            }
        }
    } 
}

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


void solve(long long a){
    long long ans = a + a * a + a * a * a;
    cout << ans << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    solve(a);
    return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,a[29],b[29],c[29],last=-1,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=1;i<=n;i++) scanf("%d",b+i);
	for(int i=1;i<=n-1;i++) scanf("%d",c+i);
	for(int i=1;i<=n;i++) {
		ans+=b[a[i]];
		if(a[i]==last+1) ans+=c[last];
		last=a[i];
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int n;
    int ans = 0;
    int h,bh = -1;
    cin >> n;

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

        if(h >= bh){
            ans++;
            bh = h;
        }
    }

    cout << ans << endl;
}


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

int V[3003][3003];
long long dp[3003][3003][4];

long long solve(int r, int c, int f)
{
    if (r < 1 || c < 1)
        return - (long long) 1e18;

    if (r == 1 && c == 1)
    {
        if (f == 0)
            return 0;
        
        return V[r][c];
    }

    if (dp[r][c][f] != -1)
        return dp[r][c][f];
    
    long long ans = max(solve(r-1, c, 3), solve(r, c-1, f));
    
    if (f > 0)
    {
        ans = max(ans, solve(r-1, c, 3) + V[r][c]);
        ans = max(ans, solve(r, c-1, f-1) + V[r][c]);
    }

    return dp[r][c][f] = ans;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
 
    int r, c, k;
    cin >> r >> c >> k;

    while (k--)
    {
        int x, y, z;
        cin >> x >> y >> z;
        V[x][y] = z;
    }

    memset(dp, -1, sizeof(dp));

    cout << solve(r, c, 3) << "\n";
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n*3);
    for(int i=0; i<n*3; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    unsigned long sum=0;
    int index = 1;
    for(int i=0; i<n; i++){
        sum += a[index];
        index += 2;
    }
    cout << sum << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	char s;
	cin >> s;
	if (s == 'A') {
		cout << 'T';
		}
	else if (s == 'T') {
		cout << 'A';
	}
	else if (s == 'C') {
		cout << 'G';
	}
	else {
		cout << 'C';
	}

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){	
			final String t = sc.next();
			final String s = sc.next();
			System.out.println(s + "" + t);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {

	int n;
	cin >> n ;
	vector<int> aVec(n);
	bool up = true;
	bool syokika = true;
	for (int i = 0; i < n; i++)
	{
		cin >> aVec[i];
	}
	

	int ans = 0;
	for (int i = 0; i < n - 1; i++)
	{
		//初回
		if (syokika) {
			if (aVec[i] == aVec[i + 1]) {
				continue;
			}
			if (aVec[i] < aVec[i + 1]) {
				up = true;
			}
			if (aVec[i] > aVec[i + 1]) {
				up = false;
			}
			syokika = false;
			continue;
		}

		if (aVec[i] < aVec[i + 1]) {
			if (up == false) {
				ans++;
				syokika = true;
			}
			//up = true;
		}
		if (aVec[i] > aVec[i + 1]) {
			if (up == true) {
				ans++;
				syokika = true;

			}
			//up = false;
		}
		
	}


	cout << ++ans << endl;


}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

class unionfind
{
private:
	ll _size;				// 森の要素数
	vector<ll> _parent;		// 自分の親
	vector<ll> _rank;		// 自分以下の深さ
public:
	unionfind(ll size = 0) {
		_size = size;
		_parent.resize(_size);
		_rank.resize(_size);
		for(ll i = 0; i < _size; ++i) {
			_parent[i] = i;
			_rank[i] = 1;
		}
	}
	virtual ~unionfind() {

	}
private:
	ll find(ll pos) {		// 引数の親を返す
		if(_parent[pos] == pos) {
			return pos;
		} else {
			return _parent[pos] = find(_parent[pos]); // 辺を縮約
		}
	}
public:
	void unite(ll a, ll b) {	// a を含む木と b を含む木を併合
		a = find(a);
		b = find(b);
		if(a == b) return;
		if(_rank[a] < _rank[b]) {
			_parent[a] = b;
		} else {
			_parent[b] = a;
		} if(_rank[a] == _rank[b]) ++_rank[a];
	}
	bool same(ll a, ll b) {		// a と b が同じ木に属するか
		return find(a) == find(b);
	}
	ll count() {
		ll res = 0;
		for(ll i = 0; i < _size; ++i) {
			if(_parent[i] == i) ++res;
		}
		return res;
	}
};

int main(void) {
	char a, b;
	int ah, bh;
	cin>>a>>b;
	if(a == 'H') ah = 1;
	else ah = -1;
	if(b == 'H') bh = 1;
	else bh = -1;
	if(ah * bh == 1) cout<<'H'<<endl;
	else cout<<'D'<<endl;
}



Measured memory_bytes: 256