akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF = 0x1fffffffffffffff;
int main(){
	ll n,W;
	cin>>n>>W;
	vector<ll> w(n+1);
	vector<ll> v(n+1);
	for(ll i=1;i<n+1;i++)cin>>w[i]>>v[i];
	vector<vector<ll>> dp(W+1,vector<ll>(n+1,0));
	for(ll i=1;i<n+1;i++){
		for(ll j=0;j<W+1;j++){
			dp[j][i]=dp[j][i-1];
			if(j-w[i]+1>0){
				dp[j][i]=max(dp[j-w[i]][i-1]+v[i],dp[j][i]);
			}
		}
	}
  /*for(ll j=0;j<W+1;j++){
    for(ll i=0;i<n+1;i++){
      cout<<dp[j][i]<<" ";
    }
    cout<<endl;
  }*/
	cout<<dp[W][n]<<endl;
}

Measured memory_bytes: 82304
n,k,q = map(int,input().split())
count_dict = {s: 0 for s in range(1,n+1)}
for i in range(q):
    seikaisha = int(input())
    if seikaisha in count_dict:
        count_dict[seikaisha] +=1
    else:
        count_dict[seikaisha] = 0
count_dict_sorted = sorted(count_dict.items(), key=lambda x:x[0])
# print(type(count_dict_sorted))
# print(count_dict_sorted)
for i, j in count_dict_sorted:
    if k + j-q >0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 25192
import java.util.*;
public class Main{
	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	char[] c = sc.next().toCharArray();
      	int ans = 1;
      	for(int i=0;i<N-1;i++){
          if(c[i]!=c[i+1]){
            ans++;
          }
        }
        System.out.println(ans);
    }
}
      	

Measured memory_bytes: 26452
def SME(N):
    if len(N)==1:
        return N
    else:
        for i in range(len(N)):
            if N[i] in ["*", "+", "-", "/"]:
                i = int(i)
                a, b = N.pop(i-2), N.pop(i-2)
                c = N.pop(i-2)
                N.insert(i-2, str(float(eval(a+c+b))))
                return SME(N)

while 1:
    try:
        N = list(input().split())
        answer = SME(N)
        answer = float(answer[-1])
        print("{:.6f}".format(answer))
    except:
        break



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
signed main()
{
    int h1 , m1 , h2 , m2 , k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    
    h1 = h1 * 60 + m1;
    h2 = h2 * 60 + m2;
    
    cout << h2-h1 - k << endl;
    return(0);
}

Measured memory_bytes: 3636
io = STDIN
ab=Hash.new{|h,k|h[k]=[[],0]}
n,m=io.gets.split.map(&:to_i)
$h=io.gets.split.map(&:to_i)
def height(i)
  $h[i-1]
end
(1..n).each do |i|
  ab[i]=[[],0]
end
m.times do
  a,b=io.gets.split.map(&:to_i)
  ar,max=ab[a]
  ar << b
  ab[a]=[ar,[max,height(b)].max]
  ar,max=ab[b]
  ar << a
  ab[b]=[ar,[max,height(a)].max]
end
ans=0
ab.each do |k,v|
  ar,max=v
  ans+=1 if height(k)>max
end
puts ans


Measured memory_bytes: 34928
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;

struct Point {
  long long x;
  long long y;
  Point(long long x, long long y): x(x), y(y) {};
  bool operator <(const Point &r) {
    return atan2(static_cast<double>(y), static_cast<double>(x)) < atan2(static_cast<double>(r.y), static_cast<double>(r.x));
    /*
    if ((0*y-x*1 > 0) ^ (0*r.y-r.x*1 > 0)) {
      return x*r.y-r.x*y > 0;
    } else {
      return 0*y-x*1 > 0;
    }
    */
    /*
    if (x > 0) {
      if (r.x > 0) {
        return y*r.x < r.y*x;
      } else if (r.x == 0) {
        return r.y > 0;
      } else {
        return true;
      }
    } else if (x == 0) {
      if (r.x > 0) {
        return y < 0;
      } else if (r.x == 0) {
        return y < r.y;
      } else {
        return true;
      }
    } else {
      if (r.x > 0) {
        return false;
      } else if (r.x == 0) {
        return false;
      } else {
        return y*r.x > r.y*x;
      }
    }
    */
  }
};


