akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() 
{
  int r,c;
  cin >> r >> c;
  int matrix[r][c];
  int i,j;
  for(i = 0;i < r;++i){
    for(j = 0;j < c;++j){
      cin >> matrix[i][j];
    }
  }
  int sumyoko[r] = {0};
  int sumtate[c] = {0};
  int allsum = 0;
  for(i = 0;i < r;++i){
    for(j = 0;j < c;++j){
      sumyoko[i] += matrix[i][j];
    }
  }
  for(j = 0;j < c;++j){
    for(i = 0;i < r;++i){
      sumtate[j] += matrix[i][j];
    }
  }
  for(i = 0;i < r;++i){
    allsum += sumyoko[i];
  }
  for(i = 0;i <= r;++i){
    for(j = 0;j <= c;++j){
      if(i != r){
        if(j != c){
          cout << matrix[i][j] << " ";
        }else{
          cout << sumyoko[i] << endl;
        }
      }else if(j != c){
        cout << sumtate[j] << " ";
      }else{
        cout << allsum << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3092
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)
	writer := bufio.NewWriter(os.Stdout)

	var n, q, d int
	fmt.Sscan(getNextLine(scanner), &n, &q)
	stops := make(Stops, n)
	persons := make(Persons, q)
	for i := 0; i < n; i++ {
		stx := getIntList(scanner)
		stops[i].s = stx[0] - stx[2]
		stops[i].t = stx[1] - stx[2]
		stops[i].x = stx[2]
	}
	sort.Sort(stops)
	ans := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Sscan(getNextLine(scanner), &d)
		persons[i].i = i
		persons[i].d = d
		persons[i].next = i + 1
		ans[i] = -1
	}

	sort.Sort(persons)

	for i := 0; i < n; i++ {
		l := 0
		r := q
		for l < r {
			m := (l + r) / 2
			if persons[m].d < stops[i].s {
				l = m + 1
				continue
			}
			r = m
		}
		update(r, q, stops[i].t, stops[i].x, persons, ans)
	}
	for i := 0; i < q; i++ {
		fmt.Fprintln(writer, ans[i])
	}

	writer.Flush()
}

func update(r int, q int, t int, x int, persons Persons, ans []int) int {
	if r == q || persons[r].d >= t {
		return r
	}

	ret := update(persons[r].next, q, t, x, persons, ans)
	persons[r].next = ret
	if ans[persons[r].i] == -1 {
		ans[persons[r].i] = x
	}
	return ret

}

type Stop struct {
	s int
	t int
	x int
}

type Stops []Stop

func (a Stops) Len() int           { return len(a) }
func (a Stops) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Stops) Less(i, j int) bool { return a[i].x < a[j].x }

type Person struct {
	d    int
	i    int
	next int
}
type Persons []Person

func (a Persons) Len() int           { return len(a) }
func (a Persons) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Persons) Less(i, j int) bool { return a[i].d < a[j].d }


Measured memory_bytes: 54912
#include <iostream>

