akhauriyash/Code-Regression huggingface dataset:
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

int main() {
	
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++) {
		if(s[i] == '?') cout<<"D";
		else cout<<s[i];
	}
	cout<<endl;

    return 0;
}



Measured memory_bytes: 3756
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const long long MOD = 1000000007;
int main(){
	ll n;
	cin >> n;
	vector<ll> h(n);
	
	for (ll i = 0; i < n; i++)	cin >> h[i];

	ll max = 0;
	ll count = 0;

	for (ll i = 1; i < n; i++){
		if (h[i - 1] >= h[i])	count++;
		else  count = 0;
		if (max < count)	max = count;
	}

	cout << max << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> vec(N+1, 1);
    vector<bool> ans(N+1, false);
    ans[1]=true;
    ans.push_back(1);
    for(int m=0; m<M; m++) {
        int x, y;
        cin >> x >> y;
        vec[x]--;
        vec[y]++;
        if(ans[x]) {
            if(vec[x]==0) ans[x]=false;
            ans[y]=true;
        }
    }
    int cnt=0;
    for(int n=1; n<=N; n++) {
        if(ans[n]) cnt++;
    }
    cout << cnt << endl;

    return 0;
    
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    int p;
    int m = N + 2;
    int ans =0;
    for(int i=0; i<N; i++){
        cin >> p;
        if(p <= m) ans++;
        m = min(p, m);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

int n;
long long num;

int main() {
	while (cin >> n) {
		long long sum = 0;
		for (int i = 0; i < n; ++i) {
			long long a; cin >> a; sum += a;
		}
		sum /= n;
		cout << sum << endl;
	}
    return 0;
}


Measured memory_bytes: 1164
#include<bits/stdc++.h>
    #define vll vector<ll>
    #define vi vector<int>
    #define vpll vector<pair<ll,ll>>
    #define pii pair<int,int>
    #define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
    #define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
    #define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
    #define MOD 1000000007
    #define ALL(v) v.begin(), v.end()
    #define m0(x) memset(x,0,sizeof(x))
    typedef long long ll;
     
    using namespace std;
     
    int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int M, D;
      cin >> M >> D;
      int ans = 0;
      REP2(i, 1, M+1){
        REP2(j, 1, D+1){
          int d1 = j%10, d10 = (j/10)%10;
          if(d1 <= 1 || d10 <= 1) continue;
          if(d1 * d10 == i) ans++;
        }
      }
      cout << ans << endl;
      return 0;
    }

Measured memory_bytes: 256
#include <stdio.h>

int min(int a, int b) { return a < b ? a : b; }

int main(void) {
	int i, N, T, t, before_t, ans = 0;
	scanf("%d%d%d", &N, &T, &t);

	for (i = 1; i < N; i++) {
		before_t = t;
		scanf("%d", &t);
		ans += min(t - before_t, T);
	}
	printf("%d\n", ans + T);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

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

        Integer a = sc.nextInt();
        Integer b = sc.nextInt();

        String stra = String.valueOf(a);
        String strb = String.valueOf(b);

        String c = "";
        String d = "";

        for (int j = 0; j < b; j++) {
            c += stra;
        }

        for (int j = 0; j < a; j++) {
            d += strb;
        }

        int intc = Integer.parseInt(c);
        int intd = Integer.parseInt(d);

        if (a < b) {
            System.out.println(intc);
        } else {
            System.out.println(intd);
        }

    }

}

Measured memory_bytes: 21712
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		ll n;
		cin>>n;
		int a[20];
		ll k=0;
		while(n>0)
		{
			n--;
			a[k]=n%26;
			k++;
			n/=26;
		}
		char g;
		FORD(i,k,0)
		{
			g='a'+a[i];
			cout<<g;
		}
	}
	return 0;
}

Measured memory_bytes: 3648
using System;

class Program
{
    private static string alp = "abcdefghijklmnopqrstuvwxyz";
    private static string s;
    private static int K;

    public static void Main()
    {
        /*入力を受け取る*/
        s = Console.ReadLine();
        K = int.Parse(Console.ReadLine());

        /*先頭から順に、'a'にできるなら'a'にし、できないなら放置*/
        char[] ans = new char[s.Length];
        for (int i = 0; i < s.Length; i++)
        {
            if (K >= MinToA(s[i]))
            {
                K -= MinToA(s[i]);
                ans[i] = 'a';
                continue;
            }
            ans[i] = s[i];
        }

        /*残った回数の操作を末尾に対して行う*/
        ans[ans.Length - 1] = Operation(ans[ans.Length - 1], K);

        /*答えの出力*/
        foreach (var c in ans)
            Console.Write(c);
        Console.WriteLine();
    }

