akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
int cnt;
vector<int> G;

void insertionSort(vector<int> &A, int n, int g)
{
	for (int i = g; i < n; i++)
	{
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v)
		{
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}
void shellsort(vector<int> &A, int n)
{
	for (int h = 1; h <= n; h = 3 * h + 1)
	{
		G.push_back(h);
	}
	for (int i = G.size() - 1; i >= 0; --i)
	{
		insertionSort(A, n, G[i]);
	}
}
int main()
{
	int n;
	scanf("%d", &n);
	vector<int> v(n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &v[i]);
	}
	
	shellsort(v, n);

	printf("%d\n", G.size());
	for (int i = G.size() - 1; i >= 0; --i)
		printf("%d ", G[i]);
	printf("%d\n", cnt);
	for (int i = 0; i < n; ++i)
		printf("%d\n", v[i]);

	return 0;
}

Measured memory_bytes: 6740
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
i = np.array([j for j in range(1, n+1)])
b = a - i
ans = sorted(b)
if n % 2 == 1:
    index = n//2
    print(np.sum(abs(b - ans[index])))
else:
    index = n//2 - 1
    x1 = np.sum(abs(b-ans[index]))
    x2 = np.sum(abs(b - ans[index+1]))
    print(min(x1, x2))


Measured memory_bytes: 34196
#include <stdio.h>
int main (void){
char a[100];
for(int i=0;i<3;i++){
    scanf("%c",&a[i]);
    }
for(int i=0;i<3;i++){
    if(a[i]=='1'){
        a[i]='9';
    }else if(a[i]=='9'){
        a[i]='1';
    }
}
printf("%c%c%c",a[0],a[1],a[2]);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    #include<chrono>
    using namespace std;
    using namespace std::chrono;
    using namespace __gnu_pbds; 
    #define lli long long int
    #define fr(i,a,b) for(lli i=a;i<b;i++)
    #define bfr(i,a,b) for(lli i=a;i>=b;i--)
    #define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
    #define tc int t;cin>>t;while(t--)
    #define mod 1000000007LL
    #define mod2 998244353LL
    #define all(vec) vec.begin(),vec.end()  
    #define ld long double
    #define pb push_back

    #define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 



      

       int main()
      
    {
                           
             

                        
              fio  

               
               string s,t;
               cin>>s>>t;
               if(s==t.substr(0,t.length()-1))cout<<"Yes";
               else cout<<"No";
              





    return 0;}

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

int main() {

    long long x;
    cin >> x;

    long int thu = x / 500;
    long int five = (x - thu * 500) / 5;
    cout << thu * 1000 + five * 5 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
int cnt;
void fun(vector<int>a,vector<int>b,vector<int>c,int n)
{
    for(int i=0;i<a.size();i++)
 {
     for(int j=1;j<=n;j++)
     {
         int p=a[i]+j,q=a[i]+2*j;
         if(p<n&& q<n)
         {
             bool ans1=binary_search(b.begin(),b.end(),p);
             bool ans2=binary_search(c.begin(),c.end(),q);
             if(ans1 && ans2)
             cnt++;
         }
     }
 }
}
signed main()
{
 int n;
 string s;
 cin>>n>>s;
 vector<int>a,b,c;
 for(int i=0;i<n;i++)
 {
     if(s[i]=='R')
     a.pb(i);
     if(s[i]=='B')
     b.pb(i);
     if(s[i]=='G')
     c.pb(i);

 }

 fun(a,b,c,n);
 
 fun(a,c,b,n);
 
 fun(b,c,a,n);
 
 fun(b,a,c,n);
 
 fun(c,b,a,n);
 
 fun(c,a,b,n);
 
 cout<<a.size()*b.size()*c.size()-cnt<<endl;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define ll long long
#define MX 1000000000000000000
using namespace std;

int main() {
    int n;
  	cin>>n;
  	ll a[n];
  	for(int i = 0;i < n;i++) {
    	cin>>a[i];
  	}
  	sort(a,a+n);
  	ll ret=MX;
  	if(a[0]!=0) {
        bool v=true;
        for(int i = 0;i < n;i++){
            ret/=a[i];
            if(ret<1) {
                cout<<-1<<endl;
                v=false;
                break;
            }
        }
        if(v) {
            ret=1;
            for(int i = 0;i < n;i++)
                ret*=a[i];
            cout<<ret<<endl;
        }
  	}
  	else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 4380
using System;
using System.Collections.Generic;

namespace abc144_e
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var k = CIn.ReadLong();
      var a = CIn.ReadIntArray(n);
      var f = CIn.ReadIntArray(n);

      Array.Sort(a);
      Array.Sort(f);
      Array.Reverse(f);

      var ok = (long)a[n - 1] * f[0];
      var ng = -1L;
      
      while (ok - ng > 1)
      {
        var mid = (ok + ng) / 2;
        var sum = 0L;

        for (var i = 0; i < n; i++)
        {
          var aa = mid / f[i];

          if (a[i] > aa)
          {
            sum += a[i] - aa;
          }

          if (sum > k)
          {
            break;
          }
        }

        if (sum > k)
        {
          ng = mid;
        }
        else
        {
          ok = mid;
        }
      }

      Console.WriteLine(ok);
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }
  }
}

Measured memory_bytes: 48076
#include <iostream>
#include <algorithm>
#define N 100
using namespace std;
int main() {
        int n, d[N] = {};
        cin >> n;
        for (int i=0; i<n; i++) cin >> d[i];
        sort(d, d+n);
        unique(d, d+N);
        int i;
        for (i=0; i<n; i++) if (d[i] >= d[i+1]) break;

        cout << i+1 << endl;
        return 0;
}


Measured memory_bytes: 256
a = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
e = 0
for i in range(a):
    d = min(c[i], b[i])
    e += d
    c[i] -= d
    b[i] -= d
    d = min(c[i], b[i+1])
    e += d
    c[i] -= d
    b[i+1] -= d
print(e)


Measured memory_bytes: 18468
#import sys
#input = sys.stdin.readline
def main():
    N = int( input())
    D = list( map( int, input().split()))
    D.sort()
    ans = 0
    if D[N//2] != D[N//2-1]:
        ans = D[N//2] - D[N//2-1]
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 14428
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		for(int i=1;i<=n;i++) {
			ans += i;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 20560
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

while true
  m,f,r=get_i
  break if m==-1 and f==-1 and r==-1
  if m==-1 or f==-1
    puts "F"
  elsif m+f>=80
    puts "A"
  elsif 65<=m+f and m+f<80
    puts "B"
  elsif 50<=m+f and m+f<65
    puts "C"
  elsif 30<=m+f and m+f<50
    if r>=50
      puts "C"
    else
      puts "D"
    end
  else
    puts "F"
  end
end


Measured memory_bytes: 6872
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        bool output_flag = false;
        if (i % 3 == 0) {
            output_flag = true;
        } else {
            int x = i;
            while (x) {
                if (x % 10  == 3) {
                    output_flag = true;
                    break;
                }
                x /= 10;
            }
        }
        if (output_flag) cout << " " << i;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1160
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N,K,X,Y;
int main(){
	cin>>N>>K>>X>>Y;


	if(N>K)cout<<K*X+(N-K)*Y<<endl;
	if(N<=K)cout<<N*X<<endl;


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

vector<ll> dx={0,0,1,-1};
vector<ll> dy={1,-1,0,0};

ll char_to_num(char c){
  if(c>='A' && c<='M'){return 0;}
  else if(c>='N' && c<='Z'){return 1;}
  else if(c>='a' && c<='m'){return 2;}
  return 3;
}

char num_to_char(ll a){
  if(a==0){return 'A';}
  else if(a==1){return 'N';}
  else if(a==2){return 'a';}
  return 'n';
}

int main(){
  ll n;
  cin>>n;
  string s;
  cin>>s;
  ll x=0,y=0;
  for(auto &I:s){
    ll a=char_to_num(I);
    x+=dx[a];
    y+=dy[a];
  }
  string ans;
  if(y>0){
    for(int i=0;i<abs(y);i++){
      ans.push_back(num_to_char(0));
    }
  }
  else{
    for(int i=0;i<abs(y);i++){
      ans.push_back(num_to_char(1));
    }
  }
  if(x>0){
    for(int i=0;i<abs(x);i++){
      ans.push_back(num_to_char(2));
    }
  }
  else{
    for(int i=0;i<abs(x);i++){
      ans.push_back(num_to_char(3));
    }
  }
  cout<<ans.size()<<endl;
  cout<<ans<<endl;
  
  return 0;
}



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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll a;
    double b;
    cin >> a >> b;
    int bi = b * 100.0 + 0.5;
    ll ans = a * bi / 100;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    char c;
    int ans=0,mx=0;
    while(cin>>c){
    	(c=='I')?++ans:--ans;
    	if(ans>mx) mx=ans;
    }
    cout<<mx;
    return 0;
}

Measured memory_bytes: 3584
import sys
sys.setrecursionlimit(10**6)

def main():
	n, k = map(int,input().split())
	ans = 0
	b = int(n/k)
	ans += b**3
	if k % 2 == 0:
		c = k/2
		d = int((n+c)/k)
		ans += d**3
	print(ans)

main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const int N =  1e6 + 9;
int was[N];

signed main(){
   IOS;
   int n; cin >> n;
   vector<int> a(n);
   for(auto &it : a) {
      cin >> it;
      was[it]++;
   }  
   int ans = 0;
   for(auto x : a) {
      bool ok = true;
      for(int i = 1; i*i<=x; i++) {
         if(x%i == 0) {
            if(was[i]) {
               if(i == x and was[i] > 1) {
                  ok = false;
                  break;
               }
               else if (i != x) {
                  ok = false;
                  break;
               }
            }
            if(was[x/i]) {
               if(x/i == x and was[x/i] > 1) {
                  ok = false;
                  break;
               }
               else if (x/i != x) {
                  ok = false;
                  break;
               }
            }
         }
      }
      if(ok) ans++;
   }
   cout << ans << '\n';
}

Measured memory_bytes: 12584
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	ll d,a; cin >> d >> a;
	ll ans=0;
	vector<pair<ll,ll>> v;
	for(int i=0;i<n;i++){
		int x,y; cin >> x >> y;
		v.push_back(make_pair(x,y));
	}
	sort(v.begin(),v.end());
	queue<pair<ll,ll>> q;
	ll cnt=0;
	for(int i=0;i<n;i++){
		while(q.size()){
			auto p=q.front();
			if(p.first<v[i].first){
				q.pop();
				cnt-=p.second;
			}
			else{
				break;
			}
		}
		if(cnt*a>=v[i].second)continue;
		v[i].second-=cnt*a;
		ll kk=(v[i].second+a-1)/a;
		cnt+=kk;
		ans+=kk;
		q.push({v[i].first+2*d,kk});
	}
	cout << ans << endl;
}

Measured memory_bytes: 5232
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	int max(int[] a) {
		int max = Integer.MIN_VALUE;
		for (int i = 0; i < a.length; i++) {
			if(max < a[i])
				max = a[i];
		}
		return max;
	}
	
	void run() {
		int n, w;
		while (true) {
			n = sc.nextInt(); w = sc.nextInt();
			if (n == 0 && w == 0) break;
			int[] v = new int[n];
			for (int i = 0; i < n; i++)
				v[i] = sc.nextInt();
			int max = max(v);
			int num = max/w + 1;
			int[] x = new int[num];
			for (int i : v)
				x[i/w]++;
			
			int m = max(x);
			double ans = 0;
			for (int i = 0; i < num; i++) {
				ans += (double)(num-i-1)/(num-1)*x[i]/m;
			}
			
			out.println(ans+0.01);
		}
		
		
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 23776
using System;
using System.IO;
using System.Linq;
 
class Program
{
    static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split();
        var a = int.Parse(ab[0]);
        var b = int.Parse(ab[1]);
        int answer = 0;
        for (int soc = 1; soc < b; soc += a, b++) answer++;
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 27420
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9+7;
vector<vector<ll>>dp;
ll h,w;

ll solve(ll y,ll x){
  if(dp[y][x]!=-1)return dp[y][x];
  dp[y][x]=solve(y+1,x)+solve(y,x+1);
  return (dp[y][x]%MOD);
}

main(){

  cin>>h>>w;
  vector<string> a(h);
  for(ll i=0;i<h;++i)cin>>a[i];

  dp = vector<vector<ll>>(h+1,vector<ll>(w+1,-1));
  dp[h-1][w-1]=1;
  for(ll i=0;i<=h;++i)dp[i][w]=0;
  for(ll i=0;i<=w;++i)dp[h][i]=0;
  for(ll i=0;i<h;++i)for(ll j=0;j<w;++j){
    if(a[i][j]=='#')dp[i][j]=0;
  }
  
  cout<<solve(0,0)<<endl;
  
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int K;
vector<ll> vs;

void dfs(int d, ll val){
    if(d == 0) vs.push_back(val);
    else{
        int a = val % 10;
        if(a != 9) dfs(d - 1, val * 10 + a + 1);
        if(a != 0) dfs(d - 1, val * 10 + a - 1);
        dfs(d - 1, val * 10 + a);
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> K;
    int digi = 0, f = 1;
    while(vs.size() < K){
        dfs(digi, f++);
        if(f == 10) f = 1, digi++;
    }
    sort(vs.begin(), vs.end());
    cout << vs[K - 1] << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
  unsigned long long int N, ans=0, add;
  cin>>N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
  	cin >> vec.at(i);
  }
  for(int i=0; i<N-1; i++){
    if(vec.at(i)>vec.at(i+1)){
      add = vec.at(i)-vec.at(i+1);
      vec.at(i+1) += add;
      ans += add;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

long long int countDivisibles(long long int a, long long int b, long long int x)
{
    if (a % x == 0)
        return (b / x) - (a / x) + 1;
    return (b / x) - (a / x);
}

int main()
{
    long long int a, b, x;
    cin >> a >> b >> x;
    cout << countDivisibles(a, b, x) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
cnt = [0]*4
for i in range(N):
    S = readline().decode().rstrip()
    if S == 'AC':
        cnt[0] +=1
    if S == 'WA':
        cnt[1] +=1
    if S == 'TLE':
        cnt[2] +=1
    if S == 'RE':
        cnt[3] +=1
print('AC x '+str(cnt[0]))
print('WA x '+str(cnt[1]))
print('TLE x '+str(cnt[2]))
print('RE x '+str(cnt[3]))

Measured memory_bytes: 9256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
using namespace std;
void dfs(vector<vector<int> > &list, vector<int> &count, int from,int now){
    if (from > -1)
    {
        count.at(now) += count.at(from) ;
    }
    for (size_t i = 0; i < list.at(now).size(); i++)
    {
        if (list.at(now).at(i) == from)
        {
            continue ;
        }else
        {
            dfs(list,count,now,list.at(now).at(i)) ;
        }
        
        
    }
    
}

int main(){
    int n,q ;
    cin >> n >> q ;
    vector<vector<int> > list(n,vector<int>()) ;
    for (size_t i = 0; i < n-1; i++)
    {
        int x,y ;
        cin >> x >> y ;
        list.at(x-1).push_back(y-1) ;
        list.at(y-1).push_back(x-1) ;
    }
    vector<int> count(n,0) ;
    
    for (size_t i = 0; i < q; i++)
    {
        int p,x ;
        cin >> p >> x ;
        count.at(p-1) += x ;
    }
    dfs(list,count,-1,0) ;

    for (size_t i = 0; i < n-1; i++)
    {
        cout << count.at(i) << " " ;
    }
    cout << count.at(n-1) << endl ;
}

Measured memory_bytes: 32896
program BBB
!
      implicit none
      integer :: N
      integer :: i
      integer,dimension(100,2) :: D
      integer :: count
      integer :: jud
!
      count = 0
      jud = 0
!
      read(*,*) N
      do i=1,N
        read(*,*) D(i,1),D(i,2)
        if(D(i,1) == D(i,2)) then
          count = count + 1
        else
          count = 0
        end if
        if(count == 3) then 
          jud = 1
        end if
      end do
!
      if(jud == 1) then 
         write(*,*) 'Yes'
      else 
         write(*,*) 'No'
      end if
!
      end program BBB

Measured memory_bytes: 2864
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

ll A, B, C, D;
map<ll, ll> m;

ll dfs(ll n) {
    if (n == 0) return 0;
    if (m[n] > 0) return m[n];

    ll ans = 1e18;
    if (n < ans / D) ans = n * D;
    if (n % 5 == 0) ans = min(ans, C + dfs(n / 5));
    else {
        ll lower = n / 5 * 5, upper = lower + 5;
        ans = min(ans, dfs(lower / 5) + C + (n - lower) * D);
        ans = min(ans, dfs(upper / 5) + C + (upper - n) * D);
    }

    if (n % 3 == 0) ans = min(ans, B + dfs(n / 3));
    else {
        ll lower = n / 3 * 3, upper = lower + 3;
        ans = min(ans, dfs(lower / 3) + B + (n - lower) * D);
        ans = min(ans, dfs(upper / 3) + B + (upper - n) * D);
    }

    if (n % 2 == 0) ans = min(ans, A + dfs(n / 2));
    else {
        ll lower = n / 2 * 2, upper = lower + 2;
        ans = min(ans, dfs(lower / 2) + A + (n - lower) * D);
        ans = min(ans, dfs(upper / 2) + A + (upper - n) * D);
    }

    return m[n] = ans;
}

void solve() {
    ll N;
    cin >> N >> A >> B >> C >> D;
    m.clear();
    m[1] = D;
    cout << dfs(N) << endl;
}

int main() {
    int T;
    cin >> T;
    REP(i, T) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4500
/*input
1000 2 16
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
ll n,x,m;
bool vis[maxn];
ll nxt(ll x){
    return (x*x)%m;
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    cin>>n>>x>>m;
    ll ans=0;
    vector<int> v;
    v.pb(x);
    vis[x]=1;
    ans+=x;
    x=nxt(x);
    --n;
    while(n>0 and !vis[x]){
        //cout<<x<<'\n';
        ans+=x;
        vis[x]=1;
        v.pb(x);
        x=nxt(x);
        --n;
    }
    if(n==0){
        cout<<ans;
        return 0;
    }
    REP(i,sz(v)){
        if(v[i]==x){
            ll cyc=0;
            for(int j=i;j<sz(v);j++) cyc+=v[j];
            ans+=(n/(sz(v)-i))*cyc;
            n%=(sz(v)-i);
            REP(j,n){
                ans+=v[i+j];
            }
            break;
        }
    }
    cout<<ans;
}  


Measured memory_bytes: 3864
from scipy.sparse import*;f=lambda*z:map(int,input().split());n,=f();a,b=zip(*map(f,[0]*~-n));g,h=csgraph.dijkstra(csr_matrix(([1]*~-n,(a,b)),[n+1]*2),0,[1,n]);print('FSennunkeec'[sum(g[i]>h[i]for i in range(n+1))*2>=n::2])

Measured memory_bytes: 68188
import java.util.Scanner;

public class Main  {

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

		int n = scan.nextInt();
		int k = scan.nextInt();
		
		int[] array = new int[k];
		for(int i=0; i<k; i++) {
			array[i] = scan.nextInt();
		}

		for(int i=0; i<Math.pow(2, k); i++){
			int[] array2 = new int[n];
			int tmp = i;
			int index = 0;
			for(int j=0; tmp>0; j++) {
				if(tmp %2 == 1) {
					array2[array[j]] = 1;
					index += Math.pow(2, array[j]);
				}
				tmp /= 2;
			}
			
			System.out.print(index + ":");
			for(int j=0; j<k; j++) {
				if(array2[array[j]] == 1) System.out.print(" " + array[j]);
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 64812
#import sys

#input = sys.stdin.readline
import math
import itertools
#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def main():
#    h,w,a,b = map(int, input().split())
    x,y = map(int,input().split())
    a=max(x,y)
    b=min(x,y)

    t=a//2
    if b<t:
       ans=0
    elif (b-t)%3==0 and a%2==0:
       aa=a//2
       bb=(b-t)//3*2
       aa-=(b-t)//3
       ans=1
       ans=cmb(aa+bb,bb)

    elif (b-t+1)%3==0 and a%2!=0:
       aa=a//2
       bb=(b-t)//3*2+1
       aa -= (b - t) // 3
       ans=1
       ans=cmb(aa+bb,bb)

    else:
        ans=0


#    print(ans)
    print(ans%(10**9+7))
if __name__ == "__main__":
    main()

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

typedef long long ll;

int main(){
  int N;
  cin >> N;
  ll mxans = 0;
  ll ans = 0;
  int minus_num = 0;
  int abs_min = 10000000000;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
    if(A.at(i) < 0){
      minus_num++;
    }
  }
  
  for(int i=0; i<N; i++){
    abs_min = min(abs_min, abs(A.at(i)));
    mxans += abs(A.at(i));
  }
  
  if(minus_num % 2 ==0){
    ans = mxans;
  }
  else{
    ans = mxans - abs_min*2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <map>




#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;
long long int INF = 1000000007;


int main() {
  int a;
  cin >> a;
  if(a % 10 == 9 || a / 10 == 9) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
S = input()
T = input()
for i in reversed(range(len(S) - len(T) + 1)):
    frag = True
    for j in range(len(T)):
        if S[i + j] == T[j] or S[i + j] == "?":
            continue
        else:
            frag = False
            break
    if frag:
        ans = S[:i] + T
        if i + len(T) < len(S):
            ans += S[i + len(T):]
        ans = ans.replace("?", "a")
        print(ans)
        exit()
print("UNRESTORABLE")


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

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

  vector<bool> prime(1e6, true);
  prime[0] = prime[1] = false;
  for(int i = 2; i * i < 1e6; ++i) {
    if(prime[i]) {
      for(int j = i * i; j < 1e6; j += i) {
        prime[j] = false;
      }
    }
  }

  vector<int> cnt(1e6, 0);
  for(int i = 1; i <= 1e6; ++i) {
    cnt[i] = cnt[i - 1] + prime[i];
  }

  int n;
  while(cin >> n, !cin.eof()) {
    cout << cnt[n] << endl;
  }
}


Measured memory_bytes: 6684
def comb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
############################################################

N, M, K = map(int, input().split())
MOD = 10**9+7
sumx = 0
sumy = 0

for d in range(1, N):
    cnt = (N-d)*M**2
    cnt %= MOD
    cnt *= comb(N*M-2, K-2, MOD)
    sumx += d*cnt
    sumx %= MOD

for d in range(1, M):
    cnt = (M-d)*N**2
    cnt %= MOD
    cnt *= comb(N*M-2, K-2, MOD)
    sumy += d*cnt
    sumy %= MOD
print((sumx + sumy)%MOD)

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

int main()
{
	string s;
	cin >> s;
	int ans = 700;
	for(int i = 0; i < 3; i++){
		if(s[i] == 'o'){
			ans += 100;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll a,b;cin>>a>>b;
  ll k;cin>>k;
  set<ll>S;
  for(ll i=a;i<=a+k-1 && i<=b;i++)S.insert(i);
  for(ll i=b;i>=b-(k-1)&&i>=a;i--)S.insert(i);
  while(S.size()>0){
    cout<<*begin(S)<<endl;
    S.erase(*begin(S));
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long ll;
using namespace std;
const ll inf=(1e+10)+1;
int main(void){
    int n;ll m;cin>>n>>m;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    ll left=-1,right=inf;
    
    while(right-left>1){
        ll mid=(right+left)/2;
        ll tot=0;
        rep(i,n){
            //左手を確定
            //a[i]+a[x]>=midとなるxがいくつあるのかを二分探索で求める
            int l=-1,r=n;
            while(r-l>1){
                int mid2=(r+l)/2;
                if(a[i]+a[mid2]>=mid) r=mid2; else l=mid2;
            }
            tot+=n-r;
        }
        if(tot<=m) right=mid; else left=mid;
        //cout<<right<<endl;
    }
    vector<ll> b(n+1,0);b[n-1]=a[n-1];
    rep(i,n) b[n-i-1]=b[n-i]+a[n-i-1];
    ll mid=right;
    //cout<<mid<<endl;
    ll res=0;
    rep(i,n){
        ll buf=mid-a[i];
        auto itr=lower_bound(a.begin(),a.end(),buf);
        int k=itr-a.begin();
        res+=(n-k)*a[i]+b[k];
        m-=n-k;
    }
    res+=m*left;
    
    if(n*n==m){
        res=(n+1)*b[0];
    }
    cout<<res<<endl;
}

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


vector<int> point;
vector<int> Rank;
vector<int> Cost;


void CreateSet(int x);
int Find(int x);
void Relate(int x, int y, int z);
void Diff(int x, int y);
int main() {
    int n,q;
    int operation;
    int x,y,z;
    cin >> n >> q;

    for (int i = 0; i < n; ++i) {
        CreateSet(i);
    }

    for (int j = 0; j < q; ++j) {
        cin >> operation >> x >> y;
        if(operation == 0){
            cin >> z;
            Relate(x,y,z);
        }else{
            Diff(x,y);
        }
    }
    return 0;
}
void CreateSet(int x){
    point.push_back(x);
    Rank.push_back(0);
    Cost.push_back(0);
}
int Find(int x){
    int prev = point[x];
    if (x != point[x])
    {
        point[x] = Find(point[x]);
    }
    Cost[x] += Cost[prev];
    return point[x];
}
void Relate(int x, int y, int z){
    int rootX = Find(x);
    int rootY = Find(y);
    if(rootX == rootY){
        // the same union
        return;
    }
    z = z + Cost[x] - Cost[y];

    if(Rank[rootY] > Rank[rootX]){
        point[rootX] = rootY;
        Cost[rootX] = -z;
        if(Rank[rootX] == Rank[rootY]){
            Rank[rootY] += 1;
        }
    }else{
        point[rootY] = rootX;
        Cost[rootY] = z;
    }
}
void Diff(int x, int y){
    if(Find(x) == Find(y)){
        cout << Cost[y] - Cost[x] << endl;
    }else{
        cout << "?" << endl;
    }
}


Measured memory_bytes: 4284
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int[] p = new int[n];
    for (int i = 0; i < n; i++) {
      p[i] = Integer.parseInt(sc.next());
    }

    int cnt = 0;
    for (int i = 1; i < n - 1; i++) {
      if (Math.min(p[i - 1], p[i]) == p[i]) {
        if (Math.min(p[i], p[i + 1]) == p[i + 1]) {
          cnt += 1;
        }
      } else {
        if (Math.min(p[i], p[i + 1]) == p[i]) {
          cnt += 1;
        }
      }
    }
    System.out.println(cnt);
  }
}


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

using namespace std;

int main() {
	int k,s;
	cin >> k >> s;
	long long ans = 0;

	for(int x = 0; x <= k; x++){
		for(int y = 0; y <= k; y++){
			int z = s-x-y;
			if(0 <= z && z <= k)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
struct card{
  char mark;
  int num;
  int we;
};
 
int main(){
   
  int i,j,n,s,minj,stable=0;
  struct card card[37],card2[37];
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c%d",&card[i].mark,&card[i].num);
    card[i].we = i;
    card2[i]= card[i];
  }
   
  //BubbleSort
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(card[j].num<card[j-1].num){
    card[36] = card[j-1];
    card[j-1] = card[j];
    card[j] = card[36];
      }
    }
  }
   
  //SelectionSort
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(card2[j].num<card2[minj].num){
    minj = j;
      }
    }
    card2[36] = card2[i];
    card2[i] = card2[minj];
    card2[minj] = card2[36];
 
  }
   
  //print BubbleSort
  for(i=0;i<n;i++){
    printf("%c%d",card[i].mark,card[i].num);
    if(i==n-1){
      printf("\n");
      break;
    }
    printf(" ");
  }
  printf("Stable\n");
   
   
  //print SelectionSort
  for(i=0;i<n;i++){
    printf("%c%d",card2[i].mark,card2[i].num);
    if(i==n-1){
      printf("\n");
      break;
    }
    printf(" ");
  }
   
  for(i=0;i<n;i++){
    if(card2[i].we>card2[i+1].we&&card2[i].num==card2[i+1].num)stable =1;
  }
   
  if(stable == 1){
    printf("Not stable\n");
  }else{
    printf("Stable\n");
  }
   
  return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

ll A, B;

static inline ll get_sum(ll n) { return n * (n + 1) / 2; }

signed main()
{
    cin >> A >> B;

    ll sub = B - A;
    for(ll i = 1; i < 999; ++i) {
        ll cur = get_sum(i);
        ll next = get_sum(i+1);
        ll cand_sub = next - cur;
        if(sub == cand_sub) {
            printf("%lld\n", cur - A);
            break;
        }
    }

    return 0;
}


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

int main() {
	long long int X, Y;
	cin >> X >> Y;
	long long int a = X;
	if(X % Y == 0 || X < 1 || Y < 1){
		cout << -1 << endl;
		return 0;
	}
	while(true){
		if(a % Y != 0){
			if(a < 1000000000000){
				cout << a << endl;
				return 0;
			}
			else{
				cout << -1 << endl;
			}
		}
		a *= 2;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 256
from math import radians, sin, cos, sqrt

a, b, c = map(int, input().split())
sin_c = sin(radians(c))
cos_c = cos(radians(c))
S =(a*b*sin_c) / 2
print(S)
print(sqrt(a**2 + b**2 - 2*a*b * cos_c) + a + b)
print((2*S) / a)


Measured memory_bytes: 5708
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int MOD = (int) 1e9 + 7;
const double EPS = 1e-9;

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> v(M);
  REP(i, N) {
    int a,b;
    cin >> a >> b;
    if (a > M) continue;
    v[M-a].pb(b);
  }

  int ans = 0;
  priority_queue<int> que;

  DEC(i, M-1, -1) {
    for (auto b: v[i]) que.push(b);

    if (!que.empty()) {
      ans += que.top();
      que.pop();
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5632
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000000)
 
N,X,Y=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())
 
memo={}
def func(n,last,turn):  #n:カードの残り枚数、last:前の手番が最後に引いたスコア、turn: 0先手の番 1後手の番
    #print "func(",n,",",last,",",turn,")"
    if (n,turn) in memo:    #カードの残り枚数と、どちらの手番かが決まっていたら最終スコアはいつも同じ
        return memo[(n,turn)]
    if n==1:
        ret=abs(last-A[N-n])
    elif turn==0:
        ret=max( func(n-1,last,0) , func(n-1,A[N-n],1) ) #手番がXのまま  手番がYに移動
    elif turn==1:
        ret=min( func(n-1,last,1) , func(n-1,A[N-n],0) ) #手番がYのまま  手番がXに移動
    memo[(n,turn)]=ret
    return ret
 
 
print func(N,Y,0)

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

vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	string s;
	cin >> s;
	if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]){
		cout << "Yes" << endl;
	}else if(s[0] == s[2] && s[1] == s[3] && s[0] != s[3]){
		cout << "Yes" << endl;
	}else if(s[0] == s[3] && s[1] == s[2] && s[0] != s[1]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
using namespace std;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = 4*atan(1);
typedef long long ll;
typedef pair<int,int> pii;
// int gcd(int a, int b) { 
//     if (a == 0) return b; 
//     return gcd(b % a, a); 
// }
// ll power(int base, int power) {
// 	ll prod = 1;
// 	ll b = base;
// 	while(power) {
// 		if (power & 1) {
// 			prod = f(prod*b);
// 		}
// 		b = f(b*b);
// 		power/=2;
// 	}
// 	return prod;
// }
// struct line {
//     int m, c;
//     ll eval(int x) { return 1LL * m * x + c; }
//     double intersectX(line l) { return (double) (c - l.c) / (l.m - m); }
// };
int A,B,C,D;
void solve() {
	cin >> A>>B>>C>>D;
	int x = (C+B-1)/B;
	int y = (A+D-1)/D;
	if (x <= y) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}

}
int main() {
	int t;
	// cin >> t;
	// for (int i = 1; i <= t; i++) { 
		// cout << "Case #" << i << ": ";
		solve();
	// }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    string meghans;
    int up=abs(ty-sy);
    int right=abs(tx-sx);
    for(int i=1;i<=up;i++)
        meghans+='U';
    for(int i=1;i<=right;i++)
        meghans+='R';
    for(int i=1;i<=up;i++)
        meghans+='D';
    for(int i=1;i<=right;i++)
        meghans+='L';
    meghans+='L';
    for(int i=1;i<=(up+1);i++)
        meghans+='U';
    for(int i=1;i<=(right+1);i++)
        meghans+='R';
    meghans+='D';
    meghans+='R';
    for(int i=1;i<=(up+1);i++)
        meghans+='D';
    for(int i=1;i<=(right+1);i++)
        meghans+='L';
    meghans+='U';
    cout<<meghans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;

signed main(){
    string s;
    cin >> s;
    bool flag = true;
    rep(i,s.size()){
        if(i % 2 == 0){
            if(s[i] != 'h') flag = false;
        }
        else{
            if(s[i] != 'i') flag = false;
        }
    }
    if(s.size() % 2 == 0){
        if(flag) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let m: usize = iterator.next().unwrap().parse().unwrap();
    return (48 - m).to_string();
}


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

int main()
{
  string S;
  cin >> S;
  int ans = 1;
  string now;
  now = S[0];
  for (int i = 1; i < S.size(); i++)
  {
    string a;
    a = S[i];
    if (a == now)
    {
      now = S.substr(i, 2);
      if (i == S.size() - 1)
      {
        break;
      }
      else
      {
        ans++;
        i++;
      }
    }
    else
    {
      now = S[i];
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int H, W, h, w;
    cin >> H >> W >> h >> w;

    if(H % h == 0 && W % w == 0){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    bool trans = (W % w == 0);

    if(trans){
        swap(H, W);
        swap(h, w);
    }

    vector<int> sum(W + 1, -W - 1);
    sum[W] = 1;
    rrep(j, W){
        if(j + w <= W){
            sum[j] = sum[j + w] + 1;
        }
    }
    sum[0] = 0;

    vector< vector<int> > ans(H, vector<int>(W));
    rep(i, H){
        rep(j, W){
            ans[i][j] = sum[j + 1] - sum[j];
        }
    }

    if(trans){
        rep(j, W){
            rep(i, H){
                if(i) cout << ' ';
                cout << ans[i][j];
            }
            cout << '\n';
        }
    }else{
        rep(i, H){
            rep(j, W){
                if(j) cout << ' ';
                cout << ans[i][j];
            }
            cout << '\n';
        }
    }

    cout << flush;

    return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
struct Point{
    long int x,y;
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<Point> A(n);
    REP(i,n){
        cin >> A[i].x >> A[i].y;
    }
    int s= 0;
    long double sum=0;
    FOR(i,0,n-1){
        FOR(j,i+1,n){
            s++;
            sum+= sqrt((abs(A[i].x-A[j].x)*abs(A[i].x-A[j].x))+(abs(A[i].y-A[j].y)*abs(A[i].y-A[j].y)));
        }
    }
    // cout << sum << endl;
    // cout << s+1 << endl;
    // cout << nn << endl;
    // cout << nn;
    
    cout <<fixed<<setprecision(8)<< sum*(n-1)/s<< endl;

    // 8*7*6*5*4*3*2*1=
}

Measured memory_bytes: 256
import java.io.*;

class Main{
    
        public static int maxv(int x, int y){
            if(x >= y){
                return x;
            }else{
                return y;
            }
        }

        public static int minv(int x, int y){
            if(x <= y){
                return x;
            }else{
                return y;
            }
        }

    public static void main(String[] args){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {       
                    int N = Integer.parseInt(reader.readLine());;
                    

                    int[] a = new int[N];

                    for(int i = 0; i < N; i ++){
                        a[i] = Integer.parseInt(reader.readLine());
                    }

                    int min = a[0];
                    int max = a[1] - a[0];

                    for(int i = 0; i < (N- 1); i++){
                        min = minv(min, a[i]);
                        max = maxv(max, (a[i + 1] - min));
                    }

                    System.out.println(max);
                            
        } catch (IOException e) {
            //TODO: handle exception
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 42532
(defun input ()
  (coerce (read-line) 'character))

(defun cap? (code)
  (cond ((< code 91) t)
		(t nil)))

(defun main ()
  (let* ((chr (input))
		(code (char-code chr)))
	(if (cap? code)
	  (format t "A~%")
	  (format t "a~%")
	  )))

(main)


Measured memory_bytes: 23552
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, C: int, B: "List[int]", A: "List[List[int]]"):
    c = 0
    for i in range(N):
        result = C
        for j in range(M):
            result += A[i][j]*B[j]
        if result > 0:
            c+=1
    print(c)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    B = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    A = [ [ int(next(tokens)) for _ in range(M) ] for _ in range(N) ]  # type: "List[List[int]]"
    solve(N, M, C, B, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064