akhauriyash/Code-Regression huggingface dataset:
/*
csc -debug C.cs && mono --debug C.exe <<< "5
1 2 1 1 3"
*/

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Reflection;

public class HelloWorld {
    public static void SolveCodeForces() {
        var N = cin.NextInt();
        var H = cin.LongArray();
        var prev = H[0] - 1;
        for (var i = 1; i < H.Length; i++) {
            var h = H[i];

            if (h < prev) {
                System.Console.WriteLine("No");
                return;
            }
            if (h > prev) {
                h--;
            }

            prev = h;
        }
        System.Console.WriteLine("Yes");
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public static class Helpers {
    public static string Join<T>(this IEnumerable<T> arr, string sep = " ") {
        return string.Join(sep, arr);
    }

    public static void Swap<T>(ref T a, ref T b) {
        var tmp = a;
        a = b;
        b = tmp;
    }

    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}

Measured memory_bytes: 25180
while 1:
    try:
        n = float(input())
        if n <= 48:
            print('light fly')
        elif 48 < n and n <= 51:
            print('fly')
        elif 51 < n and n <= 54:
            print('bantam')
        elif 54 < n and n <= 57:
            print('feather')
        elif 57 < n and n <= 60:
            print('light')
        elif 60 < n and n <= 64:
            print('light welter')
        elif 64 < n and n <= 69:
            print('welter')
        elif 69 < n and n <= 75:
            print('light middle')
        elif 75 < n and n <= 81:
            print('middle')
        elif 81 < n and n <= 91:
            print('light heavy')
        elif 91 < n:
            print('heavy')
    except:
        break
    


Measured memory_bytes: 5576
// AtCoder.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <math.h>
#include <cmath>

using namespace std;

bool sol(){
    int k, a, b;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++){
        if(i % k == 0) return true;
    }
    return false;
}

int main() {
    if(sol()) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
using namespace std;

int main()
{
    int n;
    int i, judge = 1, time, dist;
    
    cin >> n;
    
    int t[n], x[n], y[n];
    
    for(i = 0; i < n; i++) {
        cin >> t[i] >> x[i] >> y[i];
        
        if(i == 0) {
            time = t[i];
            dist = x[i] + y[i];
        } else {
            time = t[i] - t[i-1];
            dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
        }
        
        if((dist > time) || ((dist % 2) != (time % 2))) {
            judge = 0;
        }
    }
    
    
    if(judge == 1) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 1408
#include <cstdlib>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int K;
	cin >> K;
	ll md = 7 % K;
	ll cnt = 1;
	set<int> st;
	while (st.count(md) == 0)
	{
		st.insert(md);
		if (md == 0) {
			cout << cnt << endl;
			return 0;
		}
		md = (md * 10 + 7) % K;
		cnt++;
	}
	cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 50344
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		String s = sc.next();
        int ans = 0;
        int count = 0;
        for(int i=0;i<3;i++){if(s.charAt(i)=='R'){count++;}
                             else{ans=Math.max(ans,count);
                                 count=0;}
                            }        
		System.out.println(Math.max(ans,count));
	}
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);	
  string s, t;
  cin >> s >> t;
  cout << (s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2]);
  return 0;
} 

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

int main(){
    string s;
    cin >> s;
    int cnt0 = 0,cnt1 = 0;
    for (int i = 0;i < s.size();i++){
        if (s[i] == '0') cnt0++;
        if (s[i] == '1') cnt1++;
    }

    cout << 2 * min(cnt0,cnt1) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int a, b, t; cin >> a >> b >> t;
    t = t / a;
    cout << t * b << endl;
}

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

using ll = long long;

int main(){
  long long int h,w;
  cin >> h >> w;
  long long int ans=0;
  ans = ( (h*w) +1) / 2;
  int minnum = min(h,w);

  cout << (minnum==1 ? 1 : ans) << endl;
}

/*
クッソ直感的にはマスの数/2が答えな気がする
常に左上からスタート
偶*偶、偶*奇、奇*偶 → いわずもがな
奇*奇 → 左上マスからスタートなので四隅のマスは到達可能、よって到達可能マスのほうが1マス多い
HW<=1e9なのでmax=1e18


※※※※※※※※※※※
！！コーナーケース！！
※※※※※※※※※※※
1行・1列の構成は「動けない！！」←確かに！！！！
*/

Measured memory_bytes: 256
#include <stdio.h>

char convert_mark(int i);

