akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    int n,m;
    while(sf("%d %d",&n,&m)==2)
    {
        int x1[n+5],y1[n+5];
        for(int i=0;i<n;i++)sf("%d %d",&x1[i],&y1[i]);

        int x2[m+5],y2[m+5];
        for(int i=0;i<m;i++)sf("%d %d",&x2[i],&y2[i]);

        for(int i=0;i<n;i++)
        {
            int mn=INT_MAX;
            int id;
            for(int j=0;j<m;j++)
            {
                int dis=abs(x1[i]-x2[j])+abs(y1[i]-y2[j]);
                if(dis<mn)
                {
                    mn=dis;
                    id=j;
                }
                else if(dis==mn)
                {
                    id=min(id,j);
                }
            }
            pf("%d\n",id+1);
        }
        nl;
    }
    return 0;
}
 









 




























Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

struct edge{int to,w;};
vector<edge> V[100009];

int main(void){
	int n,u,v,w;
	cin>>n;
	rep(i,n-1){
		cin>>u>>v>>w;
		V[u].push_back(edge{v,w});
		V[v].push_back(edge{u,w});
	}
	vector<int> ans;
	rep(i,n+1){
		ans.push_back(-1);
	}
	queue<pair<int,int>> q;//num,color
	q.push (pair<int, int>{1, 0});
	while(q.size() > 0){
		pair<int,int> now = q.front();q.pop();
		if(ans[now.first] != -1) continue;
		ans[now.first] = now.second;
		rep(j,V[now.first].size()){
			q.push(pair<int, int>{V[now.first][j].to,(ans[now.first]+V[now.first][j].w)%2});
		}
	}
	reps(i,n){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 6908
#include <stdio.h>
int main(void){
    
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    
    if (W>=x+r && H>=y+r && r<=x && r<=y && x>=0 && y>=0){ 
        
        printf("Yes\n");
        
    } 
        
    else { 
        
        printf("No\n");
        
    } 
        
        
        return 0;
    
}



Measured memory_bytes: 2104
#include <iostream>

using namespace std;

int sum;

int gcd(int a, int b) {
    if (a % b == 0) {
        return b;
    }
    else {
        return gcd(b, (a % b));
    }
}

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

    sum = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int l = 1; l <= k; l++) {
                sum += gcd(gcd(i, j), l);
            }
        }
    }
    cout << sum << endl;
}



Measured memory_bytes: 3624
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,cnt=0; cin>>n;
    map<string,int> m;
    rep(i,n){
        string s; cin>>s;
        int t; cin>>t;
        m[s]=cnt+t;
        cnt+=t;
    }
    string x; cin>>x;
    cout<<cnt-m[x]<<endl;
}


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

using namespace std;

typedef long long ll;

const int MAX_N = 1100;
const ll INF = 1e12;

vector<pair<ll, ll> > g[MAX_N]; // firstに最短距離, secondに頂点番号
ll d[MAX_N];
int n; // 頂点数

bool used[MAX_N][MAX_N];

int pr[MAX_N]; // 最短路の直前の頂点

// bellman ford法で負辺がない場合。計算量はO(|E|log|V|)
void dijkstra(int s){
  priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, greater<pair<ll, ll> > > PQ;
  for(int i=1;i<=n;i++) d[i] = INF;
  for(int i=1;i<=n;i++) pr[i] = -1;
  d[s] = 0;
  PQ.push(make_pair(0, s));

  while(!PQ.empty()){
    pair<ll, ll> p = PQ.top(); PQ.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(auto gvi: g[v]){
      ll cost = gvi.first;
      int u = gvi.second;
      if(d[u] > d[v] + cost){
        d[u] = d[v] + cost;
        PQ.push(make_pair(d[u], u));
        pr[u] = v;
      }
    }
  }
}

// 頂点tへの最短路
void get_path(int t){
  for(;t!=-1;t=pr[t]){
    used[t][pr[t]] = true;
    used[pr[t]][t] = true;
  }
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int m; cin >> n >> m;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      used[i][j] = true;
    }
  }
  for(int i=0;i<m;i++){
    int a, b;
    ll c; cin >> a >> b >> c;
    g[a].push_back(make_pair(c, b));
    g[b].push_back(make_pair(c, a));
    used[a][b] = false;
    used[b][a] = false;
  }
  for(int i=1;i<=n;i++){
    dijkstra(i);
    for(int j=i+1;j<=n;j++){
      // cout << i << " " << j << " " << d[j] << endl;
      get_path(j);
    }
  }
  int cnt = 0;
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      if(used[i][j] == false) cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline

# N = 4

# for M in range(N, N+5):
#     P = list(permutations(range(M),N))
#     #print(P)
#     ans = 0
#     for A in P:
#         ok = True
#         for i, a in enumerate(list(A)):
#             if i == a:
#                 ok = False
#                 break
#         if ok:
#             ans += 1
#     print(ans)

mod = 10**9+7
N, M = map(int, input().split())

