akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
H_list = list(map(int, input().split()))

temp = [0 for i in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    if H_list[A - 1] < H_list[B - 1]:
        temp[A - 1] = -1
    elif H_list[A - 1] == H_list[B - 1]:
        temp[A - 1] = -1
        temp[B - 1] = -1
    else:
        temp[B - 1] = -1

count = 0
for i in temp:
    if i == 0:
        count += 1
print(count)

Measured memory_bytes: 19924
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int a[301][301];
int b[301][301];
int main(){
	cin>>N;
	REP(i,N){
		string s;
		cin>>s;
		REP(j,N){
			a[i][j]=(s[j]-'a');
		}
	}
	int ans=0;
	REP(i,N){
		REP(j,N){
			REP(k,N){
				b[j][k]=a[(j+i)%N][k];
			}
		}
		bool check=true;
		REP(j,N){
			REP(k,N){
				if(b[j][k]!=b[k][j])check=false;
			}
		}
		if(check)ans+=N;
	}
	cout<<ans<<endl;
	return(0);
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	int n;
	cin >> n;
	vector<pair<double, double>> xy(n);
	FOR(i, 0, n - 1) {
		double x, y;
		cin >> x >> y;
		xy[i] = { x,y };
	}

	sort(ALL(xy));
	double res = 0;
	double loop = 0;
	do {
		double d = 0;
		FOR(i, 1, n - 1) {
			d += sqrt(pow(xy[i].first - xy[i-1].first,2) + pow(xy[i].second - xy[i - 1].second, 2));
		}
		res += d;
		loop += 1;
	} while (next_permutation(ALL(xy)));
	res /= loop;
	cout << setprecision(16) << res << endl;
	return(0);
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
	int A, B, N;
	int As, Bs;

	while (1){
		scanf("%d", &N);
		if (N == 0) break;
		As = Bs = 0;
		for (int i = 0; i < N; i++){
			scanf("%d %d", &A, &B);
			if (A > B) {
				As += A + B;
			}
			else if(A < B){
				Bs += A + B;
			} else {
				As += A;
				Bs += B;
			}
		}
		printf("%d %d\n", As, Bs);
	}

	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL (long long)
#define IT iterator
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,/*<=1e5*/a[200000+10];
bool flag[2*(100000)+10];
int sz;
bool check(int x){
	rb(i,1,sz){
		if(a[i]>=x){
			flag[i]=1;
		}
		else{
			flag[i]=0;
		}
	}
	int fir1=-INF,fir0=-INF,last1=INF,last0=INF;
	rb(i,2,n){
		if(flag[i]==1&&flag[i-1]==1){
			fir1=i;
		}
	}
	rb(i,2,n){
		if(flag[i]==0&&flag[i-1]==0){
			fir0=i;
		}
	}
	rl(i,sz-1,n){
		if(flag[i]==1&&flag[i+1]==1){
			last1=i;
		}
	}
	rl(i,sz-1,n){
		if(flag[i]==0&&flag[i+1]==0){
			last0=i;
		}
	} 
	if(fir1==-INF&&fir0==-INF&&last1==INF&&last0==INF){
		return flag[1];
	}
	int best1=INF,best0=INF;
	if(last1>=n){
		best1=min(best1,last1-n);
	}
	if(fir1<=n){
		best1=min(best1,n-fir1);
	}
	if(last0>=n){
		best0=min(best0,last0-n);
	}
	if(fir0<=n){
		best0=min(best0,n-fir0);
	}
	if(best1>best0){
		return false;
	}
	else{
		return true; 
	} 
}
int main(){
	scanf("%d",&n);
	sz=(n<<1)-1;
	rb(i,1,sz){
		scanf("%d",&a[i]);
	}
	int l=1,r=2*n;
	while(l<r-1){
		int mid=(l+r)>>1;
		if(check(mid)){
			l=mid;
		}
		else{
			r=mid;
		}
//		cout<<l<<" "<<r<<endl;
	}
//	cout<<check(5)<<endl;
	printf("%d\n",l);
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
using namespace std;
//using namespace boost::multiprecision;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

vector<int> G[100'010];
vector<int> lat(100'010, -1);
vector<int> upre(100'010, -1);
vector<int> udist(100'010, -1);
vector<int> vpre(100'010, -1);
vector<int> vdist(100'010, -1);
void udfs(int v){
  for(int nv:G[v]){
    if(nv == upre[v]){
      continue;
    }
    udist[nv] = udist[v] + 1;
    upre[nv] = v;
    udfs(nv);
    lat[v] = nv; 
  }
  return;
}
void vdfs(int v){
  for(int nv:G[v]){
    if(nv == vpre[v]){
      continue;
    }
    vdist[nv] = vdist[v] + 1;
    vpre[nv] = v;
    vdfs(nv);
    //lat[v] = nv; 
  }
  return;
}
    
int main(){
  
  int n,u,v;
  cin>>n>>u>>v;
  u--;v--;
  int a[n-1],b[n-1];
  REP(i,n-1){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  udist[u] = 0;
  udfs(u);
  vdist[v] = 0;
  vdfs(v);
  
  vector<int> endn;
  REP(i,n){
    if(lat[i] < 0){
      endn.push_back(i);
    }
  }
  int m = endn.size();//ブランチの数
  int maxlen = 0;
  REP(i,m){
    if(udist[endn[i]] >= vdist[endn[i]])continue;
    maxlen = max(maxlen, vdist[endn[i]]);
  }
  if(G[u].size() == 1){
    if(udist[u] < vdist[u]){
      maxlen = max(maxlen, vdist[u]);
    }
  }
  int ans = maxlen - 1;
  cout<<ans<<endl;
  return 0; 
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;

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




int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int x,n;
    cin >> x >> n;
    int p[n];

    rep(i,n){
        cin >> p[i];
        
    }
    int res1=0,res2=0;
    while(1){
        bool a = true;
        bool b = true;
        rep(i,n){
            if(x+res1 == p[i]){
                a = false;
            }
            if(x+res2 == p[i]){
                b =false;
            }
        }
        if(a){
            res2 = 1000;
            break;
        }else if(b){
            res1 = 1000;
            break;
        }else{
            res1--;
            res2++;
        }
    }

    cout << x+min(res1,res2) <<endl;
    return 0;



}


Measured memory_bytes: 3644
n,p = map(int,input().split())
x = 1
y = 0
a = list(map(int,input().split()))
for ai in a:
  if ai%2 == 0:
    x += x
    y += y
  else:
    t = x
    x += y
    y += t
if p == 0:
  print(x)
else:
  print(y)

Measured memory_bytes: 61848
using System;

namespace ConsoleApp27
{
    class Program
    {
        static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            if (s.Length <= k)
            {
                Console.WriteLine(s);
            }
            else
            {
                Console.WriteLine(s.Substring(0, k) + "...");
            }
        }
    }
}


Measured memory_bytes: 27360
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) {
	  cout << "Yes" << endl;
	} else {
	  cout << "No" << endl;
	}
  return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
typedef long long i64;
typedef vector<int> Vi;
typedef pair<int, int> Pii;
# define pb push_back
# define mp make_pair
# define MOD 1000000007
# define INF 1000000000
# define bug puts("H");

const int N = 200000 + 5;

inline int Scan() {
    int x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

int a[N], b[N];
Vi v;

int main ()
{
    int n, x;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = n; i >= 1; --i) {
        int s = 0;
        for (int j = 2*i; j <= n; j += i) s += b[j];
        s %= 2;
        if (s != a[i]) b[i] = 1, v.pb(i);
    }
    cout << v.size() << endl;
    for (auto i: v) cout << i << " ";
    return 0;
}


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

int main(){
  int N;
  string s,t;
  cin>>N>>s>>t;
  for(int i=0;i<=N;i++)
    if(s.substr(i,N-i)==t.substr(0,N-i)){
      cout<<N+i<<endl;
      return 0;
    }
}

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

bool contains(string str, string pre){
    int s = str.length(), p = pre.length();
    if(s < p)   return false;

    for(int i = 0; i <= s - p; i++){
        int j;
        for(j = 0; j < p; j++){ 
            if(str[i+j] != pre[j])  break;
        }
        if(j == p)  return true;
    }

    return false;
}

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

    int n;
    cin >> n;

    int ans = 0;
    string t;
    for(int i = 0; i < n; i++){
        cin >> t;
        t += t;
        if(contains(t,s))   ans++;
    }

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


Measured memory_bytes: 3204
/** 	Author: Apoorva Mittal  **/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define nl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pair<int, int>>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repD(i, a, b) for (int i = a; i >= b; i--)
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define init(i, k) memset(i, k, sizeof i)
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define inp(a) rep(i, 0, a.size()) cin >> a[i];
#define out(a)                               \
    cout << #a << ": " << endl;              \
    rep(i, 0, a.size()) cout << a[i] << " "; \
    cout << endl;
#define out2d(a)                \
    cout << #a << ": " << endl; \
    rep(i, 0, a.size())         \
    {                           \
        rep(j, 0, a[0].size())  \
                cout            \
            << a[i][j] << " ";  \
        cout << endl;           \
    }
#define flush fflush(stdout);
#define lb lower_bound
#define ub upper_bound
#define maxe *max_element
#define mine *min_element
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define pqueue priority_queue
#define precise(x) cout << fixed << showpoint << setprecision(x);
#define setbit(x) __builtin_popcountll(x)
#define gcd(a, b) __gcd(a, b)
#define deb(x) cout << #x << " " << x << endl;
#define Y "YES"
#define N "NO"
const int mod = 1e9 + 7;
// ====== Useful functions begin ======
inline int add(int a, int b) { return ((a % mod) + (b % mod)) % mod; }
inline int sub(int a, int b) { return ((a % mod) - (b % mod) + mod) % mod; }
inline int mul(int a, int b) { return ((a % mod) * (b % mod)) % mod; }
// ====== Useful functions end ======
const int inf = 1e18;
const int maxn = 1e3 + 5;

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

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

void solve()
{
    int n,K;
    cin >> n>>K;
    vi arr(n);
    inp(arr)
        vector<int>
            dp(n, 0);
    
    for(int i=n-2;i>=0;i--)
    {
        int&v = dp[i];
        v=inf;
        for(int k=1;k<=K;k++)
        {
            if(i+k<n)
            {
                v = min(v,abs(arr[i+k]-arr[i])+dp[i+k]);
            }
        }
        // deb(dp[i])
    }
    cout<<dp[0]<<endl;

    // cout<<dp[0]<<endl;
}
signed main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    speed;
    int t = 1;
    // cin >> t;

    for (int tt = 1; tt <= t; tt++)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
    }
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var N, X, ans int

	fmt.Scan(&N, &X)
	var m = make(SortBy, N)

	for i := 0; i < N; i++ {
		fmt.Scan(&m[i])
		X -= m[i]
	}
	ans += N
	sort.Sort(m)

	ans += floor((X / m[0]))
	fmt.Println(ans)
}

/*  ----------------------------------------  */

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return abs(a[i]) < abs(a[j]) }


Measured memory_bytes: 512
import math
import bisect
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

prime=set([2])
for i in range(3,100001):
    if i%2!=0 and is_prime(i):
        prime.add(i)

sim_prime=[]
for p in prime:
    if (p+1)//2 in prime:
        sim_prime.append(p)
sim_prime.sort()


q=int(input())
ans_list=[]
for i in range(q):
    l,r=map(int,input().split())
    l_idx=bisect.bisect_left(sim_prime,l)
    r_idx=bisect.bisect_left(sim_prime,r+1)
    ans_list.append(r_idx-l_idx)

for g in range(len(ans_list)):
    print(ans_list[g])

Measured memory_bytes: 8656
#include <iostream>
#include <string>
#include <vector>

int main()
{
    int n;
    std::cin >> n;
    
    std::vector<int> numArray(n);
    int allXOR = 0;
    
    for(int i = 0; i < n; ++i)
    {
        std::cin >> numArray[i];
        allXOR ^= numArray[i];
    }
    
    std::string resultStr;
    
    for(int i = 0; i < n; ++i)
    {
        resultStr += std::to_string(allXOR ^ numArray[i]) + ' ';
    }
    
    resultStr.pop_back();
    
    std::cout << resultStr << std::endl;
}

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

int main(){
    string s;
    getline(cin, s);
    for(int i=0;i<s.size();++i){
        if(s[i] >= 'a' && s[i] <= 'z')
            cout << (char)(s[i] - 'a' + 'A');
        else
            cout << s[i];
    }
    cout << endl;
    return 0;
}


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

int main(void)
{
	int n;
	cin >> n;

	int k;
	cin >> k;

	vector<int> arr;
	for(int i = 0;i < n;i++)
	{
		int inp;
		cin >> inp;

		arr.push_back(inp);
	}

	vector<int> dp(n,INT_MAX);
	dp[0] = 0;

	for(int i = 0;i < arr.size();i++)
	{
		for(int j = i + 1;j <=i+k;j++)
		{
			if(j < n)
				dp[j] = min(dp[j],dp[i] + abs(arr[i]-arr[j]));
		}
	}

	cout << dp[n-1];

	return 0;

}

Measured memory_bytes: 1272
#include <stdio.h>
#include <ctype.h>
#include <string.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  char    src[ 256 ]
     , *  s;
  int     n;
  int     i, j;

  fgets ( src, 256, stdin );
  sscanf ( src, "%d", &n );

  while ( n-- )
  {
    char tmp[ 256 ];

    fgets ( src, 256, stdin );

    for ( j = 1; j < 26; ++j )
    {
      for ( s = src; *s != '\0'; ++s )
      {
        tmp[ s - src ] = islower ( *s )
                       ? ( ( *s - 'a' ) * j ) % 26 + 'a'
                       : *s;
      }
      tmp[ s - src ] = '\0';

      for ( i = 0; i < 26; ++i )
      {
        for ( s = tmp; *s != '\0'; ++s )
        {
          if ( islower ( *s ) )
          {
            *s = ( *s - 'a' + 1 ) % 26 + 'a';
          }
        }
        if ( strstr ( tmp, "this" ) != NULL
          || strstr ( tmp, "that" ) != NULL )
        {
          goto ESC;
        }
      }
    }
ESC:
    fputs ( tmp, stdout );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define Start ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
ll n,Dp[200200],A[200200];
int Solve(int i)
{
    if(i>=n)
        return 1e18;
    if(i==n-1)
        return 0;
    if(Dp[i]!=-1)
        return Dp[i];
    Dp[i]=min(Solve(i+1)+abs(A[i]-A[i+1]),Solve(i+2)+abs(A[i]-A[i+2]));
    return Dp[i];

}

int main() {
    Start;
   cin>>n;
  memset(Dp,-1, sizeof(Dp));
   for(int i=0;i<n;i++)
       cin>>A[i];
   cout<<Solve(0);


}

Measured memory_bytes: 4224
{-# LANGUAGE BangPatterns #-}

main :: IO ()
main = do
  getLine
  as <- map read . words <$> getLine
  print $ solve as

solve :: [Double] -> Double
solve = go 0.0
  where
    go !rsum []     = recip rsum
    go !rsum (a:as) = go (rsum + recip a) as

Measured memory_bytes: 1020
import sys

a = int(sys.stdin.readline())
b = int(sys.stdin.readline())
c = int(sys.stdin.readline())
d = int(sys.stdin.readline())

sum_4 = a + b + c + d
minutes = int(sum_4 / 60)
seconds = sum_4 % 60

print(minutes)
print(seconds)

Measured memory_bytes: 7708
#include <iostream>
#include <string>
#include <vector>
#include <set>
typedef long long ll;
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    ll ans = 0;
    ll a_count = 0;

    set<int> bc;
    for(int i = 1; i < S.length(); i++){
        if(S[i] == 'C' && S[i-1] == 'B') bc.insert(i-1);
    }

    int now = 0;
    while(now < S.length()){
        if(S[now] == 'A') a_count++;
        else if(bc.count(now) == 1) {
            ans += a_count;
            now = now+2;
            continue;
        } else{
            a_count = 0;
        }
        
        now++;
        
    }
    
    
    cout << ans << endl;
    
    
}


Measured memory_bytes: 3588
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 0; i < n; i++){
			String imput = sc.next();
			String [] a = new String[imput.length() - 1];
			String [] b = new String[imput.length() - 1];
			String [] answer = new String[(imput.length() - 1)  * 8];
			int counter = 0;
			String kanri;
			for(int j = 0; j < imput.length() - 1; j++){
				a[j] = imput.substring (0, j + 1);
				b[j] = imput.substring (j + 1);
			}
			for(int j = 0; j < a.length;j++){
				answer [j + j * 7] = a[j] + b[j];
				answer [1 + j + j * 7] = b[j] + a[j];
				StringBuilder a1 = new StringBuilder (a[j]);
				a1.reverse();
				String ra = new String (a1);
				answer [2 + j + j * 7] = ra + b[j];
				answer [3 + j + j * 7] = b[j] + ra;
				StringBuilder b1 = new StringBuilder (b[j]);
				b1.reverse();
				String rb = new String (b1);
				answer [4 + j + j * 7] = rb + a[j];
				answer [5 + j + j * 7] = a[j] + rb;
				answer [6 + j + j * 7] = ra + rb;
				answer [7 + j + j * 7] = rb + ra;
			}
			Arrays.sort(answer);
			kanri = answer[0];
			for(int j = 0; j < answer.length;j++){
				if(j == 0){
					counter++;
				}
				else if(!kanri.equals(answer[j])){
					counter++;
					kanri = answer[j];
				}
			}
			System.out.println(counter);
		}
	}

}

Measured memory_bytes: 71528
#include <iostream>

using namespace std;

int main() {
    long long n, k;
    cin >> n >> k;
    if (n < k) {
        if (n < abs(k - n)) cout << n << endl;
        else cout << abs(k - n) << endl;
    }
    else if (n == k) cout << 0 << endl;
    else {
        long long rem = n % k;
        if (rem == 0) cout << 0 << endl;
        else cout << k - rem << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
H=int(input())
count=0
bunretsunum=0
while True:
    if H>1:
        H=int(math.floor(H/2))
        count=count+int(math.pow(2,bunretsunum))
        bunretsunum=bunretsunum+1
    else:
        count=count+int(math.pow(2,bunretsunum))
        break
print(count)

Measured memory_bytes: 3060
N=int(input())
A=list(map(int,input().split()))
ans=1
limit=10**18
flag=True
for x in A:
  if x==0:
    flag=False
    ans=0
if flag:
  for x in A:
    ans=ans*x
    if ans > limit:
      ans=-1
      break
print(ans)

Measured memory_bytes: 21712
#include <bits/stdc++.h>
using namespace std;
#define oo 0x3f3f3f3f
#define ooLL 0x3f3f3f3f3f3f3f3f
#define mod 1e9+7
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
typedef long long ll;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
 
int main(){
    int s, w;
    cin >> s >> w;
    if(w >= s) cout << "unsafe\n";
    else cout << "safe\n";
    return 0;
}

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

using namespace std;

int main(void)
{
	set <int> count;
	int a, b, c;

	cin >> a >> b >> c;
	count.insert(a);
	count.insert(b);
	count.insert(c);

	cout << count.size() << endl;

	return 0;
}

Measured memory_bytes: 256
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/ICPC/Prelim/1186?year=2013

#include <bits/stdc++.h>

using namespace std;


bool cmp(pair<int, int> lhs, pair<int, int> rhs) {
    int diagonal_l = lhs.first * lhs.first + lhs.second * lhs.second;
    int diagonal_r = rhs.first * rhs.first + rhs.second * rhs.second;

    if (diagonal_l != diagonal_r)
        return diagonal_l < diagonal_r;
    else // 5で割った余りが等しいなら普通に大小比較する
        return lhs.first < rhs.first;
}


int main() {
    int H, W;

    while (true) {
        cin >> H >> W;
        if (H == 0 and W == 0) return 0;

        vector<pair<int, int>> vt;
        for (int i = 1; i <= 150; ++i) {//高さ
            for (int j = i + 1; j <= 150; ++j) {//幅
                if (H * H + W * W < i * i + j * j) {
                    vt.emplace_back(make_pair(i, j));
                }
                if (H * H + W * W == i * i + j * j and H < i) {
                    vt.emplace_back(make_pair(i, j));
                }
            }
        }

        sort(vt.begin(), vt.end(), cmp);
        cout << vt[0].first << " " << vt[0].second << endl;
    }
}

/*
 * データ数が150*150程度と小さいので全検索。
 * ソート用の比較関数を書いた。
 */


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll A[MAX_N];

void solve() {
	cin >> N;
	int ans = 0;
	rep(i, 0, N) {
		cin >> A[i];
		ans |= (A[i] % 2);
	}
	if(ans) cout << "first\n";
	else cout << "second\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 1024
import sys

n, m, l = [ int( val ) for val in sys.stdin.readline().split( " " ) ]

matrixA = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( n ) ]
matrixB = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( m ) ]	
c = 0

output = []
for i in range( n ):
	for j in range( l ):
		c = 0
		for k in range( m ):
			c += ( matrixA[i][k] * matrixB[k][j] )
		output.append( "{:d}".format( c ) )
		output.append( " " )
	output.pop()
	output.append( "\n" )

output.pop()
print( "".join( output ) )

Measured memory_bytes: 5536
h,w = map(int,input().split())
a = [input() for i in range(h)]
col = [0]*h
row = [0]*w
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            col[i] = 1
            row[j] = 1
for i in range(h):
    ans=""
    for j in range(w):
        if col[i] == 1 and row[j] == 1:
            ans+=a[i][j]
    if ans!="":
        print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <functional>
#include <sstream>
#include <cstdio>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))           \
		{                           \
			goto Exit0;             \
		}                           \
}

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

inline int read() {
	int ret = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-') f = -f;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
	return ret * f;
}//快读优化

int main(int argc, char* argv[])
{
	int			nAreaArrays[4][4];
	int			nSumNumber;

	memset(nAreaArrays, 0, sizeof(nAreaArrays));

	cin >> nAreaArrays[1][1] >> nAreaArrays[1][2] >> nAreaArrays[2][2];

	nSumNumber = nAreaArrays[2][2] * 3;

	nAreaArrays[1][3] = nSumNumber - nAreaArrays[1][1] - nAreaArrays[1][2];
	nAreaArrays[3][3] = nSumNumber - nAreaArrays[1][1] - nAreaArrays[2][2];
	nAreaArrays[3][1] = nSumNumber - nAreaArrays[1][3] - nAreaArrays[2][2];
	nAreaArrays[2][1] = nSumNumber - nAreaArrays[1][1] - nAreaArrays[3][1];
	nAreaArrays[2][3] = nSumNumber - nAreaArrays[2][1] - nAreaArrays[2][2];
	nAreaArrays[3][2] = nSumNumber - nAreaArrays[1][2] - nAreaArrays[2][2];

	for (int i = 1; i <= 3; i++)
	{
		for (int j = 1; j <= 3; j++)
		{
			cout << nAreaArrays[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;cin>>s;
  vector<bool> a(26,false);
  for(int i=0; i<s.size(); i++){
    a[s[i]-'a']=true;
  }
  bool g=true;
  for(int i=0; i<26; i++){
    if(g&&!a[i]){cout<<char('a'+i)<<endl;g=false;}
  }
  if(g)cout<<"None"<<endl;
}

Measured memory_bytes: 512
import numpy as np
N = int(input())
nums = [int(input()) for _ in range(N)]
nums = np.array(nums)
max_num = max(nums)
max_index = np.where(nums == nums.max())[0]

if len(max_index) == 1:
  for i in range(len(nums)):
    if i == max_index[0]:
      print(sorted(nums)[-2])
    else:
      print(max_num)
else:
  for i in range(len(nums)):
    print(max_num)

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> edges(N, vector<pair<int, int>>());
  for (int i = 0; i < N - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    edges[a].push_back({b, c});
    edges[b].push_back({a, c});
  }
  int Q, K;
  cin >> Q >> K;
  K--;
  vector<int> X(Q), Y(Q);
  for (int i = 0; i < Q; i++) {
    cin >> X[i] >> Y[i];
    X[i]--;
    Y[i]--;
  }
  vector<long long> D(N, -1);
  D[K] = 0;
  queue<int> que;
  que.push(K);
  while (!que.empty()) {
    auto p = que.front();
    que.pop();
    for (auto e : edges[p]) {
      if (D[e.first] != -1) continue;
      D[e.first] = D[p] + e.second;
      que.push(e.first);
    }
  }
  for (int i = 0; i < Q; i++) {
    long long ans = D[X[i]] + D[Y[i]];
    cout << ans << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 9588
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 1e9 + 123;//786433;//998244353;
const double Pi = acos(-1);
const int p = 510200;
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m;
vector <int> Adj[9];
int cnt = 0;

bool Vis[9];

void DFS(int node, int l = 0)
{
	if(l == n - 1)
	{
		cnt++;
		return;
	}
	Vis[node] = true;
	for(auto x : Adj[node])
	{
		if(!Vis[x])
		{
			DFS(x, l + 1);
		}
	}
	Vis[node] = false;
}

signed main()
{
	Fastio();
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		Vis[i] = false;
	}
	for(int i = 1; i <= m; i++)
	{
		int u, v;
		cin >> u >> v;
		Adj[u].eb(v);
		Adj[v].eb(u);
	}
	DFS(1);
	cout << cnt;
}


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

using ll = long long;

// Segment-Tree
struct SegmentTree {
  int n;
  vector<ll> dat;
  
  SegmentTree(int _n) {
    init(_n);
  }
  
  void init(int _n) {
    n = 1;
    while (n < _n) n *= 2;
    dat.resize(2 * n - 1, 0);
  }
  
  // i番目の値にxを加算
  void add(int i, int x) {
    i += n - 1; // 葉のノード
    dat[i] += x;
    while (i > 0) { // 更新
      i = (i - 1) / 2;
      dat[i] = dat[2 * i + 1] + dat[2 * i + 2];
    }
  }
  
  // [a, b)の和
  // k:ノードの番号 [l, r)がkに対応づいている
  ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return dat[k];
    else {
      ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
      ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
      return vl + vr;
    }
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  ll l = 1, r = 1e9 + 1, total = n * (n + 1) / 2, itadd = 1e5;
  while (r - l > 1) {
    ll mid = (l + r) / 2, count = 0, now = 0;
    SegmentTree st(2e5 + 1);
    st.add(0 + itadd, 1);
    for (int i = 0; i < n; i++) {
      if (a.at(i) >= mid) now++;
      else now--;
      count += st.query(0, now + 1 + itadd);
      st.add(now + itadd, 1);
    }
    if (count >= (total + 1) / 2) l = mid;
    else r = mid;
  }
  
  cout << l << '\n';
}

Measured memory_bytes: 8228
#include <iostream>
#include <cstdlib>

using namespace std;

typedef struct rec {

  int team;
  int point;

} record;

int comp(const void* a,const void* b) {

  record t1=*(record*)a;
  record t2=*(record*)b;

  return t2.point-t1.point;

}

int main() {

  int n;
  int a,b,c,d;

  record rec[101];
  int rank;
  

  cin >> n;

  for(int i=0;i<=100;i++) {

    rec[i].team=i;

    rec[i].point=0;

  }

  for(int i=0;i<n*(n-1)/2;i++) {

    cin >> a >> b >> c >> d;

    if(c==d) {

      rec[a].point++;

      rec[b].point++;

    }

    else if(c<d) rec[b].point+=3;

    else rec[a].point+=3;

  }

  //for(int i=1;i<=n;i++) cout << rec[i].point << endl;

  //qsort(rec,n,sizeof(rec[0]),comp);

  //for(int i=1;i<=n;i++) cout << rec[i].team << endl;

  for(int i=1;i<=n;i++) {

    rank=n;

    for(int j=1;j<=n;j++) {

      if(rec[i].point>=rec[j].point && i!=j) rank--;

    }

    cout << rank << endl;

  }

  return 0;

}

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

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

  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N - 1);

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    A.at(i)--;
  }
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  for (int i = 0; i < N - 1; i++) {
    cin >> C.at(i);
  }

  int result = B.at(A.at(0));
  int before = A.at(0);
  for (int i = 1; i < N; i++) {
    result += B.at(A.at(i));
    if (A.at(i) == before + 1) {
      result += C.at(before);
    }
    before = A.at(i);
  }

  cout << result << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
#define MAX_INT INT_MAX

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

Measured memory_bytes: 256
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;


//#define int long long
#define all(v) v.begin() , v.end()
#define endl '\n'

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 2e3 + 10 ;

int n , k , can ;
vector < int > adj [ N ] ; 
pair < int , int > ar [ N ] ; 

void dfs ( int v , int lim = -1 , int p = -1 , int d = 0 ) {
	if ( d > k / 2 ) return ; 
	++ can ; 
	for ( int u : adj [ v ] ) {
		if ( ( u ^ lim ) && ( u ^ p ) )
			dfs ( u , lim , v , d + 1 ) ; 
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k ;
	for ( int i = 0 ; i < n - 1 ; ++ i ) {
		int u , v ;
		cin >> u >> v ;
		adj [ v ] . push_back ( u ) ;
		adj [ u ] . push_back ( v ) ;
		ar [ i ] . first = u ;
		ar [ i ] . second = v ; 
	}
	int res = n + 1 ;
	if ( k & 1 ) {
		for ( int i = 0 ; i < n - 1 ; ++ i ) {
			can = 0 ; 
			dfs ( ar [ i ] . first , ar [ i ] . second ) ;
			dfs ( ar [ i ] . second , ar [ i ] . first ) ;
			smin ( res , n - can ) ; 
		}
	}
	else {
		for ( int i = 1 ; i <= n ; ++ i ) {
			can = 0 ;
			dfs ( i ) ;
			smin ( res , n - can ) ; 
		}
	}
	cout << res << '\n' ; 
}


Measured memory_bytes: 512
(defun get-array (n)
 (let ((arr (make-array n :element-type 'fixnum)))
    (loop :as i
           :below n
           :do (setf (aref arr i) (read)))
    (sort arr #'<)
    ))

(defun get-diff (arr c n)
  (loop :as i
        :below n
        :collect (mod (- (aref arr (mod (+ i 1) n))
                         (aref arr i))
                      c)))


(let* ((c (read))
       (n (read))
       (arr (get-array n)))
  (princ (- c (apply #'max (get-diff arr c n)))))

Measured memory_bytes: 70920
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L+10)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    REP(i, N){
        cin >> w[i] >> v[i];
    }

    vector<vector<ll>> dp(100010, vector<ll>(N+1, INF));
    REP(i, N+1){
        dp[0][i] = 0;
    }

    Rep(i, 1, 100005){
        Rep(j, 1, N+1){
            chmin(dp[i][j], dp[i][j-1]);
            if(i-v[j-1] >= 0){
                chmin(dp[i][j], dp[i-v[j-1]][j-1] + w[j-1]);
            }
        }
    }
    ll ans = 0;
    REP(i, 100005){
        Rep(j, 1, N+1){
            if(dp[i][j] != 0 && dp[i][j]<=W) ans = max(ans, (ll)i);
        }
    }
    pr(ans);
}

Measured memory_bytes: 82304
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

string S[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	string s; cin>>s;
	int i=0;
	for(;S[i]!=s;i++);
	if(i==0) cout<<7<<"\n";
	else cout<<7-i<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a[3],i,j,temp;
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  for(i=0;i<2;i++){
    for(j=0;j<2;j++){
      if(a[j]>a[j+1]){
	temp=a[j];
	a[j]=a[j+1];
	a[j+1]=temp;
      }
    }
  }
  printf("%d %d %d\n",a[0],a[1],a[2]);
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    int A, B;
    string s;
    cin >> A >> B;
    cin >> s;

    for(int i = 0; i < A; i++){
        if(s[i] < '0' || s[i] > '9'){
            cout << "No" << endl;
            return 0;
        }
    }

    if(s[A] != '-') {
        cout << "No" << endl;
        return 0;
    }

    for(int i = A+1; i < A+B+1; i++){
        if(s[i] < '0' || s[i] > '9'){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 2e5 + 17;

int n, k;
int a[maxn];

bool read()
{
	if (scanf("%d %d", &n, &k) != 2)
		return false;

	forn (i, n)
		scanf("%d", a + i);

	return true;
}

void solve()
{
	if (k > *max_element(a, a + n))
		return void(printf("IMPOSSIBLE\n"));

	int g = a[0];

	forn (i, n - 1)
		g = __gcd(g, a[i + 1]);

	if (k % g == 0)
		printf("POSSIBLE\n");
	else
		printf("IMPOSSIBLE\n");
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 640
# include <stdio.h>
# include <string.h>

int max(int a, int b)
{
    return a >= b ? a : b;
}


int main()
{
    int H, W;
    int head = 0;
    int tail = 0;
    scanf("%d%d", &H, &W);
    char A[H][W];
    int dis[H][W];
    memset(dis, -1, sizeof(dis));
    int queue_y[H*W], queue_x[H*W];
    for (int y = 0; y < H; ++y)
    {
        scanf("%s", A[y]);
        for (int x = 0; x < W; ++x)
        {
            if (A[y][x] == '#')
            {
                queue_y[tail] = y;
                queue_x[tail] = x;
                tail++;
                dis[y][x] = 0;
            }
        }
    }

    int ans = 0;
    int y, x, yy, xx;
    int move_y[4] = {1, 0, -1, 0};
    int move_x[4] = {0, 1, 0, -1};
    while (head <= tail)
    {
        y = queue_y[head];
        x = queue_x[head];
        head++;
        for (int i = 0; i < 4; ++i)
        {
            yy = y + move_y[i];
            xx = x + move_x[i];
            if (0 <= yy && yy < H && 0 <= xx && xx < W && dis[yy][xx] == -1)
            {
                dis[yy][xx] = dis[y][x] + 1;
                queue_y[tail] = yy;
                queue_x[tail] = xx;
                tail++;
                ans = max(ans, dis[yy][xx]);
            }
        }
    }

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

}

Measured memory_bytes: 12800
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll K;
    cin>>K;
    vector<ll> A(K);
    REP(i,K) cin>>A[i];
    ll x1,x2;
    x1=2;
    x2=3;
    REP(i,K-1){
        x1=max(((x1-1)/A[K-2-i]+1)*A[K-2-i],x1);
        x2=(1+x2/A[K-2-i])*A[K-2-i]-1;
    }
    

    if(x1>x2||A[K-1]!=2){
        cout<<-1<<endl;
    }else{
        cout<<x1<<" "<<x2<<endl;
    }
    
}

Measured memory_bytes: 4036
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n;
	char w[100][13];

	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%s",w[i]);
		if(i >= 1){
			for (int j = 0; j < i; ++j)
			{
				if((w[i - 1][strlen(w[i - 1]) - 1] != w[i][0]) || strcmp(w[i],w[j]) == 0){
					puts("No");
					return 0;
				}
			}
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 128
fun main(arg: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    val M = java.util.HashMap<Int, Int>()
    A.forEach { M[it] = M.getOrElse(it, { 0 }) + 1 }
    var ans = 1
    M.asIterable().forEach {
        val x = it.key
        val c = M.getOrElse(x - 1, { 0 }) +
                M.getOrElse(x + 0, { 0 }) +
                M.getOrElse(x + 1, { 0 })
        if (ans < c) ans = c
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(D: Int = 0) = listOfString().map { Integer.parseInt(it) + D }
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }


Measured memory_bytes: 58144
import java.io.PrintWriter
import java.util.ArrayDeque

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}


fun solve(out: PrintWriter) {
    val k = readLong()
    val queue = ArrayDeque<Long>()
    for (i in 1L..9) {
        queue.add(i)
    }

    for (i in 1 until k) {
        val tmp = queue.removeFirst()
        val lastDigit = tmp % 10
        for (i in -1..1L) {
            if (lastDigit + i in 0..9) {
                queue.add(tmp * 10 + lastDigit + i)
            }
        }
    }

    println(queue.first())
}

/** O(log(m)) */
fun pow(n: Long, m: Long, MOD: Long = 1000000007L): Long {
    var ret = 1L
    var x = n
    var k = m
    while (k > 0) {
        if ((k and 1L) == 1L) { ret = (ret * x) % MOD }
        x = (x * x) % MOD
        k = k shr 1
    }
    return ret
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 38572