int main(int argc, char *argv[])
{
  int cards[4][13 + 1];
  int n, i, j;
  char mark, ret;
  int rank;
  
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 14; j++) {
      cards[i][j] = 0;
    }
  }
  
  scanf("%d", &n);
  scanf("%c", &ret);

  for (i = 0; i < n; i++) {
    scanf("%c", &mark);
    scanf("%d", &rank);
    scanf("%c", &ret);
    switch (mark) {
    case 'S':
      cards[0][rank] = 1;
      break;
      
    case 'H':
      cards[1][rank] = 1;
      break;
      
    case 'C':
      cards[2][rank] = 1;
      break;
      
    case 'D':
      cards[3][rank] = 1;
      break;
    }
  }
  
  for (i = 0; i < 4; i++) {
    for (j = 1; j <= 13; j++) {
      if (cards[i][j] == 0) {
        printf("%c %d\n", convert_mark(i), j);
      }
    }
  }
  
  return 0;
}

char convert_mark(int i)
{
  switch (i) {
  case 0:
    return 'S';
    
  case 1:
    return 'H';
    
  case 2:
    return 'C';
    
  case 3:
    return 'D';
    
  default:
    return 'X';
  }
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
 int N,K,i,sum=0;
  
  cin>>N>>K;
  
 for(i=0;i<N;i++)
 {
   int x;
   cin>>x;
   
   if(x>K/2)
   {
     x= K-x;
   }
   
   sum+=x*2;
 }
  
  cout<<sum<<endl;
  
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  switch (x) {
    case 7:
    case 5:
    case 3:
      cout << "YES" << endl;
      break;

    default:
      cout << "NO" << endl;
      break;
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int swap(int ,int );

int main()
{
  int x,y,n,i,m;

  scanf("%d%d",&x,&y);
  if(x <= y) m = swap(x,y);
  else m = swap(y,x);

  printf("%d\n",m);
      
      return 0;
    }
int swap(int a,int b)
{
  int r;
  
  while(b > 0)
    {
      r = a % b;
      a = b;
      b = r;
    }

      return a;
}



Measured memory_bytes: 2144
//??§????????????????????????????????????(k??????????????????k-1???????????????)
#include <iostream>
#include <cmath>
#define int long long
using namespace std;

int n;
int s, d;

int next(int pos, int maxPos) {
	int x = abs(pos);
	int i;
	for (i = 0; (x >> i) % 2 == 0 && i < 30; i++);
	for (; i >= 0 && pos + (1 << i) > maxPos; i--);
	return pos + (1 << i);
}

signed main() {
	cin >> n;
	
	for(int i = 0; i < n; i++ ) {
		cin >> s >> d;
		
		int cnt = 0;
		while (s < d) {
			s = next(s, d);
			cnt++;
		}
		
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
if __name__ == "__main__":
    S = input()
    count_right = 0
    count_left = 0
    prev = ""
    a = []

    current = 0
    for i, s in enumerate(S):
        if prev == ">" and s == "<":
            a.append((count_left, count_right))
            count_left = 0
            count_right = 0
        if s == ">":
            count_right += 1
            prev = ">"
            # a.append((count_left)
        else:
            count_left += 1
            prev = "<"
    a.append((count_left, count_right))
    s = 0
    for x in a:
        large = max(x[0], x[1])
        small = min(x[0], x[1])
        s += sum(range(large + 1)) + sum(range(small))
    print(s)


Measured memory_bytes: 13212
import sys
from operator import itemgetter


def solve(tasks):
    tasks.sort(key=itemgetter(1))
    t = 0
    for a, b in tasks:
        t += a
        if t > b:
            return False
    return True


n = int(input())
tasks = [tuple(map(int, line.split())) for line in sys.stdin]
print('Yes' if solve(tasks) else 'No')


Measured memory_bytes: 31876
#include<bits/stdc++.h>
#define i64 long long 

using namespace std;

int main()
{
    string s;
    string t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0;i<3;i++)if(s[i]==t[i])cnt++;
    cout<<cnt;

}
/*
 
Code written by a random fan of Tokyo_Square 
gb_DH_VNU

 */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define MANX MAXN
#define itn int
#define in(x); { for (auto &to : x) cin>>to;}
#define out(x); { for (auto &to : x) cout<<to<<" ";cout<<'\n'; }

const ll INFLL = 1e18;
const int MAXN = 5e5+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;
int f[MAXN];
void add(int x,int pos)
{
    for (;pos<MAXN;pos|=pos+1)
        f[pos]+=x;
}

int res(int l)
{
    int sum=0;
    for (;l>=0;l=((l+1)&l)-1)
        sum+=f[l];
    return sum;
}

int res(int l,int r)
{
    return res(r)-res(l-1);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef Mip182
    freopen("a.in","r",stdin);
    #endif
    map <int,int> m;
    int n,q;
    cin>>n>>q;
    vi c(n);
    rep(i,n)
    cin>>c[i];
    vector <pair <pii,int> > qu(q);
    rep(i,q)
    cin>>qu[i].fi.fi>>qu[i].fi.se,qu[i].fi.fi--,qu[i].fi.se--,qu[i].se=i;
    vi ans(q);
    sort(rall(qu));
    int now=n;
    for (auto to:qu)
    {
        int x=to.fi.fi,y=to.fi.se;
        while (now>x)
        {
            now--;
        //    cout<<now<<'\n';
            if (m.find(c[now])==m.end())
                add(1,now),m[c[now]]=now;
            else {
           //     cout<<m[c[now]]<<'\n';
                add(-1, m[c[now]]), m[c[now]] = now,add(1,now);
              //  cout<<m[c[now]]<<'\n';
            }
        }
      //  cout<<to.se<<'\n';
        ans[to.se]=res(x,y);
    }
    for (auto to:ans)
        cout<<to<<'\n';


    //n=1 ?
    //recursion - matrix exponential
    //linear algebra - just a joke
    //check ios_base, MAXN, mod1 before submit
    //if debug more than 15 minutes - write stress
    //compression
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;++i) cin >> h[i];
  vector<int> cost(n);
  cost[0] = 0;
  cost[1] = abs(h[0] - h[1]);

  for(int i=2;i<n;++i) {
    cost[i] = min(cost[i-2] + abs(h[i]-h[i-2]), cost[i-1] + abs(h[i]-h[i-1]));
  }

  cout << cost[n-1] << endl;
}

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

N = int(input())
A = list(map(int, input().split()))
B = []
ans = []
for i in range(N):
    B.append([A[i], i+1])

B.sort(key = lambda x:x[0])
for i in range(N):
    ans.append(B[i][1])
print(*ans)

Measured memory_bytes: 23656
import sys
N,M=map(int,input().split())
if abs(N-M)>=2:
    print(0)
    sys.exit()
if N<M:
    N,M=M,N#Nが大きい
table=[1]*(N+1)
mod=10**9+7
for i in range(1,N+1):
    table[i]=(table[i-1]*i)%mod
if N!=M:
    ans=(table[N]*table[M])%mod
    print(ans)
    sys.exit()
print((2*table[N]*table[M])%mod)

Measured memory_bytes: 39280
def main():
    from itertools import combinations_with_replacement

    N, M, Q = map(int, input().split())

    conds = []
    for _ in range(Q):
        a, b, c, d = map(int, input().split())
        a -= 1
        b -= 1
        conds.append((a, b, c, d))

    ans = 0
    for temp_A in combinations_with_replacement(iterable=range(1, M + 1), r=N):
        # print(*temp_A)
        t = 0
        for ai, bi, ci, di in conds:
            c = temp_A[bi] - temp_A[ai]
            if c == ci:
                t += di
        ans = max(ans, t)
    print(ans)


if __name__ == '__main__':
    main()

# def choose(n, r):
#     ret = 1
#     for i in range(r):
#         ret *= n - i
#     for i in range(r):
#         ret //= (i + 1)
#     print(ret)
#
# print(choose(20, 10))
# # 184756


Measured memory_bytes: 9144
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y%2) res=(x*res)%hell;
    x=(x*x)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();

void fastIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);