# コンビネーション
mod = 10**9+7
def cmb(n, r, mod=mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NN = 6*10**5 # 使うデータによって変える
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, NN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

# a(n) = sum((-1)^i*binomial(3,i)*(n-i)!/(n-3)!,i=0..3).

ans = 0
for k in range(N+1):
    ans = (ans + (-1)**k * cmb(N, k)*g1[M-k]*g2[M-N] ) % mod
print(ans*g1[M]*g2[M-N]%mod)

Measured memory_bytes: 162744
nmax = 10**5+1
mod = 10**9+7

fac = [1]*nmax
finv = [1]*nmax
inv = [1]*nmax
def ncr_pre():
    for i in range(2,nmax):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) %mod
        finv[i] = finv[i-1] * inv[i] %mod

def ncr(n,r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fac[n]* (finv[r] * finv[n-r] %mod) %mod


import collections
ncr_pre()
n,k = map(int,input().split())
A = list(map(int,input().split()))
co = sorted(collections.Counter(A).items())
smax = 0
c= 0
l = len(co)
for i in range(l):
    num,cnt = co[i]
    c+=cnt
    if c>=k:
        smax += num*(ncr(c,k) - ncr(c-cnt,k))
        smax%=mod
smin = 0
c= 0
for i in range(l):
    num,cnt = co[-i-1]
    c+=cnt
    if c>=k:
        smin += num*(ncr(c,k) - ncr(c-cnt,k))
        smin%=mod
print((smax - smin)%mod)


Measured memory_bytes: 72432
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  string S;
  cin >> S;
  int Q;
  cin >> Q;
  deque<char> ans(0);
  REP(i, S.size()) ans.push_back(S[i]);
  bool tenti = false;
  REP(i, Q) {
    int id;
    cin >> id;
    if (id == 1) {
      tenti = !tenti;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1) {
        if (tenti) {
          ans.push_back(c);
        } else {
          ans.push_front(c);
        }
      } else {
        if (!tenti) {
          ans.push_back(c);
        } else {
          ans.push_front(c);
        }
      }
    }
  }
  if (tenti) reverse(ans.begin(), ans.end());
  REP(i, ans.size()) { cout << ans[i]; }
  cout << endl;
}

Measured memory_bytes: 4008
from collections import Counter
h, w = map(int, input().split(" "))
a = [input() for i in range(h)]

rr = []
for i in range(h):
    c = Counter(a[i]).most_common()
    if len(c) > 1 or c[0][0] == '#':
        rr.append(i)

rc = []
for i in range(w):
    c = Counter([x[i] for x in a]).most_common()
    if len(c) > 1 or c[0][0] == '#':
        rc.append(i)

a = '\n'.join(''.join(a[j][i] for i in rc) for j in rr)
print(a)


Measured memory_bytes: 3316
#!/usr/bin/perl


$line = 0;
while (<>) {
    chomp;
    if($line == 0) {
        $n = $_;
    } else {
        @a = split /\s+/, $_
    }
    $line++;
}

foreach (@a) {
    $e{$_}++;
}

foreach (sort {$b <=> $a} keys %e) {
    if($e{$_} >= 2) {
        push @h, $_;
        if($#h >= 1) {
            print $h[0] * $h[1], "\n";
            exit;
        }
        if($e{$_} >= 4) {
            print $_ * $_, "\n";
            exit;
        }
    }
}

print "0\n";


Measured memory_bytes: 31692
n = int(input())
A = list(map(int, input().split()))
freq = [0]*(10**5+1)

for a in A:
    freq[a] += 1
q = int(input())
ans = sum(A)
for i in range(q):
    b, c = map(int, input().split())
    ans -= freq[b] * b
    freq[c] += freq[b]
    ans += freq[b] * c
    freq[b] = 0
    print (ans)

Measured memory_bytes: 21044
#include <iostream>
#include <vector>
#include <algorithm>
#include<string>

using namespace std;

int main(){
    int n;

    cin >> n;

    int a[n];

    int max = 0;
    int _m = 0;

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

        if(max < a[i]){
            max = a[i];
            _m = i;
        }
    }

    int all = 0;

    for(int i = 0; i < n; i++){
        if(i != _m){
            all += a[i];
        }
    }

    if(all > max){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
     
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]) {
  bool all_visited = true;
  rep(i,N) if(!visited[i]) all_visited = false;
  if(all_visited) return 1;
  int ret = 0;
  rep(i,N) {
    if(!graph[v][i]) continue;
    if(visited[i]) continue;
    visited[i] = true;
    ret += dfs(i,N,visited);
    visited[i] = false;
  }
  return ret;
}

