akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){
    int a[5],b[5],lastorder,rest,i,pos,ans;
    lastorder = 0;
    pos = 10;
    scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);
    for(i=0;i<5;i++){
        if(a[i]%10 !=0 ){
            b[i]= ((a[i]+10)/10)*10;
        }else{
            b[i] = a[i];
        }
    }
    for (i=0;i<5;i++){
        rest = a[i]%10;
        if (rest!=0 && rest<pos){
            lastorder = a[i];
            pos = rest;
            // printf("%d\n",lastorder);
        }
    }
    if(lastorder == 0){
        ans = a[0]+a[1]+a[2]+a[3]+a[4];
    }else{
        ans = b[0]+b[1]+b[2]+b[3]+b[4]-((lastorder+10)/10)*10+lastorder;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_pow(int base, int exp)
{
	_T ans = 1;

	for (int i = 0; i < exp; i++) {
		ans *= (_T)base;
	}
	return ans;
}

static void D();

int main()
{
	D();
	fflush(stdout);
	return 0;
}

static void D()
{
	int N;
	get(N);
	std::string s, t;
	get(s, t);

	int match = 0;
	for (int st = 0; st < N; st++) {
		bool ng = false;
		for (int i = 0; i < N - st; i++) {
			if (s[st + i] != t[i]) ng = true;
		}
		if (!ng) {
			match = std::max(match, N - st);
		}
	}
	printf("%d\n", N * 2 - match);
}


Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		String W = input().toLowerCase();
		String T;
		int count = 0;

		while (!(T = input()).equals("END_OF_TEXT")) {

			String[] TArrays = T.split(" ");

			for (int i = 0; i < TArrays.length; i++) {

				if (TArrays[i].equalsIgnoreCase(W)) {

					count++;

				}
			}
		}

		System.out.println(count);

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 26264
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

int main() {
  int D;
  cin >> D;
  if (D == 25) {
    cout << "Christmas" << endl;
  } else if (D == 24) {
    cout << "Christmas Eve" << endl;
  } else if (D == 23) {
    cout << "Christmas Eve Eve" << endl;
  } else {
    cout << "Christmas Eve Eve Eve" << endl;
  }
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  if (s == "SAT") cout << 1 << endl;
  if (s == "FRI") cout << 2 << endl;
  if (s == "THU") cout << 3 << endl;
  if (s == "WED") cout << 4 << endl;
  if (s == "TUE") cout << 5 << endl;
  if (s == "MON") cout << 6 << endl;
  if (s == "SUN") cout << 7 << endl;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define  sz(x)  (int)x.size()
#define  ff first
#define  ss second
#define  pii  pair<int,int>
using namespace std;

inline void solve(){ 
    map <char,int> mp;
    string s;
    cin>>s;
    int ans;
    for (int i=0;i<(int)s.size();i++){
        if (s[i]=='A'){
            if (mp[s[i]]) continue;
            else mp[s[i]]=i+1;
        }
        if (s[i]=='Z'){
            if (mp['A']) ans=i+2-mp['A'];
        }
    }
    cout << ans << endl; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 832
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC753A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
           
           

            if (x == 3 || x == 5 || x == 7)
            {
                Console.Write("YES");
            }
            else
            Console.WriteLine("NO");
            Console.ReadKey();



        }

    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main(void)
{
    int A,B,C;

    scanf("%d %d %d",&A,&B,&C);

    if(C-A+B < 0){
        printf("0\n");
    } else{
        printf("%d\n",C-A+B);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

ll dp[100100][2];
const int gleich = 0;
const int kleiner = 1;

int main(){
	string l; cin >> l;
	int bound = l.l_ength();
	dp[0][gleich] = 2;
	dp[0][kleiner] = 1;
	for( int i = 0; i < bound-1; ++i ){
		if( l[i+1] == '1' ){
			dp[i+1][gleich] += ( dp[i][gleich] * 2 ) % mod;
			dp[i+1][kleiner] += ( dp[i][gleich] + dp[i][kleiner]*3 ) % mod;		
		} else {
			dp[i+1][gleich] += dp[i][gleich];
			dp[i+1][kleiner] += ( dp[i][kleiner] * 3 ) % mod;
		}
	}
	cout << ( dp[bound-1][gleich]+dp[bound-1][kleiner] ) % mod << endl;
	return 0;
}

Measured memory_bytes: 2048
#include<stdio.h>
#include<iostream>
#include<cstdlib>
using namespace std;

int N;
int main (){
    cin >> N;
    int a[N];
    long long int sum = 0;
    for(int i=0; i<N; i++){
        cin >> a[i];
        sum += a[i];
    }
    long long int x = 0;
    long long int ans = 9999999999;
    for(int i=0; i<N-1; i++){
        x += a[i];
        ans = min( abs(sum - x * 2), ans);
    }
    cout << ans << endl;
    return 0;
}


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

int atoix(char n){
  int d,i;
  if(n=='0') d=0;
  else if(n=='1') d=1;
  else if(n=='2') d=2;
  else if(n=='3') d=3;
  else if(n=='4') d=4;
  else if(n=='5') d=5;
  else if(n=='6') d=6;
  else if(n=='7') d=7;
  else if(n=='8') d=8;
  else if(n=='9') d=9;
  else d=0;
  return d;
} 

main(){
  char m[11];
  int ans[11];
  int i,j;

  while(scanf("%s",m)!=EOF){

    for(i=0;i<10;i++){
      ans[i]=atoix(m[i]);
    }
    
    for(j=9;j>0;j--){
      for(i=0;i<j;i++){
	ans[i]=(ans[i]+ans[i+1])%10;
      }
    }
    
    printf("%d\n",ans[0]);
  }

  return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110


signed main()
{
    int L;
    string S;
    cin >> L >> S;

    int ans = 0;
    for(int i = 0; i < S.length()-1; ++i) {
        string X = S.substr(0, i + 1);
        string Y = S.substr(i + 1, S.length() - (i + 1));
        bool hasX[30] = {};
        bool hasY[30] = {};
        REP(j, X.length()) { hasX[X[j] - 'a'] = true; }
        REP(j, Y.length()) { hasY[Y[j] - 'a'] = true; }
        int cand = 0;
        REP(j, 30) {
            if(hasX[j] && hasY[j]) { cand++; }
        }
        ans = max(ans, cand);
    }
    printf("%lld\n", ans);
    return 0;
}


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

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)


const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef long long ll;
typedef pair<int, int> P;

const int MAX_V = 200;

struct edge{int to, cost;};

//V := number of nodes
//G := adj
//rest := number of nodes which are not determined yet
int V;
vector<edge> G[MAX_V];
int d[MAX_V];
int rest = V-1;
void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        rep(G[v].size(), i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

void solve(void){
    int H, W; cin >> H >> W;
    V = 10;
    rep(10, i) rep(10, j) {
        int c; cin >> c;
        G[j].push_back({i, c});
    }
    dijkstra(1);
    int ans = 0;
    rep(H, i) rep(W, j) {
        int w; cin >> w;
        if (w == -1) continue;
        ans += d[w];
    }
    //rep(10, i) cout << d[i] << ' ';
    cout << ans << '\n';
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin>>N>>M;
    int L[M],R[M];
    for(int i=0;i<M;i++){
        cin>>L[i]>>R[i];
    }

    int lm=L[0],rm=R[0];
    for(int i=0;i<M;i++){
        if(L[i]>lm){
            lm=L[i];
        }

        if(R[i]<rm){
            rm=R[i];
        }
    }

    if(lm>rm){
        cout<<0<<endl;
    }
    else{
        cout<<rm-lm+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;

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

  ll bla=0,whi=0,pos,ans=0;
  int len=s.size();
  bool flag=false;
  rep(i,len){
    if(flag==false && s.at(i)=='B') flag=true,pos=i;

    if(s.at(i)=='W' && flag){
      ans+=(i-pos-whi);
      whi++;
    }
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

#define MOD 1e9+7

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int h, w;
    ll m = MOD;
    cin >> h >> w;
    vector<ll> tmp(w+1, 0);
    vector<vector<ll>> dp(h+1, tmp);
    vector<string> a;
    rep(i, h){
        string s;
        cin >> s;
        a.push_back(s);
    }

    dp[0][1] = 1;
    rep2(i, 1, h+1){
        rep2(j, 1, w+1){
            if(a[i-1][j-1]=='.'){
              dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % m;
            }
        }
    }
    cout << dp[h][w] << endl;
    return 0;
}

Measured memory_bytes: 12508
// LNU_Algotesters
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <fstream>
#include <complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

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

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 55;
const int MOD = INF;



int main()
{
    //freopen("in.txt", "r", stdin);
    //ios::sync_with_stdio(false); cin.tie(0);
    
    LL a, b;
    cin>> a >> b;
    LL ans = LINF;
    if (a <= b)ans = min(ans, b-a);
    a = -a;
    if (a <= b)ans = min(ans, b-a+1);
    b = -b;
    if (a <= b)ans = min(ans, b-a+2);
    a = -a;
    if (a <= b)ans = min(ans, b-a+1);
    cout << ans << endl;
    
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};
int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int aa[10000];

#define DBL(x) ((x)*(x))

int main(){
  int a,b;
  int tmp[4];

  while(a = getInt(), b = getInt(), a + b){
    int ca = 0;
    int ans = INT_MAX;
    for(int i=1; i*i <= a; i++)
      if(a % i == 0) aa[ca++] = i;
    for(int i=1; i*i <= b; i++){
      if(b % i == 0){
        REP(j,ca){
          tmp[0] = i;
          tmp[1] = b / i;
          tmp[2] = aa[j];
          tmp[3] = a / aa[j];
          //printf("%d %d %d %d\n",tmp[0],tmp[1],tmp[2],tmp[3]);
          sort(tmp, tmp+4);
          ans = min(ans, DBL(tmp[3]-tmp[2]) + DBL(tmp[2]-tmp[1]) + DBL(tmp[1]-tmp[0]));
        }
      }
    }
    print(ans);
  }
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]"):
    l = set(S)
    print(len(l))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()

Measured memory_bytes: 103488
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdlib>
#include<set>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

#include<iostream>

int main(){
    int a, b;
    cin >> a >> b;
    int sm[999];
    rep(i, 999) sm[i] = 0;
    sm[0] = 1;
    rep(i, 998) sm[i+1] += sm[i] + i + 2;
    // rep(i, 20) cout << sm[i] <<endl;
    int idx = b - a;
    cout << sm[idx-1] - b << endl;
}

Measured memory_bytes: 256
from sys import stdin
import numpy as np
mod = 10**9+7
N,K = [int(x) for x in stdin.readline().rstrip().split()]
l = np.cumsum(range(0,N+1))
r = np.cumsum(range(N,-1,-1))
ans = 0
for k in range(K,N+2):
    ans += (r[k-1] - l[k-1] + 1)
    ans %= mod
print(ans%mod)

Measured memory_bytes: 37840
#include <stdio.h>
long long gcd(long long x,long long y);
int main()
{
    long long n,t,c;
    scanf("%lld %lld",&n,&t);
    c=n/gcd(n,t)*t;
    printf("%lld",c);
}
long long gcd(long long x,long long y)
{
    return x?gcd(y%x,x):y;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF LLONG_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

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

  vector<int> ABC(3);
  for (int i = 0; i < 3; i++) {
    cin >> ABC[i];
  }

  vector<int> l(N);
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }

  int ans = INF;
  for (int bit = 0; bit < (1 << (2*N)); bit++) {
    vector<int> Temp(3, 0);
    int a = 0;

    for (int i = 0; i < N; i++) {
      int x  = (bit >> 2*i) & 3;
      if (x == 0) {
        continue;
      } else if (x == 1) {
        if (Temp[0] != 0) {
          a += 10;
        }
        Temp[0] += l[i];
      } else if (x == 2) {
        if (Temp[1] != 0) {
          a += 10;
        }
        Temp[1] += l[i];
      } else if (x == 3) {
        if (Temp[2] != 0) {
          a += 10;
        }
        Temp[2] += l[i];
      }
    }

    int flag = 0;
    for (int i = 0; i < 3; i++) {
      if (Temp[i] == 0) {
        flag = 1;
        break;
      } else {
        a += abs(ABC[i] - Temp[i]);
      }
    }

    if (flag == 0) {
      ans = min(ans , a);
    }
  }

  cout << ans << endl;
}


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

int main()
{
  int a, b, cd;
  cin >> a >> b >> cd;
  double PI = acos(-1);
  double cr, s, l, h;
  cr = cd * PI / 180;
  s = a * b * sin(cr) / 2;
  l = a + b + sqrt(a*a+b*b-2*a*b*cos(cr));
  h = s / a * 2;
  printf("%f\n%f\n%f\n", s, l, h);
  return 0;
}



Measured memory_bytes: 3380
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

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

    int n;
    cin >> n;
    vector<int> arr(n);
    vector<int> cnt(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        cnt[arr[i]]++;
    }
    int res = 0;
    for (int i = 0; i <= n; i++) {
        res += (cnt[i] * (cnt[i] - 1)) / 2;
    }
    for (int i = 0; i < n; i++) {
        cout << res - cnt[arr[i]] + 1 << '\n';
    }

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 6300
#include <stdio.h>
#include <math.h>
#include <iostream>
using namespace std;
int main()
{   int n,t,j=0;
      char c[6];
      for(int i=0;i<6;i++)cin>>c[i];
      
            if(c[2]==c[3]&& c[4]==c[5])cout<<"Yes";
            else cout<<"No";
 
   return 0;

}

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

int main() {
  int n;
  int ans = 0;
  
  cin >> n;
  vector<int> vec(n);
  
  rep(i, n)
    cin >> vec.at(i);
  
  for(int i = 0; i < n; i+=2){
    if(vec.at(i) % 2 == 1)
      ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdbool.h>
#define N 101
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define INF -1

int GX[N][N],x,color[N],Q[N],d[N],head,tail;

bool isEnpty(){
  if(tail == head) true;
  else false;
}

void enqueue(int x){
  Q[tail] = x;
  if(tail+1 == N) tail = 0;
  else tail = tail +1;
}
			  
int dequeue(){
  int x;
  x = Q[head];
  if(head+1 == N) head = 0;
  else head = head +1;
  return x;
}

void bfs(int s){

  int i,j,k,v;

  for(i=1;i<=x;i++){
    if(i==s) continue;
    color[i] = WHITE;
    d[i] = INF;
  }
  color[s] = GRAY;
  d[s] = 0;

  enqueue(s);

  while(head != tail){
    k = dequeue();
    for(v=1;v<=x;v++){
      if(GX[k][v] == 1){
	if(color[v] == WHITE){
	  color[v] = GRAY;
	  d[v] = d[k]+1;
	  enqueue(v);
	}
	 color[k] = BLACK;
      }
    }
  }
}
  

int main(){

  int i,j,a,b,c,v,g;

  scanf("%d",&x);

  for(i=0;i<x;i++){
    for(j=0;j<x;j++){
      GX[i][j]=0;
    }
  }

  for(i=0;i<x;i++){
    scanf("%d",&v);
    scanf("%d",&g);
    for(j=0;j<g;j++){
      scanf("%d",&a);
      GX[v][a]=1;
    }
  }

  bfs(1);


  for(i=1;i<=x;i++){
    printf("%d %d\n",i ,d[i]);
  }
  return 0;
}



Measured memory_bytes: 2112
N = int(input())

line = input().split()

num1 = 0
num2 = 0
temp = 0
ans = 0

for i in range(N) :
    num1 = int(line[i])
    for j in range(i+1,N) :
        if int(line[j]) != num1 :
            num2 = int(line[j])
            temp = j
            for k in range(temp+1,N) :
                temp = int(line[k])
                if temp == num1 or temp == num2 :
                    continue
                if num1 + num2 > temp and num1 + temp > num2 and num2 + temp > num1 :
                    ans += 1


print(ans)
        

Measured memory_bytes: 9192
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var monsters = map[int]int{}
	var braves = map[int]int{}
	var count int
	n := nextInt()
	for i := 0;i <= n; i++{
		monsters[i] = nextInt()
	}
	for i := 0;i < n; i++{
		braves[i] = nextInt()
	}
	for i := 0;i < n; i++{
		if monsters[i] <= braves[i] {
			monster := monsters[i]
			count += monsters[i]
			monsters[i] = 0
			braves[i] -= monster
			if monsters[i+1] <= braves[i] {
				count += monsters[i+1]
				monsters[i+1] = 0
			} else {
				count += braves[i]
				monsters[i+1] -= braves[i]
			}
		} else {
			count += braves[i]
			monsters[i] -= braves[i]
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 12600
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;//brige, treasure
int main(){
  int n;
  while(std::cin >> n, n){
    vector<pii> island(n);
    for (int i = 0; i < n; i++) {
      std::cin >> island[i].second >> island[i].first;
    }
    sort(island.begin(), island.end());
    int w = 0;
    for (int i = 0; i < n; i++) {
      if(w + island[i].second > island[i].first){
        std::cout << "No" << std::endl;
        break;
      }
      w += island[i].second;
      if(i == n - 1){
        std::cout << "Yes" << std::endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1192
use std::io;
use std::cmp::max;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let mut sum:i32 = 0;
	let v:Vec<i32> = procon_read();
	let mut maxi:i32 = v[0];
	for i in 1..n {
		let v:Vec<i32> = procon_read();
		if maxi != max(maxi, v[0]) {
			sum += maxi;
			maxi = max(maxi, v[0]);
		}else{
			sum += v[0];
		}
	}
	sum += maxi / 2;
	println!("{}", sum);
	
}

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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int digi(int n)
{
    int cnt=0;
    while(n)
    {
        ++cnt;
        n/=10;
    }
    return cnt;
}
int n,ans=0;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    

    cin>>n;
    rep(i,1,n)
        if(digi(i)&1)
            ++ans;
    cout<<ans;
}


Measured memory_bytes: 256
from itertools import combinations
n,d = map(int,input().split())
l = []
ans = 0

for i in range(n):
    l.append(list(map(int,input().split())))
for a,b in combinations(l,2):
    if (sum((a[i]-b[i])**2 for i in range(d))) ** (1/2) % 1 == 0:
        ans += 1
print(ans)


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



int main(){
    int n;
    cin >> n;
    int count=1;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    int now=a[0];
    while(count<=n+1){
        if(now==2) break;
        now=a[now-1];
        count++;
    }
    if(count>n) cout << -1 << endl;
    else cout << count << endl;
    return 0;
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

struct UF{
	vector<int> p;
	UF() {}
	UF(int n) : p(n, -1) {}
	int find(int a){ return p[a] < 0 ? a : p[a] = find(p[a]); }
	bool unite(int a, int b) {
		a = find(a); b = find(b);
		if(a == b) return false;
		if(-p[a] < -p[b]) swap(a, b);
		p[a] += p[b]; p[b] = a;
		return true;
	}
	bool root(int a){ return p[a] < 0; }
	bool same(int a, int b){ return find(a) == find(b); }
	int size(int a){ return -p[find(a)]; }
};


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m;
	cin >>n >>m;
	vector<pii> vp(m);
	rep(i, m) cin >>vp[i].first >>vp[i].second;
	rep(i, m) vp[i].first--, vp[i].second--;
	ll ful = (ll)n*(n-1)/2;
	VL ans(m);
	UF ufa(n);
	repr(i, m-1, 0){
		int vf,vs; tie(vf,vs) = vp[i];
		ans[i] = ful;
		if(ufa.same(vf, vs)) continue;
		ful -= (ll)ufa.size(vf) * ufa.size(vs);
		ufa.unite(vf, vs);
	}
	for(auto x:ans) cout <<x <<"\n";
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cstdint>

std::uint32_t calc_gcd(std::uint32_t a, std::uint32_t b)
{
	if (a % b == 0) {
		return b;
	}
	return calc_gcd(b, a % b);
}

int main()
{
	std::uint32_t a, b;
	while (std::cin >> a >> b) {
		std::uint32_t const gcd = calc_gcd(std::max(a, b), std::min(a, b));
		std::uint32_t const lcm = a / gcd * b;
		std::cout << gcd << ' ' << lcm << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int ara[11];
int r(int n)
{
    while(n)
    {
        int p=n%10;
       
        n/=10;
        if(ara[p]==1)
            return 0;
    }

    return 1;
}
int main()
{
    int n,k,x,i,p;
    cin>>n>>k;
    for(i=0;i<k;i++)
    {
        cin>>x; ara[x]=1;
    }
    for(i=n;;i++)
    {
        p=r(i);
        if(p==1)
        {
            cout<<i<<endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int a = 0;
  int x;
  // ここにプログラムを追記
  

    cin >> N;
    int M = N;
 for (int i = 0; i < 8; i++) {
     x = M % 10;
     a = a + x;
     M = (M - x) / 10;
} 
  
 // cout << a << endl;
  if (N % a == 0) {
      cout << "Yes" << endl;
    }
  else { cout << "No" << endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<char, int> pci;
int life, maxi, r, c, t, s, p;
vector<int> potion;
map<char, int> damage;
 
void calcDP(vector<vector<int> > &dp, vector<string> &grid,
            int nx, int ny, int x, int y, int trun){
  for (int i = 0; i < (1<<p); i++) {
    int next_life = dp[i][trun - 1], tmp = next_life;
    if(next_life == 0)continue;
    dp[i][trun] = max(dp[i][trun], next_life -
                      damage[grid[ny][nx]]);
    for (int j = 0; j < p; j++) {
      if(i & (1<<j))continue;
      next_life = min(maxi, next_life + potion[j]);
      next_life -= damage[grid[ny][nx]];
      dp[i + (1<<j)][trun] = max(dp[i + (1<<j)][trun],
                                 next_life);
      next_life = tmp;
    }
  }
}
 
int main(){
  map<char, int> dx, dy;
  dx['U'] = 0;
  dx['D'] = 0;
  dx['R'] = 1;
  dx['L'] = -1;
  dy['U'] = -1;
  dy['D'] = 1;
  dy['R'] = 0;
  dy['L'] = 0;
  while(std::cin >> life >> maxi, life){
    std::cin >> r >> c;
    vector<string> grid(r);
    for (int i = 0; i < r; i++) {
      std::cin >> grid[i];
    }
    std::cin >> t;
    for (int i = 0; i < t; i++) {
      char floor;
      int d;
      std::cin >> floor >> d;
      damage[floor] = d;
    }
    std::cin >> s;
    vector<pci> action(s);
    int sum = 0;
    for (int i = 0; i < s; i++) {
      std::cin >> action[i].first >> action[i].second;
      sum += action[i].second;
    }
    std::cin >> p;
    potion.resize(p);
    for (int i = 0; i < p; i++) {
      std::cin >> potion[i];
    }
    vector<vector<int> > dp((1<<p), vector<int>(sum + 1, 0));
    for (int i = 0; i < (1<<p); i++) {
      dp[i][0] = life;
      for (int j = 0; j < p; j++) {
        if((i & (1<<j)) == 0)continue;
        dp[i][0] = min(maxi, dp[i][0] + potion[j]);
      }
    }
    int x = 0, y = 0;
    int trun = 0;
    vector<vector<char> > foot_stanp(r, vector<char>(c, ' '));
    int a = 0;
    for(int i = 0; i < s; i++) {
      for (int j = 0; j < action[i].second; j++) {
        trun++;
        foot_stanp[y][x] = '.';
        int nx = x + dx[action[i].first],
          ny = y + dy[action[i].first];
        a += damage[grid[ny][nx]];
        calcDP(dp, grid, nx, ny, x, y, trun);
        x = nx, y = ny;
      }
    }
    // for (int i = 0; i < (1<<p); i++) {
    //   for (int j = 0; j <= sum; j++) {
    //     std::cout << dp[i][j] << " ";
    //   }
    //   std::cout << std::endl;
    // }
    // for (int i = 0; i < r; i++) {
    //   for (int j = 0; j < c; j++) {
    //     std::cout << foot_stanp[i][j] << " ";
    //   }
    //   std::cout << std::endl;
    // }
    // std::cout << a << std::endl;
    bool flag = 0;
    for (int i = 0; i < (1<<p); i++) {
      if(dp[i][sum] > 0)flag = 1;
    }
    if(flag){
      std::cout << "YES" << std::endl;
    }else{
      std::cout << "NO" << std::endl; 
    }
    potion.clear();
    damage.clear();
  }
  return 0;
}

Measured memory_bytes: 17232
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10,mod=1e9+7;
void plusle(int &a,int b){
    a+=b;if(a>=mod)a-=mod; return;
}
void minun(int &a,int b){
    a-=b; if(a<0)a+=mod; return;
}
int add(int a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
int sub(int a, int b) {
  a -= b;
  if (a < 0) a += mod;
  return a;
}
int mul(int a, int b) {
  return (int) ((long long) a * b % mod);
}
int power(int a,int b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
int n,u,v,k,fac[maxn],invf[maxn];
vector<int> a[maxn];
int ncr(int N,int R){
    if(R==0||R==N)return 1;
    return mul(fac[N],mul(invf[R],invf[N-R]));
}
int pnr(int N,int R){
    if(R>N){
        printf("0");
        exit(0);
    }
    if(R==N)return fac[N];
    return mul(fac[N],invf[N-R]);
}
int dfs(int nod,int pa){
    int res=1;
    if((int)a[nod].size()==1&&nod!=1)return 1;
    for(int i:a[nod]){
        if(i!=pa){
            res=mul(res,dfs(i,nod));
           // if(nod==1)cout<<res<<' ';
        }
    }
    res=mul(res,(nod!=1)?pnr(k-2,(int)a[nod].size()-1):pnr(k,(int)a[nod].size()+1));
    return res;
}

int main(){
    scanf("%d%d",&n,&k);
    fac[0]=1;
    for(int i=1;i<=100000;i++){
        fac[i]=mul(fac[i-1],i);
    }
    invf[100000]=power(fac[100000],mod-2);
    for(int i=99999;i>=1;i--){
        invf[i]=mul(i+1,invf[i+1]);
    }
    invf[0]=1;
    for(int i=1;i<n;i++){
        scanf("%d%d",&u,&v);
        a[u].push_back(v);
        a[v].push_back(u);
    }
    printf("%d\n",dfs(1,0));
}


Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

#define MOD (1000000000+7)

int h[100001];
int dp[100001];
int main() {
    ll N, K;
    cin >> N >> K;
    REP(i, N) {
        cin >> h[i];
        if (i == 0) dp[0] = 0;
        else dp[i] = MOD;
        REP(j, K) {
            if (i - j-1 >= 0) {
                dp[i] = min(dp[i], dp[i-j-1] + abs(h[i] - h[i-j-1]));
            }
        }
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
const mod = 1000000007
func main() {
	scanInit()
	n := scanInt()
	K := scanInt()
	// 全部で 0 ~ NまでのN+1の数列
	mins := make([]int,n+1)
	maxs := make([]int,n+1)
	minsum := 0
	maxsum := 0
	for i:= 0; i<=n; i++ {
		minsum += i
		maxsum += n-i
		maxs[i] += maxsum
		mins[i] += minsum
	}
	sum := 0
	for i:= K-1; i<n; i++ {
		// fmt.Println(i,maxs[i]-mins[i]+1)
		// この中から
		//K
		// 個以上の数を選ぶとき、その和としてあり得るものの個数
		//この日本語解釈むずすぎだろ
		sum += (maxs[i]-mins[i]+1) % mod
	}
	sum += 1
	sum %= mod
	fmt.Println(sum)
}

var sc = bufio.NewScanner(os.Stdin)
func scanInit () {
	sc.Split(bufio.ScanWords)
}
func scanInt () int{
sc.Scan()
	i,_ := strconv.Atoi(sc.Text())
	return i
}
//func scan () string{
//  sc.Scan()
//	return sc.Text()
//}


Measured memory_bytes: 5004
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;

int q;

int main(){
	cin >> q;
	multiset<int> msa;
	for(int i = 0; i < q; i++){
		char query;
		cin >> query;
		if(query == '0'){
			int x;
			cin >> x;
			msa.insert(x);
			cout << msa.size() << endl;
		}else if(query == '1'){
			int x;
			cin >> x;
			cout << msa.count(x) << endl;
		}else if(query == '2'){
			int x;
			cin >> x;
			msa.erase(x);
		}else if(query == '3'){
			int L, R;
			cin >> L >> R;
			multiset<int>::iterator itr;
			pair<multiset<int>::iterator, multiset<int>::iterator> itr1, itr2;
			itr1 = msa.equal_range(L);
			itr2 = msa.equal_range(R);
			for(itr = itr1.first; itr != itr2.second; itr++){
				cout << *itr << endl;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 12268
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i] << " "
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
bool isPerfectSquare(long double x) {   
    long double sr = sqrt(x); 
    return ((sr - floor(sr)) == 0); 
} 
bool isPrime(int x){
    for(int i = 2; i * i <= x; ++i){
        if(x % i == 0) return 0;
    }
    return 1;
}
int fun(int n){
    if(n & 1) return 3 * n + 1;
    else return n/2;
}
int32_t main(){
    SPEED;
    string s;
    cin >> s;
    int ans = INF;
    for(int i = 0; i < (len(s) - 2); ++i){
        string temp = "";
        temp += s[i];
        temp += s[i + 1];
        temp += s[i + 2];
        int res = stoi(temp);
        ans = min(ans, abs(res - 753));
    }
    cout << ans ;
}


Measured memory_bytes: 3656
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		s := strings.Split(scanner.Text(), "")
		ans, dir := make([]string, 0), ">"
		for _, x := range s {
			if IsLetter(x) {
				if dir == ">" {
					if !isIn(ans, x) {
						ans = append(ans, x)
					}
				} else {
					if !isIn(ans, x) {
						ans = append([]string{x}, ans...)
					}
				}
			} else if x == ">" || x == "<" {
				dir = x
			}
		}
		fmt.Println(strings.Join(ans, ""))
	}
}

func IsLetter(s string) bool {
	for _, r := range s {
		if !unicode.IsLetter(r) {
			return false
		}
	}
	return true
}

func isIn(arr []string, target string) bool {
	for _, val := range arr {
		if val == target {
			return true
		}
	}
	return false
}



Measured memory_bytes: 1628
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h> // sqrt
using namespace std;

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> data(M);
    for (int i = 0; i < M; i++) {
        cin >> data.at(i);
    }
    vector<vector<int>> sor(N,vector<int>(M));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> sor.at(i).at(j);
        }
    }
    int ans = 0;
    int sum;
    for (int i = 0; i < N; i++) {
        sum = 0;
        for (int j = 0; j < M; j++) {
            sum += data.at(j) * sor.at(i).at(j);
        }
        sum += C;
        if (0 < sum) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
B=list(map(int,input().split()))
A=a.copy()
for i in reversed(range(N)):
  if A[i+1]-B[i]<=0:
    if A[i]+A[i+1]-B[i]>=0:
      A[i]=A[i]+A[i+1]-B[i]
      A[i+1]=0
    else:
      A[i]=0
      A[i+1]=0
  else:
    A[i+1]=A[i+1]-B[i]
print(sum(a)-sum(A))


Measured memory_bytes: 18624
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#define pi acos(-1)
using namespace std;
int main()
{
    string s;
    char E[]="-";
    int a,b;
    while (cin>>s&&s!=E)
    {
        cin>>a;
        while (a--)
        {
            cin>>b;
            s=s.substr(b,s.size()-b)+s.substr(0,b);
        }
        cout<<s<<endl;
    }
    return 0;
}



Measured memory_bytes: 3180
# import sys; input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**7)
from collections import defaultdict
mod = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

def inverse(N, mod):
	return (pow(N, mod - 2, mod))

def main():
	N = int(input())
	ans = 0
	for i in range(1, N):
		ans += int((N - 1) // i)

	print(ans)

	




if __name__ == '__main__':
	main()

Measured memory_bytes: 68096
n = int(input())
w = [input() for i in range(n)]
ans = True
for j in range(n-1):
    if w[j][-1] != w[j+1][0]:
        ans = False
for k in range(n):
    for l in range(n):
        if l != k:
            if w[l] == w[k]:
                ans = False
        else:
            continue
if ans == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
 
using namespace std;

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


long gcd(long a, long b) {
 	if ( a % b == 0 ) return b;
 	return gcd(b, a%b);
 }

map<long, int> prime_factor(long n) {
    map< long, int > ret;
    for(long i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main () {
    // int n, m;
    // cin >> n >> m;

    long a, b;
    cin >> a >> b;
    long result = gcd(a, b);

    cout << prime_factor(result).size()+1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  string s;
  cin >> s;
  
  int itr = s.length();
  
  rep(i,itr)cout << "x";
  cout << endl;
  
}




Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
//#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                        
using namespace std;
                        
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                        
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define prev prev228
#define list list228
#define complex complex228

const int N = 100 * 1000 + 228;

int n;
int a[N];

struct node
{
	int mx;
	int l, r;
	node() {
		mx = l = r = 0;
	}
};

vector< node > d;

void build(int l, int r, int v = 1) {
	d[v].l = l;
	d[v].r = r;
	if (l == r) return;
	int m = (l + r) >> 1;
	build(l, m, v << 1);
	build(m + 1, r, v << 1 | 1);
}

void init() {
	int ss = 1;
	while (ss < n) ss <<= 1;
	ss <<= 1;
	d.resize(ss + 3, node());
	build(1, n);
}

void update(int i, int x, int v = 1) {
	if (d[v].l == d[v].r) uax(d[v].mx, x);
	else {
		int m = (d[v].l + d[v].r) >> 1;
		if (i <= m) update(i, x, v << 1);
		else update(i, x, v << 1 | 1);
		d[v].mx = max(d[v << 1].mx, d[v << 1 | 1].mx);
	}
}

int get(int l, int r, int v = 1) {
	if (l > r || d[v].l > r || d[v].r < l) return 0;
	if (l <= d[v].l && d[v].r <= r) return d[v].mx;
	return max(get(l, r, v << 1), get(l, r, v << 1 | 1));
}

ghost main() {
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	vector<int> crd;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		crd.push_back(a[i]);
	}
	sort(crd.begin(), crd.end());
	crd.erase(unique(crd.begin(), crd.end()), crd.end());
	for (int i = 1; i <= n; ++i) a[i] = lower_bound(crd.begin(), crd.end(), a[i]) - crd.begin() + 1;
	init();
	update(a[1], 1);
	int res = 1;
	for (int i = 2; i <= n; ++i) {
		int nup = get(a[i], n) + 1;
		update(a[i], nup);
		uax(res, nup);
	}
	cout << res << '\n';
	return 0;
} // kek ;
// Ого! Кажетсья это $#@!










Measured memory_bytes: 8180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}


char c[2100][2100];
ll l[2100][2100];
ll r[2100][2100];
ll u[2100][2100];
ll d[2100][2100];

int main() {
    ll h, w;
    cin >> h >> w;
    rep(i, 0, h) rep(j, 0, w) cin >> c[i][j];

    rep(i, 0, h) rep(j, 0, w) {
        if (c[i][j] == '#') l[i][j] = 0, u[i][j] = 0;
        else {
            l[i][j] = l[i][j-1] + 1;
            u[i][j] = u[i-1][j] + 1;
        }
    }

    for (ll i = h-1; i >=0; i--) {
        for (ll j = w-1; j >= 0; j--) {
            if (c[i][j] == '#') r[i][j] = 0, d[i][j] = 0;
            else {
                r[i][j] = r[i][j+1] + 1;
                d[i][j] = d[i+1][j] + 1;
            }
        }
    }

    ll ans = 0;
    rep(i, 0, h) rep(j, 0, w) chmax(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
    cout << ans << endl;
}

Measured memory_bytes: 142208
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, -1, 0, 1 , 1,  1, -1, -1 };

VI _array;
int n;

int main() {
	while ( ~scanf( "%d", &n ) && n ) {
		_array.resize( n );
		for ( int i = 0; i < n; i++ ) {
			scanf( "%d", &_array[ i ] );
		}
		int ans = 0;
		while ( true ) {
			VI _array_copy = _array, _array_copy2 = _array;
			sort( _array_copy.begin(), _array_copy.end() );
			for ( int i = 0; i < n; i++ ) {
				_array[ i ] = upper_bound( _array_copy.begin(), _array_copy.end(), _array[ i ] ) - lower_bound( _array_copy.begin(), _array_copy.end(), _array[ i ] );
			}
			if ( _array == _array_copy2 ) {
				break;
			}
			ans++;
		}
		printf( "%d\n", ans );
		for ( int i = 0; i < n - 1; i++ ) {
			printf( "%d ", _array[ i ] );
		}
		printf( "%d\n", _array[ n - 1 ] );
	}
	return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  cout << a * b;
}

Measured memory_bytes: 3568