akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        br.lines().forEach(s -> {
            List<Integer> list = Arrays.stream(s.split(" "))
                    .map(Integer::parseInt)
                    .sorted(Comparator.naturalOrder())
                    .collect(Collectors.toList());

            int a = list.get(0);
            int b = list.get(1);

            if (a != 0 || b != 0) {
                System.out.println(a + " " + b);
            }
        });
    }
}

Measured memory_bytes: 34308
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Contrast
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

int as[MAX_N], bs[MAX_N], ds[MAX_N];
int acs[MAX_N + 1], bcs[MAX_N + 1];

/* subroutines */

void calccs(int n, int vs[], int cs[]) {
  cs[0] = 0;
  for (int v = 1, i = 0; v <= n; v++) {
    while (i < n && vs[i] == v) i++;
    cs[v] = i;
  }
}

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);
  for (int i = 0; i < n; i++) scanf("%d", bs + i);

  calccs(n, as, acs);
  calccs(n, bs, bcs);
  //for (int i = 0; i <= n; i++) printf("%d ", acs[i]); putchar('\n');
  //for (int i = 0; i <= n; i++) printf("%d ", bcs[i]); putchar('\n');

  int maxx = 0;
  for (int i = 1; i <= n; i++) {
    if (acs[i] - acs[i - 1] + bcs[i] - bcs[i - 1] > n) {
      puts("No");
      return 0;
    }

    int x = acs[i] - bcs[i - 1];
    if (maxx < x) maxx = x;
  }
  //printf("maxx=%d\n", maxx);

  for (int i = 0; i < n; i++) ds[(i + maxx) % n] = bs[i];

  puts("Yes");
  for (int i = 0; i < n; i++) {
    printf("%d", ds[i]);
    putchar(i + 1 < n ? ' ' : '\n');
  }
  return 0;
}


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

using namespace std;
typedef long long ll;

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

int main()
{
  int s, w; cin >> s >> w;
  if (s <= w) cout << "unsafe" << endl;
  else cout << "safe" << endl;
  return 0;
}


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


Measured memory_bytes: 3596
#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 < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int a, b;
	cin >> a >> b;
	cout << max(a - 2 * b, 0) << endl;
    
    return 0;
}



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