int main() {
  int N,M;
  cin >> N >> M;
  for(int i=0;i<M;++i){
    int A,B;
    cin >> A >> B;
    graph[A-1][B-1]=graph[B-1][A-1]=true;
  }
  bool visited[nmax];
  for(int i=0;i<N;++i){
  visited[i]=false;
  }
  visited[0]=true;
  cout << dfs(0,N,visited) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    long a = nextLong();
    long b = nextLong();
    long c = nextLong();
    long k = nextLong();

    long ans = 0;

    if(a>=k){
      ans = k;
    }
    else if((a+b)>=k){
      ans = a;
    }
    else{
      long ok = a + b + c - k;
      ans = a - (c - ok);
    }

    System.out.println(ans);

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

  static int gcd(int a,int b){
    if(a%b!=0){
      return gcd(b,a%b);
    }
    else{
      return b;
    }
  }

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 35692
#include <stdio.h>

int main(){
	long long A, B, C, K, ans=0;

	scanf("%lld %lld %lld %lld", &A, &B, &C, &K);

	if(A<=K && K>0){
		ans += A;
		K -= A;
	}
	else if(A>K && K>0){
		ans += K;
		K = 0;
	}

	if(B<=K && K>0){
		K -= B;
	}
	else if(B>K && K>0){
		K = 0;
	}

	if(K>0){
		ans -= K;
	}

	printf("%lld", ans);

	return 0;
}


Measured memory_bytes: 1724
from operator import mul
import sys
from functools import reduce

def cmb(n,r):
    if n == 1:
        return 0
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


from collections import defaultdict
d = defaultdict(int)

N = int(input())
s = list(list(input()) for i in range(N))

for i in range(N):
    s[i] = sorted(s[i])

s.sort()

temp = ""


for i in s:
    temp = ''.join(i)
    d[temp] += 1

box = list(d.values())

ans = 0
for j in box:
    ans += cmb(j, 2)

print(ans)

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

int main() {
  int n, k;
  cin >> n;
  cin >> k;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x.at(i);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (abs(k - x.at(i)) > x.at(i))
      ans += 2 * x.at(i);
    else
      ans += 2 * abs(k - x.at(i));
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import math
from collections import deque
n = int(input())
#x, y = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
B = deque()
if n%2==0:
    for i in range(n):
        a=str(A[i])
        if i%2==1:
            B.appendleft(a)
        else:
            B.append(a)
if n%2==1:
    for i in range(n):
        a=str(A[i])
        if i%2==0:
            B.appendleft(a)
        else:
            B.append(a)
print(' '.join(B))

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

vector<int> prime;
vector<int> ls;

void sieve(int N){
    prime.resize(N+1,1);
    prime[0] = prime[1] = 0;
    for(int i=2;i*i<=N;i+=i%2+1){
        for(int j=i*i;j<=N;j+=i){
            prime[j] = 0;
        }
    }
    for(int i=2;i<=N;i++){
        if(prime[i])ls.push_back(i);
    }
}

int main() {
    sieve(int(1e7+100));
    int n;
    while(cin >> n, n){
        int ans;
        for(int i=0;ls[i]<=n-8;i++){
            if(ls[i+1]-ls[i]==2 && ls[i+2]-ls[i]==6 && ls[i+3]-ls[i]==8){
                ans = ls[i+3];
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 45860
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		//int n = Integer.parseInt(sc.next());
		//long res=n;
		//int l = Integer.parseInt(sc.next());
		//int sum=0;
		//String s = sc.next();
		//int a = Integer.parseInt(sc.next());
		//String t = sc.next();

		/*if(b>a/2.0) {
			System.out.println(a-b);
		}else {
			System.out.println(b-1);
		}*/
		System.out.println((a+b)*c/2);
	}
}




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

// Dantai
class Dantai {
public:
	void SetNinzuu(int l, int r);
	int GetNinzuu() const;
private:
	int m_left;
	int m_right;
};

void Dantai::SetNinzuu(int l, int r) {
	m_left = l;
	m_right = r;
}

int Dantai::GetNinzuu() const {
	return m_right - m_left + 1;
}


// Manager
class Manager {
public:
	Manager(int dantaisuu);
	~Manager();
	int GetAllNinzuu() const;
	int GetDantaisuu() const;
	void AddDantai(int l, int r);
private:
	int m_dantaisuu;
	Dantai* m_pDantai;
	int m_index;
};

Manager::Manager(int dantaisuu) {
	m_dantaisuu = dantaisuu;
	m_pDantai = new Dantai[m_dantaisuu];
	m_index = 0;
}

Manager::~Manager() {
	delete[] m_pDantai;
}

int Manager::GetAllNinzuu() const {
	int allNinzuu = 0;
	for (int i = 0; i < m_dantaisuu; i++) {
		allNinzuu += m_pDantai[i].GetNinzuu();
	}
	return allNinzuu;
}

int Manager::GetDantaisuu() const {
	return m_dantaisuu;
}

void Manager::AddDantai(int l, int r) {
	if (m_index >= m_dantaisuu) {
		throw "団体が多すぎます";
	}
	m_pDantai[m_index].SetNinzuu(l, r);
	m_index++;
}

// Main
int main() {
	int N = 0;
	cin >> N;
	Manager mgr(N);
	for (int i = 0; i < N; i++) {
		int l = 0, r = 0;
		cin >> l >> r;
		mgr.AddDantai(l, r);
	}
	cout << mgr.GetAllNinzuu() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  size_t N; cin >> N;
  auto ans = N*N;
  cout << ans << CRLF;

  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if a == b:
   print("YES")
   exit()
if v <= w:
   print("NO")
   exit()

if abs(a - b) / abs(w - v) <= t:
   print("YES")
else:
   print("NO")

Measured memory_bytes: 61576
#include <stdio.h>

int main(void){

  long n,m;
  scanf("%ld %ld", &n, &m);
  long l[m];
  long r[m];
  for (long i = 0; i < m; i++) {
    scanf("%ld %ld", &l[i], &r[i]);
  }
  long max_l = l[0];
  long min_r = r[0];
  for (long i = 1; i < m; i++) {
    if (l[i] > max_l) {
      max_l = l[i];
    }
    if (r[i] < min_r) {
      min_r = r[i];
    }
  }
  long answer = min_r-max_l+1;
  if (answer < 0) {
    answer = 0;
  }
  printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());

            var b = int.Parse(Console.ReadLine());

            var c = int.Parse(Console.ReadLine());

            var d = int.Parse(Console.ReadLine());

            var e = int.Parse(Console.ReadLine());

            var k = int.Parse(Console.ReadLine());

            if(e - a <= k)
            {
                Console.WriteLine("Yay!");
            }
            else
            {
                Console.WriteLine(":(");
            }
        }
    }
}


Measured memory_bytes: 11092
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto& e:c)
#define iter(it,c) for(auto it=c.begin(); it!=c.end(); ++it)

ll const inf = 1<<28;
double const pi = acos(-1);

int sx,sy,gx,gy;
int n;
int fx[1000], fy[1000];
int lx,ly;
int g[256][256];
inline int & ref(int arr[256][256], int x, int y){
    return arr[y+128][x+128];
}

inline int valid(int x,int y){
    return abs(x)<=lx && abs(y)<=ly;
}

struct state {
    int x,y,t, ign;
    bool operator<(const state& s)const{
        if(ign != s.ign) return ign>s.ign;
        return t>s.t;
    }
};

int d[6][256][256];

int solve(){
    priority_queue<state> q;
    rep(i,6)rep(j,256)rep(k,256)d[i][j][k]=inf;
    q.push({sx,sy,0,0});
    ref(d[0],sx,sy) = 0;

    while(q.size()){
        auto s=q.top();q.pop();
        int t=s.t, x=s.x, y=s.y, ign=s.ign;
        // printf("x:%d y:%d t:%d ign:%d\n",x,y,t,ign);
        if(ref(d[t%6], x, y) > ign) break;
        if(x==gx && y==gy) return ign;
        static const int dx[]={0, 1, 1, 0,-1,-1, 0};
        static const int dy1[]={1, 0,-1,-1,-1, 0, 0};
        static const int dy2[]={1, 1, 0,-1, 0, 1, 0};

        rep(i,7){
            int nx=x+dx[i];
            int ny=y+(x&1 ? dy2[i] : dy1[i]);
            int nign;
            if(i!=6 && i==abs(x*y*t)%6 && valid(nx,ny) && ref(g,nx,ny)!=1){
                nign=ign;
            } else {
                nign = ign+1;
                if(!valid(nx,ny) || ref(g,nx,ny)==1){
                    nx=x, ny=y;
                }
            }

            if(ref(d[(t+1)%6], nx, ny) > nign){
                // printf("(%d,%d) -> (%d,%d) t:%d ign:%d dir:%d\n",x,y,nx,ny,t,ign,i);

                ref(d[(t+1)%6], nx, ny) = nign;
                q.push({nx,ny,t+1, nign });
            }
        }
    }
    int ans=inf;
    rep(i,6)ans=min(ans,ref(d[i],gx,gy));
    if(ans==inf) ans=-1;
    return ans;
}

int main(){
    while(scanf("%d%d%d%d",&sx,&sy,&gx,&gy)!=EOF){
        scanf("%d",&n);
        memset(g,0,sizeof(g));
        rep(i,n){
            int x,y;scanf("%d%d",&x,&y);
            ref(g,x,y)=1;
        }
        scanf("%d%d",&lx,&ly);
        printf("%d\n",solve());
    }
}

Measured memory_bytes: 3124
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }
fun main(args:Array<String>){
  var n = nextInt()
  var mp = mutableMapOf(-1 to 0)
  var cnt = 0
  for(i in 1..n){
    var tmp = nextInt()
    var x = mp[tmp]
    if(x==null){
      mp[tmp] = 1
    }else{
      mp[tmp] = x+1
    }
  }
  mp.forEach{
    if(it.value%2 == 1) cnt++
  }
  println(cnt)
}


