akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;cin>>k;
    bool used[46][k];
    rep(i,0,46)rep(j,0,k)used[i][j]=false;
    queue<pii> q;
    q.push({1,1});
    used[1][1]=true;
    while(q.size()>0){
        pii p=q.front();q.pop();
        int dis=p.first;
        if(dis==45)continue;
        int now=p.second;
        int t=now*10;
        t%=k;
        if(used[dis][t]==false){
            used[dis][t]=true;
            q.push({dis,t});
        }
        t=now+1;
        t%=k;
        if(used[dis+1][t]==false){
            used[dis+1][t]=true;
            q.push({dis+1,t});
        }
    }
    rep(i,1,46){
        if(used[i][0]){
            cout<<i<<endl;
            return 0;
        }
    }
}


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	string s,t;
	cin >> s >> t;

	int ans = 0;
	rep(i,s.size()){
		if(s[i] != t[i]){
			ans++;
		}
	}

	cout << ans << endl;

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3776
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int grandSum = 0;
		for (int i = 1; i <= N; i++) {
			String s = Integer.toString(i);
			int sum = 0;
			for (char c : s.toCharArray()) {
				sum += (int) (c - '0');
			}
			if (sum >= A && sum <= B) {
				grandSum += i;
			}
		}
		System.out.println(grandSum);
	}
}


Measured memory_bytes: 22736
/*
Submitted With (^^) by -> Hossam ^_^
_____________________
|     ___     ___     |
|    (^_^)   (^_^)    |
|   /( | )\_/( | )\   |
|_____|_|_____|_|_____|
*/

#include <bits/stdc++.h>

using namespace std;

inline void prep()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
};

#define X first
#define Y second
#define endl '\n'
#define ll long long
#define inf (0x7fffffffffffffff)
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << (x) << "\n";
#define ZXC cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl;

const int mod = (int)1e9 + 7;
// const int mod = 998244353;
const int MX = (int)5e5 + 10;

int main()
{    
    
    prep();
    
    int n, x;
    cin >> n >> x;

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

    sort(a, a + n);
    for(int i = 0; i + 1 < n; ++i){
        if(x >= a[i] && x <= a[i + 1]) gcd = __gcd(gcd, __gcd(x - a[i], a[i + 1] - x));
        else gcd = __gcd(gcd, a[i + 1] - a[i]);
    }

    if(x > a[n - 1]) gcd = __gcd(gcd, x - a[n - 1]);
    else if(x < a[0]) gcd = __gcd(gcd, a[0] - x);

    cout << gcd << endl;

    // ZXC
    return 0;
}

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

using namespace std;
long long k, a, b;
int main()
{
    cin>> k >> a >> b; //输入
    for(int i=a; i<=b; i++){ //暴力枚举
        if(i%k == 0){ //判断是否能被整除
            cout<< "OK";//输出
            return 0;
        }
    }
    cout<< "NG"; //输出
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,k,a[10010]={0},x,y,z;
	scanf("%d",&n);
	for(x=1;x<=100;x++){
		for(y=1;y<=100;y++){
			for(z=1;z<=100;z++){
				k=x*x+y*y+z*z+x*y+x*z+y*z; 
				if(k<=10000) a[k]++;
			}
		}
    }
	for(int i=1;i<=n;i++){
		printf("%d\n",a[i]);
	}
    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
int main(){
int x,y,z;
std::cin >> x >> y >> z;
if(x+y <= y+z && x+y <= x+z)
std::cout << x+y << std::endl;
else if(y+z <= x+y && y+z <= x+z)
std::cout << y+z << std::endl;
else
std::cout << x+z <<std::endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int M = GetInt();
		WriteLine(N * (N - 1) / 2 + M * (M - 1) / 2);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

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

int main()
{
  long long a,b,k;
  cin >> a >> b >> k;
  if(a>=k)
    cout << a-k <<" "<< b << endl;
  else if(b>=(k-a))
    cout << "0 " << b-(k-a) << endl;
  else 
    cout << "0 0" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);
		int n = sc.nextInt();

		HashMap<Integer, Integer> odd = new HashMap<>();
		HashMap<Integer, Integer> even = new HashMap<>();

		for (int i = 0; i < n / 2; i++) {
			int o = sc.nextInt();
			int e = sc.nextInt();

			odd.put(0, 0);
			even.put(0, 0);

			if (!odd.containsKey(o)) {
				odd.put(o, 0);
			}
			odd.put(o, odd.get(o) + 1);

			if (!even.containsKey(e)) {
				even.put(e, 0);
			}
			even.put(e, even.get(e) + 1);
		}

		List<Entry<Integer, Integer>> oddList = new ArrayList<>(odd.entrySet());
		List<Entry<Integer, Integer>> evenList = new ArrayList<>(even.entrySet());

		Collections.sort(oddList, new Comparator<Entry<Integer, Integer>>() {
			public int compare(Entry<Integer, Integer> o1, Entry<Integer, Integer> o2) {
				return o2.getValue().compareTo(o1.getValue());
			}
		});

		Collections.sort(evenList, new Comparator<Entry<Integer, Integer>>() {
			public int compare(Entry<Integer, Integer> o1, Entry<Integer, Integer> o2) {
				return o2.getValue().compareTo(o1.getValue());
			}
		});

		if (!oddList.get(0).getKey().equals(evenList.get(0).getKey())) {
			out.println(n - oddList.get(0).getValue() - evenList.get(0).getValue());
		} else {
			out.println(
					Math.min(n - oddList.get(0).getValue() - evenList.get(1).getValue(),
							n - oddList.get(1).getValue() - evenList.get(0).getValue()));
		}

		sc.close();
	}

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

}


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