void solve(long long N, std::vector<long long> x, std::vector<long long> y){
  vector<Point> p;
  for (int i = 0; i < N; i++) {
    p.push_back(Point(x[i], y[i]));
  }
  sort(p.begin(), p.end());
  double ans = 0;
  for (int i = 0; i < N; i++) {
    Point a = {0LL, 0LL};
    for (int j = 0; j < N; j++) {
      // if (p[i].x*p[(i+j)%N].y-p[i].y*p[(i+j)%N].x > 0 || (p[i].x*p[(i+j)%N].y-p[i].y*p[(i+j)%N].x == 0 || p[i].x*p[(i*j)%N].x >= 0)) {
        a.x += p[(i+j)%N].x;
        a.y += p[(i+j)%N].y;
        ans = max(ans, sqrt(static_cast<double>(a.x*a.x+a.y*a.y)));
      //} else {
        //break;
      //}
    }
  }
  std::cout << std::fixed << std::setprecision(12) << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> x(N);
  std::vector<long long> y(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&x[i]);
    scanf("%lld",&y[i]);
  }
  solve(N, std::move(x), std::move(y));
  return 0;
}


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

using namespace std;

struct st{
	int p;
	int num;

	bool operator<(const st &in) const{
		return num<in.num;
	};
};

int main(){

	int n;
	vector<st> v;

	cin>> n;
	v.resize(n);
	for(int i=0;i<n;i++){
		cin>> v[i].num;
		v[i].p=i+1;
	}

	sort(v.begin(), v.end());

	for(int i=0;i<n;i++) cout<< v[i].p << " ";

	cout<< endl;

}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a<=100&&a>=1&&b<=100&&b>=1&&c<=100&&c>=1)
    {
    if(a+b==c||a+c==b||b+c==a)
    {
        cout << "Yes";
    }
    else cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define mx(a) maxx=max(a,maxx)
int main(){
	int a,b,c,maxx=0;
	cin>>a>>b>>c;
	mx(10*a+b+c);
	mx(10*b+a+c);
	mx(10*c+a+b);
	cout<<maxx<<endl;
	return 0;
}

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

struct data
{
    int u,v,t;
};

int n;
data a[100005];

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i].t>>a[i].u>>a[i].v;
    int X=0,Y=0,time=0;
    for(int i=1;i<=n;i++)
    {
        if(abs(X-a[i].u)+abs(Y-a[i].v)>a[i].t-time)
        {
            cout<<"No";
            return 0;
        }
        if((abs(X-a[i].u)+abs(Y-a[i].v))%2!=(a[i].t-time)%2)
        {
            cout<<"No";
            return 0;
        }
        X=a[i].u;
        Y=a[i].v;
        time=a[i].t;
    }
    cout<<"Yes";
}


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

int main() {
  int A, B;
  cin >> A >> B;
  if (A==1 && B!=1) {
    cout << "Alice" << endl;
  } else if (B==1 && A!=1) {
    cout << "Bob" << endl;
  } else if (A==1 && B==1) {
    cout << "Draw" << endl;
  } else if (A>B) {
    cout << "Alice" << endl;
  } else if (A<B) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)

int main() {
	ll n, a, b; cin >> n >> a >> b;
	ll d = b - a;
	if (d & 1) {
		ll e = (b - (a + 1)) / 2 + a;
		ll f = (n - (a + (n - b + 1))) / 2 + (n-b+1);
		cout << min(e, f) << endl;
	}
	else {
		cout << (b - a) / 2 << endl;
	}

}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

X, Y = MAP()

