akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    char[]ss = S.toCharArray();
    
    if(N%2!=0){
    System.out.println("No");
    }else if(S.substring(0,N/2).equals (S.substring(N/2,N))){
    System.out.println("Yes");
    }else{
    System.out.println("No");   
        }
    }
}

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

namespace program {
  class Program {
    static void Main()
    {
      var n = Input.ScanInt();
      int k = (n+1)/2;
      Out((double)k/n);
    }
    static public void Out(object s) { Console.Write($"{s} "); }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


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

long long int gcd(long long int a, long long int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    if (a == b) 
        return a; 
   
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 

int main()
{
	long long int a,b;
	cin>>a>>b;
	long long int c=gcd(a,b);
	cout<<((a*b)/c);
	return 0;
}

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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct unionFind{

    vector<int> par, rank;

    void init(int n){
        par.resize(n);
        rank.resize(n, 0);
        rep(i, n){
            par[i] = i;
        }
        return;
    }

    int root(int x){
        if(par[x] == x){
            return x;
        }else{
            par[x] = root(par[x]);
            return par[x];
        }
    }

    bool unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return false;
        }
        if(rank[rx] < rank[ry]){
            par[rx] = ry;
        }else if(rank[rx] == rank[ry]){
            par[rx] = ry;
            rank[ry]++;
        }else{
            par[ry] = rx;
        }
        return true;
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

};

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
        a[i]--;
    }
    unionFind uf;
    uf.init(n);
    rep(i, m){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        uf.unite(x, y);
    }
    int ans = 0;
    rep(i, n){
        if(uf.same(i, a[i])){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

long long int dp[100000];
long long int cost(long long int n,vector<long long int>&arr)
{
    if(dp[n]!=-1)return dp[n];
    dp[n]=min(abs(arr[n]-arr[n-1])+cost(n-1,arr),abs(arr[n]-arr[n-2])+cost(n-2,arr));
    return dp[n];
}

int main()
{
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    long long int n;
    cin>>n;
    vector<long long int>arr(n);
    for(long long int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    dp[1]=abs(arr[1]-arr[0]);
    cout<<cost(n-1,arr);
}


Measured memory_bytes: 4096
'use strict'
 
function main(A) {
  A = A.replace(/\r?\n/g,' ');
  A = A.split(' ');
  let N = A.shift(); //sortNum | A.length
  var s = A.map(Number);
  let humidai = 0;
  
  for(let i = 1; i < N; i++){
    if(s[i - 1] > s[i]){
      humidai += s[i - 1] - s[i];
      s[i] = s[i - 1];
    }else if(s[i - 1] == s[i]){
	  humidai += 0;
    }
  }
  
  console.log(humidai);
  
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 53624
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <string>
#include <numeric>
#include <tuple>

intmax_t constexpr mod = 1e9+7;

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

  std::vector<size_t> a(m);
  for (auto& ai: a) scanf("%zu", &ai);
  std::set<size_t> s(a.begin(), a.end());

  std::vector<intmax_t> dp(n+3);
  dp[0] = 1;
  for (size_t i = 0; i < n; ++i) {
    if (s.count(i)) continue;
    (dp[i+1] += dp[i]) %= mod;
    (dp[i+2] += dp[i]) %= mod;
  }
  printf("%jd\n", dp[n]);
}


Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;

ll dp[50];
void solve(){
  int n;
  cin>>n;
  memset(dp,0,sizeof(dp));
  dp[0]=1,dp[1]=1;
  rep(i,n-1)dp[i+2]=dp[i+1]+dp[i];
  cout<<dp[n]<<"\n";
}

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



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

#define F first 
#define S second

using namespace std;

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

const int N = 3, M = 55, mod = 1000000007;

int n;
char s[N][M];

int main()
{
	cin >> n;
	for (int i = 1; i < N; i ++ ) cin >> s[i] + 1;
	
	int i, last;
	LL res;
	if (s[1][1] == s[1][2]) res = 6, i = 3, last = 2;
	else res = 3, i = 2, last = 1;
	
	while (i <= n)
	{
		if (s[1][i] == s[1][i + 1])
		{
			if (last == 2) res = res * 3LL % mod;
			else res = res * 2LL % mod;
			last = 2;
			i += 2;
		}
		else
		{
			if (last == 1) res = res * 2LL % mod;
			last = 1;
			i ++ ;
		}
		// cout << res << endl;
	}
	cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;

  class Program {
    static void Main(string[] args) {

      int lenA = Convert.ToInt32(Console.ReadLine());
      int[] A = Array.ConvertAll(Console.ReadLine().Split(' '), Temp => Convert.ToInt32(Temp));
      
      for (int i = 0; i < lenA; i++)
      {
        if (A[i] != (i +1))
        {
            int c = A[A[i]-1];
            A[A[i]-1] = A[i];
            A[i] = c;
         break;
        }
        
      }

      for (int i = 0; i < lenA - 1; i++)
      {
          if (A[i]>A[i+1])
          {
            Console.WriteLine("NO");
            return;
          }
        
      }

      Console.WriteLine("YES");
      return;
    }
  }

    // static int[] climbingLeaderboard(int[] scores, int[] alice) {
    //   int[] ans = new int[] { 5, 4, 3, 2, 1 };
    //   return ans;
//int[] alice = Array.ConvertAll(Console.ReadLine().Split(' '), aliceTemp => Convert.ToInt32(aliceTemp));

    // }


Measured memory_bytes: 17916
IDENTIFICATION DIVISION.
PROGRAM-ID. 158B.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(100).
01 A          PIC 9(3).
01 B          PIC 9(3).
01 T1         PIC 9(3).
01 T2         PIC 9(3).
01 P1         PIC 9(4).
01 P2         PIC 9(4).
01 PRI        PIC 9(4).
01 OUT-PRI    PIC ----9.
*> 
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO A B.
*>  
  COMPUTE P1 ROUNDED = A * 12.5
  COMPUTE P2 = B * 10
  IF (P1 > P2)
    MOVE P1 TO PRI
  ELSE
    MOVE P2 TO PRI
  END-IF
*>
  COMPUTE T1 = PRI * 0.08
  COMPUTE T2 = PRI * 0.1
*>
  IF (T1 NOT = A) OR (T2 NOT = B)
    MOVE -1  TO OUT-PRI
  ELSE
    MOVE PRI TO OUT-PRI
  END-IF

  DISPLAY OUT-PRI.
 
MAIN-EXIT.
  STOP RUN.


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

long long N,K,cnt=0,cnt2=0;

int main(){
    cin>>N>>K;
    if(K%2==0){
        rep(i,N+1)if(i%K==K/2)cnt2++;
    }
    repi(i,1,N+1)if(i%K==0)cnt++;
    out(cnt*cnt*cnt+cnt2*cnt2*cnt2);

    
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    string line;
    while(cin >> line) {
        for(int i = 0; i < line.size(); ++i) 
            if(line[i] == ',') line[i] = ' ';
        istringstream is(line);
        vector<int> ls(10);
        int v1, v2;
        for(int i = 0; i < 10; ++i) is >> ls[i];
        is >> v1 >> v2;
        int len = accumulate(ls.begin(), ls.end(), 0);
        int pos = v1*len/(v1+v2);
        int mod = v1*len%(v1+v2);
        int acc = 0;
        for(int i = 0; i < 10; ++i) {
            acc += ls[i];
            if(acc >= pos) {
                if(acc > pos || (acc == pos && mod == 0)) cout << i+1 << endl;
                else cout << i+2 << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
    #include <stdlib.h>

    int main(){
        int a = 0, b = 0,soma = 0;
        scanf("%i %i", &a, &b);
        soma = a + b;
        if(a < 9 && b < 9){
            printf("Yay!");
        }
        else
            printf(":(");
    return 0;
    }

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
#define int long long
#define inf   1000000009
#define minf -1000000009
int a[2005];
signed main() {
	int n, z, w;
	cin >> n >> z >> w;
	for (int i = 0; i < n; i++)cin >> a[i];

	if (n == 1)cout << abs(a[0] - w) << endl;
	else cout << max(abs(a[n - 1] - a[n - 2]), abs(a[n - 1] - w)) << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

mod = 10**9+7
ism = defaultdict(int)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]

for i in range( n):
    dl = factorization(a[i])
    for x, y in dl:
        if ism[x] < y:
            ism[x] = y
lcd = 1
for i in ism.keys():
    lcd = (lcd * (i ** ism[i]))%mod
result = 0
for i in range(n):
    result =(result + lcd *extgcd(a[i],mod)[0])%mod
print(result)

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;


void solve(){
    ll x;
    cin>>x;
    vector<ll> pw;

    // map<ll, int> mp;
    ll lim = numeric_limits<ll>::max();
    ll i = 0;
    while(!i || lim/(i*i*i*i) > i){
        pw.push_back(i*i*i*i*i);
        i++;
    }

    ll z = pw.size();
    ll a, b;

    for(ll i=0; i<z; i++){
        a = pw[i];
        for(ll j=0; j<z; j++){
            b = pw[j];
            if(a >= b && a - b == x){
                cout<<i<<" "<<j;
                return;
            }
            if(a <= x && a + b == x){
                cout<<i<<" "<<-j;
                return;
            }
        }
    }

}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



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

using namespace std;
typedef pair<int,int> pii;
const int N = 1010;
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
int _w;

int n, m;
char str[N][N];
int dis[N][N];
queue<pii> q;

bool inside( int x, int y ) {
	return x >= 1 && x <= n && y >= 1 && y <= m;
}

int main() {
	_w = scanf( "%d%d", &n, &m );
	for( int i = 1; i <= n; ++i )
		_w = scanf( "%s", str[i]+1 );
	memset(dis, -1, sizeof dis);
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= m; ++j )
			if( str[i][j] == '#' )
				dis[i][j] = 0, q.push( pii(i, j) );
	int ans = 0;
	while( !q.empty() ) {
		pii now = q.front(); q.pop();
		ans = max(ans, dis[now.first][now.second]);
		for( int i = 0; i < 4; ++i ) {
			int nx = now.first + dx[i];
			int ny = now.second + dy[i];
			if( inside(nx, ny) && dis[nx][ny] == -1 ) {
				dis[nx][ny] = dis[now.first][now.second] + 1;
				q.push( pii(nx, ny) );
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
#define FRO freopen("in.txt","r",stdin);


int main()
{
        int n,i,j,t,tcs=0,k,m,u,v;
        string s1,s2;
        cin>>s1>>s2;
        int len1=s1.size(),len2=s2.size();

        int arr[len1][len2];
        bool flag=0;
        for(i=0;i<len1;i++)
        {
                if(flag || s1[i]==s2[0])
                {
                        flag=1;
                        arr[i][0]=1;
                }
                else arr[i][0]=0;
        }
        flag=0;
        for(i=0;i<len2;i++)
        {
                if(flag || s1[0]==s2[i])
                {
                        flag=1;
                        arr[0][i]=1;
                }
                else arr[0][i]=0;
        }

        for(i=1;i<len1;i++)
        {
                for(j=1;j<len2;j++)
                {
                        if(s1[i]==s2[j])
                                arr[i][j]=arr[i-1][j-1]+1;
                        else
                                arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
                }
        }

//        for(i=0;i<len1;i++)
//        {
//                for(j=0;j<len2;j++)
//                {
//                        cout<<arr[i][j]<<' ';
//                }cout<<endl;
//        }

        stack<char>stk;
        i=len1-1; j=len2-1;
        while(0<i && 0<j)
        {
                if(s1[i]==s2[j])
                {
                        stk.push(s1[i]);
                        i--;
                        j--;
                }
                else
                {
                        if(arr[i][j]==arr[i-1][j])
                                i--;
                        else
                                j--;
                }
        }

        if(arr[i][j]==1)
        {
                if(i==0)
                        stk.push(s1[0]);
                else
                        stk.push(s2[0]);
        }

        while(!stk.empty())
        {
                cout<<stk.top();
                stk.pop();
        }

	return 0;
}



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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int t[24][60][60];

void read_time(int& h, int& m, int& s) {
    string str;
    cin >> str;
    replace(ALL(str), ':', ' ');
    stringstream ss(str);
    ss >> h >> m >> s;
}

int main() {
    int n;
    while (cin >> n, n) {
        fill_n((int *)t, 24*60*60, 0);
        REP(i, n) {
            int sh, sm, ss, eh, em, es;
            read_time(sh, sm, ss);
            read_time(eh, em, es);
            bool ok = false;
            REP(h, 24) {
                REP(m, 60) {
                    REP(s, 60) {
                        if (h == sh && m == sm && s == ss) {
                            ok = true;
                        }
                        if (h == eh && m == em && s == es) {
                            goto NEXT;
                        }
                        if (ok) t[h][m][s]++;
                    }
                }
            }
NEXT: {}
        }
        int ma = 0;
        REP(h, 24) {
            REP(m, 60) {
                REP(s, 60) {
                    ma = max(ma, t[h][m][s]);
                }
            }
        }
        cout << ma << endl;
    }
}

Measured memory_bytes: 3320
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    map<int, int> mp;
    REP(i, n){
        int tmp; cin >> tmp;
        auto fd = mp.find(tmp);
        if(fd != mp.end()) {
            if(mp.at(tmp) == 1) mp[tmp] = 0;
            else mp[tmp] = 1;
        }
        else mp.emplace(tmp, 1);
    }
    ll ans = 0;
    for(pair<int, int> i : mp){
            if(i.second == 1) ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
char mape[256];
int idx[256];
bool vis[256];
int main()
{
    memset(vis, 0, sizeof(vis));
    memset(mape, -1, sizeof(mape));
    for (char c = 'a'; c <= 'z'; c++)
    {
        mape[c] = c;
        idx[c] = c;
    }
    string a, b;
    cin >> a >> b;
    int n = a.size();
    for (int i = 0; i < n; i++)
    {
        char A = mape[a[i]];
        char B = b[i];
        if (vis[A] || vis[B])
        {
            if (A != B)
            {
                //cout << A << B << endl;
                cout << "No" << endl;
                system("pause");
                return 0;
            }
        }
        else
        {
            mape[idx[A]] = B;
            mape[idx[B]] = A;

            swap(idx[A], idx[B]);

            vis[B] = true;
        }
    }
    cout << "Yes" << endl;
    system("pause");
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int n = sc.nextInt();
		int xl = 0; int xr = w;
		int yl = 0; int yr = h;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int a = sc.nextInt();
			if(a == 1) xl = Math.max(x, xl);
			else if(a == 2) xr = Math.min(x, xr);
			else if(a == 3) yl = Math.max(y, yl);
			else yr = Math.min(y, yr);
		}
		System.out.println(xr>xl&&yr>yl?(xr-xl)*(yr-yl):0);
		sc.close();
	}
}

Measured memory_bytes: 22100
'use strict';

function Main(INPUT) {
    const input = INPUT.split("\n")[0].split(" ");
    const A = parseInt(input[0], 10);
    const B = parseInt(input[1], 10);

    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
        console.log("Possible");
    } else {
        console.log("Impossible");
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define sanyes ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long
#define pb push_back
#define bpc __builtin_popcount

const llong mxn = 1e5 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

llong n, a[mxn], k, dp[mxn];

bool ok = 0;

int main (){
    cin >> n >> k;
    for (int i = 1; i <= n; i ++){
        cin >> a[i];
    }for(int i = 1; i <= k; i ++){
        for (int j = 1; j <= n; j ++){
            if(i == a[j]){
                dp[i] = 1;
            }
        }
    }for (int i = 1; i <= k; i ++){
        ok = 0;
        for (int j = 1; j <= n; j ++){
            if(i >= a[j]){
                if(dp[i - a[j]] != 1){
                    ok = 1;
                }
            }
        }if(ok == 1){
            dp[i] = 1;
        }else{
            dp[i] = 0;
        }//cout << dp[i] << ' ';
    }//cout << endl;
    if(dp[k] == 1){
        cout << "First";
    }else{
        cout << "Second";
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 2e5+10;

ll n,k,a[maxn],b[maxn],c[maxn],bit[maxn*1000];

void add(ll x,int v){
	while(x<maxn){
		bit[x] += v;
		x += x&-x;
	}
}

ll sum(ll x){
	ll res = 0;
	while(x > 0){
		res += bit[x];
		x -= x&-x;
	}
	return res;
}

int main(){
	cin >> n >> k;
	for(int i=1; i<=n; i++)
		a[i] = read();
	
	for(int i=0; i<=n; i++){
		a[i] -= k;
		b[i] = b[i-1]+a[i];
		c[i] = b[i];
	}

	sort(b,b+n+1);
	int sz = unique(b,b+n+1)-b;
	ll res = 0;
	for(int i=0; i<=n; i++) c[i] = lower_bound(b,b+sz,c[i])-b+1;
	for(int i=0; i<=n; i++){
		res += sum(c[i]);
		add(c[i],1);
	}
	cout << res << endl;

    return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
 using namespace std;
 int main()
 {
int n1;
 cin>>n1;
  int n=n1%10;
 if(n==2|| n==4|| n==5||n==7|| n==9)
   cout<<"hon";
   else if(n==0|| n==1|| n==6|| n==8)
    cout<<"pon";
    else
    cout<<"bon";
     
     
 }

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i,N) cin >> P[i];
  bool ok = true;
  vector<bool> arr(N);
  rep(i,N) arr[i] = false;
  rep(i,N){
    if(P[i]==i+1){
      ok = false;
      arr[i] = true;
    }
  }
  if(ok) {cout << 0 << endl; return 0;}
  int ans = 0;
  for(int i=1;i<N;i++){
    if(arr[i-1] && arr[i]) {ans++; arr[i-1] = arr[i] = false;}
    else if(arr[i-1] && !arr[i]){ ans++; arr[i-1] = false;}
    else if(!arr[i-1] && arr[i]){
      if(i==N-1) ans++;
    }
  }

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


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    string S;
    cin >> S;
    bool ok = true;
    if (S[0] != 'A'){
        ok = false;
    } 
    int cnt = 0;
    for (int i=2;i<S.length()-1;i++){
        if (S[i]=='C') cnt+=1;
    }
    if (cnt != 1) ok = false;
    int sml_cnt = 0;
    for(int i=0;i<S.length();i++){
        if ((S[i]>='a') && (S[i]<='z')) sml_cnt+=1;
    }
    if (sml_cnt != S.length()-2) ok = false;



    if (ok) cout << "AC" << endl;
    else cout << "WA" << endl;

    
}

Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n int64
    fmt.Scan(&n)
    var ans int64 = 1
    for i:=int64(1);i*i<=n;i++{
        ans = i*i
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

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

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

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}


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

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b,c;
  int x = 'a' - 'A';
  cin >> a >> b >> c;
  a[0] -= x;
  b[0] -= x;
  c[0] -= x;
  cout << a[0] << b[0] << c[0] << '\n';
  return 0;
}

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

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        public static List<long> GeneratePrime(long max)
        {
            long prime;
            double sqrtMax = Math.Sqrt(max);
            var primeList = new List<long>();

            List<long> searchList = new List<long>();
            for (long i = 2; i <= max - 1; i++)
            {
                searchList.Add(i);
            }

            do
            {
                prime = searchList.First();
                primeList.Add(prime);
                searchList.RemoveAll(n => n % prime == 0);
            } while (prime < sqrtMax);

            primeList.AddRange(searchList);

            return primeList;
        }

        void Omame()
        {
            cin = new Scanner();
            long N = cin.nextLong();
            long M = cin.nextLong();

            if (N == M)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

signed main () {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while (b <= a) {
		b *= 2;
		--k;
	}
	while (c <= b) {
		c *= 2;
		--k;
	}
	if (k >= 0)
		cout << "Yes\n";
	else
		cout << "No\n";
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

struct UFT{
  int * p;
  
  UFT(int N):p(new int[N]){fill(p,p+N,-1);}  
  ~UFT(){delete[] p;}  
  int par(int a)   { if( p[a] >= 0 ){ p[a] = par( p[a] ); return p[a]; } return a;  }
  int size(int a)  { return -p[par(a)]; }
  bool	same(int a, int b) { return par(a) == par(b); }
  void unite(int a, int b){
    a = par(a);  b = par(b);
    if( a == b ) return;
    if( size(a) < size(b) )a^=b^=a^=b;
    p[a] -= size(b);
    p[b] = a;
  }
};


int main(){
  int n,m; cin >> n >> m;  
  vector<P<int,int>> v;
  for(int i = 0; i < m; ++i){
    int a,b; cin >> a >> b; a--; b--;
    v.push_back({a,b});
  }
  int ans = 0;
  for(int i = 0; i < m; ++i){
    UFT uft(n);
    for(int j = 0; j < m; ++j){
      if(j == i) continue;
      uft.unite(v[j].first,v[j].second);
    }
    bool connect = true;
    int p = uft.par(0);
    for(int i = 0; i < n; ++i)connect &= (uft.par(i)==p);
    if(!connect)ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def solve(ans, array)
  if ans == 0
    return true
  elsif array.nil? or array.empty?
    return false
  elsif array.length == 1
    if ans == array[0]
      return true
    else
      return false
    end
  else
     solve(ans-array[0], array[1..-1]) or solve(ans, array[1..-1])
  end
end

n = STDIN.gets.to_i
A = STDIN.gets.split(" ").map { |i| i.to_i }

q = STDIN.gets.to_i
M = STDIN.gets.split(" ").map { |i| i.to_i }

M.each do |m|
  if solve(m, A)
    print "yes\n"
  else
    print "no\n"
  end
end

Measured memory_bytes: 8876
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define eps 1e-8
//#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int mod = 1e9+7;
long double PI = acosl(-1);
const ll infl = 3e18+100;
const int inf = 1e8+100;
const int nmax = 1e5+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

void NA(){
    cout<<"0";
    exit(0);
}

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

    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int>typ(2*n);
    if(s[0]=='W' or s[2*n-1]=='W') NA();

    for(int i=1; i<2*n; i++){
        if(s[i]==s[i-1]) typ[i] = typ[i-1] ^ 1;
        else typ[i] = typ[i-1];
    }
    if(typ[2*n-1]==0) NA();
    int pref1=0, pref0=1;
    ll ans = 1;
    int sam = 0;
    for(int i=1; i<2*n; i++){
        if(typ[i]){
            int opshon = pref0-pref1;
            ans = (ans * max(0, opshon))%mod;
            sam++;
        }
        if(typ[i]) pref1++;
        else pref0++;
    }
    if(sam!=n) NA();
    for(int i=1; i<=n; i++) ans = (ans * i) % mod;
    cout<<ans<<endl;

}


Measured memory_bytes: 4664
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

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

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 998244353;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

int main(){


  string s = stin();
  string t = stin();
  if(s == t){
    puts("H");
  } else {
    puts("D");
  }

  return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  int k = 0;
  string ans = "No";
  while(k <= n) {
    if ((n-k) % 7 == 0) {
      ans = "Yes";
      break;
    }
    k += 4;
  }
  cout << ans << endl;
}

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

int main(){
	string s;
	int m, n;

	while(!cin.eof()){
		cin >> s >> m;
		if (s == "-"){
			break;
		}
		for (int i = 0; i < m; i++){
			cin >> n;
			s = s.substr(n) + s.substr(0,n);
		}
		cout << s << endl;
	}
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

int main() {
	Int a, b, c, d; cin >> a >> b >> c >> d;
	
	Int c1, d1, lcm1, c2, d2,lcm2,lcm_;
	Int ans;
	lcm_ = lcm(c, d);
	c1 = b / c;
	d1 = b / d;
	lcm1 = b / lcm_;
	c2 = (a-1) / c;
	d2 = (a-1) / d;
	lcm2 = (a-1) / lcm_;
	ans = (b - c1 - d1 + lcm1) - (a - 1 - c2 - d2 + lcm2);

	cout <<ans << endl;


	
	//cout << 4 / 6;
	

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    double ax,ay,bx,by,cx,cy,dx,dy;
    while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&ax,&ay,&bx,&by,&cx,&cy,&dx,&dy)){
        if(((ax-cx)*(by-ay)+(ay-cy)*(ax-bx))*((ax-cx)*(dy-ay)+(ay-cy)*(ax-dx))<=0&& ((bx-dx)*(ay-by)+(by-dy)*(bx-ax))*((bx-dx)*(cy-by)+(by-dy)*(bx-cx))<=0)
printf("YES\n");
        else printf("NO\n");
    }
}

Measured memory_bytes: 1036
/*Saurav Paul*/
#include<bits/stdc++.h>
using namespace std;

int main()
{
	int item, knapsack;
	scanf("%d%d",&item,&knapsack);
	
	const int nax = 1e3 * item + 90;
	const int INF = 1e9 + 90;
	vector<long long int > dp(nax,INF);
	dp[0] = 0;
	
	for(int i = 0 ; i < item ; i++){
		int w , v;
		scanf("%d%d",&w,&v);
		
		for(int value = nax-1 ; value >= v ; value--) {
			dp[value] = min( dp[value ] , dp[value-v] + w );
		}
	}
	
	long long int ans = 0;
	for(int x = nax-1 ; x >= 0 ; x--){
		if(dp[x] <= knapsack ){
			ans = x;
			break ;
		}
	}
	
	printf("%lld\n",ans);
	
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
	int N;
	cin >> N;
	int ans;
	if(N%1000==0){
		cout<<0;
	}else{
	    cout<<1000 - N%1000;
	}
	
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,max1;cin>>n;
	vector <int> l[n+1];
	int i,k,j;
	int a[n],b[n];
	for(i=1;i<=n-1;i++)
	{
		cin>>a[i]>>b[i];
		l[a[i]].push_back(b[i]);
		l[b[i]].push_back(a[i]);
	}
	set <int> s[n+1];
	set <int>:: iterator st;
	map <pair<int,int>,int> mp;map <pair<int,int>,int> :: iterator it;
	max1=0;char col[n+1];
	for(i=1;i<=n;i++)
	{
		if(l[i].size()>max1)max1=l[i].size();col[i]='w';
	}
	col[1]='g';
	queue <int> q;
	q.push(1);
	int v;vector <int>  used(n+1,0);
	while(q.size())
	{
		v=q.front();
		k=1;
		for(j=0;j<l[v].size();j++)
		{
			if(col[l[v][j]]=='w')
			{
				if(used[v]==k)k++;
				used[l[v][j]]=mp[make_pair(l[v][j],v)]=mp[make_pair(v,l[v][j])]=k++;
				col[l[v][j]]='g';
				q.push(l[v][j]);
			}
		}
		col[v]='b';q.pop();
	}
	cout<<max1<<endl;
	for(i=1;i<=n-1;i++)
	{
		cout<<mp[{a[i],b[i]}]<<endl;
	}
}

Measured memory_bytes: 24448
s=input()
t=input()
l=[]
check=0
for i in range(len(s)-len(t)+1):
    c=0
    for j in range(len(t)):
        if s[i+j]!=t[j] and s[i+j]!="?":
            break
        else:
            c+=1
    if c==len(t):
        check+=1
        l.append(s[:i]+t+s[i+j+1:])
    #print(c)
#print(l)
if check==0:
    print("UNRESTORABLE")
else:
    L=[]
    for i in range(len(l)):
        x=""
        for j in range(len(s)):
            if l[i][j]=="?":
                x+="a"
            else:
                x+=l[i][j]
        L.append(x)
    L.sort()
    print(L[0])

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

using namespace std;

int main() {
  int n;
  string a, b, c;
  cin >> n >> a >> b >> c;

  int ans = 0;
  for (int i = 0; i < n; i++) {
    set<char> dict;
    dict.insert(a[i]);
    dict.insert(b[i]);
    dict.insert(c[i]);
    ans += dict.size() - 1;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,k,q;
  cin >> n >> k >> q;

  vector<int> a(q);
  REP(i,q) cin >> a[i],a[i]--;
  
  vec cnt(n,0);
  REP(i,q){
    cnt[a[i]] ++;
  }

  REP(i,n){
    if(cnt[i] > q - k){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cmath>
#define _USE_MATH_DEFINES
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n, m, c;
	cin >> n >> m >> c;
	ll b[m];
	ll a[n][m];
	for(ll i=0; i<m; i++)
		cin >> b[i];
	ll ans = 0, cur = 0;
	for(ll i=0; i<n; i++){
		for(ll j=0; j<m; j++){
			cin >> a[i][j];
			cur += a[i][j]*b[j];
		}
		if(cur + c > 0)
			ans++;
		cur = 0;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3608
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

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

const int mod = 1e9 + 7;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> a(n * 2);
    for (int i = 0; i < n * 2; i++) {
        a[i] = (s[i] == 'B') ^ (i & 1);
    }
    //1 = r, 0 = l
    int cnt = 0;
    ll ans = 1;
    for (int i = 0; i < n * 2; i++) {
        cnt += a[i];
        if (a[i] == 0) {
            (ans *= cnt) %= mod;
            cnt--;
        }
    }
    for (int i = 2; i <= n; i++) {
        (ans *= i) %= mod;
    }
    if (cnt) {
        ans = 0;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1360
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a[100000],ans[100001];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ans[a[i]]=i+1;
	}
	for(int j=1;j<n+1;j++){
		cout<<ans[j];
		if(j!=n){
			cout<<" ";
		}
	}
	return 0;
}


Measured memory_bytes: 1536
use strict;
use warnings;

my $n = <>;
my @s = ();
for (0..$n-1) {
    $s[$_] = <>;
    chomp $s[$_];
}

my @judge_kinds = ('AC', 'WA', 'TLE', 'RE');
my %cnt = map { $_ => 0 } @judge_kinds;

for (@s) {
    ++$cnt{$_};
}

for (@judge_kinds) {
    printf("%s x %d\n", $_, $cnt{$_}); 
}

Measured memory_bytes: 19076
//C++14 (Clang 3.8.0)

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

int main(){
    int N;
    vector<int> a;
    cin>>N;
    for(int i=0;i<N;i++){int A;cin>>A;a.push_back(A);}

    int ave=0;
    for(int i=0;i<N;i++) ave+=a[i];
    ave=ave/N;
    int ans=100000000;
    
    for(int j=-1;j<=1;j++){
        int av=ave+j;
        int d=0;
        for(int i=0;i<N;i++) d=d+abs(a[i]-av)*abs(a[i]-av);
        if(ans>d) ans=d;
    }
    cout<<ans<<endl;
    return 0;
};


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

priority_queue<ll>Q;
vector<ll> v[100010];
int main(){
  ll n,m; cin>>n>>m;
  for(int i=0;i<n;i++){
    ll a,b; cin>>a>>b;
    v[a].push_back(b);
  }
  ll ans=0;
  for(int i=1;i<=m;i++){
    for(auto t:v[i])Q.push(t);
    if(!Q.empty()){
      ans+=Q.top();
      Q.pop();
    }
  }
  cout<<ans<<endl;
  return 0;
}
      
  
  

Measured memory_bytes: 5632