int main(){
    int a_num[4];
    int b_num[4];
    
    while (true) {
        
        // input a's number.
        for (int i=0; i<4; ++i) {
            if(! (std::cin >> a_num[i]) ){
                return 0;
            }
        }
        // input b's number.
        for (int i=0; i<4; ++i) {
            if(! (std::cin >> b_num[i]) ){
                return 0;
            }
        }
        
        // count hit.
        int hit=0;
        for (int i=0; i<4; ++i) {
            if (a_num[i] == b_num[i]) {
                ++hit;
            }
        }
        std::cout << hit << " ";
        
        // count blow.
        int blow=0;
        for (int i=0; i<4; ++i) {
            for (int j=0; j<4; ++j) {
                if (i!=j && b_num[i] == a_num[j]) {
                    ++blow;
                }
            }
        }
        std::cout << blow << std::endl;
        
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;

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

   ll x,y,z,k; cin >> x >> y >> z >> k;
   vector<ll> a(x), b(y), c(z);
   for(int i=0; i<x; ++i) cin >> a[i];
   for(int i=0; i<y; ++i) cin >> b[i];
   for(int i=0; i<z; ++i) cin >> c[i];

   vector<ll> ab;
   for(int i=0; i<x; ++i) for(int j=0; j<y; ++j){
       ab.push_back(a[i]+b[j]);
   }
   sort(ab.begin(), ab.end(), greater<ll>());

   vector<ll> abc;
   for(int i=0; i<min(x*y, k); ++i) for(int j=0; j<z; ++j) abc.push_back(ab[i]+c[j]);
   sort(abc.begin(), abc.end(), greater<ll>());

    for(int i=0; i<k; ++i) cout << abc[i] << endl;

    return 0;
}

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

typedef long long ll;
bool is_prime(ll n){
    switch(n){
        case 0: 
        case 1: return false;
        case 2:
        case 3: return true;
    } 

    if(n % 2 == 0 || n % 3 == 0) return false;

    for(ll 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 main(){
    ll N = 100000;
    vector<ll> v(N, 0);
    for(ll i = 0; i < N; i++){
        if(i % 2 == 0){
            v[i] = 0;
        } else { 
            if(is_prime(i) && is_prime((i+1)/2)){
                v[i] = 1;
            }
        }
    }

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

    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int l, r;
        cin >> l >> r;
        cout << v[r] - v[l-1] << endl;
    }

}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>

using namespace std;

typedef pair<int,int> P;

vector<int> g[100];
int ans[100][2]; //[i][0] 到着　　[i][1] 終了
int used[100];
int t=1;

void dfs(int v){
	//cout << "初　点" << v+1 << "  " << t << "\n";
	used[v] = 1;
	ans[v][0] = t;
	t++;
	if(g[v].size() == 0){
	//	cout << "　　点" << v+1 << "  " << t << "\n";
	}
	else{
		for(int i=0;i<g[v].size();i++){
			if(!used[g[v][i]]) dfs(g[v][i]);
			//t++;
	//		cout << "　　点" << v+1 << "  " << t << "\n";
		}
	}
	ans[v][1] = t;
	t++;
	return;
}

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

	int n;
	cin >> n;
	
	for(int i=0;i<n;i++){
		int u, nume;
		cin >> u >> nume;

		int v;
		for(int j=0;j<nume;j++){ //jは回数数えるだけ
			cin >> v;
			g[u-1].push_back(v-1);
		}
	}

//	for(int i=0;i<n;i++){
//		for(int j=0;j<g[i].size();j++){
//			cout << g[i][j] + 1 << " ";
//		}
//		cout << "\n";
//	}

//	cout << "\n";
	for(int i=0;i<n;i++){
		if(!used[i]){
			dfs(i);
		}
	}

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

	return 0;
}


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

using namespace std;

struct a{
    string name;
    int score;
    int num;
}a[105];
bool com(struct a a,struct a b)
{
    if(a.name==b.name)
        return a.score>=b.score;
    return a.name<=b.name;
}
int main()
{
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i-1].name >> a[i-1].score;
        a[i-1].num=i;
    }
    sort(a,a+n,com);
    for(int i=0;i<n;i++)
        cout << a[i].num << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define SIZE 100005
#define PI acosl(-1) //3.14159265358979323846264338327950L 
#define rep(i, N) for (i = 0; i < N; i++) //制御変数iを用いてN回転
#define array(N, t) (t*)calloc(N, sizeof(t)) //t型N要素の1次元配列を動的確保後0クリア(freeを忘れずに)
#define zero(a); {int iter; rep(iter, sizeof(a)/sizeof((a)[0])) (a)[iter]=0;} //1次元配列aのゼロ初期化?

typedef long long ll; typedef long double ld;
typedef struct node { int data; struct node *next; } Node;

Node *list[SIZE];
int queue[SIZE]; int q_head = 0, q_tail = 0;

void print_log(); //とりあえず文字を出力してどこまで実行できているか確認(for debug)
void printa_int(int *a, int size); //int型の1次元配列aを出力(for debug)
void printl_int(int size); //リンクリストを出力(for debug)
Node* add_node(int i, int data); void free_list(Node* head);
int queue_empty(); int queue_full();
void enqueue(int data); int dequeue();

int main() {
    ll A, ans = 0;
    ll t[3];
    char B[5];
    scanf("%lld %s", &A, &B);
    t[0] = A * (B[0] - '0');
    t[1] = A * (B[2] - '0');
    t[2] = A * (B[3] - '0');
    t[1] = (t[1] * 10 + t[2]) / 10;
    t[0] = (t[0] * 10 + t[1]) / 10;
    printf("%lld\n", t[0]);
    return 0;
}

void print_log() {
    printf("=== print log ===\n");
}
void printa_int(int *a, int size) {
    int i;
    printf("[");
    for (i = 0; i < size; i++)
        printf("%d, ", a[i]);
    printf("]\n");
}
void printl_int(int size) {
    int i;
    Node *t;
    rep(i, size) {
        printf("[%d] ", i);
        for (t = list[i]; t; t = t->next) printf("%d, ", t->data);
        printf("\n");
    }
}
Node* add_node(int i, int data) {
    if (!list[i]) {
        list[i] = (Node*)malloc(sizeof(Node*));
        list[i]->data = data;
    } else {
        Node *t;
        t = list[i];
        list[i] = (Node*)malloc(sizeof(Node*));
        list[i]->data = data;
        list[i]->next = t;
    }
    return list[i];
}
void free_list(Node* head) {
    Node *prev = NULL, *t = head;
    while (t) {
        prev = t;
        t = t->next;
        free(prev);
    }
}
int queue_empty() {
    return q_head == q_tail;
}
int queue_full() {
    return (q_head - 1) % SIZE == q_tail % SIZE;
}
void enqueue(int data) {
    if (queue_full()) {
        printf("full!\n");
        return;
    }
    queue[q_tail++] = data;
    q_tail %= SIZE;
}
int dequeue() {
    if (queue_empty()) {
        printf("empty!\n");
        return -444444;
    }
    int data = queue[q_head++];
    q_head %= SIZE;
    return data;
}