print(X+Y//2)

Measured memory_bytes: 4016
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll N;

void func(){

	ll num1 = 4*2*N;
	ll num2 = 2*(4*N-4);
	ll num3 = 0;
	ll x;

	for(x = 1; x*x < N/2; x++){
		num3 += (N+2*x-1)/(2*x)-1;
	}
	num3 = 2*num3-(x-1)*(x-1);
	num3 *= 8;

	printf("%lld\n",num1+num2+num3);
}

int main(){

	while(true){
		scanf("%lld",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3144
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(a, b);
    int c = a + b;
    c %= 24;

    pri(c);

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i32 = input();
    let b: i32 = input();
    let c: i32 = input();
    println!("{}", std::cmp::max(0, c - (a - b)));
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 1005;
int N;

int getNodeNum(int i, int j) {
  if(i > j) swap(i,j);
  return i*N+j;
}

II getIndex(int nodeNum) {
  return II(nodeNum/N, nodeNum%N);
}

const int MAX_V = MAX_N*MAX_N ;
int V = MAX_N*MAX_N;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
int cmp[MAX_V];
vector<vector<int>> GG;

void add_edge(int from, int to) {
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v) {
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    if (!used[G[v][i]]) dfs(G[v][i]);
  }
  vs.push_back(v);
}

void rdfs(int v, int k) {
  used[v] = true;
  cmp[v] = k; GG[k].push_back(v);
  for (int i = 0; i < rG[v].size(); i++) {
    if(!used[rG[v][i]]) rdfs(rG[v][i], k);
  }
}

int scc() {
  memset(used, 0, sizeof(used));
  vs.clear();
  for (int v = 0; v < V; v++) {
    if (!used[v]) dfs(v);
  }
  memset(used, 0, sizeof(used));
  int k = 0;
  for(int i = vs.size()-1; 0 <= i; i--) {
    if (!used[vs[i]]) {
      GG.push_back(vector<int>());
      rdfs(vs[i], k++);
    }
  }

  return k;
}

int depth[MAX_N*MAX_N];
int inEdge[MAX_N*MAX_N];

void solve(int pos)
{
  if(used[pos]) return;
  used[pos] = true;
  for(int next : G[pos]) {
    inEdge[next]--;
    depth[next] = max(depth[next], depth[pos]+1);
    if(inEdge[next] == 0) solve(next);
  }
}

signed main()
{
  cin >> N;
  V = N*N;
  REP(n,N) {
    int pre = -1;
    REP(k,N-1) {
      int to; cin >> to; to--;
      if(pre == -1) pre = to;
      else {
        add_edge(getNodeNum(n, pre), getNodeNum(n, to));
        inEdge[getNodeNum(n, to)]++;
        pre = to;
      }
    }
  }

  scc();
  REP(n,GG.size()) {
    if(GG[n].size() != 1) {
      cout << -1 << endl;
      return 0;
    }
  }

  memset(used, 0, sizeof(used));
  REP(n,N*N) {
    if(inEdge[n] == 0 && !used[n]) {
      depth[n] = 1;
      solve(n);
    }
  }

  int ans = 0;
  REP(n,N*N) {
    ans = max(ans, depth[n]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 166880
import java.util.Scanner;

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

		int min = Integer.MAX_VALUE;
		for (int i = 0; i < S.length() - 2; i++) {
			int subS = Integer.parseInt(S.substring(i, i + 3));
			if (min > Math.abs(753 - subS))
				min = Math.abs(753 - subS);
		}

		System.out.println(min);

		sc.close();
	}
}

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

int main()
{
  int n;
  string s;

  cin >> n >> s;

  int len = s.size();
  int ans = 0;

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

    int l = str.size();
    for (int j = 1; j < l; j++){
      for (int k = 0; k < l; k++){
        int cnt = 0;
        int idx= 0;
        for (int N = k; N < l; N += j){
          if (str[N] == s[idx]){
            idx++;
            cnt++;
          } else {
            idx = cnt = 0;
            break;
          }

          if (cnt == len){
            ans++;
            goto next;
          }
        }
      }
    }
next:;
  }

  cout << ans << endl;
}

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

int dp[2][1 << 19];
char s[21][21];
int main() {
	int m, n; scanf("%d%d", &m, &n);
	int cnt = 1;
	rep(i, m)scanf("%s", s[i]);
	rep(i, m)rep(j, n) {
		if (s[i][j] == '?')cnt = (cnt * 3) % MOD;
	}
	int*now = dp[0], *nxt = dp[1];
	now[0] = 1;
	rep(i, m)rep(j, n) {
		fill(nxt, nxt + (1 << n - 1), 0);
		rep(k, 1 << n - 1) {
			if (now[k] == 0)continue;
			int a = k&~(1 << (j - 1));
			if (s[i][j] == 'J' || s[i][j] == '?') {
				if (j < n - 1)(nxt[a | 1 << j] += now[k]) %= MOD;
				else(nxt[a&~(1 << j)] += now[k]) %= MOD;
			}
			if (s[i][j] == 'O' || s[i][j] == '?')
				(nxt[k&~(1 << j)] += now[k]) %= MOD;
			if (s[i][j] == 'I' || s[i][j] == '?') {
				if (!(k >> j & 1))(nxt[a&~(1 << j)] += now[k]) %= MOD;
			}
		}
		swap(now, nxt);
	}
	rep(i, 1 << n - 1)cnt = (cnt + MOD - now[i]) % MOD;
	printf("%d\n", cnt);
}

Measured memory_bytes: 7240
#include<stdio.h>
#include<math.h>
 
#define PI 3.14159265359
 
int main() {
    int a, b, c;
    double s, l, h;
    scanf("%d %d %d", &a, &b, &c);
    h = sin(((double)c/180) * PI) * (double)b;
    s = (h * (double)a) / 2;
    l = hypot(h, (double)a - cos(((double)c/180) * PI) * (double)b) + (double)a + (double)b;
    printf("%f\n%f\n%f\n", s, l, h);
    return 0;
}


Measured memory_bytes: 2068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll X;
  cin>>X;
  ll num=X/100;
  ll num2=X%100;
  
  if(num2<=5*num&&num2>=0){
cout<<1<<endl;
  }
else{
cout<<0<<endl;
}
}



Measured memory_bytes: 384
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;

#[fastout]
fn main() {
    input! {
        ss: Chars,
        ts: Chars,
    }
    let ss_len = ss.len();
    let ts_len = ts.len();
    let mut ans = ts_len;

    for i in 0..=ss_len - ts_len {
        let count = ss[i..i + ts_len]
            .iter()
            .zip(ts.iter())
            .filter(|&(s, t)| s != t)
            .count();
        ans = ans.min(count)
    }
    println!("{}", ans);
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
// 2의 제곱수 판정
#define POW2(X) (X) == ((X)&(-(X)))

// 기본설정
typedef long long ll;
using namespace std;
int dirx[4] = {1, 0, -1, 0};
int diry[4] = {0, 1, 0, -1};

// 전역변수

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

	int a;
	cin >> a;
	cout << a + pow(a, 2) + pow(a, 3);

	return 0;
}

Measured memory_bytes: 4200
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: u32,
        a: u32,
        b: u32,
    }
    let mut ssum = 0;
    for j in 0..n+1 {
        let sum = (j.to_string()).chars().map(|c| c.to_digit(10).unwrap()).sum::<u32>();
        if sum >= a && sum <= b {
            ssum+=j;
        }
    }
    println!("{}", ssum);
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

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

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main() {
    int n, m;
    cin >> n >> m;
    vi a(n), b(n), c(m), d(m);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, m) cin >> c[i] >> d[i];

    rep(i, n) {
        int ans = 0;
        int mm = 1000000000;
        rep(j, m) {
            if(abs(a[i] - c[j]) + abs(b[i] - d[j]) < mm) {
                mm = abs(a[i] - c[j]) + abs(b[i] - d[j]);
                ans = j+1;
            }
        }
        cout << ans << endl;
    }

}

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

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define pll  pair<ll,ll>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1000000000+7;
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
ll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans.sz+1;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

