akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

int solve(vector<int> &a, int k)
{
    fast
    int n = a.size();
    vector<int> dp(n, INT_MAX);
    dp[0] = dp[1] = 0;
    for(int i=1; i<=n; i++){
        if(i>k){
            for(int j=1; j<=k; j++){
                dp[i] = min(dp[i-j] + abs(a[i]-a[i-j]), dp[i]);        
            }
        }
        else
        {
            for(int j=1; j<i; j++){
                dp[i] = min(dp[i-j] + abs(a[i]-a[i-j]), dp[i]);        
            }
        }
    }
    return  dp[n-1];
}


int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n+1);
    for(int i=1; i<=n; i++) cin >> a[i];
    cout << solve(a, k) << '\n';
    return 0;
}

Measured memory_bytes: 4056
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊

    let (n, T) = (io.read::<usize>(), io.read::<i64>());

    let t = io.readn::<i64>(n);
    let mut ans = 0;
    let mut nxt = 0;

    for (i, &tt) in t.iter().enumerate() {
        if i == 0 {
            ans += T;
            nxt = T;
        } else {
            if tt <= nxt {
                ans += T - (nxt - tt);
                nxt = tt + T;
            } else {
                ans += T;
                nxt = tt + T;
            }
        }
    }
    io.writeln(ans);
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 6396
#include <iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0){
            break;
        }else{
            for(int i = 0;i<H;i++){
                for(int j=0;j<W;j++){
                    cout << "#";
                }
                cout << "\n";
            }
            cout << "\n";
        }
       }
    return 0;
}


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

using namespace std;
string s,t;
int len1,len2,dp[3005][3005],dir[3005][3005];

int func(int i, int j)
{
    if(i==len1 || j==len2) return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    int ans=0;
    if(s[i]==t[j])
    {
        ans=1+func(i+1,j+1);
        dir[i][j]=1;
    }
    else
    {
        int p1=func(i+1,j);
        int p2=func(i,j+1);
        if(p1>p2)
        {
            dir[i][j]=2;
            ans=p1;
        }
        else dir[i][j]=3,ans=p2;
    }
    return dp[i][j]=ans;
}

void go(int i, int j)
{
    if(i==len1 || j==len2) return ;
    if(dir[i][j]==1)
    {
        cout<<s[i];
        go(i+1,j+1);
    }
    else if(dir[i][j]==2) go(i+1,j);
    else go(i,j+1);
}

int main()
{
    int i,j;
    cin>>s>>t;
    len1=s.length();
    len2=t.length();
    memset(dp, -1, sizeof dp);
    int ans=func(0,0);
    go(0,0);
    cout<<endl;
    return 0;



}


Measured memory_bytes: 71040
#include<iostream>
#include<algorithm>
#include<vector>
#include<fstream>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define X 2100
ll n,m,s,t;
char edge[X][X];
bool vis[X];
bool dfs(ll x,ll moku){
	if(x==moku)return 1;
	if(vis[x])return 0;
	vis[x]=1;
	rep(y,n){
		if(edge[x][y]!='|'){
			if(dfs(y,moku))return 1;
		}
	}
	return 0;
}
void solve(){
	rep(i,X){
		rep(j,X)edge[i][j]='|';
	}
	while(m--){
		ll a,b;
		string str; 
		cin>>a>>b>>str;
		for(int i=0;i<str.size()-1;i++){
			chmin(edge[a][n],str[i]);
			a=n;
			n++;
		}
		chmin(edge[a][b],str.back());
	}
	bool ava[X];
	rep(i,n){
		rep(j,n)vis[j]=0;
		ava[i]=dfs(i,t);
	}
	if(ava[s]==0){
		cout<<"NO"<<endl;
		return;
	}
	rep(i,n)rep(j,n){
		if(ava[i]==0||ava[j]==0){
			edge[i][j]='|';
		}
	}
	char mis[X];
	vector<ll> to[X];
	rep(i,X)to[i].clear();
	rep(i,n){
		char mi='|';
		rep(j,n){
			chmin(mi,edge[i][j]);
		}
		rep(j,n)if(edge[i][j]!=mi){
			edge[i][j]='|';
		}
		mis[i]=mi;
		rep(j,n)if(edge[i][j]==mi){
			to[i].push_back(j);
		}
	}
	string ans="";
	bool stay[X],cop[X];
	rep(i,n)stay[i]=0; stay[s]=1;
	rep(u,X){
		if(stay[t]==1){
			cout<<ans<<endl;
			return;
		}
		char mi='|';
		rep(i,n)if(stay[i])chmin(mi,mis[i]);
		ans+=mi;
		rep(i,n)cop[i]=0;
		if(mi!='|'){
			rep(i,n)if(stay[i]&&mis[i]==mi){
				for(auto j:to[i])cop[j]=1;
			}
			rep(i,n)stay[i]=cop[i];
		}
	}
	cout<<"NO"<<endl;
}
int main(){
	while(1){
		cin>>n>>m>>s>>t;
		if(n==0)break;
		solve();
	}
}