/*class CompareDist
{
public:
    bool operator()(pair<ll,int> a,pair<ll,int> b) {
        if(a.F!=b.F)
        return a.F<b.F;
        else
        return a.S>b.S;
    }
};*/

bool comp(pair<ll,ll> a,pair<ll,ll> b){
  if(a.S!=b.S)
  return (a.S<b.S);
  else
  return a.F<b.F;
}

ll p[3];
char mat[16][16];
int si,sj,ei,ej;
vector<ll> res;
bool vis[16][16];

bool issafe(int i,int j,int n,int m){
  return (i>=0 && j>=0 && i<n && j<m && mat[i][j]=='.');
}
int dx[]={0,1,-1};
int dy[]={1,1,1};

void dfs(int i,int j,int n,int m,ll cp){
  if(i==ei && j==ej){
    //cout<<cp<<'\n';
    res.pb(cp);
    return;
  }

  vis[i][j]=true;

  for(int k=0;k<3;k++){
    int nx=i+dx[k];
    int ny=j+dy[k];
    if(issafe(nx,ny,n,m) && vis[nx][ny]==false){
        dfs(nx,ny,n,m,(cp*p[k])%hell);
    }
  }
  vis[i][j]=false;
}


void solve(){

  int test;
  //cin>>test;
  test=1;
  while(test--){
      string s;
      cin>>s;
      int n=s.length();
      int ans=0;
      for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1])
        ans++;
      }
      cout<<ans;
  }
}