int main() {
	int n, k;
	cin >> n >> k;
	if ((n + 1) / 2 >= k) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
	return 0;
}


Measured memory_bytes: 3536
#include <iostream>
using namespace std;
struct sList{
public:
    int val;
    sList *next;
    sList *prev;
};

int main(void){
    int n, x, a = 0;
    string s;
    cin >> n;
    sList l[n+1];
    sList nil;
    nil.prev = &nil;
    nil.next = &nil;
    nil.val = -1;
    for(int i = 0; i < n; i++){
        cin >> s;
        if(s == "insert"){
            cin >> x;
            l[a].val = x;
            l[a].next = nil.next;
            nil.next->prev = &l[a];
            nil.next = &l[a];
            l[a].prev = &nil;
            if(nil.prev == &nil){
                nil.prev = &l[a];
            }
            //cout << &nil.next->val << endl;
            a++;
        } else if(s == "delete"){
            cin >> x;
            sList b = *nil.next;
            while(b.val != -1){
                if(b.val == x){
                    b.prev->next = b.next;
                    b.next->prev = b.prev;
                    break;
                } else {
                    b = *b.next;
                }
            }
        } else if(s == "deleteFirst"){
            nil.next = nil.next->next;
            nil.next->prev = &nil;
        } else if(s == "deleteLast"){
            nil.prev = nil.prev->prev;
            nil.prev->next = &nil;
        }
        //cout << nil.next->val << " " << nil.prev->val << endl;
    }
    sList* b = nil.next;
    while(b != nil.prev){
        cout << b->val << " ";
        //cout << b << " " << nil.prev << endl;
        b = b->next;
    }
    cout << b->val << endl;
    //cout << ltail->val << endl;
    return 0;
}



Measured memory_bytes: 28956
n,t = input().split()
n = int(n)
t = int(t)
r = [[] for i in range(n)]
min = 1001
for i in range(n):
    r[i] = input().split()
    r[i][0] = int(r[i][0])
    r[i][1] = int(r[i][1])
    if r[i][1] <= t:
        if r[i][0] < min:
            min = r[i][0]
if min == 1001:
    print("TLE\n")
else:
    print(min)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>


using namespace std;


int main() {
	int A,B,C;
	cin>>A>>B>>C;
	bool ans=false;
	for(int i=1;i<=B;++i){
		if((i*A)%B==C){
			ans=true;
			break;
		}
	}
	ans?cout<<"YES"<<endl:cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
using namespace std;

const long int INF = 1000000007;

int main(void)
{
    long long N, K;
    cin >> N >> K;
    vector<int> a(N);
    map<int, int> m;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        m[a[i]]++;
    }

    // 1ループ分
    long long count = 0;
    for (int i = 1; i < N; i++)
    {
        for (int j = 0; j < i; j++)
        {
            if(a[j] > a[i])
            {
                count++;
            }
        }
        
    }
    // printf("in group : %d\n", count);
    
    // effect by before group
    long long before_effect = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (a[i] < a[j])
            {
                before_effect++;
            }
            
        }
        
    }
    
    // printf("effect by before group : %d\n", before_effect);
    
    // calc ans
    long long ans = count * K % INF;
    // printf("ans1 : %d\n", ans);

    long long bc = K * ((K - 1) / 2) % INF;
    if ((K - 1) % 2 == 1)
    {
        bc += (K - 1) / 2 + 1;
    }
    bc %= INF;
    
    ans += bc * before_effect % INF;

    cout << ans % INF << endl;
}

Measured memory_bytes: 3684
#include <cstdio>
#include <queue>

#define INF (1<<28)

using namespace std;

#define MAX_M 200005

int N, M;
vector<int> G[MAX_M];

void solve() {
  int ans[MAX_M];
  for (int i = 0; i <= N; i++) ans[i] = INF;

  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    int x = q.front(); q.pop();
    for (int i = 0; i < G[x].size(); i++) {
      int y = G[x][i];
      if (ans[y] == INF) {
        q.push(y);
        ans[y] = x;
      }
    }
  }

  for (int i = 2; i <= N; i++) {
    if (ans[i] == INF) {
      puts("No");
      return;
    }
  }

  puts("Yes");
  for (int i = 2; i <= N; i++) {
    printf("%d\n", ans[i]);
  }
}