Measured memory_bytes: 11384
/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/
#include<bits/stdc++.h>
#define mod 1000000007
#define modc 998244353
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define deb(x) cout << #x << " " << x << endl;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
using namespace std;
void solve()
{
	int n;
	cin >> n;
	ll sum =0;
	for(int i=1;i<=n;i++)
	{
		if(i%3 == 0 || i%5 == 0)
		{
		}
		else
			sum+=i;
	}
	cout << sum << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
		solve();
}


Measured memory_bytes: 3612
#include<stdio.h>

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

   scanf("%d", &a);
   scanf("%d", &b);
   scanf("%d", &c);

   if (a < b && b < c) {
      printf("Yes\n");
   } else {
      printf("No\n");
   }

   return 0;
}


Measured memory_bytes: 2140
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

string s,t;
pair<Pii,pair<ll,char> > dp[3010][3010];
string ans;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>s>>t;
  repeat(i,s.length()){
    dp[i][0].second.second = '!';
  }
  repeat(j,t.length()){
    dp[0][j].second.second = '!';
  }
  repeat(i,s.length()){
    repeat(j,t.length()){
      dp[i+1][j+1] = dp[i][j];
      if(s[i]==t[j]){
        dp[i+1][j+1].second.first++;
        dp[i+1][j+1].second.second = s[i];
        dp[i+1][j+1].first = make_pair(i,j);
      }
      if(dp[i+1][j+1].second.first<dp[i][j+1].second.first){
        dp[i+1][j+1] = dp[i][j+1];
      }
      if(dp[i+1][j+1].second.first<dp[i+1][j].second.first){
        dp[i+1][j+1] = dp[i+1][j];
      }
    }
  }
  int i=s.length(),j=t.length();
  while(i>0&&j>0){
    if(dp[i][j].second.second != '!')ans = dp[i][j].second.second + ans;
    tie(i,j) = dp[i][j].first;
  }
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 211968
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

from itertools import product
import numpy as np

INF = 1001001001
ans = INF

for i in product(range(2), repeat=n): # product(range(2),n)でn桁のbit全探索が可能
    tmp_price = 0
    tmp_und = np.zeros((m, ))
    for j in range(n):
        if i[j]:
            c, *a = ca[j]
            # Pythonでは、タプルやリストの要素を展開して複数の変数に代入できる。アンパック代入などと呼ばれる
            # 変数の数が要素の数よりも少ない場合、変数名にアスタリスク*をつけると、要素がリストとしてまとめて代入される
            tmp_price += c
            tmp_und += np.array(a, dtype=np.int64)
    tmp_und = tmp_und.tolist()
    if all(tmp_und_ele >= x for tmp_und_ele in tmp_und):
        ans = min(ans, tmp_price)

print(ans if ans != INF else -1)

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

class Cube{
public:
    int face[6];

    Cube(){}

    void roll(char direction) {
        if (direction == 'N') {
            int t = face[0];
            face[0] = face[1];
            face[1] = face[5];
            face[5] = face[4];
            face[4] = t;
        } else if (direction == 'S') {
            int t = face[0];
            face[0] = face[4];
            face[4] = face[5];
            face[5] = face[1];
            face[1] = t;
        } else if (direction == 'E') {
            int t = face[0];
            face[0] = face[3];
            face[3] = face[5];
            face[5] = face[2];
            face[2] = t;
        } else if (direction == 'W') {
            int t = face[0];
            face[0] = face[2];
            face[2] = face[5];
            face[5] = face[3];
            face[3] = t;
        }
    }
};

int main() {
    string command;

    Cube c;

    for (int i = 0; i < 6; i++) cin >> c.face[i];

    cin >> command;

    for (int i = 0; i < command.size(); i++) {
        c.roll(command[i]);
    }

    cout << c.face[0] << endl;
}


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

int main(){

    int N;
    double N2;
    int K;

    double p = 0;

    scanf("%d", &N);
    scanf("%d", &K);

    N2 = N;

    int x[N];

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

        int a = n;

        int y = 0;

        while(a<K){

            a = 2 * a;

            y += 1;
        }

        x[n - 1] = y;
    }

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

        p += (1/N2)*(pow(0.5 , x[i]));
    }

    printf("%.12f", p);

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>

using namespace std;