int main(void){
  int N;
  
  
  scanf("%d",&N);
  
  for(int i = 0; i <= N; i = i + 4){
    for(int j = 0; i + j <= N; j = j + 7){
      if(N == i+j){
        printf("Yes");
        return 0;
      }
    }
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD=1e9+7;
const int INF=1<<29;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m=MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
inline int modinv(int a){return powerexp(a,MOD-2,MOD);}
inline int lcm(int a,int b){int g=__gcd(a,b);return a/g*b;}

//-------------------< start here >-------------------------// 
void solve(){
    string s;
    cin >> s;
    set<int> c;
    map<char,int> m;
    for(auto it :s){
      m[it]++;		
	}
	for(auto it :m )c.insert(it.s);
	if((int)m.size()==2 and (int)c.size()==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;    
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
   #endif
}


Measured memory_bytes: 384
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

ll n,a,b,ans,inv[200005];

ll quick_pow(ll x,ll y)
{
	ll res=1;
	while(y)
	{
		if(y&1)
			res=res*x%MOD;
		x=x*x%MOD;
		y>>=1;
	}
	return res;
}

ll C(ll a,ll b)
{
	ll res=1;
	for(ll i=a;i>=a-b+1;i--)
	{
		res=res*i%MOD;
	}
	return res*inv[b]%MOD;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n>>a>>b;
	inv[1]=1;
	for(ll i=2;i<=200000;i++)
	{
		inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
	}
	for(ll i=2;i<=200000;i++)
	{
		inv[i]=inv[i-1]*inv[i]%MOD;
	}
	ans=(quick_pow(2,n)-1+MOD)%MOD;
	ans=(ans-C(n,a)+MOD)%MOD;
	ans=(ans-C(n,b)+MOD)%MOD;
	cout<<ans<<endl;
	return 0;
}

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

int main(){

    int N;
    cin >> N;
    vector<string> S(N);
    
    map<string,int> dic;
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
        dic[S.at(i)]++;
    }

    int maxV =0;
    for (auto di : dic) {
        auto v = di.second;
        maxV =max(maxV,v);
    }

    for (auto di : dic) {
        auto k = di.first;
        auto v = di.second;
        if(v == maxV){
            cout << k << endl;
        }
    }
}


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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            //ここまで
            int K = IO.ReadLineToInt();
            int ans;
            if (K % 2 == 0)
            {
                ans = (K / 2) * (K / 2);
            }
            else
            {
                ans = (K / 2) * ((K / 2) + 1);
            }
            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
    
    class Func
    {
        long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(int a, int b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }
        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    class IO
    {
        static public string ReadLineToString(){return Console.ReadLine();}
        static public int ReadLineToInt(){return int.Parse(Console.ReadLine());}
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray(){return Console.ReadLine().Split(' ').ToArray();}
        static public int[] ReadLineToIntArray(){return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();}
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList(){return Console.ReadLine().Split(' ').ToList();}
        static public List<int> ReadLineToIntList(){return Console.ReadLine().Split(' ').Select(int.Parse).ToList();}
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }   
    }
}


Measured memory_bytes: 13140
#include<iostream>
using namespace std;
 
int main(){
	int i,N,count=0;
	int a[8];
        cin >> N;
	a[0]=1;
if(N==0){cout << 1;}
 
	for(i=1;i<=7;i++){
		a[i]=a[i-1]*2;
	}
 
	for(i=0;i<=7;i++){
		if(N>=a[i]){
			count=a[i];
		}
	}
        cout << count;
	return 0;
}		

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main()
{
	unsigned short *A,*B;
	int C[VMAX+1];
	int n,j,i;
	scanf("%d",&n);
	
	A=malloc(sizeof(short)*n+1);
	B=malloc(sizeof(short)*n+1);
	for(i=0;i<=VMAX;i++)
	{
		C[i]=0;
	}
	for(i=0;i<n;i++)
	{
		scanf("%hu",&A[i+1]);
		C[A[i+1]]++;
	}
	for(i=1;i<=VMAX;i++)
	{
		C[i]=C[i]+C[i-1];
	}
	for(j=1;j<=n;j++)
	{
		B[C[A[j]]]=A[j];
		C[A[j]]--;
	}
	for(i=1;i<=n;i++)
	{
		if(i>1)printf(" ");
		printf("%d",B[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 9580
def solve():
    if N >= M:
        return 0
    elif N == 1:
        cnt = abs(X[-1] - X[0])
        return cnt
    L = [0] * (M-1)
    
    for i in range(len(L)):
        L[i] = X[i+1] - X[i]
    L.sort()
    return sum(L[:M-N])



if __name__=="__main__":
    N,M = list(map(int, input().split()))
    X = list(map(int, input().split()))
    X.sort()
    print(solve())


Measured memory_bytes: 20424
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        // スペース区切りの整数の入力
        int M = sc.nextInt();

        if(N > M){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

std::string S;
int Q;
std::deque<char> deq;

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

  std::cin >> S;

  for(char &c : S){
      deq.push_back(c);
  }

  std::cin >> Q;

  bool reversed = false;

  for(int i=0;i<Q;++i){
      int t;
      std::cin >> t;

      if(t == 1){
          reversed = !reversed;
      }else{
          int f;
          char c;
          std::cin >> f >> c;

          if(!reversed){
              if(f == 1){
                  deq.push_front(c);
              }else{
                  deq.push_back(c);
              }
          }else{
              if(f == 1){
                  deq.push_back(c);
              }else{
                  deq.push_front(c);
              }
          }
      }
  }

  if(!reversed){
      until(deq.empty()){
          std::cout << deq.front();
          deq.pop_front();
      }
  }else{
      until(deq.empty()){
          std::cout << deq.back();
          deq.pop_back();
      }
  }

  std::cout << std::endl;
}


Measured memory_bytes: 976
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
#include<unordered_set>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MOD = 1000 * 1000 * 1000 + 7;

const int MAX = 100 + 47;

string A[MAX];
int CNT[MAX];

bool canTake(int k, int cnt)
{
	FOR(i, 0, 26)
	{
		if (cnt == 0) break;
		while (CNT[i] >= k)
		{
			if (cnt == 0) break;
			CNT[i] -= k;
			cnt--;
		}
	}

	return cnt == 0;
}

void yes()
{
	cout << "Yes" << endl;
	exit(0);
}

void no()
{
	cout << "No" << endl;
	exit(0);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	//ios::sync_with_stdio(false); cin.tie(0);
	int n, m;
	cin >> n >> m;
	FOR(i, 0, n) cin >> A[i];

	FOR(i, 0, n)
	{
		FOR(j, 0, m) CNT[A[i][j] - 'a']++;
	}

	if (n % 2 == 0 && m % 2 == 0)
	{
		if (canTake(4, n * m / 4)) yes();
		no();
	}

	if (n % 2 != 0 && m % 2 != 0)
	{
		int cnt2 = n / 2 + m / 2;
		int cnt4 = (n * m - cnt2 * 2 - 1) / 4;
		if (!canTake(4, cnt4)) no();
		if (!canTake(2, cnt2)) no();

		yes();
	}

	if (m % 2 != 0) swap(n, m);
	int cnt2 = m / 2;
	int cnt4 = (m * n - cnt2 * 2) / 4;
	//cout << cnt2 << " " << cnt4 << endl;
	if (!canTake(4, cnt4)) no();
	if (!canTake(2, cnt2)) no();
	yes();
}

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N, M = map(int, raw_input().split())
c = [0,2,5,5,4,5,6,3,7,6]
A = sorted(map(int, raw_input().split()))

D = [0] + [-1] * N * 9
a = [0, 0] * N

for i in range(1, N + 1):
    for j in A:
        p = i - c[j]
        if min(p, D[p], D[p] + 1 - D[i]) >= 0:
            D[i], a[i] = D[p] + 1, j

S, p = "", N
while p:S,p=S+str(a[p]),p-c[a[p]]
print S

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

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

    string s;

    cin >> s;

    if (s.size() == 2) Out(s);
    else cout << s[2] << s[1] << s[0] << End;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

VI adj[112345];
int dp[15][112345] = {};

void func(int d, int v, int c){
    if(dp[d][v] != 0) return;

    dp[d][v] = c;
    if(d == 0) return;
    func(d-1,v,c);
    for(int u : adj[v]){
        func(d-1,u,c);
    }

}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    REP(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        adj[a].eb(b);
        adj[b].eb(a);
    }

    int Q; cin >> Q;
    VI V,D,C;
    REP(i,Q){
        int v,d,c; cin >> v >> d >> c;
        v--;
        V.eb(v);
        D.eb(d);
        C.eb(c);
    }
    dump("ok")
    for(int i = Q-1; i >= 0; i--){
        func(D[i],V[i],C[i]);
    }
    REP(i,N){
        cout << dp[0][i] << endl;
    }


}


Measured memory_bytes: 14456
#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#pragma warning(disable: 4996)
#define INF (1e9)
#define mod (ll(1e9)+7)

using namespace std;
typedef long long ll;
typedef long double ld;

ll x, y;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> x >> y;
	cout << x + y / 2;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main{
	static int[] sum=new int[10000];
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		while(true) {
			int o2ri=1000-sc.nextInt();
			if(o2ri==1000) {
				System.exit(0);
			}
			int coin=0;
			coin+=o2ri/500;
			o2ri%=500;
			coin+=o2ri/100;
			o2ri%=100;
			coin+=o2ri/50;
			o2ri%=50;
			coin+=o2ri/10;
			o2ri%=10;
			coin+=o2ri/5;
			o2ri%=5;
			coin+=o2ri;
			pl(coin);
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 24300
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, k = ns()
    a = na()

    dp = [False] * (k + 1)

    for i in range(k + 1):
        for ai in a:
            if i + ai < k + 1:
                dp[i + ai] |= not dp[i]
            else:
                break

    print("First" if dp[k] else "Second")


if __name__ == '__main__':
    main()


Measured memory_bytes: 11320
N = gets.to_i
P = gets.split.map(&:to_i)

sorted = P.sort

count = 0
P.each_with_index do |p, i|
  if p != sorted[i]
    count += 1
  end
end

if count == 0 || count == 2
  puts 'YES'
else
  puts 'NO'
end


Measured memory_bytes: 1788
import java.util.Scanner;

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

		int[] dishes = new int[5];

		for (int i = 0; i < 5; i++) {
			dishes[i] = Integer.parseInt(sc.next());
		}

		int one = 10;
		int oneIdx = 0;
		int sum = 0;

		for (int i = 0; i < 5; i++) {
			if (dishes[i] % 10 != 0 && dishes[i] % 10 < one) {
				one = dishes[i] % 10;
				oneIdx = i;
			}
		}

		for (int i = 0; i < 5; i++) {
			if (i == oneIdx) {
				sum += dishes[i];
			} else {
				sum += Math.ceil(dishes[i] / 10.0) * 10;
			}
		}

		System.out.println(sum);

	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){
      lint n,w;
      cin>>n>>w;
      vector<lint> a;
      vector<lint> b;
      vector<lint> c;
      vector<lint> d;
      lint g;
      rep(i,n){
          lint w,v;
          cin>>w>>v;
          if(i==0)g=w;
          if(g==w)a.push_back(v);
          else if((g+1)==w)b.push_back(v);
          else if((g+2)==w)c.push_back(v);
          else d.push_back(v);
      }
      lint ans=0;
      sort(all(a),greater<lint>());
      sort(all(b),greater<lint>());
      sort(all(c),greater<lint>());
      sort(all(d),greater<lint>());
  if(a.size()>=2){  rep(i,a.size()-1){
        a[i+1]+=a[i];
    }}
  if(b.size()>=2){  rep(i,b.size()-1){
        b[i+1]+=b[i];
    }}

  if(c.size()>=2){  rep(i,c.size()-1){
        c[i+1]+=c[i];
    }}
  if(d.size()>=2){  rep(i,d.size()-1){
        d[i+1]+=d[i];
    }}
    rep(i,a.size()+1){
        rep(j,b.size()+1){
            rep(k,c.size()+1){
                rep(l,d.size()+1){
                    lint comp=0;
                    if(i!=0)comp+=a[i-1];
                    if(j!=0)comp+=b[j-1];
                    if(k!=0)comp+=c[k-1];
                    if(l!=0)comp+=d[l-1];
                    if(i*g+j*(g+1)+k*(g+2)+l*(g+3)<=w)ans=max(ans,comp);

                }
            }
        }
    }
    cout<<ans<<endl;
  }
      

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  string s,t;
  cin >> s >> t;
  int n=t.size();
  for(int i=s.size()-1 ; i>=0 ; i--){
    if(i+n-1<s.size()){
      bool ok=true;
      if(s[i]=='?' || s[i]==t[0]){
        rep(j,0,n){
          if(s[i+j] != t[j] && s[i+j]!='?'){
            ok = false;
          }
        }
      }else{
        ok = false;
      }
      if(ok){
        rep(k,0,i){
          cout << (s[k]!='?' ? s[k] : 'a');
        }
        cout << t;
        rep(k,i+n,s.size()){
          cout << (s[k]!='?' ? s[k] : 'a');
        }
        cout << endl;
        return 0;
      }
    }
  }
  cout << "UNRESTORABLE" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
typedef long long ll;

using namespace std;

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

    sort(a, a+N);
    int res = 10000000;
    for (int x = a[0]; x <= a[N-1]; x++){
	int sum = 0;
	for (int i = 0; i < N; i++){
	    sum += (a[i]-x)*(a[i]-x);
	}

	res = min(res, sum);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<long double> A(N);
  REP(i,N)cin>>A[i];
  long double tmp=0;
  REP(i,N){
    tmp+=1.0/A[i];
  }
  cout<<setprecision(15)<<1.0/tmp<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <ctype.h>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(){
	
	string A,B;
	cin >> A >> B;
	if(A.size()<B.size()){
		cout << "LESS" << endl;
		return 0;
	}
	else if(A.size()>B.size()){
		cout << "GREATER" << endl;
		return 0;
	}
	else{

				int i = 0;

		while(i < A.size()){
			if((int)A[i] < (int)B[i]){
				cout << "LESS" << endl;
				return 0;
			}else if((int)A[i] >(int)B[i]){
				cout << "GREATER" << endl;
				return 0;
			}
			i++;
		}
		cout << "EQUAL" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

def main():
    n = int(input())
    abc = [list(map(int, input().split())) for _ in range(n)]

    dp = [0]*(n+1)
    for x in range(n+1):
        dp[x] = [0, 0, 0]

    for i in range(1, n+1):
        for j in range(3):
            for k in range(3):
                if j != k:
                    dp[i][k] = max(dp[i][k], dp[i-1][j] + abc[i-1][k])

    ans = 0
    for i in range(3):
        ans = max(ans, dp[n][i])
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 50232
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N, C; cin >> N >> C;
	vector<pair<ll, ll>> su(N);
	for (int i = 0; i < N; i++) {
		cin >> su[i].first >> su[i].second;
	}

	ll tot = 0;
	vector<pair<ll, ll>> left(N + 2);
	for (int i = 0; i < N; i++) {
		tot += su[i].second;
		left[i + 1].first = max(left[i].first, tot - su[i].first);
		left[i + 1].second = max(left[i].second, tot - 2 * su[i].first);
	}

	tot = 0;
	vector<pair<ll, ll>> right(N + 2);
	for (int i = N; i >= 1; i--) {
		tot += su[i - 1].second;
		right[i].first = max(right[i + 1].first, tot - (C - su[i - 1].first));
		right[i].second = max(right[i + 1].second, tot - 2 * (C - su[i - 1].first));
	}

	ll ans = -1;
	for (int i = 0; i <= N; i++) {
		ans = max(ans, left[i].first + right[i+1].second);
		ans = max(ans, left[i].second + right[i + 1].first);
	}

	cout << ans << endl;
}




Measured memory_bytes: 8008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)

int main(){
    int N,count =0, res = 0;
    cin >> N;
    rep(a,8,N+1){
        rep(i,1,N+1){
            if(a%i==0) count++;
        }
        if(count == 8 && a%2==1)res++;
        count = 0;
    }
    cout << res << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll par[214514];
ll ran[214514];
ll a[114514],b[114514],c[114514],d[114514];
ll num[114514],ans[114514];
ll root(ll x){
	return par[x]==x?x:par[x]=root(par[x]);
}
void unite(ll x,ll y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	if(ran[x]<ran[y])par[x]=y;
	else{
		par[y]=x;
		if(ran[x]==ran[y])ran[x]++;
	}
}
int main(){
	ll n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)par[i]=i;
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		unite(a[i],b[i]);
		ans[a[i]]--;
		ans[b[i]]--;
	}
	map<ll,ll>mp;
	for(int i=1;i<=n;i++)mp[root(i)]++;
	for(int i=1;i<=n;i++)ans[i]+=mp[root(i)]-1;
	for(int i=0;i<k;i++){
		cin>>c[i]>>d[i];
		if(root(c[i])==root(d[i])){
			ans[c[i]]--;
			ans[d[i]]--;
		}
	}
	for(int i=1;i<=n;i++){
		if(i==n)cout<<ans[i]<<endl;
		else cout<<ans[i]<<' ';
	}
	return 0;
}


Measured memory_bytes: 13824
n = int(input())
l = map(int, input().split())

min_n = 10**9

 
for i in l:
  num = 0
  while num < min_n:
    if i % 2 == 0:
      i = i//2
      num += 1
    else:
      break
  min_n = num

print(min_n)


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

int main() {

  	int N,K;
  	cin >> N;
  string s;
  cin >> s>>K;
  char x;
  x=s.at(K-1);
  
  for(int i=0;i<N;i++){
  if(x!=s.at(i)){
  cout << "*";
  }else{
  cout << x;
  }
  }
  	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

/* 二項係数 C(n,k) mod p を計算 */
const int MAX = 114514 * 2;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a , ll b){
  if (b == 0) return 1;

  if (b%2 == 0){
    ll  t = modpow(a, b/2)%MOD;
    return t*t % MOD;
  }else{
    ll t = modpow(a, (b-1)/2)%MOD;
    return a*t %MOD * t % MOD;
  }
}

ll inverse (ll a){
  return modpow(a,MOD-2)%MOD;
}

int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;

  COMinit();
  ll ans = 0;

  ll pa = A*inv[A+B] %MOD;
  ll pb = B*inv[A+B] %MOD;

  REP(i, N){
    ans   += (modpow(pa, N) * modpow(pb, i) % MOD
             + modpow(pa, i) * modpow(pb, N) % MOD)
             * (N+i) % MOD
             * COM(N+i-1, i) % MOD
             ;
    ans %= MOD;
  }
  ans *= 100 % MOD * inv[100-C] % MOD;
  ans %= MOD;
  cout << ans << endl;
}

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

flag = True
swap_count = 0
for i in range(N):
    if p[i] != i+1:
        if swap_count == 0:
            j = p[i] - 1
            tmp = p[j]
            p[j] = p[i]
            p[i] = tmp
            swap_count += 1
        else:
            flag = False
            break

if flag:
    print("YES")
else:
    print("NO")


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

int main()
{
  vector<string> D = {"", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
  string S;
  cin >> S;
  for (int i = 0; i < 8; i++)
  {
    if (S == D[i])
      cout << i << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		for(int i = 0; i < K; i++) {
			if(i % 2 == 0) {
				if(A % 2 == 1) {
					A--;
				}
				B += A / 2;
				A = A /2;
			} else {
				if(B % 2 == 1) {
					B--;
				}
				A += B / 2;
				B = B /2;
			}
		}
		System.out.println(A + " " + B);
	}
}


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

int main(){
    string s;
    cin >> s;
    int len = s.length();
    cout << s[0] << len-2 << s[len-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int R, C; string s[20]; bool flag, visited[20][20][4][16];
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
void rec(int x, int y, int d, int m) {
	if (!visited[y][x][d][m]) {
		visited[y][x][d][m] = true;
		switch (s[y][x]) {
		case '>':
			rec((x + 1) % C, y, 0, m); break;
		case 'v':
			rec(x, (y + 1) % R, 1, m); break;
		case '<':
			rec((x - 1 + C) % C, y, 2, m); break;
		case '^':
			rec(x, (y - 1 + R) % R, 3, m); break;
		case '_':
			if (m == 0) rec((x + 1) % C, y, 0, m); else rec((x - 1 + C) % C, y, 2, m); break;
		case '|':
			if (m == 0) rec(x, (y + 1) % R, 1, m); else rec(x, (y - 1 + R) % R, 3, m); break;
		case '?':
			for (int i = 0; i < 4; i++) rec((x + dx[i] + C) % C, (y + dy[i] + R) % R, i, m); break;
		case '.':
			rec((x + dx[d] + C) % C, (y + dy[d] + R) % R, d, m); break;
		case '@':
			flag = true; return;
		case '+':
			rec((x + dx[d] + C) % C, (y + dy[d] + R) % R, d, (m + 1) % 16); break;
		case '-':
			rec((x + dx[d] + C) % C, (y + dy[d] + R) % R, d, (m + 15) % 16); break;
		default:
			rec((x + dx[d] + C) % C, (y + dy[d] + R) % R, d, s[y][x] - 48); break;
		}
	}
}
int main() {
	scanf("%d%d", &R, &C);
	for (int i = 0; i < R; i++) cin >> s[i]; rec(0, 0, 0, 0);
	printf("%s\n", flag ? "YES" : "NO");
	return 0;
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    vector<int> b(10001);

    REP(i,(n-1))cin >> b.at(i);

    ans+= b[0];

    FOR(i,1,n){
        ans += min(b[i],b[i-1]);
    }
    ans += b[n-2];

    cout << ans << endl;
}

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

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

int main() {
    ll A, B, N;
    cin >> A >> B >> N;
    ll x = N;
    if (N >= B - 1) x = B - 1;
    ll ans = A * x / B - A * (x / B);
    cout << ans << endl;
}


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

#define MAX 10000009
#define INF 99999999
#define MIN -99999999
#define in(a,b)  ( (b).find(a) != (b).end())
#define clr(a,b) memset((a), (b), sizeof((a)))
#define pb       push_back
#define all(a)   a.begin(), a.end()
#define mp       make_pair
#define ll	long long
#define FI	first
#define SE second


using namespace std;
int n,a,b;
int main() {
   
    cin >> n >> a >> b ;
    cout << min(n*a,b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void query(int A,int B,int C,int D){
	int lim=(A+B)/(min(A,B)+1);
	if (lim==1){
		if (B==A+1) C--,D--;
		for (int i=C;i<=D;i++) putchar('B'-(i&1));
		puts("");
		return;
	}
	//之前一直是lim个A和一个B，二分次数 
	int l=0,r=min(A/lim,B),p=0;
	while (l<r){
		int mid=(l+r)>>1,a=A-lim*mid,b=B-mid;
		if (min(min(lim,a),a+1-(b+lim-1)/lim)==lim) l=mid+1;else r=mid;
	}
	int times=l;
	p=(lim+1)*times;A-=times*lim;B-=times;
	for (int i=C;i<=D&&i<=p;i++) putchar('A'+(i%(lim+1)==0));
	while (A>0||B>0){
		int lena=min(min(lim,A),A+1-(B+lim-1)/lim);
		if (!lena) break;
		int l=p+1,r=p+=lena;
		for (int i=max(l,C);i<=min(r,D);i++) putchar('A');
		A-=lena;
		if (!B) break;
		p++;
		if (C<=p&&p<=D) putchar('B');
		B--;
	}
	int lenb=B-A*lim;l=p+1;r=p+=lenb;
	for (int i=max(l,C);i<=min(r,D);i++) putchar('B');
	B-=lenb;
	//剩下的部分一个A和lim个B 
	C-=p;D-=p;
	for (int i=max(C,1);i<=D;i++) putchar('A'+(i%(lim+1)!=1));
	puts("");
}
int main()
{
	int Q;
	scanf("%d",&Q);
	while (Q--){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		query(a,b,c,d);
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;

int main(){
  int a;
  cin >> a;
  int ans = floor(sqrt(a))*floor(sqrt(a));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	final static int MOD = 1000000007;
	
	public static void main(String[] args) {
		MyScanner in = new MyScanner();
		int n = in.nextInt();
		int[] b = in.nextIntArray(n-1);
		
		long sum = b[0];
		
		for (int i = 0; i < b.length-1; i++) {
			sum += Math.min(b[i],b[i+1]);
		}
		sum += b[b.length-1];
		System.out.println(sum);
		
		
	}
	
	static class MyScanner {
		static Scanner sc = new Scanner(System.in);
		
		String next() {
			return sc.next();
		}
		
		String nextLine() {
			return sc.nextLine();
		}
		
		int nextInt() {
			return Integer.parseInt(sc.next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextInt();
			}
			return array;
		}
		
		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextDouble();
			}
			return array;
		}
		
		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}
			return array;
		}
		
		String[] nextLineArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLine();
			}
			return array;
		}
		
		int[][] nextIntMatrix(int n, int m) {
			int[][] matrix = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextInt();
				}
			}
			return matrix;
		}
		
		double[][] nextDoubleMatrix(int n, int m) {
			double[][] matrix = new double[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextDouble();
				}
			}
			return matrix;
		}
		
		long[][] nextLongMatrix(int n, int m) {
			long[][] matrix = new long[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextLong();
				}
			}
			return matrix;
		}
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
  int H, W, N;
  cin >> H >> W >> N;
  vector<pair<int, int>>gyo(H + 1);
  vector<pair<int, int>>retu(W + 1);
  vector<int>Y(N);
  vector<int>X(N);
  for (int i = 0; i <= H; i ++) gyo[i] = make_pair(0, i);
  for (int j = 0; j <= W; j ++) retu[j] = make_pair(0, j);
  for (int i = 0; i < N; i ++) {
    int h, w;
    cin >> h >> w;
    gyo[h].first ++;
    retu[w].first ++;
    Y[i] = h;
    X[i] = w;
  }
  sort(gyo.begin(), gyo.end());
  sort(retu.begin(), retu.end());
  int hma = gyo[H].first;
  int fli = H;
  vector<bool> bombi(H + 1, false);
  vector<bool>bombj(W + 1, false);
  while (gyo[fli].first >= hma) {
    bombi[gyo[fli].second] = true;
    //cout << gyo[fli].second << endl;
    fli --;
  }
  //cout << endl;
  int flj = W;
  int wma = retu[W].first;
  while (retu[flj].first >= wma) {
    bombj[retu[flj].second] = true;
    //cout << retu[flj].second << endl;
    flj --;
  }
  //cout << endl;
  ll di = (ll) H - fli;
  ll dj = (ll) W - flj;
  ll key = di * dj;
  ll ans = 0;
  for (int i = 0; i < N; i ++) {
    if (bombi[Y[i]] && bombj[X[i]]) ans ++;
  }
  if (ans == key) wma --;
  cout << hma + wma << endl;
}

Measured memory_bytes: 10360
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<pii>>;
const int MOD = 1e9 + 7;

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

    int H, W;
    cin >> H >> W;

    vector<vector<bool>> isodd(H, vector<bool>(W));
    int cnt = 0;
    int u = -1;
    for (int i = 0; i < H; ++i) {
        int l = -1;
        for (int j = 0; j < W; ++j) {
            int a;
            cin >> a;
            if (isodd[i][j] = a % 2) {
                if (~l) {
                    cnt += j - l;
                    l = -1;
                } else
                    l = j;
            }
        }
        if (~l) {
            cnt += W - l - 1;
            if (~u) {
                cnt += i - u;
                u = -1;
            } else
                u = i;
        }
    }
    if (~u)
        cnt += H - u - 1;

    printf("%d\n", cnt);
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (i == H - 1 && j == W - 1)
                break;
            if (isodd[i][j]) {
                printf("%d %d ", i + 1, j + 1);
                if (j + 1 < W) {
                    isodd[i][j + 1] = !isodd[i][j + 1];
                    printf("%d %d\n", i + 1, j + 2);
                } else if (i + 1 < H) {
                    isodd[i + 1][j] = !isodd[i + 1][j];
                    printf("%d %d\n", i + 2, j + 1);
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define c4(n,m,k,l) cin>>n>>m>>k>>l
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  long a,b=2,c=0,d=0,e,n,m=0;
  c(n);
  int x[n];
  rep(i,0,n) c(x[i]);
  sort(x,x+n);
  co(x[n-1]-x[0]);
  
  return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
pts = [tuple(map(int, input().split())) for _ in range(n)]

num_nodes = n * (n - 1)
num_node_sel_total = math.factorial(n) * (n - 1)
num_node_sel = num_node_sel_total / num_nodes

ans = 0
for src in range(n):
    for dst in range(n):
        if src != dst:
            (src_x, src_y) = pts[src]
            (dst_x, dst_y) = pts[dst]
            d = math.sqrt((dst_x - src_x) ** 2 + (dst_y - src_y) ** 2)
            ans += d * num_node_sel
print(ans/math.factorial(n))


Measured memory_bytes: 9120
#include<iostream>
using namespace std;
int main(){
	int x,y,sx,sy;
	cin>>x>>y>>sx>>sy;
	int dx=sx-x;
	int dy=sy-y;
	cout<<"D";
	for(int i=0;i<dx+1;i++) cout<<"R";
	for(int i=0;i<dy+1;i++) cout<<"U";
	cout<<"L";
	for(int i=0;i<dy;i++) cout<<"D";
	for(int i=0;i<dx;i++) cout<<"L";
	for(int i=0;i<dy;i++) cout<<"U";
	for(int i=0;i<dx;i++) cout<<"R";
	cout<<"U";
	for(int i=0;i<dx+1;i++) cout<<"L";
	for(int i=0;i<dy+1;i++) cout<<"D";
	cout<<"R"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int n;
lint dp[101][4][4][4];
const lint MOD = 1e9+7;

signed main(){
  cin >> n;
  if(n == 3){
    cout << 61 << endl;
    return 0;
  }
  dp[0][3][3][3] = 1;
  for(int i = 0; i < n; i++){
    for(int c1 = 0; c1 < 4; c1++){
      for(int c2 = 0; c2 < 4; c2++){
        for(int c3 = 0; c3 < 4; c3++){
          if(dp[i][c1][c2][c3] == 0) continue;
          for(int c4 = 0; c4 < 4; c4++){
            if(c2 == 0 && c3 == 1 && c4 == 2) continue;
            if(c2 == 1 && c3 == 0 && c4 == 2) continue;
            if(c2 == 0 && c3 == 2 && c4 == 1) continue;
            if(c1 == 0 && c2 == 1 && c4 == 2) continue;
            if(c1 == 0 && c3 == 1 && c4 == 2) continue;
            dp[i + 1][c2][c3][c4] += dp[i][c1][c2][c3];
            dp[i + 1][c2][c3][c4] %= MOD;
          }
        }
      }
    }
  }
  lint ans = 0;
  for(int c1 = 0; c1 < 4; c1++){
    for(int c2 = 0; c2 < 4; c2++){
      for(int c3 = 0; c3 < 4; c3++) ans += dp[n][c1][c2][c3], ans %= MOD;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int N, M;

  cin >> N >> M;
  vector<int> as(N);
  for(int i = 0; i < N; ++i) {
    cin >> as[i];
  }
  sort(as.begin(), as.end()); // 昇順
  int b;
  int c;
  vector<pair<int, int>> cs(M);
  for(int i = 0; i < M; ++i) {
    cin >> cs[i].second >> cs[i].first;
  }
  sort(cs.begin(), cs.end(), [](auto pa, auto pb) { return pa.first > pb.first; });
  vector<int> css;
  int idx = 0;
  while(css.size() < N && idx < cs.size()) {
    auto v = cs[idx];
    for(int i = 0; i < v.second; ++i) {
      css.push_back(v.first);
      if(css.size() >= N) {
        break;
      }
    }
    idx++;
  }
  ll total = 0;
  for(int i = 0; i < N; ++i) {
    if(i < css.size()) {
      total += max(as[i], css[i]);
    } else {
      total += as[i];
    }
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 2044