int main() {
  scanf("%d %d", &N, &M);
  int a, b;
  for (int i = 0; i < M; i++) {
    scanf("%d %d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  solve();
}

Measured memory_bytes: 12456
while True:
    m,f,r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        rank = "F"
    elif m + f >= 80 :
        rank = "A"
    elif m + f >= 65 and m + f < 80:
        rank = "B"
    elif m + f >= 50 and m + f < 65:
        rank = "C"
    elif m + f >= 30 and m + f < 50:
        if r >= 50:
            rank = "C"
        else :
            rank = "D"
    elif m + f < 30:
        rank = "F"
    print(rank)


Measured memory_bytes: 5592
using System;
using System.Globalization;
using System.IO.Pipes;
using System.Runtime.InteropServices;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int A, B, C;
            A = int.Parse(str[0]);
            B = int.Parse(str[1]);
            C = int.Parse(str[2]);
            int ans = B / A;
            if (ans > C) Console.WriteLine(C);
            else Console.WriteLine(ans);

        }

    }
}


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

struct E{ int s, e, x; };

int n, c = 1;
vector<E> r;

void g(int s, int e, int x){
    r.push_back({s, e, x});
}

void f(int x){
    if(x == 1) return;
    f(x >> 1);
    c++;
    g(c - 1, c, 0);
    g(c - 1, c, x >> 1);
    if(x & 1) g(1, c, x - 1); 
}