/*bool issafe(int x,int y){
  return (x>=0 && y>=0 && x<n && y<m);
}*/

///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}

/*void sieve(){

  for(int i=2;i<=1000000;i++){
    if(prime[i]==true){
      for(int j=i*i;j<=1000000;j+=i)
      prime[j]=false;
    }
  }

}*/


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vector<pair<ll,ll>>num(n);
  for(int i=0;i<n;i++){cin>>num[i].F;num[i].S=i+1;}
  sort(ALL(num));
  set<ll>se;
  ll ans=0;
  se.insert(0);se.insert(n+1);
  for(int i=0;i<n;i++){
    auto lb = se.lower_bound(num[i].S);
    ll rnum=*lb-num[i].S-1;
    // cout<<*lb<<" ";
    ll lnum=num[i].S-*(--lb)-1;
    //cout<<*lb<<" "<<i+1<<" "<<rnum<<" "<<lnum<<endl;
    se.insert(num[i].S);
    ans+=(rnum+lnum+rnum*lnum+1)*num[i].F;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12800
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n, d = nm()
    ans = 0
    for _ in range(n):
        x, y = nm()
        if x ** 2 + y ** 2 <= d ** 2:
            ans += 1
    print(ans)
    return

solve()


Measured memory_bytes: 9204
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
 
int main(void)
{
  int N;
  int i = 0;
  int A[100] = {};
  double sum=0;
  
  
  scanf("%d", &N);
  for(i=0;i<N;i++){
  	scanf("%d", &A[i]);
  }
  
  for(i=0;i<N;i++){
    sum += 1.0/A[i];
  }
  printf("%.7f", 1/sum);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
const long long INF = 1LL << 60;

int main() {
  int N; cin>>N;
  vector<int> B(N+1);
  bool muri=1;
  for(int i=1; i<=N; i++){
    int b; cin>>b;
    B.at(i)=b;
    if(b==2) muri=0;
  }
  if(muri) cout<<-1<<endl;
  else{
    int ikeru=1;
    int count=0;
    int pika=1;
    map<int, int> kiseki;
    kiseki[pika]=1;
    while(ikeru){
      count++;
      pika=B.at(pika);
      if(pika==2) break;
      if(kiseki.count(pika)) ikeru=0;
      kiseki[pika]=1;
    }
    if(ikeru) cout<<count<<endl;
    else cout<<-1<<endl;
  } //else
}


Measured memory_bytes: 5376
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  t = "";
  rep(i,0,3){
    cin >> s;
    t += s[i];
  }
  print(t);
  return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) FOR(i,0,a)
#define RREP(i,a) RFOR(i,a,0)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) sort(ALL(a))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<int> VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::pair<int,int> PII;

template<class T> struct UnionFind {
    std::vector<T> data;
    UnionFind(T size): data(size, -1){};
    T root(T x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    bool same(T x, T y) {
        return root(x) == root(y);
    }
    T size(T x) {
        return -data[root(x)];
    }
    bool unite(T x, T y) {
        x = root(x);
        y = root(y);
        if(x != y){
            if(data[y] < data[x]){
                std::swap(x, y);
            }
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
};

int main(){
    int n, q;
    int c, x, y;

    std::cin >> n >> q;
    UnionFind<int> tree = UnionFind<int>(n);
    REP(i, q){
        std::cin >> c >> x >> y;
        if(c == 0){
            tree.unite(x,y);
        } else {
            std::cout << (tree.same(x,y) ? 1 : 0) << std::endl;
        }
    }
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  string str;
  cin >> str;
  
  int sum1 = 0 ;
  int sum2 = 0 ;
  
  for(int i = 0 ; i < str.size() ; i += 2){
      if(str.at(i) != '0'){
        sum1++ ;
      }
  }
  
  for(int i = 1 ; i < str.size() ; i += 2){
      if(str.at(i) != '1'){
        sum1++ ;
      }
  }
  
  for(int i = 0 ; i < str.size() ; i += 2){
      if(str.at(i) != '1'){
        sum2++ ;
      }
  }
  
  for(int i = 1 ; i < str.size() ; i += 2){
      if(str.at(i) != '0'){
        sum2++ ;
      }
  }
  
  cout << min(sum1 , sum2) << endl;

}

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

class Program
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string[]strs = Console.ReadLine().Split(' ');
        List<int> L = new List<int>() { Capacity = N };
        foreach (var i in strs)
            L.Add(int.Parse(i));
        L.Sort();
        int min = int.MaxValue;
        for(int i = L[0]; i <= L[N - 1]; i++)
        {
            int s = 0;
            foreach (var j in L)
                s += (j - i)* (j - i);
            min = Math.Min(min, s);
        }
        Console.WriteLine(min);
    }
}

Measured memory_bytes: 13268
import math
k = int(input())
ans = 0

for a in range(1, k+1):
    for b in range(1, a+1):
        for c in range(1, b+1):
            g_ab = math.gcd(a ,b)
            g_abc = math.gcd(g_ab, c)
            if a != b != c:
                ans += g_abc * 6
            elif a == b == c:
                ans += g_abc
            else:
                ans += g_abc * 3
print(ans)

Measured memory_bytes: 9196
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
    int[] ary = {s.nextInt(), s.nextInt(), s.nextInt()};
    Arrays.sort(ary);
    System.out.println(ary[0] + " " + ary[1] + " " + ary[2]);
	}
}