int main() {

	int N, L;
	string S[105];

	cin >> N >> L;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}

	sort(S,S+N);

	for (int i = 0; i < N; i++) {
		cout << S[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
//1~n個のノードのダイクストラ
//こっちの方が速い
long long inf=100000000000000007;
class Edge{
public:
//int s;
int t;
long long len;
};
class Node{
    public:
    int num;//node番号
    long long dist;//startからの距離
    vector<Edge> edge;//自分から生えている辺
    bool comp;//dijkstra中で到達しているかどうか
    void in_edge(Edge &edge_in){
        edge.push_back(edge_in);
    }  
};
bool operator >(const Node& a,const Node &r){
        return a.dist > r.dist;
    }
void dijkstra(vector<Node> &node,int s,int n){
    //n個のノードでできたグラフのsからtまでの最短距離を計算する
    //この時各要素のdistの値はsからの最短距離となる
    for(int i=1;i<=n;i++){
        //初期化
        node[i].dist=inf;
        node[i].num=i;
        node[i].comp=true;
    }
    node[s].dist=0;
    priority_queue<Node,vector<Node>,greater<Node>> que;
    que.push(node[s]);
    while(!que.empty()){
        Node buf;
        buf=que.top();//
        que.pop();
        int k=buf.num;
        if(node[k].comp){
            node[k].comp=false;
            int edge_num=buf.edge.size();
            for(int i=0;i<edge_num;i++){
                int buf_t=node[k].edge[i].t;
                int buf_len=node[k].edge[i].len;
                if(node[buf_t].dist>node[k].dist+buf_len){
                node[buf_t].dist=node[k].dist+buf_len;
                que.push(node[buf_t]);
                }
            }
        }
    }
}
int main(){
    int n,x,y;//n:node_num,s:start_node,t:goal_node,m:edge_num
    cin>>n>>x>>y;
    vector<Node> node(n+1);
    for(int i=1;i<n;i++){
        Edge pri;
        pri.t=i+1;
        pri.len=1;
        node[i].in_edge(pri);
        pri.t=i;
        node[i+1].in_edge(pri);
    }
    Edge input;
    input.t=y;input.len=1;
    node[x].in_edge(input);
    input.t=x;
    node[y].in_edge(input);
    vector<int> dist(n,0);
    for(int i=1;i<=n;i++){
      dijkstra(node,i,n);
      for(int j=1;j<=n;j++){
        dist[node[j].dist]++;
      }
    }
    for(int i=1;i<=n-1;i++){
      cout<<dist[i]/2<<"\n";
    }
    cout<<flush;
    return 0;
}

Measured memory_bytes: 512
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1276

#include <iostream>
#include <cmath>
using namespace std;

bool isPrime(int num){
  if(num<=3) return true;

  for(int i=2;i<=(int)sqrt(num);i++){
    if(num%i==0) return false;
  }

  return true;
}

int main(){
  int k;
  while(cin>>k&&k){
    if(isPrime(k)){
      cout << 0 << endl;
      continue;
    }

    int min_prime, max_prime;
    for(int i=k-1;i>=0;i--){
      if(isPrime(i)){
        min_prime = i;
        break;
      }
    }

    for(int i=k+1;i<=1299709;i++){
      if(isPrime(i)){
        max_prime = i;
        break;
      }
    }

    cout << max_prime - min_prime << endl;
  }

  return 0;
}

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

#define LL long long

#define FOR(INDEX, START, END) for (int INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (int INDEX = 0; INDEX < (COUNT); ++INDEX)

bool isTarget(int value) {
    int count = 0;
    for (int i = 1; i <= value / 2; ++i)
    {
        if (value % i == 0) {
            //cout << i << endl;
            count++;
        }
    }
    
    if (count == 8 - 1) {       // その値自身も含むので１個減らし
        //cout << value << endl;
        return true;
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    
    int count = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (i % 2 == 0) {
            continue;
        }
        if (isTarget(i))
        {
            count++;
        }
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a > 0){
            System.out.println("Positive");
        }else if(a <= 0 && b >= 0){
            System.out.println("Zero");
        }else{
            int c = Math.abs(a-b);
            if(c % 2 != 0){
                System.out.println("Positive");
            }else{
                System.out.println("Negative");
            }
        }
    }
}


Measured memory_bytes: 22228
n = int(input())
w = list(map(int,input().split()))
s = sum(w)

c = 0
prev_d = float('inf')
for x in w:
    c += x
    dis = abs((s - c) - c)
    if c >= s / 2:
        print(min(dis,prev_d))
        exit()
    prev_d = dis



Measured memory_bytes: 9144
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main()
    {
        var sc = new Scanner();
        int K = sc.IntArray(10)
            .OrderByDescending(x => x)
            .Take(3)
            .Sum();

        int W = sc.IntArray(10)
            .OrderByDescending(x => x)
            .Take(3)
            .Sum();

        Console.WriteLine(K + " " + W);

        Console.ReadKey();
    }
}

static class Extensions
{
    public static IEnumerable<T> Output<T>(this IEnumerable<T> source)
    {
        foreach (var item in source)
        {
            Console.WriteLine(item);
        }
        return source;
    }

    public static T Print<T>(this T obj)
    {
        Console.WriteLine(obj);
        return obj;
    }
}

public class Scanner
{
    string[] buffer = new string[0];
    int index = 0;
    public char[] SplitChars { get; set; }
    public string String()
    {
        if (index < buffer.Length) return buffer[index++];
        string line = "";
        while (line == "") line = Console.ReadLine();
        if (line == null) return null;
        buffer = line.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries);
        index = 0;
        return buffer[index++];
    }
    public string[] StringArray(int count) { return NextArray(count, x => x); }
    public void Skip(int count) { for (int i = 0; i < count; i++) String(); }
    public T Next<T>(Func<string, T> parser) { return parser(String()); }
    public T[] NextArray<T>(int count, Func<string, T> parser)
    {
        var arr = new T[count];
        for (int i = 0; i < count; i++) arr[i] = Next(parser);
        return arr;
    }
    public int Int() { return Next(int.Parse); }
    public int[] IntArray(int count) { return NextArray(count, int.Parse); }
    public double Double() { return Next(double.Parse); }
    public double[] DoubleArray(int count) { return NextArray(count, double.Parse); }
}