void solve()
{
	string s;
	cin>>s;
	vll a(26,0);
	for(ll i=0;i<s.sz;i++)
		a[s[i]-'a']++;
		
	for(ll i=0;i<26;i++)
	{
		if(a[i]>=2)
		{
			cout<<"no";
			return;
		}
	}
	cout<<"yes";
}            
int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=1e5+5;
const int mod=1e9+7;

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	int n=nxi(),m=nxi(),r1=0,r2=0;
	for(int i=1,lst=nxi(); i<n; ++i){
		int cur=nxi();
		r1=(r1+(lint)(cur-lst)*i%mod*(n-i))%mod;
		lst=cur;
	}
	for(int i=1,lst=nxi(); i<m; ++i){
		int cur=nxi();
		r2=(r2+(lint)(cur-lst)*i%mod*(m-i))%mod;
		lst=cur;
	}
	printf("%lld\n",(lint)r1*r2%mod);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long f(long long x) {
    if (x % 4 == 0) return x;
    if (x % 4 == 1) return 1;
    if (x % 4 == 2) return x ^ 1;
    return 0;
}
int main()
{
    long long A, B; cin >> A >> B;
    cout << (f(B) ^ f(A-1)) << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::*;
use std::cmp::max;

fn main() {
    input! {
        n: usize,
        m: usize,
        k: i64,
        mut a: [i64; n],
        mut b: [i64; m],
    };
    a.push(1 << 40);
    b.push(1 << 40);

    let mut acc = 0;
    let mut i = 0;
    let mut j = 0;
    let mut ans;
    let mut now_ans;

    while acc + a[i] <= k {
        acc += a[i];
        i += 1;
    }

    ans = i;
    now_ans = ans;
    i = i.wrapping_add(!0);

    loop {
        if acc + b[j] <= k {
            acc += b[j];
            now_ans += 1;
            j += 1;
        } else if i < a.len() && acc + b[j] - a[i] <= k {
            acc += b[j] - a[i];
            j += 1;
            i = i.wrapping_add(!0);
        } else if i < a.len() {
            acc -= a[i];
            i = i.wrapping_add(!0);
            now_ans -= 1;
        } else {
            break;
        }

        ans = max(ans, now_ans);
    }

    println!("{}", ans);
}


Measured memory_bytes: 9464
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>

const int N = 1e5 + 51;

std::map<int, int> mp;
int sz;
int id(int x) {
	if (!mp.count(x)) return mp[x] = ++sz;
	return mp[x];
}

int p[N];
int f(int x) { return x[p] ? x[p] = f(x[p]) : x; }

int n, a[N], b[N], ans, fl = 1;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", a + i), a[n + 1] ^= a[i];
	for (int i = 1; i <= n; i++) scanf("%d", b + i), b[n + 1] ^= b[i];
	for (int i = 1, x, y; i <= n; i++)
		if (a[i] != b[i]) {
			ans++;
			if ((x = f(id(a[i]))) != (y = f(id(b[i])))) x[p] = y;
			if (a[i] == a[n + 1] && fl) ans--, fl = 0;
			if (b[i] == b[n + 1] && fl) ans--, fl = 0;
			if (a[i] == b[n + 1] && fl) ans--, fl = 0;
			if (b[i] == a[n + 1] && fl) ans--, fl = 0;
		}
	std::sort(a + 1, a + n + 2);
	std::sort(b + 1, b + n + 2);
	for (int i = 1; i <= n + 1; i++)
		if (a[i] != b[i]) return puts("-1"), 0;
	for (int i = 1; i <= sz; i++) ans += !i[p];
	printf("%d", ans);
}