Measured memory_bytes: 48340
int main(){
	int a,b,c,d,e,r=0;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	if(a<0)r-=a*c,a=0;
	if(a==0)r+=d+e,a=1;
	printf("%d\n",r+(b-a)*e);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()




using namespace std;

int main(){
  string S;
  string T;
  cin>>S>>T;
  
  S += T[T.size()-1];
  if(S==T) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  
  


  return 0;
}

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

    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846

    void solve(){
        string s,t;
        cin>>s>>t;
        int total=0;
        for(int i=0;i<(int)s.size();i++){
            if(s[i]!=t[i])
                total++;
        }
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3820
def main():
    args = input().rstrip().split(' ')
    A, B = int(args[0]), int(args[1])
    p_A = [A * 12.5, (A+1.) * 12.5]
    p_B = [B * 10., (B+1.) * 10.]
    if(p_A[0].is_integer() == False):
        p_A[0] = int(p_A[0])+1
    else:
        p_A[0] = int(p_A[0])
    if(p_B[0].is_integer() == False):
        p_B[0] = int(p_B[0])+1
    else:
        p_B[0] = int(p_B[0])
    if(p_A[1].is_integer == False):
        p_A[1] = int(p_A[1])
    else:
        p_A[1] = int(p_A[1]) -1
    if(p_B[1].is_integer() == False):
        p_B[1] = int(p_B[0])
    else:
        p_B[1] = int(p_B[1]) -1
        
        
    if(p_A[1] <= p_B[0] or p_B[1] <= p_A[0]):
        print('-1')
    else:
        print(int(max(p_A[0], p_B[0])))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
n=input()
if int(n)<10:
    print(n)
else:
    if set(list(n[1:]))=={"9"}:
        print(int(n[0])+(len(n)-1)*9)
    elif n[0]=="1":
        print((len(n)-1)*9)
    else:
        print(int(n[0])-1+(len(n)-1)*9)

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n;
  vector<int> result;
  rep(i, 10) {
    cin >> n;
    result.pb(n);
  }
  sort(result.begin(), result.end());
  reverse(result.begin(), result.end());
  rep(i, 3) cout << result[i] << endl;
	return 0;
}


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

ll moddividing(ll x,ll y){
    vector<ll> vec(30);
    rep(i,30){
        vec[i] = y;
        y = y * y % 1000000007;
    }
    ll c = x;
    c = c * vec[0] % 1000000007;
    c = c * vec[2] % 1000000007;
    c = c * vec[9] % 1000000007;
    c = c * vec[11] % 1000000007;
    c = c * vec[14] % 1000000007;
    c = c * vec[15] % 1000000007;
    c = c * vec[17] % 1000000007;
    c = c * vec[19] % 1000000007;
    c = c * vec[20] % 1000000007;
    c = c * vec[23] % 1000000007;
    c = c * vec[24] % 1000000007;
    c = c * vec[25] % 1000000007;
    c = c * vec[27] % 1000000007;
    c = c * vec[28] % 1000000007;
    c = c * vec[29] % 1000000007;
    return c;
}

int main(){
    ll r1,c1,r2,c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ll ans = 0;
    vector<ll> factorial(2000008);
    factorial[0] = 1;
    rep(i,2000008){
        factorial[i + 1] = (factorial[i] * (i + 1)) % 1000000007;
    }
    for (ll i = r1; i <= r2; i++){
        ans = (ans + moddividing(factorial[i + c2 + 1], (factorial[i + 1] * factorial[c2]) % 1000000007)) % 1000000007;
        ans = (ans + 1000000007 - moddividing(factorial[i + c1], (factorial[i + 1] * factorial[c1 - 1]) % 1000000007)) % 1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 18840
n = int(input())
a = list(map(int, input().split()))

ah = -1e7
al = 1e7
ih = 1
il = 1
for i in range(n):
    if ah < a[i]:
        ah = a[i]
        ih = i + 1
    if a[i] < al:
        al = a[i]
        il = i + 1
ans = []
if 0 < al or abs(al) <= abs(ah):
    ans = [ih, 2, ih, 2, 2, 2, 2, 2]
    for i in range(3, n + 1):
        for _ in range(2):
            ans.append(i - 1)
            ans.append(i)
elif ah < 0 or abs(ah) < abs(al):
    ans = [il, n - 1, il, n - 1, n - 1, n - 1, n - 1, n - 1]
    for i in range(n - 2, 0, -1):
        for _ in range(2):
            ans.append(i + 1)
            ans.append(i)
print(len(ans) // 2)
for i in range(0, len(ans), 2):
    print('%d %d' % (ans[i], ans[i + 1]))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
// const int N = 2005;

const int N = 100005;

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);

    string st[3];
    cin >> st[0] >> st[1] >> st[2];
    cout << st[0][0] << st[1][1] << st[2][2] << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e3+10;
const int inf=0x3f3f3f3f;
struct node{
    int val,key;
}a[maxn];
int dp[1010][5000];
int main(){
    int n,m;
    cin>>n>>m;
    int tot=0;
    int tmp=m;
    while(m--){
        int tmp=0;
        int v,k;
        cin>>v>>k;
        while(k--){
            int x;
            cin>>x;
            tmp|=(1<<(x-1));
        }
        a[++tot].val=v;
        a[tot].key=tmp;
    }
    int up=1<<n;
    m=tmp;
    for(int i=1;i<=m;++i)
        for(int j=0;j<up;++j)
            dp[i][j]=inf;
    dp[1][0]=0;
    for(int i=1;i<=m;++i){
        for(int j=0;j<up;++j){
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            dp[i+1][j|a[i].key]=min(dp[i+1][j|a[i].key],dp[i][j]+a[i].val);
        }
    }
    if(dp[m][up-1]==inf)cout<<-1<<endl;
    else
    cout<<dp[m][up-1]<<endl;
}


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

int main(){
  int h, w, n;
  cin >> h >> w >> n;
  int num = max(h, w);
  if(n%num == 0){
    cout << n/num << endl;
  }else{	
  	cout << n/num+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
if k > n*(n-1)//2 - (n-1):
  print(-1)
  quit()
g = [[1,i+1] for i in range(1,n)]
t = (n-1)*(n-2)//2
for i in range(2,n):
  for j in range(i+1,n+1):
    if t == k:
      print(len(g))
      for l in g:
        print(*l)
      quit()
    g.append([i,j])
    t -= 1
print(len(g))
for l in g:
  print(*l)

Measured memory_bytes: 4120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(15) << << endl;
#include <cassert>
//#include "atcoder/all"

using namespace std;
//using namespace atcoder;

typedef long long ll;

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define P pair<int,int>

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};

const int MOD = 1000000007;

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

    int n; cin >> n;
    vector<ll> t(n),a(n);
    rep(i,n) cin >> t[i] >> a[i];

    rep(i,n-1)
    {
        if(t[i] > t[i+1] || a[i] > a[i+1])
        {
            ll l = ceil((long double)(t[i]) / (long double)(t[i+1]));
            ll r = ceil((long double)(a[i]) / (long double)(a[i+1]));
            ll s = max(r,l);
            t[i+1] *= s; a[i+1] *= s;
        }
    }
    cout << t[n-1] + a[n-1] << endl;
}

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

const int N = 1e5 + 7;

int n, c[N], a[N], b[N], ord[N];
long long psa, psb;

int main() { 
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i], c[i] = a[i], psa = psa + a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i], psb = psb + b[i];
	if (psa < psb) {
		cout << -1;
		return 0;
	}
	for (int i = 0; i < n; i++)
		ord[i] = i;
	sort (ord, ord + n, [](int x, int y) {
		return a[x] - b[x] < a[y] - b[y];
	});
	int l = 0, r = n - 1;
	while (a[ord[l]] < b[ord[l]]) {
		int x = ord[l], y = ord[r];
		while (a[y] - b[y] < b[x] - a[x])
			a[x] += a[y] - b[y], a[y] = b[y], r--, y = ord[r];
		a[y] -= b[x] - a[x], a[x] = b[x], l++, x = ord[x];
	
	}
	int res = 0;
	for (int i = 0; i < n; i++)
		if (c[i] != a[i])
			res++;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
P a[200005];
int ans[200005];
int main(){
	cin>>n;
	rep(i,n){
		cin>>a[i].fi;
		a[i].sc = i;
	}
	sort(a,a+n);
	rep(i,n){
		if(i<n/2){
			ans[a[i].sc] = a[n/2].fi;
		}
		else{
			ans[a[i].sc] = a[n/2-1].fi;
		}
	}
	rep(i,n){
		printf("%d\n",ans[i]);
	}
}

Measured memory_bytes: 4480
import java.util.*;

public class Main {


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        if ((s.charAt(0)==s.charAt(1))|(s.charAt(1)==s.charAt(2))|(s.charAt(2)==s.charAt(3))){
            System.out.println("Bad");
        }else{
            System.out.println("Good");
        }
    }
}



Measured memory_bytes: 21844
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int D[505][505];
int in[505][505];

ll tot[35][3];
int main() {
	int N, C, i, j, k;
	scanf("%d %d", &N, &C);
	for (i = 1; i <= C; i++) for (j = 1; j <= C; j++) scanf("%d", &D[i][j]);
	for (i = 1; i <= N; i++) for (j = 1; j <= N; j++) scanf("%d", &in[i][j]);
	
	for (i = 1; i <= C; i++) {
		for (j = 1; j <= N; j++) {
			for (k = 1; k <= N; k++) {
				tot[i][(j + k) % 3] += D[in[j][k]][i];
			}
		}
	}
	
	ll ans = LL_INF;
	for (i = 1; i <= C; i++) {
		for (j = 1; j <= C; j++) {
			for (k = 1; k <= C; k++) {
				if (i == j || i == k || j == k) continue;
				ans = min(ans, tot[i][0] + tot[j][1] + tot[k][2]);
			}
		}
	}
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
#define INF 0x7FFFFFFF
const double EPS = 1e-10;


inline bool eq(double a, double b) { return fabs(b - a) < EPS;}

struct p_t{
  double x;
  double y;
  double norm() { return x * x + y * y; }
  double abs() { return sqrt(norm()); }
};
struct l_t{
	p_t a, b;
};

double cross(p_t p,p_t q);
p_t line(p_t p,p_t q);

bool asc(p_t left,p_t right) {
    return left.x == right.x ? left.y < right.y : left.x < right.x;
}
p_t Crosspoint(l_t l,l_t m);

int main(){
  int n;
  p_t z;
  vector<p_t> a;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>z.x>>z.y;
    a.push_back(z);
  }
  int q;
  cin>>q;
  p_t u,v;
  for(int t=0;t<q;t++){
    double ans=0;
    cin>>v.x>>v.y>>u.x>>u.y;
    // if(u.y>v.y){
    //   z=u;
    //   u=v;
    //   v=z;
    // }
    int c,d;
    int f=0;
    for(c=0;c<2*n;c++){
      if(cross(line(u,v),line(a[c%n],v))<=0){
        f=1;
      }
      else if(f==1) break;
    }
    f=0;
    for(d=0;d<2*n;d++){
      if(cross(line(u,v),line(a[d%n],v))>0){
        f=1;
      }
      else if(f==1) break;
    }
    if(d==2*n&&f==0){
      cout<< fixed <<ans<<endl;
      continue;
    }
    if(d==2*n&&f==1){
      for(int i=0;i<(int)a.size();i++){
        ans+=cross(a[i],a[(i+1)%a.size()]);
      }
      ans/=2.0;
      if(ans<0){
        ans=-ans;
      }
      cout<< fixed <<ans<<endl;
      continue;
    }
    l_t uc,ud,uv;
    uc.a=a[(c-1)%n];
    uc.b=a[c%n];
    ud.a=a[(d-1)%n];
    ud.b=a[d%n];
    uv.a=u;
    uv.b=v;
    vector<p_t> b;
    b.push_back(Crosspoint(uc,uv));
    d%=n;
    for(int i=c%n;i<(c%n<d?d:d+n);i++){
      b.push_back(a[i%n]);
    }
    b.push_back(Crosspoint(ud,uv));
    for(int i=0;i<(int)b.size();i++){
      ans+=cross(b[i],b[(i+1)%b.size()]);
    }
    ans/=2.0;
    if(ans<0){
      ans=-ans;
    }
    cout<< fixed <<ans<<endl;
  }
}


p_t line(p_t p,p_t q){
  p_t z;
  z.x=q.x-p.x;
  z.y=q.y-p.y;
  return z;
}


double cross(p_t p,p_t q){
  return p.x*q.y-p.y*q.x;
}

p_t Crosspoint(l_t l,l_t m){
  p_t aa,bb,cc,dd,ee;
  aa.x=l.b.x-l.a.x;
  aa.y=l.b.y-l.a.y;
  bb.x=m.b.x-m.a.x;
  bb.y=m.b.y-m.a.y;
  cc=aa;
  dd.x=l.b.x-m.a.x;
  dd.y=l.b.y-m.a.y;
	double A = cross(aa,bb);
	double B = cross(cc,dd);
	if (abs(A) < EPS && abs(B) < EPS) return m.a;
  ee.x=m.a.x+(m.b.x-m.a.x)*B/A;
  ee.y=m.a.y+(m.b.y-m.a.y)*B/A;
	return ee;
}



Measured memory_bytes: 3300
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> al = new ArrayList<Integer>();
        for(int i = 0; i < n*3; i++){
            al.add(sc.nextInt());
        }
        Collections.sort(al, Comparator.reverseOrder());
        long ans = 0;
        for(int i = 0; i < n; i++){
            ans += al.get(i*2+1);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 100944
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

int main()
{
  int n, m, k;
  cin >> n >> m >> k;
  vector<string> s(n);
  int result = 0;
  for (int i = 0; i < n; ++i) cin >> s[i];
  for (int m1 = 0; m1 < (1 << n); ++m1) for (int m2 = 0; m2 < (1 << m); ++m2) {
    int cur = 0;
    for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
      if (m1 & (1 << i)) continue;
      if (m2 & (1 << j)) continue;
      if (s[i][j] == '.') continue;
      cur++;
    }
    if (cur == k) result++;
  }
  cout << result << endl;
  return 0;
}


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

N, T = map(int, input().split())

a = [list(map(int, input().split())) for i in range(N)]

cost = 10000000

# print(a)

for i, risuto in enumerate(a):
    if risuto[1] <= T:
        if risuto[0] <= cost:
            cost = risuto[0]

if cost == 10000000:
    cost = 'TLE'

print(cost)






Measured memory_bytes: 2940
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

    public static void main(String[] $) {
        int n = sc.nextInt(), q = sc.nextInt();
        String s = sc.next();
        int[] AC = new int[n + 1];
        for (int i = 1; i < n; i++) {
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C') {
                AC[i] = 1;
            }
        }
        for (int i = 1; i < n + 1; i++) {
            AC[i] += AC[i - 1];
        }
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt(), r = sc.nextInt();
            int k = 0;
            if (r < n && s.charAt(r - 1) == 'A' && s.charAt(r) == 'C') k++;

            out.println(max(0, AC[r] - AC[l - 1] - k));
        }
        out.close();
    }
}

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