Measured memory_bytes: 10068
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])

if a+b+c+d == 7:
	print(a, end='')
	print('+', end='')
	print(b, end='')
	print('+', end='')
	print(c, end='')
	print('+', end='')
	print(d, end='')
	print('=7')
    
elif a+b+c-d == 7:
	print(a, end='')
	print('+', end='')
	print(b, end='')
	print('+', end='')
	print(c, end='')
	print('-', end='')
	print(d, end='')
	print('=7')
    
elif a+b-c+d == 7:
	print(a, end='')
	print('+', end='')
	print(b, end='')
	print('-', end='')
	print(c, end='')
	print('+', end='')
	print(d, end='')
	print('=7')
    
elif a-b+c+d == 7:
	print(a, end='')
	print('-', end='')
	print(b, end='')
	print('+', end='')
	print(c, end='')
	print('+', end='')
	print(d, end='')
	print('=7')
    
elif a+b-c-d == 7:
	print(a, end='')
	print('+', end='')
	print(b, end='')
	print('-', end='')
	print(c, end='')
	print('-', end='')
	print(d, end='')
	print('=7')
    
elif a-b-c+d == 7:
	print(a, end='')
	print('-', end='')
	print(b, end='')
	print('-', end='')
	print(c, end='')
	print('+', end='')
	print(d, end='')
	print('=7')
    
elif a-b+c-d == 7:
	print(a, end='')
	print('-', end='')
	print(b, end='')
	print('+', end='')
	print(c, end='')
	print('-', end='')
	print(d, end='')
	print('=7')
    
elif a-b-c-d == 7:
	print(a, end='')
	print('-', end='')
	print(b, end='')
	print('-', end='')
	print(c, end='')
	print('-', end='')
	print(d, end='')
	print('=7')

Measured memory_bytes: 3192
package main

import "fmt"

func main() {
	var x1, y1, x2, y2 int
	fmt.Scan(&x1, &y1, &x2, &y2)
	vx, vy := x2-x1, y2-y1
	x3, y3 := x2-vy, y2+vx
	x4, y4 := x3-vx, y3-vy
	fmt.Printf("%d %d %d %d\n", x3, y3, x4, y4)
}


Measured memory_bytes: 512
#include<cstdio>
#define N 10000
#define NIL -1

struct Node {int p,l,r;};

Node TW[N];
int n, DT[N],HG[N];

