akhauriyash/Code-Regression huggingface dataset:
/*
ID:greenty2
LANG:C++
TASK:
*/
#include<bits/stdc++.h>
using namespace std;
int bj[30];
int main()
{
	string ss;
	cin>>ss;
	int n=ss.size();
	for(int i=0;i<n;i++)
	{
		bj[ss[i]-'a']=1;
	}
	int ans=99999999;
	for(int k=0;k<=25;k++)
	{
		string s=ss;
		int flag=0;
		char c='a'+k;
		//cout<<c<<endl;
		for(int i=0;i<n;i++)
		{
			if(s[i]!=c)
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			cout<<"0"<<endl;
			return 0;
		}
		if(bj[k]==1)
		{
			for(int i=n-1;i>=0;i--)
			{
				for(int j=0;j<i;j++)
				{
					if(s[j]==c||s[j+1]==c)
					{
						s[j]=c;
				//		cout<<"::"<<s[j]<<endl;
					}
				}
				int flag=0;
				for(int j=0;j<i;j++)
				{
					if(s[j]!=c)
					{
						flag=1;
						break;
					}
				}	
			
				if(flag==0)
				{
					if(ans>n-i)
					ans=n-i;
					break;
					
				}
			}
		}
	
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#define L 10000
void push(int);
int pop();
int S[L],top=0;
int main(){
  char S[L];
  int a,b; 
  while(scanf("%s",S)!=EOF){
    if(S[0] == '+'){
      push(pop()+pop());
    }
    else if(S[0] == '-'){
      a=pop();
      b=pop();
      push(b-a);
    }
    else if(S[0] == '*'){
      push(pop()*pop());
    }
    else push(atoi(S));
  }
  printf("%d\n",pop());
  return 0;
}
void push(int x){
  top++;
  S[top]=x;
}
int pop(){
  top--;
  return S[top+1];
}


Measured memory_bytes: 2088
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set_pair tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
  const double  pi=3.1415926535; 
  struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,i,d,sum=0;cin>>n>>d;
	d*=d;
	for(i=0;i<n;i++){
		ll x,y;cin>>x>>y;
		ll z=x*x+y*y;
		if(d>=z)
			sum++;
	}
	cout<<sum<<endl;

	return 0;
} 

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>

using namespace std;

int main(){

    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;

    vector<bool> a(N, false);
    vector<bool> b(N, false);

    a[A - 1] = true;
    b[B - 1] = true;

    for(int i = A; i < N; i++){
        if(S[i] == '#'){
            continue;
        }

        if(i >= 1 && a[i - 1]){
            a[i] = true;
            continue;
        }

        if(i >= 2 && a[i - 2]){
            a[i] = true;
        }  
    }

    for(int i = B; i < N; i++){
        if(S[i] == '#'){
            continue;
        }

        if(i >= 1 && b[i - 1]){
            b[i] = true;
            continue;
        }

        if(i >= 2 && b[i - 2]){
            b[i] = true;
        }  
    }

    if(C < D){
        if(a[C - 1] && b[D - 1]){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else{
        if(!a[C - 1] || !b[D - 1]){
            cout << "No" << endl;
        }
        else{
            bool isOk = false;
            for(int i = B - 1; i <= D - 1; i++){
                if(b[i] && a[i - 1] && a[i + 1]){
                    isOk = true;
                    break;
                }
            }

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

    return 0;
}

Measured memory_bytes: 640
void main()
{
    long n, m;
    rdVals(n, m);

    long[][] edge = new long[][](n+m);
    foreach (i; 0 .. n)
    {
        long[] lang = rdRow;
        foreach (l; lang[1..$])
        {
            long j = l + n - 1;
            edge[i] ~= j, edge[j] ~= i;
        }
    }

    bool[] comm = new bool[n+m];
    auto que = BinaryHeap!(Array!long, "a > b")();
    que.insert(0);
    while (!que.empty)
    {
        long f = que.front;
        que.popFront;
        foreach (e; edge[f])
        {
            if (comm[e]) continue;
            comm[e] = true;
            que.insert(e);
        }
    }

    writeln(comm[0..n].all!"a == true" ? "YES" : "NO");
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

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

int a[10010];

int main(){
    int n;
    cin>>n;
    for(int i=1; i<=300; ++i){
        for(int j=1; j<=300; ++j){
            for(int k=1; k<=300; ++k){
                if(i*i+j*j+k*k+i*j+j*k+k*i>10005)continue;
                a[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }
    for(int i=1; i<=n; ++i){
        cout<<a[i]<<endl;
    }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int read()
{
    char s;
    int k=0,base=1;
    while((s=getchar())!='-'&&s!=EOF&&!(s>='0'&&s<='9'));
    if(s==EOF)exit(0);
    if(s=='-')base=-1,s=getchar();
    while(s>='0'&&s<='9')
    {
        k=k*10+(s-'0');
        s=getchar();
    }
    return k*base;
}
void write(int x)
{
    if(x<0)
    {
        putchar('-');
        write(-x);
    }
    else
    {
        if(x/10)write(x/10);
        putchar(x%10+'0');
    }
}
char ch[100100];
int n,s[500];
int main()
{
	scanf("%s",ch+1);
	n=strlen(ch+1);
	if (n<=1)
	{
		printf("YES");
		return 0;
	}
	if (n==2)
	{
		if (ch[1]!=ch[2]) printf("YES"); else printf("NO");
		return 0;
	}
	for (int i=1;i<=n;i++)
	{
		s[ch[i]-'a']++;
	}
	int max1=s[0],min1=s[0];
	max1=max(max1,s[1]);max1=max(max1,s[2]);
	min1=min(min1,s[1]);min1=min(min1,s[2]);
	if (max1-min1>1)
	{
		printf("NO");
		return 0;
	}
	printf("YES");
	return 0;
}

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

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

Measured memory_bytes: 3592
/*	
*  Sachin Mittal
*/
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';
using namespace std;

void solve()
{
    int n,m;cin>>n>>m;
    int sm=0;
    rep(i,0,m)
    {
    	int x;cin>>x;
    	sm+=x;
    }
    if(sm>n)cout<<-1;
    else cout<<n-sm;
}

int32_t main(){

ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t=1;
//cin>>t;
while(t--)
{
	solve();
}
}

Measured memory_bytes: 3656
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    cunt=0
    for a in A:
        if a%2==0:cunt+=1
    print(3**n-2**cunt)

if __name__=='__main__':
    main()

Measured memory_bytes: 38384
import math

def main():
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	B = [0] * N
	if N == 1:
		if A[0] == 1:
			print(1)
			print(1)
		else:
			print(0)
		return 0
	for i in range(1, N):
		for j in range(math.ceil(N / (i + 1)), math.floor(N / i) + 1):
			ball = 0
			for k in range(2 * j, N + 1, j):
				ball += B[k - 1]
			B[j - 1] = (ball % 2 + A[j - 1]) % 2
	ans = [str(x + 1) for x, v in enumerate(B) if v == 1]
	print(len(ans))
	if len(ans) > 0:
		print(" ".join(ans))

main()


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

int main(){
    int h,w;
    cin >> h >> w;
    int count = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char c;
            cin >> c;
            if(c=='#') count++;
        }
    }
    if(count == h+w-1){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}


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

struct StList
{
  int  m_iKey;
  StList *m_poPrev;
  StList *m_poNext;
  
  StList() :
    m_iKey(0), m_poPrev(nullptr), m_poNext(nullptr)
  { }

  StList(int a_iNumber, StList &a_roHead) :
    m_iKey(a_iNumber), m_poPrev(&a_roHead), m_poNext(a_roHead.m_poNext)
  { }

  ~StList() { }
};

void fnLinkedListSet(StList &a_roHead, StList &a_roTrail)
{
  char acCommand[80];
  int iMaxCommand, iNumber;

  cin.tie(0);
  ios::sync_with_stdio(false);
 
  cin >> iMaxCommand;
  for (int i = 0; i < iMaxCommand; i++)
  {
    cin >> acCommand;
    if (acCommand[0] == 'i')
    {
      cin >> iNumber;
      StList *poList = new StList(iNumber, a_roHead);
      a_roHead.m_poNext->m_poPrev = poList;
      a_roHead.m_poNext = poList;
    }
    else if (acCommand[6] == 'F')
    {
      StList *poList = a_roHead.m_poNext;
      poList->m_poNext->m_poPrev = poList->m_poPrev;
      a_roHead.m_poNext          = poList->m_poNext;
      delete poList;
    }
    else if (acCommand[6] == 'L')
    {
      StList *poList = a_roTrail.m_poPrev;
      a_roTrail.m_poPrev         = poList->m_poPrev;
      poList->m_poPrev->m_poNext = poList->m_poNext;
      delete poList;
    }
    else if (acCommand[0] == 'd')
    {
      cin >> iNumber;
      StList *poList = a_roHead.m_poNext;
      while (poList != &a_roTrail)
      {
        if (poList->m_iKey == iNumber)
        {
          poList->m_poNext->m_poPrev = poList->m_poPrev;     
          poList->m_poPrev->m_poNext = poList->m_poNext;
          delete poList;
          break;
        }
        poList = poList->m_poNext;
      }
    }
  }
}

void fnLinkedListGet(StList &a_roHead, StList &a_roTrail)
{
  StList *poList = a_roHead.m_poNext;
  while (poList != &a_roTrail)
  {
    if (poList != a_roHead.m_poNext) cout << " ";
    cout << poList->m_iKey;
    poList = poList->m_poNext;
    delete poList->m_poPrev;
  }
  cout << endl;
}

int main()
{
  StList oHead, oTrail;
  oHead.m_poNext  = &oTrail;
  oTrail.m_poPrev = &oHead;

  fnLinkedListSet(oHead, oTrail);
  fnLinkedListGet(oHead, oTrail);

  return 0;
}

Measured memory_bytes: 32460
#include<bits/stdc++.h>
using namespace std;
void solve(){
    int n, r;
    cin >> n >> r;
    if(n >= 10){
        cout << r << endl;
    }else{
        cout << r + 100*(10 - n) << endl;
    }

}

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

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

int main() {
	int n, i, j, k, l, count = 0;
	while (cin >> n) {
		count = 0;
		for (i = 0; i<10; i++){
			for (j = 0; j<10; j++){
				for (k = 0; k<10; k++){
					for (l = 0; l<10; l++){
						if (i + j + k + l == n) count++;
					}
				}
			}
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  string a,b,c;
  cin >> a >> b >> c;
  if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
    cout << "YES" << "\n";
  }else{
    cout << "NO"<< "\n";
  }
}

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

using namespace std;
typedef long long ll;

const int N = int(1e8) + 7;

void init(){

}

void solve(){
    char c[12];
    scanf("%s", c);
    int k = 0;
    int ans = 0;
    for(int i = 0; i < strlen(c); i++){
        if(c[i] == 'A' || c[i] == 'C' || c[i] == 'G' || c[i] == 'T') k++;
        else k = 0;
        ans = max(ans, k);
    }
    printf("%d\n", ans);
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 2e5+5;
set<int> G[maxn];

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    int N,M;
    while (cin >> N >> M) {
        FOR(i,0,N+1)
            G[i].clear();
        FOR(i,0,M) {
            int a,b; cin >> a >> b;
            G[a].insert(b);
            G[b].insert(a);
        }
        string ans = "IMPOSSIBLE";
        FOR(u,2,N) if (in_(N,G[u]) && in_(u,G[1]))
            ans = "POSSIBLE";
        cout << ans << endl;
    }
    return 0;
}


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

int main(void){
   int m,f,r;

   while(true){
       cin >> m >> f >> r;
       if(m == -1 && f == -1 && r == -1){
           break;
       }
       if(m == -1 || f ==-1){
           cout << "F" ;
       }
       else if(m+f >= 80){
           cout << "A" ;
       }
       else if(65 <= m+f && m+f < 80){
           cout << "B" ;
       }
       else if(50 <= m+f && m+f < 65){
           cout << "C" ;
       }
       else if(30 <= m+f && m+f < 50){
           if(r >= 50){
               cout << "C" ;
           }
           else{
               cout << "D" ;
           }
       }
       else{
           cout << "F" ;
       }
       cout << endl;
   }
}


Measured memory_bytes: 3084
s = []
s.append(input())
s.append(input())
s.append(input())

def ne(i):
  if not s[i]:
    return i
  val = s[i][0]
  s[i] = s[i][1:]
  nex = 0 if val == 'a' else (1 if val == 'b' else 2)
  return ne(nex)

rslt = ne(0)
print('A' if rslt == 0 else ('B' if rslt == 1 else 'C'))


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

using namespace std;

typedef long long ll;
const ll maxn=110;
//struct node{
//	ll x;
//	ll y;
//	double angle;
//	friend bool operator<(node a,node b){
//		return a.angle<b.angle;
//	}
//}point[maxn];
struct node{
	ll x;
	ll y;
	double angle;
}point[maxn];
bool cmp(node a,node b){
	return a.angle<b.angle;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>point[i].x>>point[i].y;
		point[i].angle=atan2(point[i].y,point[i].x);
	}
	sort(point,point+n,cmp);
	ll ans=0;
	for(int i=0;i<n;i++){
		ll dx=point[i].x,dy=point[i].y;
		ans=max(ans,dx*dx+dy*dy);
		for(int j=(i+1)%n;j!=i;j=(j+1)%n){
			dx+=point[j].x;dy+=point[j].y;
			ans=max(ans,dx*dx+dy*dy);
		}
	}
	double res=sqrt(ans);
//	cout<<<<endl;
	printf("%.14f\n",res);
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

#include <regex>
#include <locale>
#include <iomanip>

using namespace std;
using ll = long long;

#define OVERLOAD3(_1,_2,_3,name,...) name
#define REP(i,n) REPI(i,0,n)
#define REPI(i,a,b) for(int i=int(a),i##_Len=int(b);i<i##_Len;++i)
#define rep(...) OVERLOAD3(__VA_ARGS__,REPI,REP,)(__VA_ARGS__)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main () {
  int n;
  cin >> n;
  cout << n/100 + (n%100)/10 + (n%100)%10 << endl;
}

Measured memory_bytes: 3156
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

bool data[50101] = {};

int main ()
{
	data[0] = 1;
	data[1] = 1;
	for( size_t i = 2; i < 50101; i++ )
	{
		if( data[i] == 0 )
		{
			int j = i * 2;
			for(; j < 50101; j+=i )
			{
				data[j] = 1;
			}
		}
	}
	int N;
	while( cin >> N )
	{
		int a = N+1 , b = N-1;
		while( data[a] )a++;
		while( data[b] )b--;
		cout << b << " " << a << endl;
	}
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




// 解説みた
int n;
const int V = 100005;

vector<int> v[2 * V];
int visited[2 * V];

vector<int> cnt;

void dfs(int i) {
    if (visited[i]) return;
    visited[i] = 1;
    cnt[i / V]++; // 0番か1番か
    for (int nxt : v[i]) {
        dfs(nxt);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    cin >> n;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        y += V;
        v[x].eb(y);
        v[y].eb(x);
    }
    
    ll ans = 0;
    rep(i, 2 * V) {
        if (visited[i]) continue;
        // 毎回初期化
        cnt = vector<int>(2);
        dfs(i);
        ans += (ll)cnt[0] * cnt[1];
    }
    
    cout << ans - n << endl;
}




Measured memory_bytes: 10752
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		arr[i], _ = strconv.Atoi(sc.Text())
	}

	result := make([]int, 0)
	for _, el := range arr {
		if len(result) == 0 || result[len(result)-1] >= el {
			result = append(result, el)
		} else {
			i := sort.Search(len(result), func(i int) bool {
				return el > result[i]
			})
			result[i] = el
		}
	}

	fmt.Println(len(result))
}


Measured memory_bytes: 6272
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
signed main()
{
    fast;
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int ans = 1;
    int cnt = 1;
    for(int i=2;i<=n;i++)
    {
        if(a[i]<=a[i-1])
        {
            cnt++;
        }
        else
        {
            ans = max(cnt,ans);
            cnt = 1;
        }
    }
    ans = max(ans,cnt);
    cout<<ans-1;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int A,B,cnt=0;
  string S;
  cin>>A>>B>>S;
  for(int i=0;i<A;i++){
    if(S[i]=='-') cnt++;
  }
  if(S[A]!='-') cnt++;
  for(int i=A+1;i<A+B+1;i++){
    if(S[i]=='-') cnt++;
  }
  if(cnt==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}	


Measured memory_bytes: 768
N = int(input())
X = [0] * (N + 1)
for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            a = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + i * k
            if a <= N:
                X[a] += 1
for a in X[1:]:
    print(a)

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<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; }



void func(std::string S){

    cout<<S.substr(0,3)<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    std::string S;
    std::cin >> S;
    func(S);
    return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>
#pragma comment(linker, "/STACK:836777216")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))

int GCD(int a, int b) {
	return a ? GCD(b % a, a) : b;
}

int main(void) {
	int k;
	scanf("%d", &k);
	ll sum = 0;
	FOR(i, 1, k + 1) {
		FOR(j, 1, k + 1) {
			FOR(p, 1, k + 1) {
				sum += (ll)(GCD(GCD(i, j), p));
			}
		}
	}

	printf("%lld\n", sum);
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int A, B, T;
  cin >> A >> B >> T;
  
  int ans = B * (T / A);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();

		System.out.println(c + " " + a + " " + b);
	}

}

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

int N, A, ans = 0, flag = 1;
int a, b, c, d, e, k;
vector<int> v;
int main(){
    cin >> N;
    v.resize(2*N);
	
    for(int i=0; i<N; i++)
	cin >> v[i];
    for(int i=0; i<N; i++){
	flag=1;
	for(int j=0; j<i; j++){
	    if(v[i] < v[j])   
		flag = 0;
	}
	if(flag == 1)
	    ans++;
    }
    cout << ans<< endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
int main(){
  ll n;
  cin>>n;
  vector<string> s(n);
  rep(i,n) cin>>s[i];
  sort(all(s));
  ll count=0;
  rep(i,n-1){
    if(s[i]!=s[i+1]) count++;
  }
  cout<<count+1<<endl;
return 0;
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = 0;
        int b = 0;
        while (true) {
            a = sc.nextInt();
            b = sc.nextInt();
            if (a == 0 && b == 0) {
                break;
            }
            for (int i = 0; i < a; i++) {
                for (int j = 0; j < b; j++) {
                    if (i == 0 || j == 0 || i == (a - 1) || j == (b - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }

    }
}



Measured memory_bytes: 37500
/**
    "If you have an apple and I have an apple and
    we exchange apples then you and I will still
    each have one apple. But if you have an idea
    and I have an idea and we exchange these
    ideas, then each of us will have two ideas."
                        -George Bernard Shaw
*/
#include<bits/stdc++.h>
using namespace std;

#define clean(x,y) memset(x,y,sizeof(x));
#define pb push_back
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define ALL(v) v.begin(),v.end()
#define PI acos(-1.0)
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define printa(a,L,R) for(int ii=L; ii<R; ii++) cout<<a[ii]<<" \n"[ii==R-1]
#define printv(a) printa(a,0,(int)a.size())
#define Unique(a) sort(ALL(a)); (a).resize(unique(ALL(a)) - (a).begin())
#define SZ(v) (int)v.size()
#define MOD 1000000007
#define MAX 200005

#define dbg(x) cout<<(#x)<<"="<<(x)<<":\n"
#define CS(i) cout<<"Case "<<i<<": "

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector< pii > vpi;
typedef vector< pll > vpl;
typedef map<int, int> mii;
typedef map<ll, ll> mll;


void syntex_error()
{
    ll i,j,k,l,r,n,m,a,b,c,x,y,z,sum=0LL;
    vl v;
    
    cin>>n>>k;
    for(i=0; i<n; ++i)
    {
        ll xx;
        cin>>xx;
        v.pb(xx);
    }
    sort(ALL(v));
    for(i=0; i<k; i++)
        sum+=v[i];
    cout<<sum<<endl;

}

int main()
{
    FAST
    
    ll TC=1LL;

    //cin>>TC;

    while(TC--){
        syntex_error();
    }

    return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll dp[100][4][4][4];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    rep(i,0,4){
        rep(j,0,4){
            rep(k,0,4){
                dp[2][i][j][k]=1;
            }
        }
    }
    dp[2][0][2][1]=0;
    dp[2][0][1][2]=0;
    dp[2][2][0][1]=0;
    rep(i,1,N-1){
        rep(j,0,4){
            rep(k,0,4){
                rep(u,0,4){
                    dp[i+1][k][u][0]+=dp[i][j][k][u];
                    dp[i+1][k][u][1]+=dp[i][j][k][u];
                    dp[i+1][k][u][2]+=dp[i][j][k][u];
                    dp[i+1][k][u][3]+=dp[i][j][k][u];
                    if((j==0||k==0)&&u==2){
                        dp[i+1][k][u][1]-=dp[i][j][k][u];
                    }
                    else if(k==0&&u==1){
                        dp[i+1][k][u][2]-=dp[i][j][k][u];
                    }
                    else if(k==2&&(j==0||u==0)){
                        dp[i+1][k][u][1]-=dp[i][j][k][u];
                    }
                    dp[i+1][k][u][0]%=MOD;
                    dp[i+1][k][u][1]%=MOD;
                    dp[i+1][k][u][2]%=MOD;
                    dp[i+1][k][u][3]%=MOD;
                }
            }
        }
    }
    ll ans=0;
    rep(i,0,4){
        rep(j,0,4){
            rep(k,0,4){
                ans+=dp[N-1][i][j][k];
                ans%=MOD;
            }
        }
    }
    cout <<ans<<"\n";
}

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

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define output_to_error freopen("error.txt" , "w" ,stderr)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'
#define int long long
const int mod = 1e9+7 , N = 1e6+1;
int fact[2*N];
int find(int x , int y)
{
    int ans = 1;
    while(y)
    {
        if(y&1)ans = (ans * x)%mod;
        y >>= 1;
        x = (x * x)%mod;
    }
    return ans;
}

signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
        output_to_error;
    #endif
    fastio;cin.tie(0);cout.tie(0);
    int x , y , ans = 0; cin >> x >> y ;
    fact[0] = 1;
    for(int i = 1 ; i < 2*N ; ++i)
        fact[i] = (i*fact[i-1])%mod;
    for(int a = 0 ; a <= x ; ++a)
    {
        if((x-a)&1) continue;
        else
        {
            int b = (x - a)/2;
            if(a + 2 * b == x && 2*a + b == y)
            {
                int num = fact[a+b];
                int den = (fact[a] * fact[b])%mod;
                ans = ( ans + num*find(den , mod-2))%mod;
            }
        }
    }
    cout << ans ;

    return 0;
}


Measured memory_bytes: 15872
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data = scanner.nextLine();

			String[] arr = data.split(" ");
			int d = Integer.parseInt(arr[0]);
			int t = Integer.parseInt(arr[1]);
			int s = Integer.parseInt(arr[2]);

			System.out.println((s * t) >= d ? "Yes" : "No");
		}
	}
}


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

//ans = 境界の数

int main() {
    int64_t n, m, ans;
    cin >> n >> m;
    if (n > m/2) {
        ans = m/2;
    }
    else {
        ans = (2*n + m) / 4;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d

def main():
    N = int(input())
    S = tuple(map(int,input()))

    ans = 0

    # Rnum: 000 ~ 999
    for Rnum in range(1000):
        R = list(map(int,str(Rnum).zfill(3)))

        for s in reversed(S):
            if s == R[-1]:
                R.pop()
            if not R:
                ans += 1
                break

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 42860
#include <iostream>
using namespace std;
int main()
{
    int n, x, l[100], ans = 0, d = 0, i;
    cin >> n >> x;
    for(i = 0; i < n; i++){
        scanf("%d", &l[i]);
    }
    i = 0;
    while(d <= x){
        ++ans;
        d += l[i++];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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



int dp[3030][3030];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;

    REP(i,s.size()){
        REP(j,t.size()){
            if(s[i]==t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
            chmax(dp[i+1][j+1],dp[i+1][j]);
            chmax(dp[i+1][j+1],dp[i][j+1]);
        }
    }
    string res="";
    int i = s.size(), j = t.size();
    while(i>0 && j>0){
        if(dp[i][j]==dp[i-1][j]) --i;
        else if(dp[i][j]==dp[i][j-1]) --j;
        else{
            res = s[i-1] + res;
            --i,--j;
        }
    }
    cout<<res<<endl;
}

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

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define lll __int128
#define ull unsigned long long
#define fi first
#define se second
#define db double
#define ld long double
#define lld __float128

/// order_of_key, find_by_order

template<class T, class COMP>
using custom_set = tree<T, null_type, COMP, rb_tree_tag, tree_order_statistics_node_update>;

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

template<class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T, class U>
using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd_64(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 200005;

ll dp[MAXN];

int main()
{
    int n; cin >> n;
    pair<int, int> dat[n], sg[n];
    for(int i = 0; i < n; i++)
    {
        int x, l; cin >> x >> l;
        dat[i] = {x-l, x+l};
    }
    vector< pair<int, pair<char, int> > > vc;
    for(int i = 0; i < n; i++)
    {
        vc.push_back({dat[i].fi, {1, i}});
        vc.push_back({dat[i].se, {0, i}});
    }
    sort(vc.begin(), vc.end());
    for(int i = 0; i < vc.size(); i++)
    {
        if(vc[i].se.fi == 0)
        {
            sg[vc[i].se.se].se = i;
        }
        else
        {
            sg[vc[i].se.se].fi = i;
        }
    }
    for(int i = 0; i < vc.size(); i++)
    {
        if(vc[i].se.fi == 1)
        {
            dp[sg[vc[i].se.se].se] = max(dp[sg[vc[i].se.se].se], dp[i]+1);
        }
        dp[i+1] = max(dp[i+1], dp[i]);
    }
    cout << dp[vc.size()] << endl;
}






































/// shche ne vmerla Ykraina


Measured memory_bytes: 6512
n = int(input().strip())
S = input().strip()

r=[]
g=[]
b=[]
for i,s in enumerate(S):
    if s=="R":
        r.append(i)
    elif s=="G":
        g.append(i)
    else:
        b.append(i)

ans=len(r)*len(g)*len(b)
for gap in range(1,(n-1)//2+1):
    i=0
    j=i+gap
    k=j+gap
    while k<=n-1:
        if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
            ans-=1
        i+=1
        j+=1
        k+=1
    
print(ans)

Measured memory_bytes: 9308
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n,k ;
	set<ll> s ;
	cin >> n >> k ;
	for(int i=0;i<k;i++){
		ll d ; cin >> d ;
		for(int j=0;j<d;j++){
			ll a ; cin >> a ;
			s.insert(a) ;
		}
	}
	cout << n-s.size() << endl ;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
int main()
{   int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int e,f,g;
	e=fabs(a-b);
	f=fabs(a-c);
	g=fabs(b-c);
	int max=e;
	 if(f>max)
	   max=f;
	   if(g>max)
	   max=g;
	   printf("%d",e+f+g-max);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (H, W) = Read2Longs();
            var sb = new StringBuilder();
            for (int i = 0; i < H; i++)
            {
                var c = ReadText();
                sb.AppendLine(c);
                sb.AppendLine(c);
            }
            return sb.ToString().Trim();
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> t(n + 1);
  vector<int> x(n + 1);
  vector<int> y(n + 1);
  for (int i = 1; i < n + 1; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  string ans = "Yes";
  for (int i = 0; i < n; i++) {
    int dt = t[i+1] - t[i];
    int dd = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if (dd > dt || (dd & 1) ^ (dt & 1)) {ans = "No"; break;}
  }
  cout << ans << '\n';
  return 0;
  
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    int n;
    cin >> n;
    int ac=0,wa=0,tle=0,re=0;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        if(s=="AC") ac++;
        if(s=="WA") wa++;
        if(s=="TLE") tle++;
        if(s=="RE") re++;
    }
    printf("AC x %d\n",ac);
    printf("WA x %d\n",wa);
    printf("TLE x %d\n",tle);
    printf("RE x %d\n",re);
}

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

#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define inf 1e18
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100001
// <<fixed << setprecision(9)

void err()
{
	cout<<"NO\n";
	exit(0);
}

int main()
{
	int n,i,w,j;
	boost;
	cin>>n>>w;
	int val[n+1],wt[n+1];
	ll dp[n+1][space];
	
	rep(i,1,n+1)cin>>wt[i]>>val[i];
	
	rep(i,0,space)dp[0][i]=-1;
	dp[0][0]=0;
	rep(i,1,n+1)
	{
		dp[i][0]=0;
		rep(j,1,space)
		{
			if(val[i]>j) dp[i][j]=dp[i-1][j];
			else
			{
				if(dp[i-1][j-val[i]]==-1) dp[i][j]=dp[i-1][j];
				else if(dp[i-1][j]==-1) dp[i][j]=dp[i-1][j-val[i]]+wt[i];
				else dp[i][j]=min(dp[i-1][j],dp[i-1][j-val[i]]+wt[i]);
			}
			
		}
	}
//	rep(i,1,n+1)
//	{
//		rep(j,0,space)
//		{
//			cout<<dp[i][j]<<' ';
//		}
//		cout<<'\n';
//	}
j=0;
	rep(i,0,space)
	{
		if(dp[n][i]<=w && dp[n][i]!=-1)j=i;
	}
	cout<<j;
	
	
}



Measured memory_bytes: 79232
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
vector<P> IG[2505];
vector<int> FG[2505];
vector<int> RG[2505];
vector<P> G[2505];
int fok[2505];
int rok[2505];
ll D[2505];

ll dfs(int idx, vector<int> *G, int *ok) {
  ok[idx] = 1;
  for (auto i : G[idx]) {
    if (!ok[i]) {
      dfs(i, G, ok);
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  int N, M, P;
  cin >> N >> M >> P;
  for (int i=0; i<M; i++) {
    int A, B, C;
    cin >> A >> B >> C;
    IG[A].push_back(make_pair(B, -(C-P)));
    FG[A].push_back(B);
    RG[B].push_back(A);
  }
  dfs(1, FG, fok);
  dfs(N, RG, rok);
  for (int i=1; i<=N; i++) {
    if (!fok[i]) continue;
    for (auto it: IG[i]) {
      if (!rok[it.first]) continue;
      G[i].push_back(it);
    }
  }
  int step = 0;
  for (int i=2; i<=N; i++) D[i] = 1LL << 40;
  while (1) {
    bool f = false;
    for (int i=1; i<=N; i++) {
      for (auto it: G[i]) {
        if (D[it.first] > D[i] + it.second) {
          f = true;
          D[it.first] = D[i] + it.second;
        }
      }
    }
    step++;
    if (!f) break;
    if (step > N) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << max(0LL, -D[N]) << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int[][] F = new int[N][10];
		int[][] P = new int[N][11];
		
		for(int i = 0;i < N;++i)
			for(int j = 0;j < 10;++j)
				F[i][j] = sc.nextInt();
		for(int i = 0;i < N;++i)
			for(int j = 0;j < 11;++j)
				P[i][j] = sc.nextInt();
		
		int max = Integer.MIN_VALUE;
		for(int i = 1;i < 1024;++i) {
			int[] duplicate = new int[N];
			for(int j = 0;j < N;++j)
				for(int k = 0;k < 10;++k)
					if(((i >>> k)%2 == 1) && F[j][k] == 1)
						++duplicate[j];
			int score = 0;
			for(int j = 0;j < N;++j)
				score += P[j][duplicate[j]];
			if(score > max)
				max = score;
		}
		System.out.println(max);
		sc.close();
	}
}


Measured memory_bytes: 27752
// Copyright 2017 wu_qing
#include <cstdio>
const int K = 20;
int n, k, t, m;
bool b[K], f;
int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= k; i++) {
        scanf("%d", &t);
        b[t] = true;
    }
    while (!f) {
        m = n;
        f = true;
        while (m && f) {
            if (b[m % 10])
                f = false;
            m /= 10;
        }
        n++;
    }
    printf("%d\n", n - 1);
}


Measured memory_bytes: 128
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>

using namespace std;


//polygon의 중심 좌표를 구한다.
//중심 좌표로부터 
int main(void)
{
	int N, L;
	vector <string> s;

	cin >> N >> L;
	
	for (int i = 0; i < N; i++)
	{
		string temp;
		cin >> temp;
		s.push_back(temp);
	}

	sort(s.begin(), s.end());
	for (int i = 0; i < N; i++)
	{
		cout << s[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main(){
    int n,m,slime;
    string s;
    m=s.length();
    cin>>n>>s;
    slime=0;
    for(int i=0;i<n;i++){
        if(s[i]!=s[i+1]){
            slime++;
        }
    }
    cout<<slime<<endl;
    return 0;
}

    
    

Measured memory_bytes: 512