Measured memory_bytes: 1720
N=int(input())
MOD=10**9+7
dp=[[0]*4 for i in range(N)]
for i in range(4):
  dp[0][i]=1
  dp[1][i]=4
dic={'AG':1,'AC':1,'GA':1,'AGA':0,'AGG':0,'AGT':0,'AAG':0,'ATG':0,'AA':1,'AT':1}
def chk(i,j):
  global dp,dic
  if j==0:
    return 0
  elif j==1:
    return dic['AGG']+dic['AGT']+dic['ATG']+dic['AG']+dic['GA']
  elif j==2:
    return dic['AC']
  else:
    return 0
dp[2][0]=sum(dp[1])
dp[2][1]=sum(dp[1])-dp[0][0]-dp[0][2]
dp[2][2]=sum(dp[1])-dp[0][0]
dp[2][3]=sum(dp[1])
#dic['AGA']=dic['AG']
dic['AGG']=dic['AG']
dic['AGT']=dic['AG']
#dic['AAG']=dic['AA']
dic['ATG']=dic['AT']
dic['AG']=dp[1][0]
dic['AC']=dp[1][0]-dic['GA']
dic['GA']=dp[1][2]
dic['AT']=dp[1][0]
for i in range(3,N):
  _=sum(dp[i-1])
  for j in range(4):
    dp[i][j]=_-chk(i,j)
  dic['AGG']=dic['AG']
  dic['AGT']=dic['AG']
  dic['ATG']=dic['AT']
  dic['AG']=dp[i-1][0]
  dic['AC']=dp[i-1][0]-dic['GA']
  dic['GA']=dp[i-1][2]
  dic['AT']=dp[i-1][0]