const int N = 5e6 + 5;

int n, k, p[N], q[N], du[N];
set <int> L, R;
vector <int> G[N];

typedef set <int> :: iterator it;

int main(void) {
	L.clear(); R.clear();
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++ i) {
		scanf("%d", &p[i]);
		q[p[i]] = i;
	}
	
	for (int i = 1; i < k; ++ i) {
		R.insert(p[i]);
	}
	for (int i = 1; i <= n; ++ i) {
		if (i + k - 1 <= n) R.insert(p[i + k - 1]);
		if (i) R.erase(p[i - 1]);
		
		L.insert(p[i]);
		if (i > k) L.erase(p[i - k]);
		
		it cur = R.upper_bound(p[i]);
		if (cur != R.end()) G[i].push_back(q[* cur]), ++ du[q[* cur]];
		cur = L.upper_bound(p[i]);
		if (cur != L.end()) G[i].push_back(q[* cur]), ++ du[q[* cur]];
	}
	
	L.clear(); R.clear();
	
	for (int i = 1; i <= n; ++ i) if (du[i] == 0) {
		L.insert(i);
	}
	
	int tp = 0;
	while (L.size()) {
		int pos = (* L.begin());
		p[ ++ tp] = pos;
		L.erase(L.begin());
		
		for (int i = 0; i < G[pos].size(); ++ i) {
			int v = G[pos][i]; -- du[v];
			if (du[v] != 0) continue;
			L.insert(v);
		}
	}
	
	for (int i = 1; i <= n; ++ i) {
		q[p[i]] = i;
	}
	
	for (int i = 1; i <= n; ++ i) {
		printf("%d\n", q[i]);
	}
	
	return 0;
}