void setDepth(int u,int p){
    if (u == NIL)return;
    DT[u] = p;
    setDepth(TW[u].r,p+1);
    setDepth(TW[u].l,p+1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if(TW[u].l != NIL)h1=setHeight(TW[u].l)+1;
    if(TW[u].r != NIL)h2=setHeight(TW[u].r)+1;
    return HG[u] = (h1>h2?h1:h2);
}

int getSibling(int u){
    if (TW[u].p == NIL) return NIL;
    if(TW[TW[u].p].l != u && TW[TW[u].p].l != NIL)return TW[TW[u].p].l;
    if(TW[TW[u].p].r != u && TW[TW[u].p].r != NIL)return TW[TW[u].p].r;
    return NIL;
}

void print(int u){
    printf("node %d: ", u);
    printf("parent = %d, ", TW[u].p);
    printf("sibling = %d, ",getSibling(u));
    int deg = 0;
    if(TW[u].l != NIL)deg++;
    if(TW[u].r != NIL)deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", DT[u]);
    printf("height = %d, ", HG[u]);

    if (TW[u].p == NIL){
     printf("root\n");
    }
    else if (TW[u].l == NIL && TW[u].r == NIL){
     printf("leaf\n");
    }
    else{
     printf("internal node\n");
    }
}

int main(){
    int v,l,r,root=0;
    scanf("%d" , &n);
    for(int i=0;i<n;i++)TW[i].p = NIL;

    for(int i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        TW[v].l =l;
        TW[v].r =r;
        if (l != NIL) TW[l].p =v;
        if (r != NIL) TW[r].p =v;
    }

    for(int i=0;i<n;i++){
        if(TW[i].p == NIL)root=i;  
    }

    setDepth(root,0);
    setHeight(root);

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

    return 0;
}



Measured memory_bytes: 2768
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static readonly int[] dy = { -1, 1, 0, 0 };
    static readonly int[] dx = { 0, 0, -1, 1 };

    static void Main(string[] args)
    {
        while (true)
        {
            var input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int W = input[0], H = input[1];
            if (W == 0 && H == 0) break;
            int N = int.Parse(Console.ReadLine());
            int[][] rect = Enumerable.Range(0, N).Select(i => Array.ConvertAll(Console.ReadLine().Split(), int.Parse)).ToArray();
            var hashX = new HashSet<int>();
            var hashY = new HashSet<int>();

            Action<int, int, HashSet<int>> Add = (pos, max, hash) =>
            {
                if (pos - 1 >= 0) hash.Add(pos - 1);
                hash.Add(pos);
                if (pos + 1 < max) hash.Add(pos + 1);
            };

            foreach (int[] a in rect)
            {
                Add(a[0], W, hashX); Add(a[2] - 1, W, hashX);
                Add(a[1], H, hashY); Add(a[3] - 1, H, hashY);
            }
            var xs = hashX.OrderBy(x => x).ToList();
            var ys = hashY.OrderBy(y => y).ToList();
            W = xs.Count;
            H = ys.Count;
            bool[][] board = Enumerable.Range(0, H).Select(i => new bool[W]).ToArray();
            foreach (int[] a in rect)
            {
                int x1 = xs.BinarySearch(a[0]), x2 = xs.BinarySearch(a[2] - 1);
                int y1 = ys.BinarySearch(a[1]), y2 = ys.BinarySearch(a[3] - 1);
                for (int y = y1; y <= y2; y++)
                    for (int x = x1; x <= x2; x++)
                        board[y][x] = true;
            }
            int ans = 0;
            for (int sy = 0; sy < H; sy++)
                for (int sx = 0; sx < W; sx++)
                    if (!board[sy][sx])
                    {
                        ans++;
                        board[sy][sx] = true;
                        Queue<int> que = new Queue<int>();
                        que.Enqueue(sy); que.Enqueue(sx);

                        while (que.Count > 0)
                        {
                            int y = que.Dequeue(), x = que.Dequeue();
                            for (int d = 0; d < 4; d++)
                            {
                                int ny = y + dy[d], nx = x + dx[d];
                                if (ny >= 0 && ny < H && nx >= 0 && nx < W && !board[ny][nx])
                                {
                                    board[ny][nx] = true;
                                    que.Enqueue(ny); que.Enqueue(nx);
                                }
                            }
                        }
                    }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 25184
import sys
input = sys.stdin.readline
 
N=int(input())
A=list(map(int,input().split()))
 
XOR=0
for a in A:
    XOR^=a
 
for i in range(N):
    A[i] &=~XOR
    
USED=[0]*N
 
for bi in range(60,-1,-1):
    for i in range(N):
        if USED[i]==0 and A[i] & (1<<bi)!=0:
            USED[i]=1
            useind=i
            break
    else:
        continue
 
    for i in range(N):
        if i==useind:
            continue
        if A[i] & (1<<bi)!=0:
            A[i]^=A[useind]
            
ANS=0
for a in A:
    ANS^=a
 
print(2*ANS+XOR)

Measured memory_bytes: 69920
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <functional>
#include <array>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long int ull;
typedef vector<int> vi;
#define rep(i,a,n) for(int i = (a);i < (n);i++)
#define per(i,a,n) for(int i = (a);i > (n);i--)
#define lep(i,a,n) for(int i = (a);i <= (n);i++)
#define pel(i,a,n) for(int i = (a);i >= (n);i--)
#define all(v) (v).begin(),(v).end()
#define clr(a,b) memset((a),(b),sizeof(a))
#define sz size()
#define pb push_back
#define print(x) cout << x << endl
#define INF 1e+9+7
int n,m;
string s,t;

int main(){
  cin >> s;
  t = "No";
  rep(i,0,s.sz){
    if(s[i] == 'A' && s[i+1] == 'C'){
      t = "Yes";
    }
  }
  print(t);
  return 0;
}

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

class Main {

    int CalcID(int r, int t) { return r + 5*t; }
    
    void solve(){

	Scanner sc = new Scanner( System.in );
	int n = sc.nextInt();
	for ( int i=0; i<n; ++i ) {

	    int r = sc.nextInt();
	    int t = sc.nextInt();

	    boolean onR = r%100 == 0;
	    boolean onT = t%30 == 0;
	    r /= 100;
	    t /= 30;

	    if ( onR && onT ) System.out.println(CalcID(r, t));
	    else if ( onR ) System.out.println(CalcID(r, t) + " " + CalcID(r, t+1));
	    else if ( onT ) System.out.println(CalcID(r, t) + " " + CalcID(r+1, t));
	    else System.out.println(CalcID(r, t) + " " + CalcID(r+1, t) + " "
				    + CalcID(r, t+1) + " " + CalcID(r+1, t+1));
	}
    }

    public static void main( String[] a ) {new Main().solve(); }
}



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

int main(){
  char c;
  int num[26] = {};

  while(cin>>c){
    if('a' <= c && c <= 'z'){
      num[c-'a']++;
    }else if('A' <= c && c <= 'Z'){
      num[c-'A']++;
    }
  }

  for(int i = 0; i < 26; i++){
    printf("%c : %d\n",i+'a',num[i]);
  }
}

Measured memory_bytes: 3184
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    vector<int>v(n);
    int gu=0,ki=0;
    rep(i,n){
        int hoge; cin>>hoge;
        if(hoge%2)ki++;
        else gu++;
    }
    gu+=(ki/2);
    ki%=2;
    if(ki&&gu!=0)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}


Measured memory_bytes: 640
N = int(input())

def dfs(s):
    if int(s) > N:
        # print(ret)
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        # print(s+c)
        ret += dfs(s + c)
    # print(ret)
    return ret

print(dfs('0'))

Measured memory_bytes: 3068
#include <bitset>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>

std::vector<std::vector<int>> getArray(int n, const std::string &org) {
  std::vector<std::vector<int>> results(n);
  for (auto &row : results) {
    row.resize(n, 0);
  }
  std::istringstream iss(org);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      iss >> results[i][j];
    }
  }
  /*
  for (const auto &row : results) {
    for (const auto n : row) {
      std::cout <<n << " ";
    }
    std::cout << std::endl;
  }
  */
  return results;
}