Measured memory_bytes: 26288
def main():
    a, b, c = map(int, input().split())
    if c - a - b < 0:
        print('No')
        exit()
    if 4 * a * b < (c - a - b) ** 2:
        print('Yes')
    else:
        print('No')



if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
const string tr="abcdefghijklmnopqrstuvwxyz";
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll 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(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}
bool ip/*is_prime*/(long long N) {if (N == 1) return false;for (long long i = 2; i * i <= N; ++i) {if (N % i == 0) return false;}return true;}
int digit(ll N) {int ans = 0;while (N) {++ans;N /= 10;}return ans;}
vector<pair<ll,ll>> pf/*prime_factorize*/(ll n){vector<pair<ll,ll>> res;for(ll a=2;a*a<=n;a++){if(n%a!=0) continue;ll ex=0;while(n%a==0){ex++;n/=a;}res.pb({a,ex});}if(n!=1) res.pb({n,1});return res;}
vector<ll> div/*divisor*/(ll n){  vector<ll> res={1};for(ll a=2;a*a<=n;a++){if(n%a!=0) continue;ll b=n/a;res.pb(b);if(b!=a) res.pb(a);}sort(all(res));return res;}

vector<int> to[100005];

int main(){
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    --a;--b;
    to[a].pb(b);
    to[b].pb(a);
  }
  queue<int> q;
  vector<int> pre(n,-1);
  vector<int> dist(n,INF);
  dist[0]=0;
  q.push(0);
  while(!q.empty()){
    int v =q.front(); q.pop();
    for(int u:to[v]){
      if(dist[u]!=INF) continue;
      dist[u]=dist[v]+1;
      pre[u]=v;
      q.push(u);
    }
  }
  cout<<"Yes"<<endl;
  rep(i,n){
    if(i==0) continue;
    cout<<pre[i]+1<<endl;
  }
}

Measured memory_bytes: 10720
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;

void solve()
{
	int n;
	cin >> n;
	
	int a[n];
	int prev;
	cin >> prev;
	a[0] = prev;
	
	for(int i = 1; i<n; i++) 
	{
		cin >> a[i];
		prev = __gcd(prev, a[i]);
	}
	
	if(prev > 1)
	{
		cout << "not coprime\n";
		return ;
	}
	
	int factors[1000005] = {};
	for(int i = 0; i<n; i++)
	{
		for(int j = 1; j*j<=a[i]; j++)
		{
			if(a[i]%j == 0)
			{
				int x = j, y = a[i]/j;
				if(x != 1) factors[x]++;
				if(y != 1 && x != y) factors[y]++;
				if(factors[x] > 1 || factors[y] > 1)
				{
					cout << "setwise coprime\n";
					return ;
				}
			}
		}
	}
	cout << "pairwise coprime\n";
	
}

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


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

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner scan = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String s = scan.next();
        String t = scan.next();
        int a = scan.nextInt();
        int b = scan.nextInt();
        String u = scan.next();
        
        if(s.equals(u)){
            a--;
        }else{
            b--;
        }
        
        out.println(a + " " + b);
        out.close();
        
    }
}

Measured memory_bytes: 38712
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String[] params = in.nextLine().split(" ");
        int a = Integer.parseInt(params[0]);
        int b = Integer.parseInt(params[1]);
        int tap = 1;
        int count = 0;
        while(tap < b ){
            tap -= 1;
            tap += a;
            count++;
        }
        System.out.println(count);

    }

}





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