    /*char cがアルファベットで何番目か*/
    private static int Index(char c)
    {
        for (int i = 0; i < alp.Length; i++)
            if (alp[i] == c)
                return i;
        return -1;
    }

    /*char cを'a'にするには最低何回操作が必要か*/
    private static int MinToA(char c)
    {
        int index = Index(c);
        if (index == 0)
            return 0;
        if (index > 0)
            return 26 - index;
        return -1;
    }

    /*char cにi回操作を行ったら何になるかを返す*/
    private static char Operation(char c, int i)
    {
        int index = Index(c);
        return alp[(i + index) % 26];
    }
}

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

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

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  int N;
  cin >> N;

  vector<pair<int, int>> pp;
  REP(i,N){
    int p;
    cin >> p;
    pp.push_back(make_pair(p,i+1));
  }
  sort(pp.begin(),pp.end());
  reverse(pp.begin(),pp.end());

  multiset<int> s;
  s.insert(0); s.insert(0);
  s.insert(N+1); s.insert(N+1);
  ll ans=0;
  for(auto e : pp){
    int w,x,y,z;
    s.insert(e.second);

    // for(auto i : s){
    //   cout << i << " ";
    // }
    // cout << endl;

    auto it = s.find(e.second);

    x = *(--it);
    w = *(--it);
    
    it = s.find(e.second);

    y = *(++it);
    z = *(++it);

    // cout << w << " " << x << " " << y << " " << z << endl;
    // cout << "val: " << e.first << endl;
    ll cnt = (x-w)*(y-e.second) + (e.second-x)*(z-y);
    // cout << "cnt: " << cnt << endl;

    ans += e.first * cnt;
  }
  cout << ans << endl;
}



Measured memory_bytes: 5876
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)


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

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AThreeLetterAcronym {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string s;
	    string res = "";
	    for(int i=0; i<3; i++){
	        in >> s;
	        res += (s[0] - 'a' + 'A');
	    }
	    out << res << endl;
	}
};