Measured memory_bytes: 171648
#include<bits/stdc++.h>
#define endl '\n'
#define mp make_pair
typedef long long int ll;
using namespace std;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll arr[n+1];
    ll sum=0;
    for(int i=1;i<=n;i++){
        sum+=k+i-1;
    }
    vector<pair<ll,ll>> v;
    for(int i=1;i<=n;i++){
        ll val=sum-(k+i-1);
        v.push_back(mp(abs(val-sum),val));
    }
    sort(v.begin(),v.end());
    cout<<v[0].second<<endl;
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

template <uint MD> struct ModInt {
    using M = ModInt;
    uint v;
    ModInt() : v(0) {}
    ModInt(ll _v) { set_v(_v % MD + MD); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(ull(v) * r.v % MD); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<998244353>;

int n;
string s;
Mint dp[4020][2020];
bool used[4020][2020] = {};

Mint calc(int ph, int _r) {
    if (ph == 2 * n) return Mint(1);
    if (used[ph][_r]) return dp[ph][_r];
    used[ph][_r] = true;
    int r = _r;
    int b = 2 * min(n, ph) - ph - r;
    if (ph < n) {
        if (s[ph] == '0') r++;
        else b++;
        if (s[ph] == '2') b++;
        else r++;
    }
    Mint ans = 0;
    if (r) ans += calc(ph + 1, r - 1);
    if (b) ans += calc(ph + 1, r);

    return dp[ph][_r] = ans;
}

int main() {
    cin >> s;
    n = int(s.size());

    cout << calc(0, 0) << endl;
    return 0;
}



Measured memory_bytes: 40192
using System;
using System.Collections.Generic;
					
public class my
{
	public static void Main()
	{
		string s;

		int angle = 0;
		double x=0.0,y=0.0;
		while( null != ( s = Console.ReadLine() ) ){
			if(s == "0,0")	break;
			
			var n = Array.ConvertAll(s.Split(','), int.Parse);
			
			x += n[0] * Math.Sin(Math.PI*angle/180);
			y += n[0] * Math.Cos(Math.PI*angle/180);
			angle += n[1];
		}
		
		Console.WriteLine((int)x);
		Console.WriteLine((int)y);
	}
	
	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
	
		private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}

	private static int[] GetIntArray(int n)
	{
		var A = new int[n];
		var s = Console.ReadLine().Split(' ');

		for(int i = 0; i < n; i++) {
			A[i] = int.Parse(s[i]);
		}
		return A;
	}

	private static int[] GetIntArray(char c)
	{
		return Array.ConvertAll(Console.ReadLine().Split(c), int.Parse);
	}
	
	public static string Reverse(string s)
	{
		var c = s.ToCharArray();
		Array.Reverse(c);
		
		return new String(c);
	}
}

Measured memory_bytes: 9188