akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

	private static final char SHEEP = 'S';
	private static final char WOLF = 'W';

	private static final char SAME = 'o';
	private static final char DIFF = 'x';

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

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final String S = sc.next();

		String ans = null;
		final char[] animals = { SHEEP, WOLF };
		for (int i = 0; i < animals.length; i++) {
			for (int j = 0; j < animals.length; j++) {
				ans = zoo(S, animals[i], animals[j]);
				if (ans != null) {
					System.out.println(ans);
					return;
				}
			}
		}
		System.out.println(-1);
		sc.close();
	}

	private String zoo(String s, char firstAnimal, char secondAnimal) {
		int len = s.length();
		char[] zoo = new char[len];
		zoo[0] = firstAnimal;
		zoo[1] = secondAnimal;
		char expectedZooN = nextAnimal(s.charAt(0), firstAnimal, secondAnimal);

		for (int i = 2; i < s.length(); i++) {
			zoo[i] = nextAnimal(s.charAt(i - 1), zoo[i - 1], zoo[i - 2]);
		}

		if (zoo[len - 1] == expectedZooN && nextAnimal(s.charAt(len - 1), zoo[len - 1], zoo[len - 2]) == zoo[0]) {
			return String.valueOf(zoo);
		} else {
			return null;
		}

	}

	private char other(char animal) {
		switch (animal) {
		case SHEEP:
			return WOLF;
		case WOLF:
			return SHEEP;
		default:
			throw new IllegalArgumentException();
		}
	}

	private char nextAnimal(char msg, char animal, char prevAnimal) {
		switch (animal) {
		case SHEEP:
			if (msg == SAME) {
				return prevAnimal;
			} else if (msg == DIFF) {
				return other(prevAnimal);
			} else {
				throw new IllegalArgumentException();
			}
		case WOLF:
			if (msg == SAME) {
				return other(prevAnimal);
			} else if (msg == DIFF) {
				return prevAnimal;
			} else {
				throw new IllegalArgumentException();
			}
		default:
			throw new IllegalArgumentException();
		}
	}

}

Measured memory_bytes: 27016
#include<iostream>

using namespace std;

int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	bool ans = true;
	if (abs(a - b) > k || abs(a - c) > k || abs(a - d) > k || abs(a - e) > k)ans = false;
	if (abs(b - c) > k || abs(b - d) > k || abs(b - e) > k)ans = false;
	if (abs(c - d) > k || abs(c - e) > k || abs(d - e) > k)ans = false;


		if (ans) {
			cout << "Yay!" << endl;	
	}
		else {
			cout << ":(" << endl;
		}
	return 0;
}

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;


const int MOD = 1000000007;

ll inv(ll a, ll b) {
	return 1 < a ? b - inv(b % a, a) * b / a : 1;
}


int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	int N, M, K;

	cin >> N >> M >> K;

	ll ch = 1;

	for (int i = 1; i <= N * M - 2; ++i) {
		ch = (ch * i) % MOD;
	}

	for (int i = 1; i <= K - 2; ++i) {
		ch = (ch * inv(i, MOD)) % MOD;
	}

	for (int i = 1; i <= N * M - K; ++i) {
		ch = (ch * inv(i, MOD)) % MOD;
	}

	ll ans = 0;

	for (int d = 1; d <= M - 1; ++d) {
		ans = (ans + d * 1LL * (M - d) * N * N) % MOD;
	}

	for (int d = 1; d <= N - 1; ++d) {
		ans = (ans + d * 1LL * (N - d) * M * M) % MOD;
	}

	cout << (ans * ch) % MOD  << '\n';



	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int a=sc.nextInt();
            int sum=0;
            int curvalue=1;
            for (int i = 0; i < a; i++) {
                sum+=curvalue++;
            }
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 9424
def main():
  import sys
  b=sys.stdin.buffer
  h,w=map(int,b.readline().split())
  x=w+1
  s=[c>>3for c in b.read()]
  dp=[10000]*h*x
  a=p=s[0]
  dp[0]=b=q=5-a
  for i in range(1,w):
    t=s[i]
    b+=a^t
    dp[i]=b
    a=t
  for i in range(x,h*x,x):
    t=s[i]
    q+=p^t
    dp[i]=b=q
    a=p=t
    for j in range(1,w):
      k=i+j
      sk=s[k]
      b+=a^sk
      l=k-x
      t=dp[l]+(s[l]^sk)
      if b>t:b=t
      dp[k]=b
      a=sk
  print(b+1>>1)
main()

Measured memory_bytes: 3188
#include <stdio.h>

#define G 100000