int64_t getPairsNum(const std::vector<std::vector<int>> &possibles) {
  const int n = static_cast<int>(possibles.size());
  std::vector<std::vector<int64_t>> dp(n);
  for (auto &row : dp) {
    row.resize(static_cast<int>(std::pow(2, n)), 0);
  }
  std::vector<std::bitset<21>> pre_bits(n);
  for (int i = 0; i < n; ++i) {
    pre_bits[i] = static_cast<unsigned long long>(1LL << i);
  }

  for (int j = 0; j < n; ++j) {
    if (possibles[0][j]) {
      dp[0][1LL << j] = 1;
    }
  }
  /*
  std::cout << "i=" << 0 << std::endl;
  for (int n = 0; n < static_cast<int>(dp[0].size()); ++n) {
    std::cout << std::bitset<21>(static_cast<unsigned long long>(n)) << ": " <<
  dp[0][n] << std::endl;
  }
    std::cout << std::endl;
    */
  for (int i = 1; i < n; ++i) {
    const auto &prev = dp[i - 1];
    auto &current = dp[i];
    for (int k = 0; k < static_cast<int>(prev.size()); ++k) {
      if (!prev[k]) continue;
      std::bitset<21> bits(static_cast<unsigned long long>(k));
      const auto count = prev[k];
      for (int j = 0; j < n; ++j) {
        //        std::cout << bits << ", " << pre_bits[j] << ", " << bits[j] <<
        //        "," << possibles[i][j] << std::endl;
        if (!bits[j] && possibles[i][j]) {
          current[(bits | pre_bits[j]).to_ulong()] += count;
        }
      }
    }
    for (auto &count : current) {
      count %= 1000000007LL;
    }
    /*
    std::cout << "i=" << i << std::endl;
    for (int n = 0; n < static_cast<int>(dp[i].size()); ++n) {
      std::cout << std::bitset<21>(static_cast<unsigned long long>(n)) << ": "
    << dp[i][n] << std::endl;
    }
    std::cout << std::endl;
    */
  }
  return dp.back().back();
}

int main() {
  int n;
  std::cin >> n;
  std::vector<std::vector<int>> results(n);
  for (auto &row : results) {
    row.resize(n, 0);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      std::cin >> results[i][j];
    }
  }
  std::cout << getPairsNum(results) << std::endl;
  return 0;
}


Measured memory_bytes: 344448
A, B, C, X, Y = [int(x) for x in input().split()]

def main():
    base = min(X, Y)
    rest = max(X, Y) - base
    is_x = X > Y

    base_price = min(A + B, 2 * C) * base
    rest_price = min((A if is_x else B), 2 * C) * rest

    print(base_price + rest_price)

if __name__ == "__main__":
    main()

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