int main(){
    scanf("%d", &n);
    f(n);
    printf("%d %d\n", c, r.size());
    for(E i : r) printf("%d %d %d\n", i.s, i.e, i.x);
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100010

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

int DP[MAX];

//
int main(){
	int n;cin >> n;
	V h(n);
	REP(i,n)cin>>h[i];

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

	cout << DP[1] << endl;

	return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>
#define fr first
#define se second

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=200000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll dp[N + 5];


int main()
{
  finp;
  ll n;
  cin>>n;
  vll v;

  ll maxl = 0;
  afor(i,1,n)
  {
    ll val;
    cin>>val;
    dp[val] = dp[val-1] + 1;
    maxl = max(maxl,dp[val]);
  }



  cout<<(n - maxl);

  
return 0;
}

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

int GCD(int a, int b){
  int tmp;
  while (a!=0) {
    tmp = a;
    a = b % a;
    b = tmp;
  }
  return b;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long 
#define fi first
#define se second
vector<int> v;
signed main(){
  int x,y,a,b,c;
  int p[10000000];
  int q[10000000];
  int r[10000000];
  int C=0,sum=0;
  cin>>x>>y>>a>>b>>c;
  for(int i=0;i<a;i++) cin>>p[i];
  for(int i=0;i<b;i++) cin>>q[i];
  for(int i=0;i<c;i++) cin>>r[i];
  sort(p,p+a,greater<int>());
  sort(q,q+b,greater<int>());
  sort(r,r+c,greater<int>());
  for(int i=0;i<x;i++) v.push_back(p[i]);
  for(int i=0;i<y;i++) v.push_back(q[i]);
  sort(v.begin(),v.end());
  for(int i=0;i<max(c,x+y)&&i<v.size();i++){
    if(v[i]<r[C]){
      v[i]=r[C];
      C++;
    }
    sum+=v[i];
  }
  cout<<sum<<"\n";
}

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

int main(){
  string s, t;
  cin >> s >> t;

  bool ans=false;
  s+=s;
  for(int i=0; i<t.size(); i++){
    if(s.substr(i, t.size())==t){
      ans=true;
      break;
    }
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


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

int main() {
    int h,w;
    cin >> h >> w;
    char s[60][60];
    int d[60][60]; // ゴールまでの最短距離
    bool m[60][60]; // 訪れたかどうか
    bool route[60][60]; // たどってきた道
    queue<pair<int, int>> que;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin >> s[i][j];
            d[i][j] = 1000; //大きい数で埋める
            m[i][j] = false;
            route[i][j] = false;
        }
    }
    que.push(make_pair(1,1));
    m[1][1] = true;
    d[1][1] = 0;
    while(!que.empty()){
        int x = que.front().second;
        int y = que.front().first;
        que.pop();
        if(0 <= x && x <= w && 0 <= y && y <= h){
            if(s[y][x+1] == '.' && m[y][x+1] == false){
                que.push(make_pair(y,x+1));
                d[y][x+1] = d[y][x] + 1;
                m[y][x+1] = true;
            }if(s[y][x-1] == '.' && m[y][x-1] == false) {
                que.push(make_pair(y, x - 1));
                d[y][x - 1] = d[y][x] + 1;
                m[y][x - 1] = true;
            }if(s[y+1][x] == '.' && m[y+1][x] == false) {
                que.push(make_pair(y+1, x));
                d[y+1][x] = d[y][x] + 1;
                m[y+1][x] = true;
            }if(s[y-1][x] == '.' && m[y-1][x] == false) {
                que.push(make_pair(y-1, x));
                d[y-1][x] = d[y][x] + 1;
                m[y-1][x] = true;
            }
        }
    }

    if(m[h][w] == false){
        cout << -1 << endl;
        return 0;
    }

    int max_d = d[h][w];

    int ans = 0;

    int black = 0;
    for(int i=h;i>=1; i--){
        for(int j=w;j>=1; j--){
            if(s[i][j] == '#'){
                black++;
            }
        }
    }

    cout << h*w - max_d - 1 - black << endl;

    /*
    // ゴールからスタートまでの道を検索
    for(int i=h;i>=1; i--){
        for(int j=w;j>=1; j--){
            if(d[i][j] == max_d && s[i][j] == '.'){
                route[i][j] = true;
                max_d--;
            }
        }
    }

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            for(int k=0;k<=d[h][w];k++){
                // 最短距離のマス群
                if(s[i][j] == '.' && !route[i][j]){
                    ans++;
                    break;
                }
            }

        }
    }
     */

    //cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n, i, j, count, sum;
	while(1){
		scanf("%d", &n);
		if( n == 0 ){
		break;
		}
		count = 0;
		for( i = 1 ; i < n-1 ; i++ ){
		sum = i;
			for( j = i + 1 ; j < n ; j++ ){
				sum += j;
				if( sum == n ){
					count++;
				}
			}
		}
		printf("%d\n",count); 
	}
	return 0;
}

Measured memory_bytes: 600
import itertools


def eratosthenes(n):
    sieve = [True for _ in range(n + 1)]
    sieve[0] = False
    sieve[1] = False

    def _update(p):
        if sieve[p]:
            for i in range(p * 2, n + 1, p):
                sieve[i] = False

    _update(2)
    p = 3
    while p * p <= n:
        _update(p)
        p += 2
    return sieve


sieve = eratosthenes(10**5)
ls = [False for _ in range(10**5)]
for n in range(3, 10**5, 2):
    ls[n] = sieve[n] and sieve[(n + 1) // 2]
accs = list(itertools.accumulate(map(int, ls)))

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(accs[r] - accs[l - 1])

Measured memory_bytes: 8112
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

#define int long long

using namespace std;


class Solver {
};

signed main() {
	while (true) {
		int n, i, j;
		cin >> n >> i >> j;
		if (n == 0)break;

		int up = i - 1;
		int down = n - up - 1;
		vector<bool> ups(n, false);
		int val = pow(2, n - 1);
		for (int i = n - 1; i >= 0; i--) {
			if (val <= up) {
				up -= val;
				ups[i] = true;
			}
			else down -= val;

			val /= 2;
		}

		int now = j - 1;
		int len = pow(2, n);
		for (int i = 0; i < n; i++) {
			bool left = now < len / 2;
			bool toLeft = false;
			if (i + 1 < n) {
				if (ups[i] == ups[i + 1]) {
					if (left)toLeft = true;
					else toLeft = false;
				}
				else {
					if (left)toLeft = false;
					else toLeft = true;
				}
			}
			else {
				if (ups[i]) {
					if (left)toLeft = true;
					else toLeft = false;
				}
				else {
					if (left)toLeft = false;
					else toLeft = true;
				}
			}
			len /= 2;
			if (toLeft) {
				cout << 'R';
				if (!left) {
					now = len - now % len - 1;
				}
			}
			else {
				cout << 'L';
				if (left) {
					now = len - now - 1;
				}
				else {
					now %= len;
				}
			}
		}
		cout << endl;
	}
}


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

int main()
{
	string s;
	cin >> s;
	if (s.at(0) == s.at(1) && s.at(1) == s.at(2) )
	{
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 200000 + 100;

int n;
int s[MAXN], ss[MAXN];

bool check(int v)
{
	for(int i = 1; i <= 2 * n - 1; i++)
		ss[i] = (s[i] >= v ? 1 : 0);
	int l = n, r = n;
	while(r + 1 <= 2 * n - 1 && ss[r] != ss[r + 1])
		r++;
	while(l - 1 >= 1 && ss[l] != ss[l - 1])
		l--;
	if(l == 1 && r == 2 * n - 1)
		return ss[n] ^ (n & 1 ? 0 : 1);
	if(ss[l] == ss[r])
		return ss[l];
	return n - l < r - n ? ss[l] : ss[r];
}

int binary(int l, int r)
{
	while(l < r)
	{
		int mid = (l + r + 1) / 2;
		if(check(mid))
			l = mid;
		else
			r = mid - 1;
	}
	return l;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n;
	for(int i = 1; i <= 2 * n - 1; i++)
		cin >> s[i];
	int ans = binary(1, 2 * n - 1);
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 1920
import math
a,b,x=map(int,input().split())

if a * a * b > 2 * x:
    d = (2*x)/(a*b)
    theta = math.atan2(b,d)
    print(math.degrees(theta))
else:
    d = ((2*x)-(b*a*a))/(a*a)
    theta = math.atan2(b-d,a)
    print(math.degrees(theta))


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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

int n;
ll a[3003];

ll PD[3003][3003][2];
bool visited[3003][3003][2];

ll pd(int i, int j, int p){
	if(i > j){
		return 0;
	}
	ll &ans = PD[i][j][p];
	if(visited[i][j][p]){
		return ans;
	}
	if(p == 1){
		ans = min(pd(i, j-1, 0) - a[j], pd(i+1, j, 0) - a[i]);
	} else {
		ans = max(pd(i, j-1, 1) + a[j], pd(i+1, j, 1) + a[i]);
	}
	visited[i][j][p] = true;
	// printf("i = %d e j = %d e p = %d, retornando %lld\n", i, j, p, ans);
	return ans;
 }

int main(){
	scanf("%d", &n);
	FOR(i, 0, n){
		scanf("%lld", a + i);
	}
	printf("%lld\n", pd(0, n-1, 0));
	return 0;
}

Measured memory_bytes: 158208
#include <stdio.h>
#include <string.h>

#define N 1000

int lcs(char X[], char Y[])
{
    int c[N + 1][N + 1];
    int m = (int)strlen(X);
    int n = (int)strlen(Y);
    int max = 0;

    for (int i = 0; i <= m; i++) {
        for (int j = 0; j <= n; j++) {
            c[i][j] = 0;
        }
    }

    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (X[i - 1] == Y[j - 1]) {
                c[i][j] = c[i - 1][j - 1] + 1;
            } else if (c[i - 1][j] >= c[i][j - 1]) {
                c[i][j] = c[i - 1][j];
            } else {
                c[i][j] = c[i][j - 1];
            }
            max = (max > c[i][j]) ? max : c[i][j];
        }
    }

    return max;
}

int main()
{
    int q;
    char s1[N], s2[N];

    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%s", s1);
        scanf("%s", s2);
        printf("%d\n", lcs(s1, s2));
    }

    return 0;
}


Measured memory_bytes: 5628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

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

	public void start() {
		Scan sc = new Scan();
		String inputs[] = new String[3];
		for (int i = 0; i < 3; i++) {
			inputs[i] = sc.next();
		}
		

		System.out.println(getResult(inputs));

	}

	private String getResult(String[] inputs) {
		for (int i = 1; i < inputs.length; i++) {
			if(inputs[i-1].charAt(inputs[i-1].length()-1)!=inputs[i].charAt(0)){
				return "NO";
			}
		}
		return "YES";
	}

}
class Scan {
	BufferedReader br;
	StringTokenizer st;

	public Scan() {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

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

}

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

int main(){
    int N,M;
    map<string,int> cnt;
    cin >> N;
    rep(i,N){
        string s;
        cin >> s;
        cnt[s]++;
    }
    cin >> M;
    rep(i,M){
        string t;
        cin >> t;
        cnt[t]--;
    }
    int ans = 0;
    for(auto itr = cnt.begin();itr!=cnt.end();itr++){
        ans = max(ans,itr->second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := getInt()
	fss := make([][]int, n)
	for i := range fss {
		fss[i] = getIntSlice(10)
	}

	ps := make([][]int, n)
	for i := range ps {
		ps[i] = getIntSlice(11)
	}

	ans := -1 * inf
	for bit := 1; bit < (1 << uint(10)); bit++ {
		now := 0
		for i, fs := range fss {
			c := bitCount(bit, fs)
			now += ps[i][c]
		}
		ans = max(ans, now)
	}

	fmt.Fprintln(wr, ans)
}

func bitCount(bit int, fs []int) int {
	ret := 0
	for i, f := range fs {
		if (bit & (f << uint(i))) > 0 {
			ret++
		}
	}
	return ret
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func digits(n int) int {
	sum := 0
	for n > 0 {
		sum += n % 10
		n /= 10
	}
	return sum
}

func main() {
	n, a, b := readInt(), readInt(), readInt()
	sum, digit := 0, 0
	for i := 1; i <= n; i++ {
		digit = digits(i)
		if a <= digit && digit <= b {
			sum += i
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 640
import heapq
H, W, M = map(int, input().split())
bomb = []
for i in range(M):
    h, w = map(int, input().split())
    h-=1; w-=1
    bomb.append((h, w))

row = [0] * H
col = [0] * W

for h, w in bomb:
    row[h] += 1
    col[w] += 1

lmax = max(row) + max(col)
row = [(r, i) for i, r in enumerate(row)]
col = [(c, i) for i, c in enumerate(col)]
row.sort(reverse=True)
col.sort(reverse=True)
bomb = set(bomb)

for r, i in row:
    for c, j in col:
        if r+c < lmax: break
        if not (i, j) in bomb:
            print(lmax)
            exit()
print(lmax-1)


Measured memory_bytes: 125984
#include<bits/stdc++.h> 
// #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
// #define endl "\n"
#define mod 1000000007
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
using namespace std;
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
bool isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
int32_t main(){
     #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout); 
    #endif
    int n,w;
    cin>>n>>w;
    vector<int> wt(n);
    std::vector<int> v(n);

    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        wt[i]=a;
        v[i]=b;
       // cout<<v[i]<<" "<<wt[i]<<endl;
    }


    int dp[n+1][w+1];
    for(int i=0;i<n+1;i++)
    {
        dp[i][0]=0;
    }
    for(int i=0;i<w+1;i++)
        dp[0][i]=0;
    for(int i=1;i<n+1;i++)
    {
        for(int j=1;j<w+1;j++)
        {
            if(i==0||j==0)
            {
                dp[i][j]==0;
            }
            else  if(wt[i-1]<=j)
            {
                dp[i][j]=max((v[i-1]+dp[i-1][j-wt[i-1]]),dp[i-1][j]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
           // cout<<dp[i][j]<<" ";
        }
       // cout<<endl;
    }
    int ans=0;
    for(int i=0;i<w+1;i++)
    {
        ans=max(ans,dp[n][i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 82508
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[][] bingoPosList = {
                {0, 1, 2},
                {3, 4, 5},
                {6, 7, 8},
                {0, 3, 6},
                {1, 4, 7},
                {2, 5, 8},
                {0, 4, 8},
                {2, 4, 6}
        };

        int[] board = new int[9];
        for (int i = 0; i < 9; i++) {
            board[i] = in.nextInt();
        }
        boolean[] checked = new boolean[9];
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            for (int j = 0; j < 9; j++) {
                if (x == board[j]) checked[j] = true;
            }
        }
        boolean res = false;
        for (int[] triple : bingoPosList) {
            boolean ok = true;
            for (int num : triple) {
                if (!checked[num]) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                res = true;
                break;
            }
        }

        System.out.println(res ? "Yes" : "No");
    }
}


Measured memory_bytes: 21844
/******************************************
* AUTHOR : SARTHAK GUPTA *
* NICK : SOPHOZAAR *
* INSTITUTION : BIT MESRA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
LL n, k;
LL arr[N];
LL dp[N];

LL func(LL x) {
	if(x >= n) {
		return INT_MAX;
	}
	if(x == n - 1) {
		return 0;
	}

	if(dp[x] != -1)
		return dp[x];

	LL temp = INT_MAX;

	for(int i = 1; i <= k; i++) {
		if(x + i >= n)
			break;
		temp = min(temp, abs(arr[x] - arr[x + i]) + func(x + i));
	}
	return dp[x] = temp;

}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);

cin >> n >> k;
for(int i = 0; i < n; i++) {
	dp[i] = -1;
	cin >> arr[i];
}

cout << func(0) << "\n";


return 0;
}

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



#define ZERO(a) memset(a,0,sizeof(a))
template<int NV, class V> class MinCostFlow {
public:
	struct edge {
		int to, capacity; V cost; int reve;
		edge(int a, int b, V c, int d) {
			to = a; capacity = b; cost = c; reve = d;
		}
	};
	vector<edge> E[NV];
	int prev_v[NV], prev_e[NV]; V dist[NV];
	void add_edge(int x, int y, int cap, V cost) {
		E[x].push_back(edge(y, cap, cost, (int)E[y].size()));
		E[y].push_back(edge(x, 0, -cost, (int)E[x].size() - 1)); /* rev edge */
	}

	V mincost(int from, int to, int flow) {
		V res = 0; int i, v;
		ZERO(prev_v); ZERO(prev_e);
		while (flow>0) {
			fill(dist, dist + NV, numeric_limits<V>::max() / 2);
			dist[from] = 0;
			priority_queue<pair<int, int> > Q;
			Q.push(make_pair(0, from));
			while (Q.size()) {
				int d = -Q.top().first, cur = Q.top().second;
				Q.pop();
				if (dist[cur] != d) continue;
				if (d == numeric_limits<V>::max() / 2) break;
				rep(i, 0, E[cur].size()) {
					edge &e = E[cur][i];
					if (e.capacity>0 && dist[e.to]>d + e.cost) {
						dist[e.to] = d + e.cost;
						prev_v[e.to] = cur;
						prev_e[e.to] = i;
						Q.push(make_pair(-dist[e.to], e.to));
					}
				}
			}

			if (dist[to] == numeric_limits<V>::max() / 2) return -1;
			int lc = flow;
			for (v = to; v != from; v = prev_v[v]) lc = min(lc, E[prev_v[v]][prev_e[v]].capacity);
			flow -= lc;
			res += lc*dist[to];
			for (v = to; v != from; v = prev_v[v]) {
				edge &e = E[prev_v[v]][prev_e[v]];
				e.capacity -= lc;
				E[v][e.reve].capacity += lc;
			}
		}
		return res;
	}
};
//-----------------------------------------------------------------
typedef long long ll;
int NV, NE, F;
//-----------------------------------------------------------------
int main()
{
	MinCostFlow<100, ll> flow;

	cin >> NV >> NE >> F;

	rep(i, 0, NE) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		flow.add_edge(a, b, c, d);
	}

	cout << flow.mincost(0, NV - 1, F) << endl;
}

Measured memory_bytes: 3184
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int N, M;

int mul(int a, int b) { return (int) ((long long) a * b % M); }

vector<int> H[100000];
int F[100000], G[100000];
int T1[100002], T2[100002];

int dfs1(int u, int p) {
  int f = 1;
  H[u].erase(find(H[u].begin(), H[u].end(), p));
  for (auto v : H[u])
    f = mul(f, 1 + dfs1(v, u));
  return F[u] = f;
}

void dfs2(int u) {
  auto m = (int) H[u].size();
  T1[0] = 1 + G[u];
  G[u] = mul(1 + G[u], F[u]);
  for (auto i = 1; i <= m; ++i)
    T1[i] = mul(T1[i - 1], 1 + F[H[u][i - 1]]);
  T2[m + 1] = 1;
  for (auto i = m; i; --i)
    T2[i] = mul(T2[i + 1], 1 + F[H[u][i - 1]]);
  for (auto i = 1; i <= m; ++i)
    G[H[u][i - 1]] = mul(T1[i - 1], T2[i + 1]);
  for (auto v : H[u])
    dfs2(v);
}

int main() {
  scanf("%d%d", &N, &M);
  for (auto i = 1; i < N; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u, --v;
    H[u].emplace_back(v);
    H[v].emplace_back(u);
  }
  H[0].emplace_back(-1);
  dfs1(0, -1);
  dfs2(0);
  for (auto i = 0; i < N; ++i)
    printf("%d\n", G[i]);
  return 0;
}


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

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

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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vector<vector<t>>;
typedef long long ll;
typedef vc<int> vi;
typedef vvc<int> vvi;
typedef pair<int, int> pi;

#define uset unordered_set
#define umap unordered_map

#define endl "\n"

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()

#define all(a) a.bg, a.ed

template <class t, class u>
ostream &operator<<(ostream &os, const pair<t, u> &p) {
    return os << "( " << p.first << ", " << p.second << " )";
}

template <class t>
ostream &operator<<(ostream &os, const vc<t> &v) {
    os << "[ ";
    for (int i = 0; i < v.size(); i++) {
        os << v[i];
        if (i != v.size() - 1) {
            os << ", ";
        }
    }
    return os << " ]";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(18);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    ll a, b, k;
    cin >> a >> b >> k;

    // Range clashes
    if (2 * k > b - a + 1) {
        for (int i = a; i <= b; i++) {
            cout << i << endl;
        }
    } else {
        // smallest A -> A + K - 1
        for (int i = a; i <= a + k - 1; i++) {
            cout << i << endl;
        }

        // largest B - K + 1 -> B
        for (int i = b - k + 1; i <= b; i++) {
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 3568
import numpy as np
bingo = []
for _ in range(3):
    l=list(map(int, input().split()))
    bingo.extend(l)

N = int(input())
indices=[]

for _ in range(N):
    num = int(input())
    if num in bingo:
        indices.append(bingo.index(num))

candidates=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
ans='No'
for candidate in candidates:
    if len(list(set(indices)&set(candidate))) == 3:
        ans='Yes'
        break
print(ans)
    
        

Measured memory_bytes: 12508
program problemB
  implicit none

  integer   :: N, i, tf

  tf = 0

  read *, N

  do i = 1, 9
     if ( real ( N ) / i <= 9 .and. &
        & real ( N ) / i == real ( N / i ) ) then
        print *, "Yes"
        tf = 1
        exit
     end if
  end do

  if ( tf == 0 ) then
     print *, "No"
  end if
  
  
end program problemB


Measured memory_bytes: 256
#include <iostream>

int main()
{
  int A[3],i,j,key;

  for(i=0;i<3;i++)
    {
      std::cin>>A[i];
    }

  for(i=0;i<3;i++)
    {
      key=A[i];
      j=i-1;

      while(j>=0&&A[j]>key)
	{
	  A[j+1]=A[j];
	  j--;
	  A[j+1]=key;
	}
    }
  for(i=0;i<2;i++)
    {
      std::cout<<A[i]<<" ";
    }
  std::cout<<A[2]<<std::endl;
  return 0;
}

  



Measured memory_bytes: 3080
import math
a,b,h,m = map(lambda x:int(x), input().split(' '))

#2つの針の長さと間の角度から距離を算出
def dst(a,b,deg):
    return ((a**2+b**2)-(2*a*b*math.cos(math.radians(deg))))**0.5

deg_1 = (60*h+m)*0.5
deg_2 = m*6
deg = abs(deg_1-deg_2)

if deg > 180:
    deg = 360-deg

ans = dst(a,b,deg)
print(ans)
#print(dst(3,4,90))

Measured memory_bytes: 9436
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

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

const ll MAX_N = 100;
ll F[MAX_N][10], P[MAX_N][11], cnt[MAX_N];

int main(void){
    ll N;
    ll answer = - INF;

    cin >> N;
    rep(i, N) rep(j, 10) cin >> F[i][j];
    rep(i, N) rep(j, 11) cin >> P[i][j];

    For(i, 1, 1024){
        ll tmp = i;
        ll idx = 0;
        ll profit = 0;
        rep(j, N) cnt[j] = 0;

        while (tmp > 0){
            ll work = tmp % 2;
            tmp /= 2;
            if (work) rep(j, N) cnt[j] += F[j][idx];
            idx ++;
        }

        rep(j, N) profit += P[j][cnt[j]];
        answer = max(answer, profit);
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
n,m = [int(k) for k in input().split()]
fo = [0]*m
ans = 0
for i in range(n):
	a = input().split()
	for k in a[1:]:
		k = int(k)
		fo[k-1]+=1
		if fo[k-1]==n:
			ans+=1
print(ans)

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (i%2) ans += (s[i] == 'p') ? 0 : 1;
    else ans += (s[i] == 'g') ? 0 : -1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
import scala.io.StdIn.{readLine, readInt};
object Main {
    def main(args: Array[String]): Unit = {
        val Array(n, m) = readLine.split(" ").map(_.toInt);
        val matrix = new Array[List[Int]](n).map( i => List[Int]());
        (0 until m).foreach { i =>
            readLine.split(" ").map(_.toInt) match {
                case Array(src, dst) => {
                    matrix(src) = dst :: matrix(src);
                    matrix(dst) = src :: matrix(dst);
                }
                case _ => ();
            }
        }
        val group = genGroup(matrix);
        val sb = new StringBuilder();
        (0 until readInt).foreach { i =>
            val Array(src, dst) = readLine.split(" ").map(_.toInt);
            if (group(src) == group(dst)) sb.append("\nyes") else sb.append("\nno");
        }
        println(sb.substring(1));
    }
    
    def genGroup(matrix: Array[List[Int]]): Array[Int] = {
        val len = matrix.length;
        val group = new Array[Int](len);
        def go(que: IntQueue, gid: Int): Unit = {
            que.peek match {
                case None => ();
                case Some(e) => {
                    val nextQue = matrix(e).foldLeft(que.dequeue) { (q, child) =>
                        if (group(child) == 0) {
                            group(child) = gid;
                            q.enqueue(child);
                        } else {
                            q;
                        }
                    }
                    go(nextQue, gid);
                }
            }
        }
        (0 until len).foldLeft(1) { (gid, i) =>
            if (group(i) == 0) {
                group(i) = gid;
                go(IntQueue(i), gid);
                gid + 1;
            } else {
                gid;
            }
        }
        group;
    }
}

class IntQueue(private val addList: List[Int], private val rmList: List[Int]) {
    def peek(): Option[Int] = if (rmList == Nil) None else Some(rmList.head);
    def enqueue(e: Int): IntQueue = {
        if (rmList == Nil) {
            new IntQueue(Nil, (e :: addList).reverse);
        } else {
            new IntQueue(e :: addList, rmList);
        }
    }
    def dequeue(): IntQueue = {
        rmList match {
            case Nil => throw new NoSuchElementException();
            case e :: Nil => new IntQueue(Nil, addList.reverse);
            case e :: es => new IntQueue(addList, rmList.tail);
        }
    }
}
object IntQueue {
    def apply(): IntQueue = new IntQueue(Nil, Nil)
    def apply(es: Int*): IntQueue = new IntQueue(Nil, es.toList);
}


Measured memory_bytes: 168824
#01:55
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
import bisect
ans = 0
for x in b:
  atmp = bisect.bisect_left(a,x)
  ctmp = bisect.bisect_right(c,x)
  ans += atmp * (n - ctmp)
print(ans)

Measured memory_bytes: 105444
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

int main(){
  string s,t;
  cin >> s >> t;
  cout << t << s << endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
n = int(s)

mochies = []

for i in range(n):
    p = input()
    q = int(p)
    mochies.append(q)

mochies.sort()

count = 1

for i in range(len(mochies)):
    if i + 1 == len(mochies):
        break
    if mochies[i] < mochies[i + 1]:
        count += 1
    else:
        continue
    
print(count)


Measured memory_bytes: 9176