int main(void) {
    int N,i;
    int A[G];
    scanf("%d",&N);
    for (i = 0; i < N; i++) {
    	int S;
	scanf ("%d",&S);
	A[S-1]=i+1;
    }
    printf("%d", A[0]);
    for(i=1;i<N;i++){
    	printf(" %d", A[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void){
    int num, count=0, i, j, k;
    scanf("%d", &num);

    int stick[num];
    for(i=0; i<num; i++){
        scanf("%d", &stick[i]);
    }

    for(i=0; i<num; i++){
        for(j=i+1; j<num; j++){
            if(stick[i] == stick[j]) continue;
            for(k=j+1; k<num; k++){
                if(stick[j]==stick[k] || stick[k]==stick[i]) continue;
                if(stick[i]+stick[j] > stick[k] && stick[j]+stick[k] > stick[i] && stick[k]+stick[i] > stick[j]) count ++;
            }
        }
    }

    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << 0 << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    string S,T;
    cin >> S >> T;
    int Ans=0;
    REP(i,S.size()){
        if(S[i]==T[i]){
            Ans++;
        }
    }
    cout << Ans << endl;
    
  return 0;
}



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

using namespace std;

#define MAX	11000

int main()
{
	long long int n;
	long long int input[MAX];

	while (cin >> n && n != 0)
	{
		long long int _min = 99999999;
		long long int all = 0;
		long long int _max = 0;
		long long int zero = 0;

		for (long long int i = 0; i < n; i++)
		{
			long long int c;
			cin >> c;

			all += c;
			_max = max(_max , c);
			_min = min(c , _min);

			if (c == 0)
			{
				zero++;
			}
		}

		if (_max <= 1)
		{
			cout << "NA" << endl;
		}
		else if (n == 1)
		{
			cout << "2" << endl;
		}
		else
		{
			cout << n + 1 - zero << endl;
		}
	
	}

	return 0;
}

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

int main()
{
    int T;
    long long s[200005];
    cin >> T;
    for(int i=0; i<T; i++)
        cin >> s[i];
    long long max1 = -2000000001, min1 = s[0];
    for(int i=1; i<T; i++)
    {
        max1 = max(max1,s[i]-min1);
        min1 = min(min1,s[i]);
    }
    cout << max1 << endl;
    return 0;
}

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

const int C = 50 * 50 + 5;
int n, m;
long long dp[55][2 * 55 * 55];

int main() {
	scanf("%d%d", &n, &m);

	for(int i = 1; i <= n; i++) {
		int x; scanf("%d", &x);
		x -= m;

		for(int j = 50 * 50; j >= -50 * 50; j--) {
			if(j - x <= 50 * 50 && j - x >= -50 * 50) {
				dp[i][j + C] += dp[i - 1][j - x + C];
				dp[i][j + C] += dp[i - 1][j + C];
			}
		}

		dp[i][x + C]++;
	}

	printf("%lld\n", dp[n][C]);
	return 0;
}

Measured memory_bytes: 2432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AthleteProgramming2
{
    class Program
    {
        static void Main()
        {
            int[] xy = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int x = xy[0];
            int y = xy[1];
            int r = x % y;
            while (r != 0)
            {
                x = y;
                y = r;
                r = x % y;
            }
            Console.WriteLine(y);
        }

    }
}

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

using namespace std;

int cnt[30];

int main()
{
    string s;
    cin >> s;
    s.pop_back();
    for(int i = 0; i < 200 ; ++i){
        // cout << s << endl;
        int n = s.length();
        if(n%2){
            s.pop_back();
            continue;
        }
        string a = s.substr(0,n/2) , b = s.substr(n/2,n/2);
        if(a==b){
            cout << s.length() << endl;
            return 0;
        }else s.pop_back();
    }
    return 0;
}

Measured memory_bytes: 3640
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 10000000;
using namespace std;
typedef long long  ll;
/** Problem0128 : Abacus **/
int main()
{
	string list[10];
	list[0] = "* = ****";
	list[1] = "* =* ***";
	list[2] = "* =** **";
	list[3] = "* =*** *";
	list[4] = "* =**** ";
	list[5] = " *= ****";
	list[6] = " *=* ***";
	list[7] = " *=** **";
	list[8] = " *=*** *";
	list[9] = " *=**** ";
	
	string n;
	string ans[5];
	bool first=true;
	
	while (cin>>n) {
		rep(i, 5) ans[i] = list[0];
		rep(i, n.length()) {
			ans[5-n.length()+i] = list[n[i]-'0'];
		}

		if (first) {
			first = false;
		} else {
			cout << endl;
		}
		rep(x, 8) {
			rep(y, 5) {
				cout << ans[y][x];
			}
			cout << endl;
		}
	}
}

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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a


using ll = long long;

int main() {
    IN(ll, a);
    IN(ll, b);
    IN(ll, k);
    
    if(k<=a){
        cout << a-k << " " << b << endl;
    }else if (k <= a+b){
        cout << 0 << " " << a+b-k << endl;
    }else{
        cout << "0 0" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define MAXN 100010
#define pb push_back
#define mp make_pair
using namespace std;

int main(){
	long long int a,n,t,from=0,till=0,cnt=0;
	cin>>n>>t;
	for(int i=0;i<n;i++){
		cin>>a;
		if(till>=a){
			cnt+=(a-from);
			from=a;
			till=a+t;
		}
		else{
			cnt+=(till-from);
			from=a;
			till=a+t;
		}
	}
	cnt+=(till-from);
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] a = new int[n][2];
		int count  = 0;
		int max = 0;
		for(int i=0;i<n;i++){
			a[i][0] = sc.nextInt();
			a[i][1] = sc.nextInt();
			if( a[i][0] == a[i][1] ){
				count++;
				if( count > max ){
					max = count;
				}
			}else{
				count = 0;
			}
		}
		if( max >= 3 ){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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

using namespace std;


void solve() {
    double t, x;
    cin >> t >> x;
    t /= x;
    cout << fixed << setprecision(10) << t;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

if len(str(n)) % 2 == 0:
  print(int("90" * int(len(str(n)) / 2 - 1) + "9"))
elif len(str(n)) == 1:
  print(n)
else:
  print(n - int("9" * (len(str(n)) -1)) + int("90" * (int((len(str(n)) - 1) / 2) - 1) + "9"))

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

int main() {
  int S; cin >> S;
  bool isYYMM = false;
  bool isMMYY = false;
  if (S % 100 >= 1 && S % 100 <= 12) {
    isYYMM = true;
  }
  if (S / 100 >= 1 && S / 100 <= 12) {
    isMMYY = true;
  }
  if (isYYMM && isMMYY) cout << "AMBIGUOUS" << endl;
  else if (isYYMM) cout << "YYMM" << endl;
  else if (isMMYY) cout << "MMYY" << endl;
  else cout << "NA" << endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto S = readln.chomp;
    auto len = S.length;
    int c;
    foreach (i; 0..len/2) {
        if (S[i] != S[len-i-1]) ++c;
    }
    writeln(c);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath> 
#include<map>
using namespace std;
const int maxn=2e5+5;
long long ula[maxn],a[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){scanf("%lld",&a[i]);ula[a[i]]++;}
	long long allsum=0;
	for(int i=1;i<=200000;i++)allsum+=(ula[i]*(ula[i]-1)/2);
	//cout<<allsum<<endl;
	
	for(int i=1;i<=n;i++){
		printf("%lld\n",allsum-((ula[a[i]]*(ula[a[i]]-1))/2)+(((ula[a[i]]-1)*(ula[a[i]]-2))/2));
	}
	return 0;
}

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

int main() {
  //カードの枚数
  int N;
  cin >> N;
  //リストに格納
  vector<int> list(N);
  for (int i = 0; i < N; i++){
    cin >> list.at(i);
  }
  //リストを小さい順に
  sort(list.begin(),list.end());
  //並びを反転
  reverse(list.begin(),list.end());
  //aliceがカードを選択
  int alice_sum = 0;
  for(int i  = 0; i < N; i = i + 2){
    alice_sum += list.at(i);
  }
  //bobがカードを選択
  int bob_sum = 0;
    for( int i = 1; i < N; i += 2){
      bob_sum += list.at(i);
    }
    //aliceの余剰を計算
     int morepoint = alice_sum - bob_sum;
     cout << morepoint << endl;
    
   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 3000000;
int mod = 1e9 + 7;
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    int n, a, b;
    cin >> n >> a >> b;
    int d = n + n - a - b - 1;
    if (d % 2){
        cout << "Alice";
    } else cout << "Borys";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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

	
	int N;
	cin >> N;
	int A[200001] = {};
	
	int mae = 0;
	ll kotae = 1;
	ll mod = 1e9 + 7;
	rep(i, N) {
		int C;
		cin >> C;
		if(mae != C) kotae = (kotae + A[C]) % mod;
		A[C] = kotae;
		mae = C;
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1024
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, a, b, c;
    scan(n, a, b, c);
    auto x = iota(n).map!(i => readln.chomp.to!int).array;

    long ans = inf6;

    foreach (s ; 0 .. 4^^n) {
        int la, lb, lc;
        int ca, cb, cc;

        foreach (i ; 0 .. n) {
            if (s % 4 == 0) {

            }
            else if (s % 4 == 1) {
                la += x[i];
                ca++;
            }
            else if (s % 4 == 2) {
                lb += x[i];
                cb++;
            }
            else if (s % 4 == 3) {
                lc += x[i];
                cc++;
            }
            s /= 4;
        }

        if (la == 0 || lb == 0 || lc == 0) continue;
        ans = min(ans, abs(la - a) + abs(lb - b) + abs(lc - c) + 10*(ca + cb + cc - 3));
    }

    writeln(ans);
}




int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i ; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i ; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {writeln(b ? "Yes" : "No");}
void YES(bool b) {writeln(b ? "YES" : "NO");}
T[] readArr(T)() {return readln.split.to!(T[]);}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%d %d", $t, $a);
$h_arr = explode(' ', trim(fgets(STDIN)));

$temp_arr = [];

foreach ($h_arr as $key => $h) {
    $tmp_arr[] = $t - $h * 0.006;
}

$min = abs($tmp_arr[0] - $a);
$min_index = 0;
for ($i = 1; $i < $n; ++$i) {
    $tmp = abs($tmp_arr[$i] - $a);
    if ($tmp < $min) {
        $min = $tmp;
        $min_index = $i;
    }
}

echo $min_index + 1;


Measured memory_bytes: 4728
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Not Divisible
 */

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

/* constant */

const int MAX_N = 200000;
const int MAX_A = 1000000;

/* typedef */

typedef pair<int,int> pii;

/* global variables */

int as[MAX_N];
pii ps[MAX_N];
bool used[MAX_A + 1];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);
  sort(as, as + n);
  
  int m = 0;
  for (int i = 0; i < n;) {
    int j = i + 1;
    while (j < n && as[i] == as[j]) j++;
    ps[m++] = pii(as[i], j - i);
    i = j;
  }

  int maxa = as[n - 1];
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    int ai = ps[i].first, ci = ps[i].second;
    if (! used[ai]) {
      if (ci == 1) cnt++;
      for (int a = ai; a <= maxa; a += ai) used[a] = true;
    }
  }

  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 6244
a = 3.times.map { gets.chomp.split(" ").map(&:to_i) }
n = gets.to_i
b = n.times.map { gets.to_i }

def check(arr)
  if arr.empty?
    puts "Yes"
    exit
  end
end

def checks(arr, b)
  arr.each do |ai|
    check(ai - b)
  end
end

check([a[0][0], a[1][1], a[2][2]] - b)
check([a[2][0], a[1][1], a[0][2]] - b)
checks(a, b)
a = a.transpose
checks(a, b)
puts "No"

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

int mod = 1e9+7;

int main() {
	
	int m,n;
	cin >> m >> n;
	vector<vector<char>> grid(m,vector<char>(n));
	
	for(int i=0; i<m; ++i) {
		for(int j=0; j<n; ++j)
		cin >> grid[i][j];
	}
	
	vector<vector<int>> dp(m,vector<int>(n,0));
	
	dp[0][0] = 1;
	
	for(int i=1; i<m; ++i) {
		if(grid[i][0]=='.' && dp[i-1][0]==1)
		dp[i][0] = 1;
	}
	
	for(int j=1; j<n; ++j) {
		if(grid[0][j]=='.' && dp[0][j-1]==1)
		dp[0][j] = 1;
	}
	
	dp[0][0] = 0;
	
	for(int i=1; i<m; ++i) {
		for(int j=1; j<n; ++j) {
			
			if(grid[i][j]=='#')
			continue;
			else
			dp[i][j] = ((dp[i-1][j]%mod)+(dp[i][j-1]%mod))%mod;
			
		}
	}
	
	// for(int i=0; i<m; ++i) {
	// 	for(int j=0; j<n; ++j)
	// 	cout << dp[i][j] << " ";
	// 	cout << endl;
	// }
	
	cout << dp[m-1][n-1]%mod << endl;
	return 0;
	
}

Measured memory_bytes: 8564
#include "bits/stdc++.h"
using namespace std;
 
int main() {
 
  int N;
  std::cin >> N;
 
  int i =0;
  int m = 0;
  int price;
  int total = 0;
  while (i < N) {
    i++;
    std::cin >> price;
    if(m < price){
      m = price;
    }
    total += price;
  }
 
  std::cout << total - (m/2) << '\n';
 
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

ll INF = (1ll << 32);
double EPS = 1e-4;

ll MOD = 1000000007;

int main() {
  ll N, K;

  cin >> N >> K;

  vi A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }

  vi v1(50);
  for (auto i: A) {
    for (ll j = 0; j < 50; j++) {
      if (i & (1ll << j)) {
        v1[j] += 1;
      }
    }
  }

  vi v2(50);
  for (ll j = 0; j < 50; j++) {
    if (K & (1ll << j)) {
      v2[j] += 1;
    }
  }

  ll ans = 0;

  for (ll i = 0; i < 49; i++) {
    if (v2[i + 1] == 0) continue;
    ll tmp = 0;
    for (ll j = 0; j <= i; j++) {
      tmp += (1ll << j) * max(v1[j], N - v1[j]);
    }
    tmp += (1ll << (i + 1)) * v1[i + 1];
    for (ll j = i + 2; j < 50; j++) {
      if (v2[j] == 0) {
        tmp += (1ll << j) * v1[j];
      } else {
        tmp += (1ll << j) * (N - v1[j]);
      }
    }
    ans = max(ans, tmp);
  }

  {
    ll tmp = 0;
    for (ll i = 0; i < 50; i++) {
      if (v2[i] == 0) {
        tmp += (1ll << i) * v1[i];
      } else {
        tmp += (1ll << i) * (N - v1[i]);
      }
    }
    ans = max(ans, tmp);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};

int a[100001],b[100001];
Pi d[100001]={};

int main() {

	int n,m;
	cin>>n>>m;
	rep(i,m){
		cin>>a[i]>>b[i];
		d[i].first=a[i];
		d[i].second=b[i];
	}
	sort(d,d+m);
	int ans=1,mi=d[0].second-1;
	for(int i=1; i<m; i++){
		if(mi<d[i].first){
			ans++;
			mi=d[i].second-1;
		}
		mi=min(mi,d[i].second-1);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1792
H, W = map(int, input().split())

A = []
for i in range(H):
  A.append(list(map(int, input().split())))
  
Q = []

for i in range(H):
  if sum(A[i]) % 2 == 1 and i < H-1:
    kurikosi_flag = True
  else:
    kurikosi_flag = False
   
  for j in range(W):
    #print(i,j)
    if A[i][j] % 2 == 0:
      continue
    elif kurikosi_flag:
      Q.append([i+1, j+1, i+2, j+1])
      A[i+1][j] += 1
      kurikosi_flag = False
    elif i < H-1:
      Q.append([i+1, j+1, i+1, j+2])
      A[i][j+1] += 1
    elif j+1 < W:
      Q.append([i+1, j+1, i+1, j+2])
      A[i][j+1] += 1
      
print(len(Q))
for i in range(len(Q)):
  print(" ".join(map(str,Q[i])))


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

const int MAX = 510000;
const ll mod = 1e9+7;

ll fac[MAX], finv[MAX], inv[MAX];

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

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

int main(){
  ll n, k;
  cin >> n >> k;
  COMinit();
  cout << COM(k,n) << endl;
  return 0;
}



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

int main(){
  long long n,c=0,ans=0;
  string s;
  cin >> n >> s;
  vector<vector<int>>a(n,vector<int>(26));
  vector<int>cnt(26,0);
  for(int i=0;i<s.size();i++){
    a.at(i)=cnt;
    cnt.at(s.at(i)-'a')++;
  }
  for(int i=0;i<s.size();i++){
    long long z=1;
    for(int j=0;j<26;j++)
      if('a'+j!=s.at(i))
      z=(z*(a.at(i).at(j)+1))%1000000007;
    ans=(ans+z)%1000000007;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 16636
#include<iostream>
#include<string>
using namespace std;
int ctoi(char c) {
	int i; char ch = '0';
	for (i = 0; i < 10; i++)if (ch == c)return i; else ch++;
	return -1;
}
int main() {
	string s;
	while (cin >> s) {
		if (s == "#")return 0;
		int map[10][110] = {};
		int h = 1, w = 1;
		//map[h][w]
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == 'b') {
				map[h][w] = 1;
				w++;
			}
			else if (s[i] == '/') {
				h++;
				w = 1;
			}
			else for (int j = 0; j < ctoi(s[i]); j++) {
				map[h][w] = 0;
				w++;
			}
		}
		w--;
		int tsu, ku, ko, ma;
		cin >> tsu >> ku >> ko >> ma;
		map[tsu][ku] = 0;
		map[ko][ma] = 1;
		for (int i = 1; i <= h; i++) {
			int cnt = 0;
			for (int j = 1; j <= w; j++) {
				if (map[i][j] == 1) {
					if (cnt)cout << cnt;
					cnt = 0;
					cout << 'b';
				}
				else 
					cnt++;
			}
			if (cnt)cout << cnt;
			if (i != h)cout << '/'; else cout << endl;
		}
	}
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K;cin>>K;
    string S;cin>>S;
    if(S.size()<=K)cout<<S;
    else {
        for (int i = 0; i < K; i++)
        {
            cout<<S[i];
        }
        cout<<"...";
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
#define endl '\n'
#define MAX 200005
#define pb push_back
#define mk make_pair
#define ll long long
vector< pair <int , int > > tes [20];
int main() {
    	
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int n;
    cin >> n;
    for(int i =0; i< n; i++)
    {
        int x;
        cin >> x;
        for(int j =0; j< x; j++)
        {
            int a,b;
            cin >> a >> b;
            a--;
            tes[i].pb(mk(a,b));
        }
    }
    int ans = 0;
    for(int i =0; i < (1<<n); i++)
    {
        //cout << " i = " << i << endl;
        map<int,int> is;
        int current = 0;
        for(int j=0; j < n; j++)
        {
            if(((1<<j) & i )== (1<<j)) 
            {
                is[j] = 1;
                current++;
            }
        }
        bool ok = true;
        for(int j=0; j < n; j++)
        {
            if(is[j] == 1)
            {
                for(int x=0; x< tes[j].size(); x++)
                {
                    int per = tes[j][x].first;
                    int val = tes[j][x].second;
                    if(is[per] != val)
                    {
        //                cout << "j,x = " << j << " " << x << endl;
                        ok = false;
                    }
                }
            }
        }
        if(ok)
        {
            ans = max(ans,current);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int result = 0;
    for(int i=0; i<2; i++){
      if(a>b){
        result += a;
        a -= 1;
      }else{
        result += b;
        b -= 1;
      }
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 23764
#include<stdio.h>
int main()
{
    char a;
    scanf("%c",&a);
    switch(a)
    {case 'A':printf("T\n");break;
    case 'T':printf("A\n");break;
    case 'C':printf("G\n");break;
    case 'G':printf("C\n");break;}
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

typedef long long LL;
typedef unsigned long UL;

using namespace std;


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

	int n, m, k, temp;
	cin >> n >> m;
	
	vector<int> ank(m + 1, 0);

	REP(i, n)
	{
		cin >> k;

		REP(j, k)
		{
			cin >> temp;
			++ank[temp];
		}
	}

	sort(ank.begin(), ank.end());
	auto itr = find(ank.begin(), ank.end(), n);

	size_t idx = distance(ank.begin(), itr);

	cout << m + 1 - idx << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>


int main()
{

    int N, D;
    std::vector<std::vector<int>> points;

    std::cin >> N >> D;
    auto is_integer = [D](const std::vector<int>& x1, const std::vector<int>& x2) {
        int sum = 0;
        for (int i = 0; i < D; i++) {
            sum += (x1[i] - x2[i]) * (x1[i] - x2[i]);
        }
        int temp = static_cast<int>(std::sqrt(sum));
        return temp * temp == sum;
    };

    points.resize(N);
    for (int i = 0; i < N; i++) {
        points[i].resize(D);
        for (int j = 0; j < D; j++) {
            std::cin >> points[i][j];
        }
    }

    int count = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (is_integer(points[i], points[j])) {
                ++count;
            }
        }
    }

    std::cout << count;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int A, B;
    cin >> A >> B;
    float alpha1 = 12.5 * A, alpha2 = 12.5 * (A + 1);
    float beta1 = 10.0 * B, beta2 = 10.0 * (B + 1);
    int A1 = int(alpha1);
    int A2 = int(alpha2);
    int B1 = int(beta1);
    int B2 = int(beta2);
    if ((alpha1) != (float)(A1))
        A1++;
    if (alpha2 != (float)(A2))
        A2++;
    if ((beta1) != (float)(B1))
        B1++;
    if (beta2 != (float)(B2))
        B2++;
    int i = A1, j = B1;
    int answer = -1;
    while (i < A2 && j < B2)
    {
        if (i == j)
        {
            answer = i;
            break;
        }
        if (i < j)
            ++i;
        else if (j < i)
            ++j;
    }
    cout << answer << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n,k;
	cin >>n;
	cin >>k;
	int a[n];
	for(int i=0; i<n; ++i){
		cin >>a[i];
	}
	sort(a,a+n);
	int s=0;
	for(int i=0; i<k; i++){
		s+=a[i];
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 3608
/*
name:       Egyptian Tourist
PlatForm:   CodeForces/SPOJ...etc
LANG:       C++
DIV:        Training
TIME:       *
RATE:       *
*/

/*
Time Consumed:*
Problem Topics: *
*/
#include <bits/stdc++.h>
#include <iostream>

using namespace std;
//----------------------------------//

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

//-------------------------------------------------------//
#define rep(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define repr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define lp(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define lpr(i,n) for (int i = (n) - 1; ~i; i--)
#define foreach(it, ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
//-------------------------------------------------------------------------------------//

#define clr(ar, val) memset(ar, val, sizeof(ar))
//----------------------------------------------//

#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#define PI 3.1415926535897932385
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define pob pop_back
#define bit(n) (1<<(n))
#define Last(i) ( (i) & (-i) )
#define all(v) ((v).begin()), ((v).end())
#define sq(x) ((x) * (x))
#define INF INT_MAX
#define Ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

//-------------------------------------------------------------//
#ifndef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1<<" | ";
    __f(comma+1, args...);
}
#else
#define debug(...)
#endif
//------------------------------------------------------------//
template<class T, class T2>
T _f_pow(T a, T2 b)
{
    T res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
#define N (int)1e5 + 5
int abc[N][4];
int dp[N][4];
int n;

int main()
{
    Ios;
    //inn;//outt;
    //auto tt = clock();
    cin >> n;
    rep(day, 1, n)
    {
        rep(j, 1,3)
        {
            cin >> abc[day][j];
        }
    }
    rep(i, 1, n)
    {
        rep(j, 1, 3)
        {
            rep(k, 1, 3)
            {
                rep(jk, 1, 3)
                {
                    if(j != k && j != jk && jk != k)
                    {
                        dp[i][j] = max(dp[i][j], dp[i - 1][k] + abc[i][k]);
                        dp[i][j] = max(dp[i][j], dp[i - 1][jk] + abc[i][jk]);
                    }
                }
            }
        }
    }
    cout << max(dp[n][1], max(dp[n][2], dp[n][3])) << "\n";
    //cout << (double(clock() - tt)/CLOCKS_PER_SEC * 1.00) << endl;
    return 0;
}


Measured memory_bytes: 3328
N, x = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])

ans = 0

if sum(a) < x:
  	ans = N - 1
elif sum(a) == x:
    ans = N
else:
    for i in range(N):
        if x >= a[i]:
            x -= a[i]
            ans += 1

print(ans)

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s;cin >> s;
	rep(i, 0, s.size()) {
		if (s[i] == ',')s[i] = ' ';
	}
	cout << s << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    ll ans = 1;
    for (char c = 'a'; c <= 'z'; c++)
    {
        ans *= (count(S.begin(), S.end(), c) + 1);
        ans %= 1000000007;
    }
    ans = (ans - 1) % 1000000007;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
	    ll a,b,c,d;
	    cin>>a>>b>>c>>d;
	    ll f=(c+b-1)/b;
	    ll s=(a+d-1)/d;
	    //cout<<f<<endl<<s<<endl;
	    if(f<=s)
	    	cout<<"Yes";
	    else
	    	cout<<"No";
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx[]= {0,0,1,-1,-1,1,-1,1};
int fy[]= {1,-1,0,0,-1,1,1,-1};
int fx1[]={0,1,1,1,0,-1,-1,-1};
int fy1[]={1,1,0,-1,-1,-1,0,1};*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
    #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
 //   freopen("output.txt","w",stdout);
    #endif
    cin>>s>>s1;
    cout<<s1+s<<endl;

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
const int maxn=2e5+10;
const double pi=3.1415926535897932384626433832;
using namespace std;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
 
struct node
{
	int l,r;
	int maxi;
	node *ls,*rs;
} *root;
int x1,y1,x2,y2;
int st,xx,yy;
int ans;
int n,s=1,cntx,cnty;
vector<pii> f;
map<int,int> lsh;
int dp[maxn];
 
void init(node *p,int l,int r)
{
	p->l=l;p->r=r;p->maxi=0;
	if (l==r) return;
	p->ls=new node;
	p->rs=new node;
	
	init(p->ls,l,(l+r)>>1);
	init(p->rs,((l+r)>>1)+1,r);
	return;
}
 
int search(node *p,int l,int r)
{
	if (l>r) return 0;
	if (l<=p->l && p->r<=r) return p->maxi;
	
	int ans=0;
	if (l<=p->ls->r) ans=max(ans,search(p->ls,l,r));
	if (p->rs->l<=r) ans=max(ans,search(p->rs,l,r));
	return ans;
}
 
void add(node *p,int index,int pos)
{
	if (p->l==p->r)
	{
		p->maxi=max(p->maxi,index);
		return;
	}
	
	if (pos<=p->ls->r) add(p->ls,index,pos);
	else add(p->rs,index,pos);
	p->maxi=max(p->ls->maxi,p->rs->maxi);
	return;
}
 
int main()
{
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	scanf("%d",&n);
	st=abs(x2-x1)+abs(y2-y1);
	
	if (x1>x2)
	{
		swap(x1,x2);
		swap(y1,y2);
	}
	
	if(y1>y2)
	{
		s=-1;
		y1*=s;y2*=s;
	}
	
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&xx,&yy);
		yy*=s;
		if (x1<=xx && xx<=x2 && y1<=yy && yy<=y2)
			f.push_back(mp(xx,yy));
	}
	
	if (x1==x2 || y1==y2)
	{
		printf("%.15lf\n",(double)st*100.+(double)f.size()*(10.*pi-20.));
		return 0;
	}
	else if (!f.size())
	{
		printf("%.15lf\n",(double)st*100.);
		return 0;
	}
	
	lsh.clear();
	for(int i=0;i<f.size();i++)
		lsh[f[i].x]=0;
	cntx=0;
	for(map<int,int>::iterator ii=lsh.begin();ii!=lsh.end();ii++)
	{
		cntx++;
		ii->second=cntx;
	}
	for(int i=0;i<f.size();i++)
		f[i].x=lsh[f[i].x];
	
	lsh.clear();
	for(int i=0;i<f.size();i++)
		lsh[f[i].y]=0;
	cnty=0;
	for(map<int,int>::iterator ii=lsh.begin();ii!=lsh.end();ii++)
	{
		cnty++;
		ii->second=cnty;
	}
	for(int i=0;i<f.size();i++)
		f[i].y=lsh[f[i].y];
	
	sort(f.begin(),f.end());
	root=new node;
	init(root,1,f.size());
	for(int i=0;i<f.size();i++)
	{
		dp[i]=search(root,1,f[i].y-1)+1;
		add(root,dp[i],f[i].y);
	}
	
	ans=0;
	for(int i=0;i<f.size();i++)
		ans=max(ans,dp[i]);
	
	printf("%.15lf\n",(double)(st*100.)-(double)(ans*(20.-5*pi))
		  +((ans==min(x2-x1,y2-y1)+1)?5*pi:0.));
	return 0;
}

Measured memory_bytes: 30704
from collections import defaultdict

from scipy.misc import comb

N, M = map(int, input().split())
A = [int(x) for x in input().split()]

B = [0] * N
B[0] = A[0]
for i in range(1, N):
    B[i] = B[i - 1] + A[i]
B = [0] + B

c = defaultdict(int)
for i in range(N + 1):
    c[B[i] % M] += 1

ans = 0
for k, v in c.items():
    if v >= 2:
        ans += comb(v, 2, exact=True)
print(ans)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){

  string str;
  IN(str);

  ll num_of_x = 0;
  REP(i,str.size()) if(str[i]=='x') num_of_x++;

  if(num_of_x<=7) OUT("YES");
  else            OUT("NO");

  return 0;
}


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

// Union-Find木
struct UnionFind {
  vector<int> par;
  
  // Constructor
  UnionFind(int n): par(n) {
    for(int i = 0; i < n; i++) par[i] = i;
  }
  
  // n要素で初期化
  void init(int n) {
    par.resize(n);
    for(int i = 0; i < n; i++) par[i] = i;
  }
  
  // 根の検索
  int find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }
  
  // xとyの属する集合を併合
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return false;
    par[x] = y;
    return true;
  }
  
  // xとyが同じ集合に属するか
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k, l;
  cin >> n >> k >> l;
  
  UnionFind road(n + 1), rail(n + 1);
  
  int p, q;
  for(int i = 0; i < k; i++){
    cin >> p >> q;
    road.unite(p, q);
  }
  
  int r, s;
  for(int i = 0; i < l; i++){
    cin >> r >> s;
    rail.unite(r, s);
  }
  
  map<pair<int, int>, int> mp;
  for(int i = 1; i <= n; i++){
    mp[make_pair(road.find(i), rail.find(i))]++;
  }
  
  for(int i = 1; i <= n; i++){
    if(i > 1) cout << " ";
    cout << mp[make_pair(road.find(i), rail.find(i))];
  }
  cout << '\n';
}

Measured memory_bytes: 13568
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n;
    cin >> n;
    vector<int> d1(n), d2(n);
    for (int i = 0; i < n; i++) cin >> d1[i] >> d2[i];

    int streak = 0;

    for (int i = 0; i < n; i++) {
        if (d1[i] == d2[i])
            streak++;
        else
            streak = 0;

        if (streak >= 3) {
            cout << "Yes"
                 << "\n";
            return 0;
        }
    }

    cout << "No"
         << "\n";
}


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

const int dx[] = { 1, 0, -1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int INF = 1e9;

struct dnode {
	int v;
	int dist;
	int d;
	dnode(int v, int dist, int d) : v(v), dist(dist), d(d) {}
	bool operator>(const dnode& that) const {
		return dist > that.dist;
	}
};

int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<int>> A(H, vector<int>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	vector<vector<vector<int>>> d(H, vector<vector<int>>(W, vector<int>(H * W, INF)));
	priority_queue<dnode, vector<dnode>, greater<>> pq;
	pq.emplace(0, 0, 0);
	while (!pq.empty()) {
		auto p = pq.top(); pq.pop();
		int x = p.v / W, y = p.v % W;
		if (d[x][y][p.d] != INF) continue;
		d[x][y][p.d] = p.dist;
		if (p.d + 1 >= H * W) continue;
		for (int i = 0; i < 4; i++) {
			int tx = x + dx[i], ty = y + dy[i];
			if (0 <= tx && tx < H && 0 <= ty && ty < W && d[tx][ty][p.d + 1] == INF) {
				int cost = (p.d * 2 + 1) * A[tx][ty];
				pq.emplace(tx * W + ty, p.dist + cost, p.d + 1);
			}
		}
	}
	cout << *min_element(d[H - 1][W - 1].begin(), d[H - 1][W - 1].end()) << endl;
	return 0;
}



Measured memory_bytes: 12260