int main()
{
    long long a[200005];
    long long i=0,sum=0,m,n;
    scanf("%lld",&n);
    for(m=0;m<n;m++)
        scanf("%lld",&a[m]);
    for(m=0;m<n-1;m++)
    {
        if(a[m+1]>=a[m])
            continue;
        else
        {
            sum=sum+(a[m]-a[m+1]);
            a[m+1]=a[m];
        }
    }
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 3268
#include <iostream>
using namespace std;
int main(void){
    long long N,i,a;
    cin>>N;
    for(i=1;i*i<N+1;i++){
        if(N%i==0){
            a=i;
        }
    }
    a=a+N/a-2;
    cout<<a<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

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

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  string S;
  cin >> N >> S;

  int x = 0;
  int mx = 0;
  rep(i,N){
    if (S[i] == 'I'){
      x += 1;
    }else{
      x -= 1;
    }
    mx = max(mx, x);
  }
  cout << mx << endl;
}


Measured memory_bytes: 3608
S = input()
# tempS= S
temp = S[2:-1]
count_c=temp.count("C")
if S[0] == "A" and count_c == 1:
    tempS=list(S)
    del tempS[0]
    del tempS[tempS.index("C")]
    tempS = "".join(tempS)
    if tempS.islower():
        print("AC")
    else:
        print("WA")
    # print(tempS)
    # print(count_c)
else:
    print("WA")
    # tempS = S[1:]
    # tempS = tempS.strip("C")
    # tempS = tempS.lstrip("A")
# print(type(tempS))
# for i in range

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

using namespace std;

char ans[600000];
int start = 200000;
int n = 0;

int main(void) {
    string s;
    string qs;
    int qn;
    cin >> s;
    cin >> qn;
    getline(cin, qs);

    for(int i = 0; i < s.length(); i++) {
        ans[start + n] = s[i];
        n++;
    }

    bool mode = true;
    for(int i = 0; i < qn; i++) {
        getline(cin, qs);

        if(qs[0] == '1') {
            mode = !mode;
        } else {
            if(qs[2] == '1') {
                if(mode) {
                    --start;
                    ans[start] = qs[4];
                } else {
                    ans[start + n] = qs[4];
                }
            } else {
                if(mode) {
                    ans[start + n] = qs[4];
                } else {
                    --start;
                    ans[start] = qs[4];
                }
            }
            ++n;
        }
    }

    ans[start + n] = '\0';
    string anss(&ans[start]);    
    if(!mode) {
        reverse(anss.begin(), anss.end());
    }

    cout << anss << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

const int INF = INT_MAX / 2;

// {h, w}
const vector<pair<int, int>> diff_for_dir = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};

vector<vector<char>> board;

vector<vector<int>> dp;

void solve(const int start_h, const int start_w, const int H, const int W, const int K) {
    queue<pair<int, int>> que;

    dp[start_h][start_w] = 0;
    que.push({start_h, start_w});

    while (!que.empty()) {
        const int cur_h = que.front().first;
        const int cur_w = que.front().second;
        const int cur_dist = dp[cur_h][cur_w];
        que.pop();

        for (int dir = 0; dir < 4; dir++) {
            int next_h = cur_h;
            int next_w = cur_w;
            int dist = cur_dist + 1;
            for (int step = 1; step <= K; step++) {
                next_h += diff_for_dir[dir].first;
                next_w += diff_for_dir[dir].second;
                if (next_h < 1 || next_h > H || next_w < 1 || next_w > W
                        || board[next_h][next_w] != '.' || dp[next_h][next_w] < dist) {
                    break;
                }

                // dp[next_h][next_w] < dist is true if it reaches here, but it sometimes have to avoid recalculation.
                // e.g. we are at the posion specified by '*' (assume that the position is (i, j)) and going up,
                // we don't have to recalculate (i - 1, j), but we have to go to (i - 2, j) and update it to 3 if K >= 2.
                // INF INF INF
                // 3   3   3 
                // 2   3*  INF
                if (dist < dp[next_h][next_w]) {
                    dp[next_h][next_w] = dist;
                    que.push({next_h, next_w});
                }
            }
        }
    }
}

// solution explaind as the 2nd soltuion in the video
int main(void) {
    int H, W, K;
    cin >> H >> W >> K;
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    board.resize(H + 2, vector<char>(W + 2, '@'));
    for (int h = 1; h <= H; h++) {
        for (int w = 1; w <= W; w++) {
            char c;
            cin >> c;
            if (c == '.') {
                board[h][w] = '.';
            }
        }
    }

    dp.resize(H + 2, vector<int>(W + 2, INF));

    solve(x1, y1, H, W, K);

    int ans = dp[x2][y2];
    if (ans == INF) {
        ans = -1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 21828
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin >> n;
  ll k;cin >> k;//必殺
  ll h[n];
  for(int i = 0;i < n;i++) cin >> h[i];
  sort(h,h+n);
  reverse(h,h+n);
  ll ans = 0;
  for(int i = 0;i < n;i++){
    if(i < k){
      continue;
    }
    ans += h[i];
  }
  cout << ans << endl;
}

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

int main()
{
    int N, X, T;
    cin >> N >> X >> T;
    if(N%(X) == 0) {
        cout << (N/(X))*T << endl;
    } else {
        cout << ((N/(X))+1)*T << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
import math


def solve(N, A, B, Hs):
    k_min = 1
    k_max = 10 ** 9
    d = A - B
    # print(N, ",", A, ",", B, ",", Hs)

    def find(k):
        # print("find %d" % k)
        kc = sum([max(math.ceil((h - B * k) / d), 0) for h in Hs])
        return kc <= k

    def bin_search(k_min, k_max):
        if k_max - k_min <= 1:
            if find(k_min):
                return k_min
            return k_max
        # print("find %d, %d" % (k_min, k_max))
        k_mid = (k_max + k_min) // 2
        m = find(k_mid)
        if m:
            return bin_search(k_min, k_mid)
        else:
            return bin_search(k_mid, k_max)

    return bin_search(k_min, k_max)

if __name__ == "__main__":
    N, A, B = tuple(map(int, input().split(" ")))
    Hs = []
    for _ in range(N):
        Hs.append(int(input()))
    print(solve(N, A, B, Hs))


Measured memory_bytes: 11076
import Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  [r,c] <- readInts
  ary <- listArray ((1,1),(r,c)) . join <$> replicateM r readInts
  forM_ [1..r] $ \i -> do
    forM_ [1..c] $ \j -> do
      printf "%d " $ ary ! (i, j)
    printf "%d\n" $ sum [ ary ! (i, j) | j <- [1..c] ]
  forM_ [1..c] $ \j -> do
    printf "%d " $ sum [ ary ! (i, j) | i <- [1..r] ]
  printf "%d\n" $ sum [ ary ! (i, j) | i <- [1..r], j <- [1..c] ]



Measured memory_bytes: 7392
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  for(int i=0; i<W+2; i++)
    cout << '#';
  cout << endl;
  for(int i=0; i<H; i++){
    string a;
    cin >> a;
    cout << '#' << a << '#' << endl;
  }
  for(int i=0; i<W+2; i++)
    cout << '#';
  cout << endl;
}


Measured memory_bytes: 256
# Enter your code here. Read input from STDIN. Print output to STDOUT
def parse(A):
    R=len(A)
    C=len(A[0])
    grid=[[1 for j in xrange(C)]  for i in xrange(R)]
    for i in xrange(R):
        for j in xrange(C):
            if A[i][j]=='.':
                grid[i][j]=0
                
    return grid

def find(grid):
    black={}
    R=len(grid)
    C=len(grid[0])
    new=[]
    for i in xrange(R):
        for j in xrange(C):
            if grid[i][j]==1:
                black[(i,j)]=0
                new+=[(i,j)]
    time=0        
    
    while len(black)<R*C:
        
        time+=1
        new_black=set([])
        
        for X in new:
            x,y=X
            check=[(x-1,y),(x+1,y),(x,y-1),(x,y+1)]
            for Y in check:
                y1,y2=Y[0],Y[1]
                if y1>R-1 or y1<0 or y2>C-1 or y2<0:
                    continue
                if grid[y1][y2]==0:
                    new_black.add((y1,y2))
                    
                    black[(y1,y2)]=1
                else:
                    continue
        for X in new_black:
            grid[X[0]][X[1]]=1
        new=[]
        new=new_black
        #print(new_black)
    return time    

H,W=list(map(int,raw_input().strip().split(' ')))
A=[]
for _ in xrange(H):
    A+=[raw_input()]
grid=parse(A)
print(find(grid))
    
                    
                                
                    
                
            
            

        



Measured memory_bytes: 235820
def solve(n, x, a):
	costs = []
	cost_min = 0
	for k in range(n):
		if k == 0:
			costs = a.copy()
		else:
			for i in range(n):
				costs[i] = min(costs[i], a[(i-k)%n])
		cost_k = sum(costs) + k*x
		if k == 0:
			cost_min = cost_k
		else:
			cost_min = min(cost_min, cost_k)
			if cost_min != cost_k:
				break
		if cost_min < (k+1) *x:
			break

	return cost_min
n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
print(solve(n,x,a))




Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = new String[3];
        for (int i = 0; i < s.length; i++) {
            s[i] = sc.next().substring(0, 1).toUpperCase();
        }
        for (int i = 0; i < s.length; i++) {
            System.out.print(s[i]);
        }
    }
}

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

public class Main {
	
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int alphabets[] = new int[26];
		char arr[] = in.readString().toCharArray();
		for(int i = 0; i<arr.length; i++) {
			alphabets[arr[i]-'a'] = 1;
		}
		for(int i = 0; i<alphabets.length; i++) {
			if(alphabets[i] != 1) {
				System.out.println((char)(97 + i));
				return; 
			}
		}
		System.out.println("None");
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
int main() {
    int a,b,c,d,e,f;
    int p=0,q=0;
    double g=0;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    for(int h=0;h*a*100<=f;h++) {
        for(int i=0;i*b*100+h*a*100<=f;i++) {
            for(int j=0;i*b*100+h*a*100+j*c<=f;j++) {
                for(int k=0;i*b*100+h*a*100+j*c+k*d<=f;k++) {
                    int ans=h*a*100+i*b*100+j*c+k*d;
                    int cnt=j*c+k*d;
                    double m=(double)cnt*1.0/ans;
                    if(m<=(double)e*1.0/(100+e)) {
                        if(m>=g) {
                            p=ans;
                            q=cnt;
                            g=m;
                        }
                    }
                }
            }
        }
    }
    printf("%d %d\n",p,q);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 1;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans %= mod;
        ans *= power(i + 1, mod - 2);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll h,n;
    cin >> h >> n;
    vector<pair<ll, ll>> m(n);
    rep0(i, n){
        ll a,b;
        cin >> a >> b;
        m[i] = make_pair(a, b);
    }
    ll d[h + ll(1e4)];
    rep0(i, h + ll(1e4))d[i] = INF;
    d[0] = 0;
    rep0(i, h){
        rep0(j, n){
            if(i + m[j].first <= h + ll(1e4) && d[i] != INF)d[i + m[j].first] = min(d[i] + m[j].second,d[i + m[j].first]);
        }
    }
    ll ans = INF;
    nfor(i, h, h + ll(1e4))ans = min(ans,d[i]);
    pf(ans);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,m;
int nu[200200];
bool check(int x)
{
    int p=x*2;
    for(int i=1;i<=n-x;++i)if(nu[p+i]+nu[n*2-i+1]<m)return 1;
    return 0;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n*2;++i)scanf("%d",&nu[i]);
    sort(nu+1,nu+n*2+1);
    int l=0,r=n,mid;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(check(mid))l=mid+1;
        else r=mid-1;
    }
    int p=l*2;
//    cout<<"l: "<<l<<endl;
    int ans=0;
    for(int i=1;i<=l;++i)
        ans=max(ans,(nu[i]+nu[p-i+1])%m);
    for(int i=1;i<=n-l;++i)
        ans=max(ans,(nu[p+i]+nu[n*2-i+1])%m);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024