def main():
    n, a, b, c = map(int, input().split())
    l = [int(input()) for _ in range(n)]

    # See:
    # https://img.atcoder.jp/abc119/editorial.pdf
    # http://drken1215.hatenablog.com/entry/2019/02/24/224100?_ga=2.107425799.427838713.1551485650-1201012407.1527836447#fnref:1
    # https://atcoder.jp/contests/abc119/submissions/4372229
    def dfs(i, cur_a, cur_b, cur_c):
        if i == n:
            if cur_a == 0 or cur_b == 0 or cur_c == 0:
                return float('inf')
            return abs(a - cur_a) + abs(b - cur_b) + abs(c - cur_c)

        w = dfs(i + 1, cur_a, cur_b, cur_c)
        x = dfs(i + 1, cur_a + l[i], cur_b, cur_c) + 10 * (cur_a != 0)
        y = dfs(i + 1, cur_a, cur_b + l[i], cur_c) + 10 * (cur_b != 0)
        z = dfs(i + 1, cur_a, cur_b, cur_c + l[i]) + 10 * (cur_c != 0)

        return min(w, x, y, z)

    print(dfs(0, 0, 0, 0))


if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    long long int a,b;
    cin>>a>>b;
    long long int ar[a+5];
    for(int k=0;k<a;k++)
    {
        cin>>ar[k];
    }
    for(int i=b;i<a;i++)
    {
        if(ar[i]>ar[i-b]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


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

int main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int xmax = -100, ymin = 100;
    for (int i = 0; i < n; i++) {
        int xs;
        cin >> xs;
        xmax = max(xs, xmax);
    }
    for (int i = 0; i < m; i++) {
        int ys;
        cin >> ys;
        ymin = min(ys, ymin);
    }
    for (int z = y; z > x; z--) {
        if (xmax < z && z <= ymin) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
string a;
  char b='a';
  int c=0x1;
  cin>>a;
  sort(a.begin(),a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  if(a.size()==26)
    cout<<"None"<<endl;
  else{
  for(int i=0;i<a.size();i++){
    if(a.at(i)!=b){
      cout<<b<<endl;
      break;
    }
    b=b+c;
    if(b=='z'){
      cout<<b<<endl;
      break;
    }
  }
}
}
    


Measured memory_bytes: 512
def main():
    ans = []
    N, K = map(int, input().split())

    for i in range(K):
        d = int(input())
        a = map(int, input().split())
        for j in a:
            ans.append(j)

    count = 0
    for i in range(1, N + 1):
        if not i in ans:
            count += 1

    print(count)
    return

main()

Measured memory_bytes: 9120
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		int N=sc.nextInt();

		int[] X=new int[N];

		int[] sortedX=new int[N];

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

			int buf = sc.nextInt();

			X[i]=buf;
			sortedX[i]=buf;
		}

		Arrays.sort(sortedX);

		int med1=sortedX[N/2-1];
		int med2=sortedX[N/2];

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

			if(X[i]<=med1) {
				System.out.println(med2);
			}else {
				System.out.println(med1);
			}

		}
	}



	//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

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

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 92900
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int n,a,b;
	cin>>n>>a>>b;
	if((a&1)==(b&1)){
		cout<<abs(a-b)/2;
	}
	else{
		int ans1=0, ans2=0;
		int a1=a,b1=b;
		if(a1>b1){
			swap(a1,b1);
		}
		b1 -= a1-1;
		ans1 += a1-1;
		if(b1%2 == 0){
			b1--; ans1++;
		}
		ans1 += (b1-1)/2;
		a1=a,b1=b;
		if(a1>b1){
			swap(a1,b1);
		}
		a1 += n-b1;
		ans2 += n-b1;
		if((a1%2)!=(n%2)){
			a1++;ans2++;
		}
		ans2+=(n-a1)/2;
		cout<<min(ans1,ans2);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll 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()
#define SZ(x) ll(x.size())

int main(){
  ll n; cin >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  sort(ALL(a));
  vector<ll> sum(n+1,0);
  REP(i,n) sum[i+1] = sum[i] + a[i];

  IREP(i,n-1){
    if(2*sum[i+1] < a[i+1]){
      cout << n-i-1 << endl;
      return 0;
    }
  }
  cout << n << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int a[n];
    
    for (int i=0;i<n;i++) cin >> a[i];
    
    int cnt=0,i;
    
    do{
        int f=1;
        for (i=0;i<n;i++)
        if (a[i]%2==1){
            cout << cnt;
            return 0;
		}
		
		cnt++;
		for (int j=0;j<n;j++) a[j]=a[j]/2;
	}while (1);
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const double INF=1e77;

int main(){
	double xs,ys,xt,yt;
	int n; cin>>xs>>ys>>xt>>yt>>n;
	double x[1002],y[1002],r[1002];
	rep(u,n) cin>>x[u]>>y[u]>>r[u];
	x[n]=xs; y[n]=ys; r[n]=0; n++; // start
	x[n]=xt; y[n]=yt; r[n]=0; n++; // goal

	double d[1002];
	rep(u,n) d[u]=(u==n-2?0:INF);
	priority_queue<pair<double,int>> Q;
	Q.emplace(0,n-2);
	while(!Q.empty()){
		auto a=Q.top(); Q.pop();
		double d0=-a.first;
		int u=a.second;

		if(u==n-1){ cout<<setprecision(10)<<d0<<endl; break; }
		if(d0>d[u]) continue;

		rep(v,n){
			double d1=d0+max(hypot(x[v]-x[u],y[v]-y[u])-r[u]-r[v],0.0);
			if(d1<d[v]){
				d[v]=d1;
				Q.emplace(-d1,v);
			}
		}
	}

	return 0;
}


Measured memory_bytes: 6512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <ctime>
#include <map>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
bool vis[10];
int main() {
  int n,k;cin>>n>>k;
  rep(i,k){
    int x;cin>>x;vis[x]=1;
  }
  for(int i=n;;++i){
    int t=i;
    bool ok=1;
    while(t){
      int d=t%10;t/=10;
      if(vis[d]){
        ok=0;
        break;
      }
    }
    if(ok){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define LL long long
using namespace std;
const LL Maxn = 200010;
const LL Mod = 924844033;
const LL G = 5;
LL A[Maxn<<2], B[Maxn<<2], N;
LL size[Maxn], n;
LL jc[Maxn<<2], inv[Maxn<<2], invN;
vector <LL> vec[Maxn];
void dfs(LL x, LL fa) {
	LL sz = vec[x].size();
	size[x] = 1;
	for(LL i = 0; i < sz; i++){
		LL y = vec[x][i];
		if(y == fa) continue;
		dfs(y, x);
		A[size[y]]++; A[n-size[y]]++;
		size[x] += size[y];
	}
}
LL qpow(LL x, LL k) {
	LL ret = 1;
	while(k){
		if(k&1) ret = ret*x%Mod;
		x = x*x%Mod;
		k >>= 1;
	}
	return ret;
}
void dft(LL *a, LL op) {
	LL i, j, k;
	j = 0;
	for(i = 0; i < N; i++){
		if(i < j) swap(a[i], a[j]);
		k = N>>1;
		while(j&k) j -= k, k >>= 1;
		j += k;
	}
	for(i = 2; i <= N; i <<= 1){
		LL wn = qpow(G, op == 1 ? (Mod-1)/i : Mod-1-(Mod-1)/i);
		for(j = 0; j < N; j += i){
			LL w = 1;
			for(k = j; k < j+i/2; k++){
				LL x = a[k], y = a[k+i/2]*w%Mod;
				a[k] = (x+y)%Mod; a[k+i/2] = (x-y+Mod)%Mod;
				w = w*wn%Mod;
			}
		}
	}
	if(op == -1) for(i = 0; i < N; i++) a[i] = a[i]*invN%Mod;
}
LL C(LL x, LL y) { return jc[x]*inv[y]%Mod*inv[x-y]%Mod; }
int main() {
	LL i, j, k;
	scanf("%lld", &n);
	for(i = 1; i < n; i++){
		LL x, y;
		scanf("%lld%lld", &x, &y);
		vec[x].push_back(y); vec[y].push_back(x);
	}
	dfs(1, 0);
	N = 1;
	while(N < 2*n-1) N <<= 1;
	jc[0] = 1;
	for(i = 1; i <= N; i++) jc[i] = jc[i-1]*i%Mod;
	inv[0] = inv[1] =1;
	for(i = 2; i <= N; i++) inv[i] = inv[Mod%i]*(Mod-Mod/i)%Mod;
	invN = inv[N];
	for(i = 2; i <= N; i++) inv[i] = inv[i-1]*inv[i]%Mod;
	for(i = 1; i <= n-1; i++) A[i] = A[i]*jc[i]%Mod;
	for(i = n-1; i >= 0; i--) B[i] = inv[n-1-i];
	dft(A, 1); dft(B, 1);
	for(i = 0; i < N; i++) A[i] = A[i]*B[i]%Mod;
	dft(A, -1);
	for(i = 1; i <= n; i++){
		LL ans = n*C(n, i)%Mod;
		LL minus = inv[i]*A[n+i-1]%Mod;
		printf("%lld\n", (ans-minus+Mod)%Mod);
	}
	return 0;
}

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

int main()
{
	int a,b;
	while(cin >> a >> b)
	{
		int len = abs(abs(a) - abs(b));
		if (a > 0 && b > 0) {
        if (a > b) len += 2;
	    } else if (a > 0 && b < 0) {
	        len++;
	    } else if (a < 0 && b > 0) {
	        len++;
	    } else if (a < 0 && b < 0) {
	        if (a > b) len += 2;
	    } else if (a == 0 && b < 0) {
	        len++;
	    } else if (a > 0 && b == 0) {
	        len++;
	    }
		printf("%d\n", len);
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	int arr[n-1];
	for(int i=0;i<n-1;i++)
		cin>>arr[i];
	int ans[n];
	ans[0]=arr[0];
	ans[1]=arr[0];
	for(int i=1;i<=n-2;i++)
	{
		if(arr[i]>arr[i-1])
		{
			ans[i+1]=arr[i];
		}
		else if(arr[i]<=arr[i-1])
		{
			ans[i]=arr[i];
			ans[i+1]=arr[i];
		}
	}
	int sum=0;
	for(int i=0;i<n;i++)
		sum+=ans[i];
	cout<<sum<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=100010;
int a,b,k,di[101],tot;
int read(){
    int f=1,x=0;
    char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
bool cmp(int a,int b){
    return a>b;
}
int main(){
    cin>>a>>b>>k;
    for(int i=1;i<=100;i++){
        if(a%i==0&&b%i==0) di[++tot]=i;
    }
    sort(di+1,di+tot+1,cmp);
    cout<<di[k]<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	int mod = 1000000007;

	void run() {
		for (;;) {
			int n = sc.nextInt();
			if (n == 0) {
				return;
			}
			Info info[] = new Info[n];
			for (int i = 0; i < n; i++) {
				info[i] = new Info(sc.nextInt(), sc.nextInt(), sc.nextInt(),
						sc.nextInt());
			}
			Arrays.sort(info, new ComparatorInfo());
			ArrayList<Info> al = new ArrayList<Info>();
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				int groupCnt = 0;
				Info now = info[i];
				for (int j = 0; j < al.size(); j++) {
					if (now.group == al.get(j).group) {
						groupCnt++;
					}
				}
				if (cnt < 10) {
					if (groupCnt < 3) {
						al.add(now);
						cnt++;
					}
				} else if (cnt < 20) {
					if (groupCnt < 2) {
						al.add(now);
						cnt++;
					}
				} else if (cnt < 26) {
					if (groupCnt == 0) {
						al.add(now);
						cnt++;
					}
				}
			}
			for (int i = 0; i < al.size(); i++) {
				System.out.println(al.get(i).id);
			}
		}
	}

	class Info {
		int id;
		int group;
		int accept;
		int pena;

		public Info(int id, int group, int accept, int pena) {
			super();
			this.id = id;
			this.group = group;
			this.accept = accept;
			this.pena = pena;
		}
	}

	class ComparatorInfo implements Comparator<Info> {
		@Override
		public int compare(Info arg0, Info arg1) {
			// TODO 自動生成されたメソッド・スタブ
			int cmp = 0;
			if (arg0.accept < arg1.accept) {
				cmp = 1;
			} else if (arg0.accept == arg1.accept) {
				if (arg0.pena > arg1.pena) {
					cmp = 1;
				} else if (arg0.pena < arg1.pena) {
					cmp = -1;
				} else {
					if (arg0.id > arg1.id) {
						cmp = 1;
					} else {
						cmp = -1;
					}
				}
			}
			return cmp;
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

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

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 17156
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a) for (int i=0; i<(a); i++)
#define rep1(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rep(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define imax INT_MAX
#define imin INT_MIN
//#define MOD 998244353
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
const double rad=3.1415926535/180;
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}

int main() {
  
  ios_base::sync_with_stdio(0); cin.tie(0);    
  ld a,b,h,m,angle,c;
  cin>>a>>b>>h>>m;
  angle=abs(m-h*5-ld(m/12))*6*rad;
  //cout<<angle<<nl;
  //cout<<cos(angle)<<nl;
  c=a*a+b*b-2*a*b*cos(angle);
  ld ans=sqrt(abs(c));
  cout<<setprecision(30)<<ans<<nl;
  return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 4192