// ze

Measured memory_bytes: 7680
// C - Together
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int solve(int N, vi &A){
	vi C(100000+1);
	rp(i, 0, N) C[A[i]]++;
	int a = C[0], b = C[1], c = C[2];
	int ans = a + b + c;
	rp(i, 3, C.size())
		if(C[i] != 0){
			a = b; b = c; c = C[i];
			ans = max(ans, a+b+c);
		}
	return ans;
}

int main(){
	int N; cin>>N;
	vi A(N); rp(i, 0, N) cin>>A[i];
	cout<< solve(N, A) <<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define _for(a,b,i) for(int i=a;i<=b;i++)
#define for1(a,b,i) for(int i=a;i<b;i++)
using namespace std;
ll ma=0x80000000;
ll mi=0x7fffffff;
const ll zfc=0xffffffff;
const ll mod=1e9+7;
inline void input(ll &x)
{
    x=0;
    int f=1;
    char ch=getchar();
    while(!isdigit(ch))
	{
		if(ch=='-')f=-f;
		ch=getchar();
	}
    while(isdigit(ch))
	{
		x=x*10+(ch-'0');
		ch=getchar();
	}
    x*=f;
}
inline void output(ll x)
{
	if(x<0)
    {
        x=-x;
        putchar('-');
    }
    if(x/10>0)output(x/10);
    putchar(x%10+'0');
}
ll a;
int main()
{
	ios::sync_with_stdio(false);
	input(a);
	output(a*(a+1)/2);
	cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
// const int INF = +100100100;
typedef pair<int,int> P;

int main(){
    set<string> st;
    int n;
    cin >> n;
    rep(i,n){
        string op,s;
        cin >> op >> s;
        if(op=="insert"){
            st.insert(s);
        }
        else if(op=="find"){
            set<string>::iterator t = st.find(s);
            if(t!=st.end())cout<<"yes"<<endl;
            else cout << "no"<<endl;
        }
        else continue;
    }
    return 0;
}


Measured memory_bytes: 32140
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


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

  vector<P> E;
  rep2(i, 1, n+1) rep2(j, i+1, n+1) {
    if (i + j == n/2 * 2 + 1) continue;
    E.push_back(P(i, j));
  }

  cout << E.size() << endl;
  for (auto e : E) {
    cout << e.first << " " << e.second << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
  int N;
  int a[100010] = {};
  int i;
  int count = 0;
  scanf("%d", &N);
  for(i = 1; i <= N; i++){
    scanf("%d", &a[i]);
  }
  i = 1;
  while(i != 2){
    i = a[i];
    count++;
    if(count > N){
      //光るボタンはN+1回目までに元に戻る
      printf("-1\n");
      return 0;
    }
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>

using namespace std;

int m,n;
double sum,x;
int tm=1900,tn=100;

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

	int i=0;
	x=tm;

	while (x>0)
	{
		i++;
		x=i*(tm*m+(n-m)*tn)*pow(0.5,m)*(pow(1-(pow(0.5,m)),i-1));
		if(sum == sum+x)
			break;
		sum=sum+x;
	}

	cout<<sum;

	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int sw = 1;
    rep(i, s.size()/2){
        if(s[i]!=s[s.size()-i-1]){
            sw=0;
        }
    }
    
    rep(i, s.size()/4){
        if(s[i]!=s[s.size()/2-i-1]){
            sw=0;
        }
    }
    rep(i, s.size()/4){
        if(s[i+s.size()/2+1]!=s[s.size()-i-1]){
            sw=0;
        }
    }
    if(sw==1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;

signed main() {
    int n;
    int ans = 0;
    cin >> n;
    rep(i, n){
        int tmp;
        cin >> tmp;
        if(((i+1) % 2 == 1) && (tmp % 2 == 1)) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;

vector<ll> arr(100000);
vector<ll> DP(100000);

int main() {
    int N;
    cin>>N;
    for(int i=0;i<N;++i){
        cin>>arr[i];
    }
    for(int i=0;i<100000;++i){
        DP[i] = big;
    }
    ll index;
    for(int i=0;i<N;++i){
        index = lower_bound(DP.begin(), DP.end(), arr[i]) - DP.begin();
        DP[index] = arr[i];
    }
    cout<<lower_bound(DP.begin(), DP.end(), big) - DP.begin()<<endl;
}




Measured memory_bytes: 4248
import numpy as np
N = int(input())
W = np.array(list(map(int, input().split())))

for i in range(1,N):
    if i == 1:
        tmp = np.abs(W[0]-W[1:].sum())
    else:
        s = np.abs(W[:i].sum()-W[i:].sum())
        if s<tmp:
            tmp = s
print(tmp)

Measured memory_bytes: 22044
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

struct edge {
	int to, di, co;
};
struct query {
	int co, di, pm, num;
};

int N, Q, a, b, c, d, cnt, A[100000], res[100000], col[100000], s, cols[100000];
bool vis[100000];
pair<int, int>tree[1 << 19];
vector<edge>v[100000];
vector<query>q[100000];

void dfs(int x, int dep) {
	vis[x] = true;
	A[x] = cnt - (1 << 18);
	tree[cnt] = mkp(dep, x);
	++cnt;
	for (edge e : v[x]) {
		if (!vis[e.to]) {
			dfs(e.to, dep + 1);
			tree[cnt] = mkp(dep, x);
			++cnt;
		}
	}
}

pair<int,int> calc(int l, int r, int p, int q, int k) {
	if (q < l || r < p)return mkp(0xE869120, -1);
	if (p <= l&&r <= q)return tree[k];
	return min(calc(l, (l + r) / 2, p, q, k * 2), calc((l + r) / 2 + 1, r, p, q, k * 2 + 1));
}


int LCA(int x, int y) {
	return calc(0, (1 << 18) - 1, min(A[x], A[y]), max(A[x], A[y]), 1).second;
}

void dfs2(int x) {
	vis[x] = false;
	for (query u : q[x]) {
		res[u.num] += (s + col[u.co] * u.di - cols[u.co])*u.pm;
	}
	for (edge e : v[x]) {
		if (vis[e.to]) {
			s += e.di;
			col[e.co]++;
			cols[e.co] += e.di;
			dfs2(e.to);
			s -= e.di;
			col[e.co]--;
			cols[e.co] -= e.di;
		}
	}
}

int main() {
	cin >> N >> Q;
	for (int i = 1; i < N; ++i) {
		cin >> a >> b >> c >> d;
		--a;
		--b;
		v[a].push_back({ b, d, c });
		v[b].push_back({ a, d, c });
	}
	cnt = (1 << 18);
	dfs(0, 0);
	for (int i = (1 << 18) - 1; i; --i) {
		tree[i] = min(tree[i * 2], tree[i * 2 + 1]);
	}
	for (int i = 0; i < Q; ++i) {
		int x, y, u, v;
		cin >> x >> y >> u >> v;
		--u;
		--v;
		q[u].push_back({ x, y, 1, i });
		q[v].push_back({ x, y, 1, i });
		q[LCA(u, v)].push_back({ x, y, -2, i });
	}
	dfs2(0);
	for (int i = 0; i < Q; ++i) {
		cout << res[i] << endl;
	}
}

Measured memory_bytes: 25076
#include<stdio.h>

int main(void){

    int H,W,a[1000][2],i=0,j=0,x=0,k;

    while(1){
        scanf("%d %d", &a[x][0], &a[x][1]);
        if(a[x][0]==0&&a[x][1]==0)break;
        x++;
    }

    for(i=0;i<x;i++){
        for(j=0;j<a[i][0];j++){
           
            if(j%2==1){
            for(k=0;k<a[i][1];k++){
                if(k%2==0){
                    printf(".");
                }else{
                    printf("#");   
                }
            }
            }else{
          
                for(k=0;k<a[i][1];k++){
                    if(k%2==1){
                        printf(".");
                    }else{
                        printf("#");   
                    }
                }

            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    unordered_map<int64_t, int64_t> m;
    int64_t s = 0;
    for (auto i : irange(0L, n)) {
        int64_t a;
        cin >> a;

        ++m[a];
        s += a;
    }

    int64_t q;
    cin >> q;

    for (auto _ : irange(0L, q)) {
        int64_t b, c;
        cin >> b >> c;

        s += (c - b) * m[b];
        m[c] += m[b];
        m[b] = 0;

        cout << s << "\n";
    }
}

Measured memory_bytes: 7124
n=int(input())
p=1
a=[]
for i in range(n):
  p*=i+1
  a.append(list(map(int,input().split())))
p//=n
ans=0
Dis=lambda x,y:((x[0]-y[0])**2+(x[1]-y[1])**2)**.5
for x in a:
  for y in a:
    ans+=p*Dis(x,y)

print("%.10f" % (ans/p/n))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdio>
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cstring>
#include <string>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <iterator>
using namespace std;
#define INF 999999999

string s;

int suf[200100];
int freq[2300];

int main(){
    cin >> s;
    int mult = 1;
    int ans = 0;
    freq[0] = 1;
    for (int i = s.size()-1; i >= 0; i--){
        suf[i] = suf[i+1]+(s[i]-'0')*mult;
        suf[i]%=2019;
        mult *= 10;
        mult %= 2019;
        ans += freq[suf[i]];
        freq[suf[i]]++;
    }
    //for (int i = 0; i < s.size(); i++) printf("%d ", suf[i]);
    //cout << "\n";
    printf("%d", ans);
}


Measured memory_bytes: 4604
#include<stdio.h>

int main(){
	int i,g,j,k;
	char s[100001];
	scanf("%s",s);
	for(g=0;s[g]!=0;g++);
	for(i=0;i<g-1;i++){
		if(s[i]==s[i+1]){
			printf("%d %d\n",i+1,i+2);
			return 0;
		}
	}
	for(i=0;i<g-2;i++){
		if(s[i]==s[i+2]){
			printf("%d %d\n",i+1,i+3);
			return 0;
		}
	}
	puts("-1 -1");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

bool dp(vl V, ll pos){
  ll tot = 0;
  rep(i, V.size()) tot += V[i];

  if((tot - pos) % 2 == 1)
    return false;

  ll targ = (tot - pos) / 2;
  vvl arr(V.size() + 1, vl(tot + 1, 0));
  arr[0][0] = 1;

  rep(i, V.size()){
    rep(j, targ + 1){
      if(j < V[i]){
	arr[i + 1][j] = arr[i][j];
      } else{
	arr[i + 1][j] = max(arr[i][j - V[i]], arr[i][j]);
      }
    }
  }

  return arr[V.size()][targ] == 1;
}

int main(){
  string s;
  cin >> s;
  ll x, y;
  cin >> x >> y;

  queue<char> que;
  rep(i, s.size()) que.push(s[i]);
  
  vl LR, UD;
  ll tmp = 0;
  ll sw = 0;

  while((!que.empty()) && (que.front() == 'F')){
    x--;
    que.pop();
  }

  if(que.empty()){
    if((x == 0) && (y == 0))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;

    return 0;
  }
  
  while(!que.empty()){
    if(que.front() == 'F'){
      tmp++;
    } else{
      if(sw == 0){
	sw = 1;
	if(tmp > 0) LR.push_back(tmp);
      } else{
	sw = 0;
	if(tmp > 0) UD.push_back(tmp);
      }
      tmp = 0;
    }
    que.pop();
  }
  if(tmp > 0){
    if(sw == 0) LR.push_back(tmp);
    else UD.push_back(tmp);
  }

  if(LR.size() == 0){
    if(x != 0){
      cout << "No" << endl;
      return 0;
    }
  } else{
    if(!dp(LR, x)){
      cout << "No" << endl;
      return 0;
    }
  }

  if(UD.size() == 0){
    if(y != 0){
      cout << "No" << endl;
      return 0;
    }
  } else{
    if(!dp(UD, y)){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 62976
#ifdef local_mode
    #include <cstdio>
    #include <cassert>
#endif
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
#define pb push_back
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
#ifdef local_mode
    ios_base::sync_with_stdio(0), cin.tie(0);
    assert(freopen("in", "r", stdin));
    assert(freopen("out", "w", stdout));
#endif
    
    int a,b,c;
    cin >> a >> b >> c;
    int a1,a2,a3;
    a1 = abs(a-b);
    a2 = abs(b-c);
    a3 = abs(a-c);

    cout << a1+a2+a3-max(max(a1, a2),a3);
    
    return 0;
}







































Measured memory_bytes: 256
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }

fun main(args: Array<String>) {
    val (a, b) = readInts()

    val v = "$a$b".toInt()
    for (x in 1..500) {
        if (x * x == v) {
            println("Yes")
            return
        }
    }

    println("No")
}

Measured memory_bytes: 37876
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cis(s);
    cis(t);
    auto ans = t + s;
    co(ans);
    return 0;
}

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

using namespace std;
#define ll long long
int main(){
    int ans=0;
    int h,w;
    cin >> h>>w;
    int field[h][w];
    int vx[8]={-1, 0, 1, 1, 1, 0,-1,-1};
    int vy[8]={-1,-1,-1, 0, 1, 1, 1, 0};
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            field[i][j]=0;
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char a;
            cin >>a;
            if (a=='#'){
                field[i][j]=-1;
                for(int k=0;k<8;k++){
                    if (i+vy[k]<0 ||i+vy[k]>=h ||j+vx[k]<0 ||j+vx[k]>=w)continue;
                    int* pos=&field[i+vy[k]][j+vx[k]];
                    *pos=(*pos==-1)?(-1):(*pos+1);
                }
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if (field[i][j]==-1){
                cout <<'#';
            }else{
                cout <<field[i][j];
            }
        }
        cout <<endl;
    }
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
import java.io.*;
public class Main {
	
	static ArrayList<Pair>[] graph;
	static int N;
	
	public static class Pair{
		int node;
		long dist;
		public Pair(int node, long dist) {
			this.node = node; this.dist = dist;
		}
	}

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		N = Integer.parseInt(br.readLine());
		
		graph = new ArrayList[N+1];
		for(int i = 1; i<=N; i++) graph[i] = new ArrayList<Pair>();
		
		for(int i = 1; i<N; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(st.nextToken()), b = Integer.parseInt(st.nextToken()), w = Integer.parseInt(st.nextToken());
			graph[a].add(new Pair(b, w)); graph[b].add(new Pair(a, w));
		}		
		StringTokenizer st = new StringTokenizer(br.readLine());
		int Q = Integer.parseInt(st.nextToken()), K = Integer.parseInt(st.nextToken());
		long dist[] = Dijkstra(K);
		for(int q = 0; q<Q; q++) {
			st = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(st.nextToken()), b = Integer.parseInt(st.nextToken());
			System.out.println(dist[a]+dist[b]);
		}
				
	}
	
	public static long[] Dijkstra(int src) {
		
		long dist[] = new long[N+1];
		Arrays.fill(dist, Long.MAX_VALUE);
		dist[src] = 0;
		LinkedList<Integer> list = new LinkedList<Integer>();
		list.add(src);
		while(!list.isEmpty()) {
			int crntnode = list.pop();
			for(Pair p : graph[crntnode]) {
				if(dist[p.node] > dist[crntnode] + p.dist) {
					dist[p.node] = dist[crntnode] + p.dist;
					list.add(p.node);
				}
			}
		}
		
		return dist;
		
	}
	

}


Measured memory_bytes: 82904
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,m;
    cin >> n >> m;
    vi a(n);
    rep(i,n)cin >> a[i];
    sort(all(a));
    vi sum = a;
    rep(i,n-1)sum[i+1] += sum[i];
    //rep(i,n)cout << " " << a[i];cout << endl;
    //rep(i,n)cout << " " << sum[i];cout << endl;
    int ok = 0, ng = INF;
    int tmp;
    while(ng - ok > 1){
        int mid = (ok + ng)/2;
        //和が mid 以上になるペアが m 個以上か？
        int cnt = 0;
        rep(i,n){//左を a[i] で固定する
            int x = mid - a[i];
            int num = lower_bound(all(a), x) - a.begin();
            cnt += n - num;
        }
        //cout << ok << " " << ng << " " << mid << " " << " " << cnt << endl;
        if(cnt >= m)ok = mid,tmp = cnt;
        else ng = mid;
    }
    //cout << ok << " " << tmp << endl;
    int ans = 0;
    //和が ok 以上になるペアをすべて足す
    rep(i,n){
        int x = ok - a[i];
        int ind = lower_bound(all(a),x) - a.begin();
        if(ind == n)continue;
        ans += sum[n-1];
        if(ind)ans -= sum[ind-1];
        ans += a[i]*(n-ind);
        //cout << i << " " << ind << endl;
    }
    ans -= (tmp-m)*ok;
    cout << ans << endl;
}


Measured memory_bytes: 1920
S = input()
len = len(S)
start = len
end = 0
for i in range(len):
  if(S[i] == "A"):
    temp_start = i+1
    start = min(start,temp_start)
  if(S[i] == "Z"):
    temp_end = i+1
    end = max(end,temp_end)
print(end-start+1)

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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int sum = Math.max(a, b);
		if (sum == a) a--; else b--;
		sum += Math.max(a, b);
		
		out.println(sum);
		
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


Measured memory_bytes: 21204