int main() {
	AThreeLetterAcronym solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
class dice():
    def __init__(self, num_list):
        self.dice_index = 0
        i = self.dice_index
        self.NS = [num_list[i], num_list[i+1], num_list[i+5], num_list[i+4]]
        self.WE = [num_list[i], num_list[i+2], num_list[i+5], num_list[i+3]]

    def set_dict(self, direction):
        i = self.dice_index
        if direction == 'N' or direction == 'W':
            m = 1
        elif direction == 'S' or direction == 'E':
            m = -1
        if direction == 'N' or direction == 'S':
            self.dice_index = self.NS[m]
            self.NS = self.NS[m:]+self.NS[:m]
            self.WE[0] = self.NS[0]
            self.WE[2] = self.NS[2]
        elif direction == 'W' or direction == 'E':
            self.dice_index = self.WE[m]
            self.WE = self.WE[m:]+self.WE[:m]
            self.NS[0] = self.WE[0]
            self.NS[2] = self.WE[2]


if __name__ == '__main__':
    dice_number = input()
    dice_direction = input()
    dice_number = dice_number.split()
    Dice = dice(dice_number)
    for i in range(len(dice_direction)):
        Dice.set_dict(dice_direction[i])
    else:
        print(Dice.dice_index)



Measured memory_bytes: 5572
#include<bits/stdc++.h>
using namespace std;
int main(){
    //freopen("input01.txt","r",stdin);
    //freopen("output01.txt","w",stdout);
    long long int t;
    cin>>t;
    if(t==1){
        cout<<0;
    }
    else{
        cout<<1;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	while(cin>>H>>W) {
		vector<string> m(H);
		REP(i, H) cin>>m[i];
		vector<string> M(H*2, string(W, ' '));
		REP(y, H*2)REP(x, W)M[y][x]=m[y/2][x];
		REP(y, H*2) cout<<M[y]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
const int mm=1e6;
ll d[mm];
int main()
{
	ll n,m,i,j,k,kk,a,b,t,ss;
	cin>>n;
	m=n/10;
	a=n/100;
	if(m%10==7||n%10==7||a%10==7)
	printf("Yes\n");
	else
	printf("No\n");
 
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    string s; cin>>s;
    vector<ll> X(26,0);
    rep(i,sz(s)){
        X[(ll)(s[i]-'a')]++;
    }
    
    string t="";
    rrep(i,26){
        t+=('a'+i);
    }
    if(s==t){
        cout<<-1<<endl;
        return 0;
    }
    
    ll tmp=INF;
    rep(i,26){
        if(X[i]==0){
            tmp=i;
            break;
        }
    }
    
    //全文字
    if(tmp==INF){
        ll c;
        vector<ll> Y;
        rrep1(i,sz(s)-1){
            Y.pb((ll)(s[i]-'a'));
            if(s[i]>s[i-1]){
                c=i-1;
                break;
            }
        }
        sort(all(Y));
        rep(i,sz(s)){
            if(c==i){
                ll d=(ll)(s[i]-'a');
                cout<<(char)('a'+*(upper_bound(Y.bg,Y.ed,d)));
                return 0;
            }
            else cout<<s[i];
        }
    }
    else{
        cout<<s<<(char)('a'+tmp)<<endl;
    }
}



Measured memory_bytes: 3640
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

//Name the Crossing
public class Main{

	class R{
		int id, col;
		Set<Integer> adj, eq;
		boolean visit;
		public R(int id) {
			this.id = id;
			col = -1;
			eq = new HashSet<Integer>();
			adj = new HashSet<Integer>();
		}
		void color(int c){
			if(visit)return;
			col = c;
			visit = true;
			for(int v:adj)rs[v].color(c%2==0?(c+1):(c-1));
		}
		boolean reach(int g){
			if(id==g)return true;
			if(visit)return false;
			visit = true;
			for(int v:eq)if(rs[v].reach(g))return true;
			return false;
		}
	}
	
	int ID;
	Map<String, R> ref;
	Set<String> streets;
	String[] names;
	R get(String s){
		if(ref.containsKey(s))return ref.get(s);
		R res = new R(ID);
		names[ID] = s;
		rs[ID++] = res;
		ref.put(s, res);
		return res;
	}
	R[] rs;
	
	void reset(){
		for(int i=0;i<ID;i++)rs[i].visit = false;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			ID = 0;
			ref = new HashMap<String, R>();
			rs = new R[200];
			names = new String[200];
			streets = new HashSet<String>();
			while(n--!=0){
				String t = sc.next();
				streets.add(t);
				String s[] = t.split("-");
				R a = get(s[0]), b = get(s[1]);
				a.adj.add(b.id); b.adj.add(a.id);
				b.eq.add(a.id);
			}
			int col = 0;
			for(int i=0;i<ID;i++){
				if(rs[i].visit)continue;
				rs[i].color(col);
				col+=2;
			}
			int N =	ID;
			for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
				boolean C, D, E;
				C = false;
				D = E = true;
				for(int k=0;k<N;k++){
					if(k==i||k==j)continue;
					if(rs[i].adj.contains(k)&&rs[j].adj.contains(k))C = true;
					if(streets.contains(names[k]+"-"+names[i])&&streets.contains(names[j]+"-"+names[k]))D = false;
					if(streets.contains(names[i]+"-"+names[k])&&streets.contains(names[k]+"-"+names[j]))E = false;
					if(!D||!E)break;
				}
				if(C&&D&&E){
					R a = get(names[i]), b = get(names[j]);
					a.eq.add(b.id); b.eq.add(a.id);
				}
			}
			System.out.println(N);
			int m = sc.nextInt();
			while(m--!=0){
				String[] t = sc.next().split("-");
				R a = get(t[0]), b = get(t[1]);
				if(a.col==b.col||Math.abs(a.col-b.col)>=2||a.col==-1||b.col==-1){
					System.out.println("NO"); continue;
				}
				reset();
				System.out.println(b.reach(a.id)?"YES":"NO");
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int maxn=105;
ll n,m,K,mod,f[maxn][maxn][maxn],C[maxn][maxn],pre[maxn][maxn*maxn];
ll tmp1[maxn][maxn],tmp2[maxn][maxn];
ll fac[maxn],inv[maxn];
inline ll qpow(ll x,ll y)
{
	ll ans=1,base=x;
	assert(y>=0);
	while(y)
	{
		if(y&1)
			ans=ans*base%mod;
		base=base*base%mod;
		y>>=1;
	}
	return ans;
}
inline void init()
{
	fac[0]=1;
	for(int i=1;i<=100;++i)
		fac[i]=fac[i-1]*i%mod;
	for(int i=0;i<=100;++i)
		inv[i]=qpow(fac[i],mod-2);
	C[0][0]=1;
	for(int i=1;i<=100;++i)
	{
		C[i][0]=1;
		for(int j=1;j<=i;++j)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for(int k=0;k<=K+2;++k)
	{
		pre[k][0]=1;
		for(int i=1;i<=n*m;++i)
			pre[k][i]=pre[k][i-1]*k%mod;
	}
}
inline void add(ll&x,ll y)
{
	x=(x+y)%mod;
}
inline void solve()
{
	f[0][0][0]=1;
	for(int k=0;k<K;++k)
	{
		memset(tmp1,0,sizeof(tmp1));
		for(int i=0;i<=n;++i)
			for(int j=0;j<=m;++j)
				for(int i1=0;i1+i<=n;++i1)
					add(tmp1[i+i1][j],f[i][j][k]*inv[i1]%mod*pre[K+1-(k+1)][i1*j]%mod*pre[k+1][(m-j)*i1]);
		memset(tmp2,0,sizeof(tmp2));
		for(int i=0;i<=n;++i)
			for(int j=0;j<=m;++j)
				for(int j1=0;j1+j<=m;++j1)
					add(tmp2[i][j+j1],tmp1[i][j]*inv[j1]%mod*pre[K+1-(k+1)][j1*i]%mod*pre[k+1][(n-i)*j1]);
		memset(tmp1,0,sizeof(tmp1));
		for(int i=0;i<=n;++i)
			for(int j=0;j<=m;++j)
				for(int i2=0;i2+i<=n;++i2)
					if(i2&1)
						add(tmp1[i+i2][j],-tmp2[i][j]*inv[i2]%mod*pre[K+1-(k+2)][i2*j]%mod*pre[k+1][(m-j)*i2]);
					else
						add(tmp1[i+i2][j],tmp2[i][j]*inv[i2]%mod*pre[K+1-(k+2)][i2*j]%mod*pre[k+1][(m-j)*i2]);
		memset(tmp2,0,sizeof(tmp2));
		for(int i=0;i<=n;++i)
			for(int j=0;j<=m;++j)
				for(int j2=0;j2+j<=m;++j2)
					if(j2&1)
						add(tmp2[i][j+j2],-tmp1[i][j]*inv[j2]%mod*pre[K+1-(k+2)][j2*i]%mod*pre[k+1][(n-i)*j2]);
					else
						add(tmp2[i][j+j2],tmp1[i][j]*inv[j2]%mod*pre[K+1-(k+2)][j2*i]%mod*pre[k+1][(n-i)*j2]);
		for(int i=0;i<=n;++i)
			for(int j=0;j<=m;++j)
				f[i][j][k+1]=tmp2[i][j];
	}
	ll ans=f[n][m][K]*fac[n]%mod*fac[m]%mod;
	ans=(ans%mod+mod)%mod;
	cout<<ans<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m>>K>>mod;
	init();
	solve();
	return 0;
}


Measured memory_bytes: 20924
n = int(input())
masklist = [[] for i in range(n)]
for i in range(n):
    mask = list(map(int, input().split()))
    masklist[i] = mask[1:mask[0]+1]

q = int(input())
bin_q = format(0, '064b')
qlist = list(bin_q)

for _ in range(q):
    query = list(map(int, input().split()))
    command = query[0]
    masknum = query[1]

    if command == 0:    # test
        i = 63 - query[1]
        print(qlist[i])

    elif command == 1:  # set
        for m in masklist[masknum]:
            qlist[63 - m] = '1'

    elif command == 2:  # clear
        for m in masklist[masknum]:
            qlist[63 - m] = '0'

    elif command == 3:  # flip
        for m in masklist[masknum]:
            if qlist[63 - m] == '0':
                qlist[63 - m] = '1'
            else:
                qlist[63 - m] = '0'

    elif command == 4:  # all
        for m in masklist[masknum]:
            if qlist[63 - m] == '0':
                print(0)
                break
        else:
            print(1)

    elif command == 5:  # any
        for m in masklist[masknum]:
            if qlist[63 - m] == '1':
                print(1)
                break
        else:
            print(0)

    elif command == 6:  # none
        for m in masklist[masknum]:
            if qlist[63 - m] == '1':
                print(0)
                break
        else:
            print(1)

    elif command == 7:  # count
        cnt = 0
        for m in masklist[masknum]:
            if qlist[63 - m] == '1':
                cnt += 1
        print(cnt)

    elif command == 8:  # val
        sum = 0
        for m in masklist[masknum]:
            if qlist[63 - m] == '1':
                sum += pow(2, m)
        print(sum)



Measured memory_bytes: 5636
#include <cmath>
#include <iostream>
using namespace std;
int a, b, d, X, Y, x, y;

int extgcd(int a, int b, int &x, int &y){
  int d = a;
  if(b){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }else{
    x = 1;
    y = 0;
  }
  return d;
}

void change_ans(){
  if(abs(x) + abs(y) < X + Y){
    X = abs(x);
    Y = abs(y);
  }else if(abs(x) + abs(y) == X + Y && a*abs(x) + b*abs(y) < a*abs(X) + b*abs(Y)){
    X = abs(x);
    Y = abs(y);
  }
}



int main(){
  while(cin >> a >> b >> d, a){
    int g = extgcd(a,b,x,y), r = d/g;
    x *= r; y *= r;
    a /= g;
    b /= g;
    X = abs(x);
    Y = abs(y);
    if(x <= 0){
      int x_ = (b - (-x)%b)%b;
      int t = (x_ - x) / b;
      y -= t*a;
      x = x_;
      change_ans();
      x -= b;
      y += a;
      change_ans();
    }
    if(y <= 0){
      int y_ = (a - (-y)%a)%a;
      int t = (y_ - y) / a;
      x -= t*b;
      y = y_;
      change_ans();
      x += b;
      y -= a;
      change_ans();
    }
    if(x >= 0){
      int x_ = x%b;
      int t = x / b;
      y += t*a;
      x = x_;
      change_ans();
      x -= b;
      y += a;
      change_ans();
    }
    if(y >= 0){
      int y_ = y%a;
      int t = y / a;
      x += t*b;
      y = y_;
      change_ans();
      x += b;
      y -= a;
      change_ans();
    }
    cout << X << " " << Y << endl;
  }
  return 0;
}

Measured memory_bytes: 3048
num = int(input())
str = input()

ans_ls = []
for x in str:
    i = ord(x) + num
    if i <= 90:
        ans_ls.append(i)
    else:
        ans_ls.append(i - 26)
ls = []
for y in ans_ls:
    l = chr(y)
    ls.append(l)

ans = ''.join(ls)
print(ans)

Measured memory_bytes: 3188
'''input
2 2
3
2 1 1
'''
h,w = map(int,raw_input().split())
n  =input()
arr = map(int,raw_input().split())
ans = [[-1]*w for i in range(h)]
ind = 0
for i in xrange(h):
	if i&1:
		for j in xrange(w-1,-1,-1):
			if arr[ind] == 0:
				ind += 1
				ans[i][j] = ind+1
				arr[ind] -= 1
			else:
				ans[i][j] = ind+1
				arr[ind] -= 1
	else:
		for j in xrange(w):
			if arr[ind] == 0:
				ind += 1
				ans[i][j] = ind+1
				arr[ind] -= 1
			else:
				ans[i][j] = ind+1
				arr[ind] -= 1
for i in xrange(h):
	for j in xrange(w):
		print ans[i][j],
	print

Measured memory_bytes: 32876
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int r;

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> r;
   cout << r * r;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 256
import sys
import math
#from queue import *
import random
#sys.setrecursionlimit(int(1e6))
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

n=inp()
ara=[]
for i in range(n):
	a,b=invr()
	ara.append([a,b])

for i in range(n-2):
	if ara[i][0]==ara[i][1]:
		if ara[i+1][0]==ara[i+1][1]:
			if ara[i+2][0]==ara[i+2][1]:
				print("Yes")
				exit(0)

print("No")


Measured memory_bytes: 9556
#include<stdio.h>

int main()
{
  int N,A[100],i,v,j,a,k;
  scanf("%d",&N);
  for(a=0;a<N;a++){scanf("%d",&A[a]);
  }
  for (i=1;i<N+1;i++){
    for(k=0;k<N-1;k++)
      printf("%d ",A[k]);
    for(k=N-1;k<N;k++){
      printf("%d",A[k]);}
    printf("\n");
    v = A[i];
    j = i - 1;
    
  while(j>=0&&A[j]>v){
    A[j+1] = A[j];
    j--;
  
    A[j+1] = v;
  }
  }
  
 
  return 0;
}
  



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

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int l = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		if (a/c < b/d) {
			if (b % d == 0)
				out.printf("%d\n", l-b/d);
			else
				out.printf("%d\n", l-b/d-1);
		} else if (b/d < a/c) {
			if (a % c == 0)
				out.printf("%d\n", l-a/c);
			else
				out.printf("%d\n", l-a/c-1);
		} else {
			if (a % c == 0 && b % d == 0)
				out.printf("%d\n", l-a/c);
			else
				out.printf("%d\n", l-a/c-1);
		}
		
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 17176
/////////////////////////////////////////////

//
//	FileName	:	First.cpp
//	Creator		:	Fm
//	Date		:	2019-10-26 22:22
//	Comment		:	OJ(P3372)
//
///////////////////////////////////////////

//#include "pch.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
#include <set>
#include <queue>
#include <map>

using namespace std;
#define	MAXNUM		10010
#define	EPS         0.0001
#define MODNUM		2e31


typedef unsigned char       BYTE;
typedef int                 BOOL;
typedef unsigned long       DWORD;


int main(int argc, char* argv[])
{
	long long				nN;
	long long				nM;
	long long				nTemp;

	scanf("%lld%lld", &nN, &nM);

	nTemp = 2 * nN;
	if (nTemp > nM)
		printf("%lld", nM / 2);
	else if (nTemp == nM)
		printf("%lld", nN);
	else
	{
		nM -= nTemp;
		nM /= 4;
		printf("%lld", nN + nM);
	}

	printf("\n");

Exit0:

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) ((c).rbegin(),(c).rend())
//#define sort(v,n) sort(v,v+n)
#define ll long long
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n, m;
bool now[20001];

int main() {
	while (cin >> n >> m, n) {
		for (int i = 0; i < 20001; i++) {
			now[i] = 0;
		}
		now[1] = 1;
		vector<pair<int,pair<int,int>>> vp;
		for (int i = 0; i < m; i++) {
			int a, b, c; cin >> a >> b >> c;
			vp.push_back(pair<int, pair<int, int>>(a, pair<int, int>(b, c)));
		}
		sort(vp.begin(), vp.end());
		for (int i = 0; i < vp.size(); i++) {
			if (now[vp[i].second.first] == 1) {
				now[vp[i].second.second] = 1;
			}
		}
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			if (now[i] == 1)ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3432
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
#define int long long
int t[234567];
set<int>s;
signed main() {
	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		int a; cin >> a;
		t[a] = i;
	}
	int ans = 0;
	s.insert(0);
	s.insert(n + 1);
	for (int i = 1; i <= n; i++) {
		auto itr = s.upper_bound(t[i]);
		ans += i * (*itr - t[i])*(t[i] - *(--itr));
		s.insert(t[i]);
	}
	cout << ans << endl;
}

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

int main(){
  int i,n,k,ans=0,c;
  cin>>n>>k;
  vector<int> a(n,0),b(n+1,0);
  for(i=0;i<n;i++){
    cin>>a.at(i);
    b.at(a.at(i))++;
  }
  sort(b.rbegin(),b.rend());
  for(i=k;i<n;i++) ans+=b.at(i);  
  cout<<ans;
}

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

int main(){
    int N;
    cin >> N;
    int X[N] = {};
    int sum1 = 0;
    int sum2 = 0;
    for (int i = 0;i < N;i++){
        cin >> X[i];
        sum1 += X[i];
        sum2 += pow(X[i], 2);
    }

    int p1 = sum1 / N;
    int p2 = p1 + 1;
    int p3 = p1 - 1;
    int ans1 = 0,ans2 = 0,ans3 = 0;

    for (int i = 0;i < N; i++){
        ans1 += pow(p1 - X[i],2);
        ans2 += pow(p2 - X[i],2);
        ans3 += pow(p3 - X[i],2);
    }

    cout << min(ans1,min(ans2,ans3)) << endl;

}


Measured memory_bytes: 256
/**
*	  Name: Ajay Subhash Jadhav
*	  Institute: International Institute of Technology Hyderabad 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void inputread()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main(){
      
  fastio();
  LL n,m,i,j,t;
  cin>>n>>m>>t;
  for(i=1;i<=10;i++)
  {
  	t= t*n-m;
  	cout<<t<<"\n";	
  }
  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 = Integer.parseInt(sc.next());
        int cnt = 0;
        for (int i=0;i<N;i++) {
            int a = Integer.parseInt(sc.next());
            if (cnt+1==a) cnt++;
        }
        if (cnt==0) {
            System.out.println(-1);
        } else {
            System.out.println(N-cnt);
        }
    }
}

Measured memory_bytes: 49204
#include <iostream>
#include <vector>
#include <algorithm>

int main(int argc, char *argv[]){
    int N,M;
    std::cin >> N >> M;
    std::vector<int> L(M), R(M);
    for(int i=0; i<M; ++i){
        std::cin >> L[i] >> R[i];
    }
    int left = *std::max_element(L.begin(),L.end());
    int right = *std::min_element(R.begin(),R.end());
    if(left > right){
        std::cout << 0 << std::endl;
        return 0;
    }
    std::cout << (right-left+1) << std::endl;
    return 0;
}


Measured memory_bytes: 1024
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,k;cin>>n>>k;
    vector<ll>x(n);
    int yy=0;
    for(int i=0;i<n;i++){
        cin>>x[i];
        if(x[i]>0)
            yy++;
        if(x[i]==0){
            k--;
            n--;
        }
    }
    int nn=n-yy;
    if(k==0){
        cout<<0<<endl;
    return 0;}
   /* if(yy==0){
        cout<<x[n-k]<<endl;
        return 0;
    }
    if(nn==0){
        cout<<x[k-1]<<endl;
        return 0;
    }
    */
    ll ans=INF;
    for(int i=0;i<n-k+1;i++){
        chmin(ans,abs(x[i])+abs(x[i+k-1]-x[i]));
        chmin(ans,abs(x[i+k-1])+abs(x[i+k-1]-x[i]));
    }
    
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nab = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        var n = nab[0];
        var a = nab[1];
        var b = nab[2];

        long d, m;
        d = Math.DivRem(n, a + b, out m);
        var k = d * a;
        k += Math.Min(m, a);
        
        Console.WriteLine(k);
    }
}


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

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

struct WeightedUnionFind{
    vector<ll> par;
    vector<ll> rank;
    vector<ll> diff_weight;

    WeightedUnionFind(ll sz){
        init(sz);
    }

    void init(ll sz){
        par.resize(sz);
        rank.resize(sz);
        diff_weight.resize(sz);
        FOR(i, 0, sz){
            par[i] = i;
            rank[i] = 0;
            diff_weight[i] = 0;
        }
    }

    int root(ll x) {
        if (par[x] == x) {
            return x;
        }
        else {
            ll r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    ll weight(ll x) {
        root(x);
        return diff_weight[x];
    }

    bool is_same(ll x, ll y) {
        return root(x) == root(y);
    }

    bool merge(ll x, ll y, ll w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    ll diff(int x, int y) {
        return weight(y) - weight(x);
    }
};


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

    // input
    ll N, Q;
    cin >> N >> Q;

    auto uf = WeightedUnionFind(N);

    while(Q--){
        ll a; cin >> a;
        // diff
        if(a){
            ll x, y; cin >> x >> y;
            if(uf.is_same(x, y)){
                p(uf.diff(x, y));
            }else{
                p('?');
            }
        }
        // relate
        else{
            ll x, y, z; cin >> x >> y >> z;
            uf.merge(x, y, z);
        }
    }
    
    return 0;
}


Measured memory_bytes: 5212
/**
 *    author:  FromDihPout
 *    created: 2020-08-17
**/

#include <bits/stdc++.h>
using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, c;
    cin >> n >> c;
    vector<vector<int>> d(c, vector<int> (c)), a(n, vector<int> (n));
    for (int i = 0; i < c; i++) {
        for (int j = 0; j < c; j++) {
            cin >> d[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    
    vector<vector<int>> cols(3, vector<int> (c));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int m = ((i + 1) + (j + 1)) % 3;
            cols[m][a[i][j] - 1]++;
        }
    }
    
    int ans = 1e9;
    for (int c1 = 0; c1 < c; c1++) {
        for (int c2 = 0; c2 < c; c2++) {
            if (c1 == c2) continue;
            for (int c3 = 0; c3 < c; c3++) {
                if (c1 == c3 || c2 == c3) continue;
                int cost = 0;
                for (int i = 0; i < c; i++) {
                    cost += cols[0][i] * d[i][c1];
                    cost += cols[1][i] * d[i][c2];
                    cost += cols[2][i] * d[i][c3];
                }
                ans = min(ans, cost);
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4244
S = input()
n = len(S)
ans = 0
for i in range(n):
    for j in range(i, n):
        # ↓文字cがACGTでない。ACGT文字列でない。
        if not any('ACGT'.count(c) == 0 for c in S[i:j + 1]):
            ans = max(ans, j - i + 1)
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int x[4], y[4], tmp_x, tmp_y;
	int i, dist;
	scanf("%d%d%d%d", &x[0], &y[0], &x[1], &y[1]);

	dist = sqrt(pow(x[1]-x[0], 2) + pow(y[1]-y[0], 2));

	tmp_x = x[1] - x[0];
	tmp_y = y[1] - y[0];

	x[3] = -tmp_y + x[0];
	y[3] = tmp_x + y[0];

	x[2] = tmp_x - tmp_y + x[0];
	y[2] = tmp_x + tmp_y + y[0];

	printf("%d %d %d %d\n", x[2], y[2], x[3], y[3]);

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
long long c(int a,int b) {
	if (b == 0)return 1;
	return a*c(a - 1, b - 1) / b;
}
int main() {
	int n, p; cin >> n >> p;
	long long s0 = 1, s1 = 0;
	for (int i = 0; i < n; i++){
		int a; cin >> a;
		if (a % 2 == 0)s0 *= 2; else s1++;
	}
	long long sum = 0;
	for (long long i = p; i <= s1; i += 2)
		sum += c(s1, min(i, s1 - i));
	cout << sum*s0 << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
x = int(input())

if x <= 6:
    ans = 1
elif 7 <= x <= 11:
    ans = 2
else:
    tmp = x // 11
    if 11 * tmp == x:
        ans = 2 * tmp
    if 11 * tmp < x <= 11 * tmp + 6:
        ans = 2 * tmp + 1
    if 11 * tmp + 6 < x < 11 * tmp + 11:
        ans = 2 * tmp + 2
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 100000

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N)cin >> a[i];
    vector<int> list(INF);
    rep(i,INF)list[i]=0;
    int Q;
    cin >> Q;
    vector<int> b(Q),c(Q);
    rep(i,Q)cin >> b[i] >> c[i];
    
    rep(i,N)list[a[i]]++;
    ll ans=0;
    rep(i,N)ans+=a[i];

    int num=0;
    rep(i,Q){
        num=c[i]-b[i];
        ans+=num*(list[b[i]]);
        list[c[i]]+=list[b[i]];
        list[b[i]]=0;
        cout << ans << endl;
    }

}

Measured memory_bytes: 4832
#include <iostream>

using namespace std;

const int max_lim = 50001;
bool prime[max_lim];

void init()
{
    for (int i = 0; i < max_lim; i++)
        prime[i] = true;
    prime[0] = prime[1] = false;

    for (int i = 2; i * i < max_lim; i++) 
        for (int j = 2 * i; j < max_lim; j += i)
            prime[j] = false;
}

int main()
{
    int n;

    init();
    while (cin >> n, n) {
        int ans = 0;
        for (int i = 2; 2 * i <= n; i++) 
            if (n - i > 0 && prime[i] && prime[n - i]) 
                ans++;
        cout << ans << endl;
    }

    return 0;
}

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

int main() {
  string s, s1 = "", s2 = "";
  int q, rev = 0;
  cin >> s >> q;
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      rev++;
    }
    else {
      int f;
      char c;
      cin >> f >> c;
      if ((f + rev%2) % 2 == 1) {
        s1.push_back(c);
      }
      else {
        s2.push_back(c);
      }
    }
  }
  if (rev%2 == 0) {
    reverse(s1.begin(), s1.end());
    cout << s1 << s << s2 << endl;
  }
  else {
    reverse(s.begin(), s.end());
    reverse(s2.begin(), s2.end());
    cout << s2 << s << s1 << endl;
  }
}

Measured memory_bytes: 1088
#include <iostream>

using namespace std;
int main(){
	int n;
	int a[100001];
	bool b[100001];
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int x = a[n - 1];
	int i = -1;
	for(int j = 0; j < n - 1; j++){
		if(a[j] <= x){
			i++;
			int tmp = a[i];
			a[i] = a[j];
			a[j] = tmp;
		}
	}
	int tmp = a[i + 1];
	a[i + 1] = a[n - 1];
	a[n - 1] = tmp;
	for(int i = 0; i < n - 1; i++){
		if(a[i] == x){
			for(int j = 0; j < i; j++){
				b[j] = false;
			}
			b[i] = true;
		}else{
			b[i] = false;
		}
	}
	for(int i = 0; i < n - 1; i++){
		if(b[i]){
			cout << "[" << a[i] <<"] ";
		}else{
			cout << a[i] <<" ";
		}
	}
	cout << a[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1644