print(sum(dp[-1])%MOD)

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define next Next
#define y1 _y1
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=200005,INF=1e9;
int n,k;
int a[N];
int las[N];
int mi[N<<2],mx[N<<2];
void build(int rt,int L,int R){
	if (L==R){
		mi[rt]=mx[rt]=a[L];
		return;
	}
	int mid=(L+R)>>1,ls=rt<<1,rs=ls|1;
	build(ls,L,mid);
	build(rs,mid+1,R);
	mi[rt]=min(mi[ls],mi[rs]);
	mx[rt]=max(mx[ls],mx[rs]);
}
pair <int,int> query(int rt,int L,int R,int xL,int xR){
	if (R<xL||L>xR)
		return mp(INF,-INF);
	if (xL<=L&&R<=xR)
		return mp(mi[rt],mx[rt]);
	int mid=(L+R)>>1,ls=rt<<1,rs=ls|1;
	pair <int,int> a=query(ls,L,mid,xL,xR),
				   b=query(rs,mid+1,R,xL,xR);
	return mp(min(a.fi,b.fi),max(a.se,b.se));
}
int main(){
	n=read(),k=read();
	For(i,1,n)
		a[i]=read()+1;
	las[1]=0;
	For(i,2,n)
		las[i]=a[i]>a[i-1]?las[i-1]+1:0;
	build(1,1,n);
	int ans=1;
	For(i,1,n-k){
		pair <int,int> p=query(1,1,n,i+1,i+k-1);
		if (a[i]>p.fi||a[i+k]<p.se)
			ans++;
	}
	int c=0;
	For(i,1,n)
		if (las[i+1]==0)
			if (las[i]>=k-1)
				c++;
	ans-=max(c-1,0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,m,c;
    cin >> n >>m >>c;
    vector<int> hai_b(m);
    for(int i=0;i<m;i++){
        cin >> hai_b.at(i);
    }
    vector<vector<int>> hai_a(n,vector<int>(m));
    int cnt=0;
    for(int i=0;i<n;i++){
        int sum =c;
        for(int j=0;j<m;j++){
            cin >> hai_a.at(i).at(j);
            sum += hai_a.at(i).at(j) * hai_b.at(j);
        }
        if(sum >0){
            cnt++;
        }
    }
    cout << cnt <<endl;
}

Measured memory_bytes: 256
def f(x,r,p):
  ans=1
  for i in range(x,x-r,-1):
    ans=(ans*i)%p
  return ans
def comb(x,r,p):
  r=min(r,x-r)
  return (f(x,r,p)*pow(f(r,r,p),p-2,p))%p
x,y=map(int,input().split())
if (2*y-x)%3!=0 or (2*x-y)%3!=0 or 2*y-x<0 or 2*x-y<0:
  print(0)
  exit()
s=(2*x-y)//3
t=(2*y-x)//3
mod=10**9+7
print(comb(s+t,s,mod))

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 998244353
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n;cin>>n;
    V<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    ll b1=0;
    for(ll i=0;i<n;i++)b1+=a[i];
        b1%=2;
    if(n%2!=0){
        if(b1==0){
            cout<<"Second"<<Endl;
        }
        else cout<<"First"<<Endl;
    }
    else{
        sort(all(a));
        ll b2=a[0]%2;
        if(b1==0&&b2==0){
            cout<<"Second"<<endl;
        }
        else cout<<"First"<<Endl;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------




































Measured memory_bytes: 4420
#include<bits/stdc++.h>
#define N 810
#define p_b push_back
#define m_p make_pair
#define m1 first
#define m2 second
#define inf 1e9

using namespace std;

typedef pair<int,int> PII;
pair<PII,int> q[N*N];
bool vis[N][N];
const int tx[4]={1,0,-1,0},ty[4]={0,1,0,-1};
int l,r,n,m,k,ans=inf;
char mp[N][N];

int main(){
	int i,j,x,y,d;
	scanf("%d%d%d",&n,&m,&k);
	for(i=1;i<=n;i++){
		scanf("%s",mp[i]+1);
		for(j=1;j<=m;j++)
		if(mp[i][j]=='S') q[1]=m_p(m_p(i,j),0);
	}
	
	x=q[1].m1.m1; y=q[1].m1.m2;
	ans=min(ans,(n-1-x)/k+1);
	ans=min(ans,(x-2)/k+1);
	ans=min(ans,(m-1-y)/k+1);
	ans=min(ans,(y-2)/k+1);
	l=1; r=1;
	while(l<=r){
		if(q[l].m2==k) break;
		for(i=0;i<4;i++){
			x=q[l].m1.m1+tx[i]; y=q[l].m1.m2+ty[i]; d=q[l].m2+1;
			if(x<1||x>n||y<1||y>m||vis[x][y]||mp[x][y]=='#') continue;
			if(x==1||x==n||y==0||y==m){puts("1"); return 0;}
			vis[x][y]=1; q[++r]=m_p(m_p(x,y),d);
			ans=min(ans,(n-1-x)/k+1);
			ans=min(ans,(x-2)/k+1);
			ans=min(ans,(m-1-y)/k+1);
			ans=min(ans,(y-2)/k+1);
		}
		l++;
	}
	printf("%d\n",ans+1);
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
using namespace std;
 
bool isPrime(int n){
    for(int i=6 ; i < n ; i+=7 ){
        if( n%i == 0 ) return false;
    }
    for(int i=8 ; i < n ; i+=7 ){
        if( n%i == 0 ) return false;
    }
    return true;
}
 
int main(){
    int n;
    for( ; cin >> n ; ){
        if( n == 1 ) break;
        cout << n << ":";
        for(int i=7 ; i <= n+1 ; i+=7 ){
            if( n%(i-1) == 0 ){
                if( isPrime(i-1) )
                    cout << " " << (i-1);
            }
            if( n%(i+1) == 0 ){
                if( isPrime(i+1) )
                    cout << " " << (i+1);
            }
        }
        cout << endl; 
    }
}

Measured memory_bytes: 868
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define forall(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define dforn(i, n) for(int i = ((int) n) - 1; i >= 0; i--)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
typedef pair<int, int> pi;
typedef long long ll;
#define ff first
#define ss second
const int MAXN = 256;

int n, A[MAXN], B[MAXN], v, mx = -1;
vector<pi> ans, segm;

void solve(bool inv = false){
  //~ int last = 0;
  //~ forr(i, 1, n){
    //~ if(A[i-1] > A[i]){
      //~ segm.pb(make_pair(last, i-1)); // cerrado cerrado
      //~ last = i;
    //~ }
  //~ }
  //~ segm.pb(make_pair(last, n - 1));
  //~ int m = segm.size();
  //~ forn(i, m - 1){
    //~ int v = segm[i].ss;
    //~ forr(w, segm[i+1].ff, segm[i+1].ss + 1){
      //~ if(inv) ans.pb(make_pair(n - 1 - (w-1), n - 1 - w));
      //~ else ans.pb(make_pair(w-1, w));
    //~ }
  //~ }
  forn(i, n - 1){
    if(!inv) ans.pb(make_pair(i, i + 1));
    else     ans.pb(make_pair(n-1-i, n-2-i));
  }
}

int main() {  
  scanf("%d", &n);
  forn(i, n){
    scanf("%d", &A[i]); B[i] = A[i];
    if( abs(A[i]) > mx ){
      mx = abs(A[i]);
      v = i;
    }
  }
  forn(i, n){
    if( (ll) A[i] * A[v] <= 0 ){
      ans.pb(make_pair(v, i));
    }
  }
  bool rev = false;
  if(A[v] < 0){
    reverse(A, A + n);
    forn(i, n){
      A[i] = -A[i];
    }
    rev = true;
  }
  solve(rev);
  assert((int)ans.size() <= 2*n);
  printf("%d\n", (int)ans.size());
  forn(i, ans.size()){
    printf("%d %d\n", ans[i].ff + 1, ans[i].ss + 1);
    //~ B[ ans[i].ss ] += B[ ans[i].ff ];
      //~ forn(j, n){
        //~ printf("%d ", B[j]);
        //~ if(i + 1 < n) assert(B[i] <= B[i+1]);
      //~ }
      //~ puts("");
  }
  
  return 0;
}
/*
9
1 7 5 3 2 9 -10 1 17 
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll r;
    cin >> r;
    
    if (1200 > r)cout << "ABC" << endl;
    else if (2800 > r)cout << "ARC" << endl;
    else cout << "AGC" << endl;
    
    
    return 0;
    
}



Measured memory_bytes: 256
x = input()
xResult = ''

for i in range(len(x)):
    xSw = True
    y = x[i:i+1]
    yU = y.upper()
    yL = y.lower()
    
    if y == yU:
        y = yL
    else:
        y = yU

    xResult = xResult + y
    
print(xResult)


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

long long int myPow2(int n) {
	long long int x = 1;
	for (int i = 1; i <= n; i++) {
		x *= 2;
	}
	return x;
}

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

	int odd = 0;
	int x;
	for (int i = 0; i < N; i++) {
		cin >> x;
		if (x % 2 == 1) {
			odd++;
		}
	}

	if (odd == 0) {
		if (P == 0) {
			cout << myPow2(N) << endl;
		}
		else {
			cout << odd << endl;
		}
	}
	else {
		cout << myPow2(N - 1) << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    map<string, int> fre;
    while(n--){
        string s;
        cin >> s;
        ++fre[s];
    }
    int Max = 0;
    for(auto it: fre){
        Max = max(Max, it.se);
    }
    for(auto it: fre){
        if(it.se == Max){
            cout << it.fi << endl;
        }
    }
}

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

int house[4][3][10];
int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int B, F, R, V;
        cin >> B >> F >> R >> V;
        house[B - 1][F - 1][R - 1] += V;
    }
    for (int i = 0; i < 4; i++) {
        if (i) {
            for (int s = 0; s < 20; s++) cout << "#";
            cout << endl;
        }
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                cout << " " << house[i][j][k];
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3092
// vim: set fdm=marker:
// {{{
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <utility>

using namespace std ;

typedef long long ll ;

// }}}

int stat[222222];

int A[222222];

int main()
{
    int N, K;
    cin >> N >> K ;
    for(int i = 1 ; i <= N ; i++)
        scanf("%d", A+i);
    for(int i = 1 ; i <= N ; i++)
        stat[A[i]]++;
    multiset<int> MS;
    for(int i = 1 ; i <= N ; i++) {
        if(stat[i] == 0)
            continue;
        MS.insert(stat[i]);
    }
    int ans = 0 ;
    while(MS.size() > K) {
        ans += *MS.begin();
        MS.erase(MS.begin());
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 11136
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <boost/graph/adjacency_list.hpp>
//#include <boost/graph/dijkstra_shortest_paths.hpp>
//#include <boost/graph/graph_utility.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <boost/version.hpp>
  
using namespace std;
//using namespace boost::multiprecision;
//using namespace boost::math;

/*
typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS,
        boost::no_property, boost::property<boost::edge_weight_t, int> > Graph;
*/


#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int n;
    cin >> n;

    string s;
    cin >> s;

    auto t = s;

    sort(all(t));

    int cnt = 0;

    rep(i,n){
        cnt += (t[i] != s[i]);
    }

    cout << min({cnt / 2, int(count(all(s), 'R')), int(count(all(s), 'W'))}) << '\n';

    return 0;
}


Measured memory_bytes: 3864
def main():
    target_list = input().split()

    result = 0
    for i in range(1, int(target_list[0])+1):
        sum = 0
        for j in range(len(str(i))):
            sum += int(str(i)[j])
        if int(target_list[1]) <= sum <= int(target_list[2]):
            result += i

    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import math
data = input().split()
N = int(data[0])
A = int(data[1])
B = int(data[2])
total = 0
digit_total = 0

for i in range(1,N+1):
    size = int(math.log10(i)+1)
    digit = []
    for j in range(size):
        digit.append(int(str(i)[j-1]))
        digit_total += digit[j]
    if A <= digit_total and digit_total <= B:
        total += i
    digit_total = 0
print(total)

Measured memory_bytes: 41196
a=[]
b=[]
A=[]
B=[]
for i in range(20):
    if i<=9:
        a.append(int(input()))
    else:
        b.append(int(input()))
        
for n in range(3):
    s=max(a)
    A.append(s)
    a.remove(s)

        
for m in range(3):
    t=max(b)
    B.append(t)
    b.remove(t)
    
print(sum(A),sum(B))



Measured memory_bytes: 5592
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> ans;
	rep(i,0,N) cin >> A[i];
	ans.push_back(A[0]);
	rep(i,1,N){
		if(ans.front()>=A[i]){
			ans.insert(ans.begin(),A[i]);
		}else if(ans.back()<A[i]){
			ans[ans.size()-1] = A[i];
		}else{
			auto itr = lower_bound(all(ans),A[i]);
			--itr;
			*itr = A[i];
		}
	}
	cout << ans.size() << endl;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18,MOD=1e9+7;
const int iINF=1e9;
int main(){
    int n,ans=0;
    string tos;
    cin>>n;
    for(int i=1;i<=n;i++){
        tos=to_string(i);
        if(tos.size()%2==1)ans++;
    }
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000

int main()
{
  int h, w; cin >> h >> w;
  vector<vector<char>> c(h, vector<char>(w));
  REP(i, h) {
    REP(j, w) {
      cin >> c.at(i).at(j);
    }
  }

  REP(i, h) {
    REP(j, w) {
      cout << c.at(i).at(j);
    }
    cout << endl;
    REP(j, w) {
      cout << c.at(i).at(j);
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("/home/rajkumar/Documents/coding/in.txt", "r", stdin);
    // freopen("/home/rajkumar/Documents/coding/out.txt", "w", stdout);
    // #endif
    ll n;
    cin>>n;
    cout<<pow(n,3);
    return 0;
}

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

#define MAX_N 100000
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	int A[MAX_N], B[MAX_N];
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> A[i];
		B[i] = A[i];
	}
	sort(B, B+N);
	unordered_map<int, bool> mp;
	for(int i=0; i<N; i++){
		if(i%2==0) mp[B[i]] = false;
		else mp[B[i]] = true;
	}

	int cnt = 0;
	for(int i=0; i<N; i++){
		if(i%2==0 && mp[A[i]]) cnt++;
		if(i%2==1 && !mp[A[i]]) cnt++;
	}

	cout << cnt / 2 << endl;


	return 0;
}


Measured memory_bytes: 5156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n;
  int a[32]={1,1,1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  string s;
  cin >> n;
  cout << a[n-1] << endl;

  return 0; 
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>

int main(void) {

	int a, b;

	std::cin >> a >> b;

	if (a + b == 15) {
		std::cout << "+" << std::endl;
	}
	else if (a * b == 15) {
		std::cout << "*" << std::endl;
	}
	else {
		std::cout << "x" << std::endl;
	}



	return 0;
}

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

using namespace std;

bool mycomp(pair<string, int> a, pair<string, int>b) {
    if (a.second == b.second) return a.first.compare(b.first) < 0;
    return a.second > b.second;
}

int main() {
    int N; cin >> N;
    string S;
    map<string, int> cnt;
    for (int i= 0; i<N; i++) {
        cin >> S;
        cnt[S]++;
    }
    vector<pair<string, int>> v;
    for (auto x = cnt.begin(); x != cnt.end(); x++) {
        v.push_back(make_pair(x->first, x->second));
    }
    sort(v.begin(), v.end(), mycomp);
    int max = v[0].second;
    for (auto& x:v) {
        if (max == x.second) {
            cout << x.first << endl;
        }else break;
    }
    return 0;
}

Measured memory_bytes: 29296
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (p : q : r : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print . minimum $ [p + q, p + r, q + r]

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <cstring>
#include<cstdio>
#include <cmath>
using namespace std;



int main()
{
	char s[3];
	int sum = 0;

	for (int i = 0; i < 3; i++)
		cin >> s[i];
	
	for (int i = 0; i < 3; i++){
		if (s[i] == '1')
			sum++;
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include<iostream>
#include<map>
#include<set>
#include<vector>

using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
#define rep(i, n) for (i32 i = 0; i < (i32)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64, i64>;

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    i64 h, w, m;
    cin >> h >> w >> m;
    set<P> st;
    i64 max_row = 0, max_col = 0;
    map<i64,i64> mp_row,mp_col;
    rep(i, m) {
        i64 H, W;
        cin >> H >> W;
        H--;
        W--;
        mp_row[H]++;
        mp_col[W]++;
        st.insert(P(H, W));
    }
    for (auto v:mp_row) {
        if (v.second > max_row) {
            max_row = v.second;
        }
    }
    for (auto v:mp_col) {
        if (v.second > max_col) {
            max_col = v.second;
        }
    }
    set<i64> row,col;
    rep(i,h) {
        if (mp_row[i] == max_row)row.insert(i);
    }
    rep(i,w) {
        if (mp_col[i] == max_col)col.insert(i);
    }
    i64 ans = max_row + max_col;
    i64 cnt = 0;
    for(auto v:st){
        if(row.count(v.first) && col.count(v.second))cnt++;
    }
    if(cnt == row.size() * col.size())ans--;
    cout << ans << endl;
}

Measured memory_bytes: 88028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i=0;i<(n);i++)
#define forr(i,n) for(ll i=(n)-1;i>=0;i--)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))

const ll W =1e5+5;
const ll N = 110;
const ll inf=1e15;
ll w[N],v[N],dp[N][W],n,k;


int main()
{
    ios_base::sync_with_stdio(false);

	clr(dp);
	cin>>n>>k;forn(i,n)cin>>w[i]>>v[i];
	forn(j,k+1)if(w[0]<=j)dp[0][j]=v[0];
	for(int i=1;i<n;i++)
	{
		forn(j,k+1)
		{
			dp[i][j]=dp[i-1][j];
			if(j>=w[i])dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
		}
	}
	//forn(j,k+1){forn(i,n)cout<<dp[i][j]<<" ";cout<<endl;}

	cout<<dp[n-1][k]<<endl;
}


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

signed main(){
	int H, W;
	char a[110][110] = {};
	cin>>H>>W;
	
	rep(i, H){
		rep(j, W){
			cin>>a[i][j];
			
		}
	}
	rep(i, H){
		rep(j, W){
			cout<<a[i][j];	
		}cout<<endl;
		rep(j, W){
			cout<<a[i][j];	
		}cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a) for(int i=0;i<a;i++)

//int型を受け取ってその桁数を返す
int check_digits(int n, int m) {
	int digits = 0;
	while (n != 0) {
		n /= m;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum = 0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


//入力された文字列が回文か判断してboolを返す
bool is_kaibun(string s) {
	string s_r(s.rbegin(), s.rend());
	return (s == s_r);
}


void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }


//提出言語もしっかり確認して…
//問題文を落ち着いて読む！
//型に注意！！
//出力例もちゃんと全部見る！！！！！
int main() {
	int n,temp;
	cin >> n;
	vi a(n,0);
	rep(i, n-1) {
		cin >> temp;
		a[temp-1]++;
	}

	rep(i, n) {
		cout << a[i] << endl;
	}

	system("pause");
	return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    set<int> water;
    rep(ia, 31) {
        rep(ib, 31) {
            int aw = ia * 100 * A;
            int bw = ib * 100 * B;
            if (aw + bw > F) continue;
            water.insert(aw + bw);
        }
    }

    set<int> sugar;
    rep(ic, 3000) {
        rep(id, 3000) {
            int cs = ic * C;
            int ds = id * D;
            if (cs + ds > F) continue;
            sugar.insert(cs + ds);
        }
    }

    double mx = -1;
    int w = 0;
    int s = 0;
    for (auto wt: water) {
        for (auto su: sugar) {
            if (wt + su > F) continue;
            if (su > wt / 100 * E) continue;
            double tmp = 100 * (double) su / (double) wt;
            if (tmp > mx) {
                mx = tmp;
                w = wt + su;
                s = su;
            }
        }
    }
    cout << w << " " << s << endl;
}

Measured memory_bytes: 384
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.Scanner;

public class Main {


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

	    BigDecimal result = execute(sc.nextLine());
        System.out.println(result.toPlainString());
    }

    public static BigDecimal execute(String value){
        BigDecimal totalLength = new BigDecimal(value);
        BigDecimal sideLength = totalLength.divide(BigDecimal.valueOf(3),7, RoundingMode.HALF_EVEN);
        return sideLength.multiply(sideLength).multiply(sideLength);
    }

}


Measured memory_bytes: 22356
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;

int main() {
	int a, b,x=0;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		string s = to_string(i);
		string str = s;
	    reverse(s.begin(),s.end());
		if (s == str)x++;
	}
	cout << x << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    string s, t;
    cin >> s >> t;
    for(int i=0;i<n;i++){
        cout << s[i] << t[i];
    }
    cout << endl;
}

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

a = []
b = []

for i in range(n):
    tmp1, tmp2 = list(map(int, input().split()))
    a.append(tmp1)
    b.append(tmp2)

c = []
d = []

for i in range(m):
    tmp1, tmp2 = list(map(int, input().split()))
    c.append(tmp1)
    d.append(tmp2)

for i in range(n):
    tmp = abs(a[i] - c[0]) + abs(b[i] - d[0])
    s = 1
    for j in range(m):
        tmp3 = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if tmp3 < tmp:
            tmp = tmp3
            s = j + 1
    print(s)

Measured memory_bytes: 3064
import sys

def main(data):
    if data[0] == '1':
        print('Hello World')
    elif data[0] == '2':
        print(str(int(data[1]) + int(data[2])))
    else:
        print('3 or more years old')
if __name__ == '__main__':
    data = [line.strip() for line in sys.stdin]
    main(data)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        int N = Integer.parseInt(br.readLine());
        List<List<String>> list = new ArrayList<>();
        
        for (int i = 0; i < N; i++) {
            String[] arr = br.readLine().split(" ");
            List<String> l = Arrays.asList(arr[0], arr[1], String.valueOf(i+1));
            list.add(l);
        }

        list.sort((x, y) -> {
            if (x.get(0).equals(y.get(0))) {
                return Integer.parseInt(y.get(1)) - Integer.parseInt(x.get(1));
            } else {
                return x.get(0).compareTo(y.get(0));
            }
        });

        for (List<String> l: list) {
            out.println(l.get(2));
        }
        out.close();
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string resurt = "No";
            {
                //ビンゴカードの作成
                long[] bingoCard1 = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
                long[] bingoCard2 = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
                long[] bingoCard3 = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
                
                List<long> bingoCard = new List<long>();
                bingoCard.AddRange(bingoCard1);
                bingoCard.AddRange(bingoCard2);
                bingoCard.AddRange(bingoCard3);

                //投げられた数値の取得
                long N = long.Parse(Console.ReadLine());
                List<long> b = new List<long>();
                for (long y = 0; y < N; y++)
                {
                    b.Add(long.Parse(Console.ReadLine()));
                }
                //ビンゴカードにあるかの確認
                Boolean[] checkflg = new Boolean[9];
                for (int q = 0; q<9; q++)
                {
                    checkflg[q] = false;
                }
                for (int r = 0; r < N; r++)
                {
                    if (bingoCard.IndexOf(b[r]) != -1)
                    {

                        checkflg[bingoCard.IndexOf(b[r])] = true;
                    }
                }
                //bingoの確認
                //横列
                for (long c = 0; c < 9; c = c + 3)
                {
                    if (checkflg[c] == true && checkflg[c + 1] == true && checkflg[c + 2] == true)
                    {
                        resurt = "Yes";
                    }
                }
                //楯列
                for (long f = 0; f < 3; f = f + 1)
                {
                    if (checkflg[f] == true && checkflg[f + 3] == true && checkflg[f + 6] == true)
                    {
                        resurt = "Yes";
                    }
                }
                //斜め
                if (checkflg[0] == true && checkflg[4] == true && checkflg[8] == true)
                {
                    resurt = "Yes";
                }
               
                if (checkflg[2] == true && checkflg[4] == true && checkflg[6] == true)
                {
                    resurt = "Yes";
                }
            }
            Console.WriteLine(resurt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

Measured memory_bytes: 13280
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
res = 0

for i, k in enumerate(A):
  res += B[k-1]
  if A[i-1] == k-1 and i != 0:
    res += C[k-2]
    
print(res)

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

int cnt = 0;

void printSequence(int A[], int N)
{
  rep(i, N)
  {
    cout << A[i];
    if (i == N - 1)
    {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}

void bubbleSort(int A[], int N)
{
  bool flag = true;
  while (flag)
  {
    flag = false;
    for (int j = N - 1; j > 0; j--)
    {
      if (A[j] < A[j - 1])
      {
        int v = A[j];
        A[j] = A[j - 1];
        A[j - 1] = v;
        flag = true;
        cnt++;
      }
    }
  }
}

int main()
{
  int n;
  cin >> n;

  int a[n];
  rep(i, n) cin >> a[i];

  bubbleSort(a, n);
  printSequence(a, n);
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <algorithm>

using namespace std;

int A, B, C, K;

void solve() {
  int ans = 0;
  ans += min(A, K);
  K -= min(A, K);
  K -= min(B, K);
  ans -= min(C, K);
  printf("%d\n", ans);
}

int main() {
  scanf("%d %d %d %d", &A, &B, &C, &K);
  solve();
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define INT long long int
using namespace std;
INT n;
bool isPrime(int x)
{
    for(int i = 2 ; i*i <= x ; i++ )
        if( x%i == 0 ) return false;
    return true;
}
int main()
{
    cin>>n; n--;
    cout<<2<<" ";
    for(int i = 0, j = 3 ; i < n ; j+=10 )
        if( isPrime(j) ) cout<<j<<" ", i++;
    cout<<endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld; //
typedef double db; //
typedef string str; //
//
typedef pair<int, int> pi;
typedef pair<ll,ll> pl; //
typedef pair<ld,ld> pd; //
#define mp make_pair
#define f first
#define s second

typedef vector<int> vi;
typedef vector<ll> vl; //
typedef vector<ld> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi; //
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //
typedef vector<vi> vvi;
typedef vector<vl> vvll;

//
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back() //
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = 4*atan((ld)1); 
const int xd[4] = {0,1,0,-1}, yd[4] = {1,0,-1,0}; //

template<class T> bool ckmin(T& a, const T& b) { 
    return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
    return a < b ? a = b, 1 : 0; }
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

    vi N(4);
    cin >> N[0] >> N[1] >> N[2] >> N[3];
    sort(all(N));

    if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256