akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//define
#define int long long
#define vint vector<int>
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define pb() push_back()
#define mod 100000007
#define elif else if
#define str string
//main
signed main(){
  int N,M,O,Q,count=0,count2=0,count3=0;
  cin>>N;
  vint d(N);
  rep(0,N)cin>>d[i];
  rep(0,N-1){
    REP(i,N){
      if(i!=j)count+=d[i]*d[j];
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<utility>
#include<algorithm>
using namespace std;
int main (){
	string S,T;
    int c;

    cin >> S >> T;

    for(int i=0;i<S.length();i++){
        if(S[i]==T[i]){
            c++;
        }
    }

    cout << c << endl;

}

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

ll a,b,c,d,n,m;
ll ans=100000000000;

string s;

int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin>>a>>b>>c>>d;
  if(c%b==0)n=c/b;
  else n=c/b+1;
  if(a-(n-1)*d<=0)cout<<"No";
  else cout<<"Yes";

  

  return 0;
}



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

int main() {
	long long int n,W;
	cin>>n>>W;
	long long int w[n],v[n];
	for(long long int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	long long int dp[n+1][W+1];
	
	for(long long int i=0;i<n+1;i++){
		for(long long int j=0;j<=W;j++){
			dp[i][j]=0;
			
		}
	}
	
	for(long long int i=0;i<n;i++){
		for(long long int j=0;j<=W;j++){
			if(j<w[i])dp[i+1][j]=dp[i][j];
				else{
			dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
			}
		}
	}
	cout<<dp[n][W]<<endl;
	// your code goes here
	return 0;
}

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

int cnt;

void insertionSort(int A[],int n,int g){
  for(int i=g;i<n;i++){
    int v=A[i];
    int j=i-g;
    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j=j-g;
      cnt++;
    }
    A[j+g]=v;
  }
}

void shellSort(int A[],int n){
  cnt=0;
  int m=0;
  for(int i=1;i*2-1<n;i*=2)
    m++;
  if(m==0) m=1;
  cout<<m<<endl;
  for(int i=0,j=pow(2,m);i<m-1;i++,j/=2){
    insertionSort(A,n,j-1);
    cout<<j-1<<" ";
  }
  insertionSort(A,n,1);
  cout<<1<<endl;
  cout<<cnt<<endl;
}

int main(){
  int n;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++)
    cin>>A[i];
  shellSort(A,n);
  for(int i=0;i<n;i++)
    cout<<A[i]<<endl;
}


Measured memory_bytes: 7172
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)

S = ins()
T = ins()
conv = {"A": 1, "B": 2}


def solve():
    cums = [0] * (len(S) + 1)
    cumt = [0] * (len(T) + 1)
    for i, x in enumerate(S):
        c = conv[x]  # 1 or 2
        cums[i + 1] = (cums[i] + c) % 3
    for i, x in enumerate(T):
        c = conv[x]  # 1 or 2
        cumt[i + 1] = (cumt[i] + c) % 3

    q = ini()
    for i in range(q):
        a, b, c, d = inm()
        if (cums[b] - cums[a - 1]) % 3 == (cumt[d] - cumt[c - 1]) % 3:
            print("YES")
        else:
            print("NO")


solve()


Measured memory_bytes: 5620
# -*- coding: utf-8 -*-
N,K = map(int,input().split())
c = [int(input()) for i in range(N)]
c.sort()
output = c[K-1] - c[0]
for i in range(N-K):
    if output > c[K+i] - c[i+1]:output = c[K+i] - c[i+1]
print(output)


Measured memory_bytes: 7444
// ABC072B - 

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

typedef unsigned long long int ull;
typedef long long int ll;

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

	for (int i = 0; i < s.size(); i += 2) {
		cout << s[i];
	}
	cout << endl;

	return 0;
}


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

int main() {
    int n, k;
    std::cin >> n >> k;

    int ans = 1;
    for (int i = 0; i < n; i++)
    {
        ans = std::min(ans * 2, ans + k);
    }

    std::cout << ans << "\n";
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>
 
using namespace std;
 
int main()
{
	long long N, count = 0, ans = 0;
	long long input, sum = 0;
	vector<long long> A, s;
 
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> input;
		A.push_back(input);
	}
 
	s.push_back(0);
	for (int i = 0; i < N; i++) {
		sum += A[i];
		s.push_back(sum);
	}
 
	sort(s.begin(), s.end());
 
	long long check = -1;
	for (int i = 0; i < N+1; ++i) {
		if (s[i] != check) {
			check = s[i];
			count = 0;
		}
		else
		{
			count++;
			ans += count;
		} 
	}
 
	cout << ans;
	char qq;
	cin >> qq;
	return 0;
}

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

using namespace std;

int main(){
    int n;
    int good_sum=0;
    vector<int> num;
    vector<int> good;
    
    cin>>n;


    for(int i=0;i<n;i++){
        int inp;
        cin>>inp;
        num.push_back(inp);
        good.push_back(0);
    }

    for(int i=0;i<n;i++){      
        int number=n-i;
        int sum=0;
        for(int j=n-1-i+number;j<n;j+=number){
            sum+=good.at(j);
        }
        if(sum % 2 != num.at(number-1)){
            good.at(number-1)=1;
            good_sum++;
        }
    }
    cout<<good_sum<<endl;
    for(int i=0;i<n;i++){
        if(good.at(i)==1){
            cout<<i+1<<" ";
        }
    }

    return 0;
}

Measured memory_bytes: 2796
import java.util.Scanner


object Main {


  def read() = {
    val sc = new Scanner(System.in)
    val a,b = sc.nextLong()
    (a,b)
  }

  //ナイーブ実装
  def pow2(n:Int): Long = List.fill(n)(2.toLong).product

  def solve(a:Long, b:Long):Long= {
    val nBits = 50//10^12上限だから40くらいで十分
    val hoge = for (i <- 0 until nBits)yield {
      // 第i桁目の処理を行う
      val mod = pow2(i + 2)
      val amod = a % mod
      val bmod = b % mod

      def func(x: Long): Long = {
        if (mod == 4) {
          if (x == 0) 0
          else if (x == 1) 1
          else if (x == 2) 1
          else 0
        }
        else {
          if (0 <= x && x < mod / 4) 0
          else if (mod / 4 <= x && x < mod / 2) (x + 1) % 2
          else if (mod / 2 <= x && x < mod * 3 / 4) 0
          else (x + 1) % 2
        }
      }

      val result = (func(bmod) + func((amod + mod - 1) % mod)) % 2
      result * pow2(i)
    }
    hoge.sum
  }

  def main(args: Array[String]): Unit = {
    val (a,b) = read()
    println(solve(a,b))
  }
}

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

int main() {
  string s;
  int n = 0;
  cin >> s;
  for (int i = 0; i < 4; i++) {
    if(s[i] == '+') n++;
    else if (s[i] == '-') n--;
  }
  cout << n << endl;
}


Measured memory_bytes: 256
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int main(int, const char**)
{
    string s;
    cin >> s;
    ll t = 0;
    for(auto c : s)
    {
        t += (c - '0');
    }
    if(t % 9 == 0) 
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std; 
 
#define int long long
#define M 1000000007 
 
signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin >> n;
	int cnt=0,flag=0;
	for(int i=0;i<n;i++){
		int a,b;
		cin >> a >> b;
		if(a==b){
			cnt++;
		}
		else{
			cnt=0;
		}
		if(cnt==3){
			flag=1;
		}
	}
	if(flag){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
}


Measured memory_bytes: 3608
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    hokan = list(map(int,input().split()))
    a.append(hokan)
for j in range(m):
    hokan = int(input())
    b.append(hokan)
for z in range(n):
    count = 0
    for y in range(m):
        count += a[z][y]*b[y]
    print(count)


Measured memory_bytes: 6016
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll a(n);
  ll ans = 0;
  re(i, n) {
    std::cin >> a[i];
    while(a[i]%2==0) a[i]/=2, ans++;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);

	ll x[1000], y[1000], z[1000];
	for (int i = 0; i < N; i++)
		scanf("%lld%lld%lld", &x[i], &y[i], &z[i]);

	ll sum[1000];
	ll res = 0;
	for (int bit = 0; bit < (1 << 3); bit++) {
		for (int i = 0; i < N; i++) {
			sum[i] = (bit & (1 << 0)) ? x[i] : - x[i];
			sum[i] += (bit & (1 << 1)) ? y[i] : - y[i];
			sum[i] += (bit & (1 << 2)) ? z[i] : - z[i];
		}
		sort(sum, sum + N, greater<ll>());

		ll top_M = 0;
		for (int i = 0; i < M; i++)
			top_M += sum[i];
		res = max(res, top_M);
	}

	printf("%lld\n", res);

	return 0;
}


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

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var h = new Dictionary<string, long>();

            long count = 0;
            for(var i = 0; i < n; i++){
                var s = string.Join("", Console.ReadLine().ToCharArray().OrderBy(t => t));
                if(!h.ContainsKey(s)){
                    h.Add(s, 1);
                }else{
                    h[s] += 1;
                }
                count += (h[s] - 1);
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 31644
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define ep emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )
#define mt( ... ) make_tuple( __VA_ARGS__ )

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()

#define MOD ( 1e9 + 7 )

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

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

	vector<int> v( N );
	rep( i, N )
	{
		cin >> v[i];
	}

	// 最大公約数を求めればOK？
	long result = 1e9 + 1;
	rep( i, N - 1 )
	{
		chmin( result, gcd( v[i], v[i + 1] ) );
	}

	cout << result << endl;

	return ( 0 );
}


Measured memory_bytes: 1144
mod = 10**9+7
rng = 200100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
def inv(x):
  return pow(x,mod-2,mod)

n,a,b,c = map(int,input().split())
num = 0
if a == 0 or b == 0:
  print(n*(max(a,b)+c)*inv(100-c)%mod)
  exit()
for i in range(n):
  num = (num+(i+n)*cmb(n-1+i,i)*pow(a+b,n-i,mod)*(inv(pow(a,n-i,mod))+inv(pow(b,n-i,mod))))%mod
ans = num*inv(pow(a+b,2*n,mod))*pow(a,n,mod)*pow(b,n,mod)*100*inv(100-c)%mod
print(ans)

Measured memory_bytes: 57712
h,w = map(int,input().split())

s = [input() for _ in range(h)]
cnt = [[0] * w for _ in range(h)]

for i in range(h):
    done=[0] * w

    for j in range(w):
        if s[i][j] == '#': continue
        if done[j] :continue

        l = 0
        while j+l < w:
            if s[i][j+l] == '#': break
            l+=1

        for k in range(l):
            cnt[i][j+k] +=l
            done[j+k] = 1

for j in range(w):
    done=[0] * h

    for i in range(h):
        if s[i][j] == '#': continue
        if done[i] :continue

        l = 0
        while i+l < h:
            if s[i+l][j] == '#': break
            l+=1

        for k in range(l):
            cnt[i+k][j] +=l
            done[i+k] = 1

ans=0

for i in range(h):
    for j in range(w):
        ans = max(ans,cnt[i][j]-1)

print(ans)

Measured memory_bytes: 106164
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,M,V,P;
  cin>>N>>M>>V>>P;
  vector<int> A(N);
  for(int &i:A)cin>>i;
  sort(A.rbegin(),A.rend());
  int ok=0,ng=N;
  while(ng-ok>1){
    int n=(ok+ng)/2,m=0;
    for(int i=0;i<N;i++){
      if(i<P-1)m+=M;
      else if(i>=n)m+=M;
      else if(A[n]+M-A[i]>=0)m+=A[n]+M-A[i];
      else{
        ng=n;
        goto home;
      }
    }
    if(m>=M*V || n<P-1)ok=n;
    else ng=n;
    home:;
  }
  cout<<ok+1<<endl;
}

Measured memory_bytes: 3988
from collections import *
from itertools import *
import copy
from heapq import *

N=int(input())
S=input()
def check(data):
    for i in range(N):
        if data[i]=="S" and S[i]=="o" or data[i]=="W" and S[i]=="x":
            if data[i-1]==data[(i+1) if i+1<N else (i+1-N)]:
                pass
            else:
                return(0)
        else:
            if data[i-1]!=data[(i+1) if i+1<N else (i+1-N)]:
                pass
            else:
                return(0)
    return(1)


for s1 in ["S","W"]:
    for s2 in ["S","W"]:
        data=[0 for i in range(N)]
        data[0],data[1]=s1,s2

        for i in range(2,N):
            if data[i-1]=="S" and S[i-1]=="o" or data[i-1]=="W" and S[i-1]=="x":
                data[i]=data[i-2]
            else:
                data[i]="S" if data[i-2]=="W" else "W"

        if check(data):
            print("".join(list(map(str,data))))
            exit()

print(-1)


Measured memory_bytes: 62392
while 1:
    a=[i+1 for i in range(10)]
    try:b=list(map(int,input().split()))
    except:break
    for i in b:a.remove(i)
    print('YES' if sum([1 for i in a if i<=20-sum(b[:2])])/7>=0.5 else 'NO')

Measured memory_bytes: 7720
s = input()

count = 0
for i in range(len(s)):
    c=0
    if s[i]!='A' and s[i]!='C' and s[i]!='G' and s[i]!='T':
        continue
    c=1
    for j in range(i+1,len(s)):
        if s[j]!='A' and s[j]!='C' and s[j]!='G' and s[j]!='T':
            break
        else:
            c+=1
    count = c if count<=c else count
print(count)

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

int func(int x){
  if(x%2 != 0) return 0;
  return func(x/2)+1;
}

int main(void){
  int N;
  int ans = 0;
  cin >> N;
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    ans += func(a);
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	int N,D;
	scanf("%d %d",&N,&D);
	
	
	double* y;
	y = (double *)malloc(sizeof(double)*D*N);
	int i,k;
	for(k=0;k<N;k++)
    	for(i=0;i<D;i++)scanf("%lf",&y[k*D+i]);//*(y+sizeof(double)*i*k));
    	
	double ret=0;
    int j;
    int cnt=0;

	for(i=0;i<N-1;i++){
		for(j=i+1;j<N;j++){
			for( k =0;k<D;k++){
				ret+= (y[i*D+k]-y[k+D*j])*(y[i*D+k]-y[k+D*j]);
			}
			ret = sqrt(ret);
			if(ceil(ret)==floor(ret))cnt++;
			ret=0;
		}
	}

	printf("%d\n",cnt);
	
	free(y);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

typedef long long ll;
#define x first
#define y second
#define mp make_pair

string s;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> s;
if(s[2] == s[3] && s[4] == s[5]){
	cout << "Yes" << endl;
}
else{
	cout << "No" << endl;
}

return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
# from pprint import pprint


N, X = [int(x) for x in sys.stdin.readline().rstrip().split()]

m = [int(sys.stdin.readline().rstrip()) for _ in range(N)]


# print(N, X, m)

s = sum(m)
min = min(m)

# print(s, min)

print(int((X-s)/min) + len(m))

Measured memory_bytes: 2940
n = gets.to_i
ps = gets.split.map(&:to_i)
qs = gets.split.map(&:to_i)

list = []
1.upto(n) do |i|
  list << i
end

p_cnt = 0
q_cnt = 0
list.permutation.each_with_index do |l, i|
  p_cnt = i+1 if ps == l
  q_cnt = i+1 if qs == l
end

puts (p_cnt-q_cnt).abs

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

int main(){
 vector<int>A(5);
 int x,k=0,sum=0; 
  for(int i=0; i<5; i++){
  cin>>A[i];
  x=(A[i]+9)/10*10;  // +9はA[i]%10==0の場合の対応
  if(x-A[i]>k){k=x-A[i];}
   sum+=x;  }
  
  cout<<sum-k<<endl;
}

Measured memory_bytes: 256
using System;

namespace AOJ.Volume0
{
    public class CardGame
    {
        public static int Main()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                var sep = input.Split(' ');
                int c1 = int.Parse(sep[0]);
                int c2 = int.Parse(sep[1]);
                int c3 = int.Parse(sep[2]);
                // 自分の手
                int my_hand = c1 + c2;

                // 合計20以下になる枚数を調べる
                int cnt = 0;
                for (int i = 1; i <= 10; i++)
                {
                    if (i == c1 || i == c2 || i == c3) { continue; }
                    if (my_hand + i <= 20) { cnt++; }
                }
                // 20以下になる枚数が3枚以上ならOK
                Console.WriteLine(cnt >= 4 ? "YES" : "NO");
            }
            return 0;
        }
    }
}

Measured memory_bytes: 8744
using System;

class Program {
    private static int Main() {
        var input = Console.ReadLine();

        var value = int.Parse( input );
        var hours = value / ( 60 * 60 );
        var minutes = ( value / 60 ) % 60;
        var second = ( value % 60 );

        var output = string.Format( "{0}:{1}:{2}", hours, minutes, second );
        Console.WriteLine( output );

        return 0;
    }
}

Measured memory_bytes: 5628
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll n;
  scanf("%lld", &n);
  ll ans = 1;
  for (int i = 1; i <= n; i++)
  {
    ans = i * ans % MOD;
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////



int main() {
	ll p = 37;

	ll N = p * p + p + 1;
	ll K = p + 1;

	cout << N << " " << K << endl;
	
	rep(i, p)rep(j, p) {
		rep(x, p) {
			cout << (j+i*x)%p + x * p + 1 << " ";
		}
		cout << p * p + i + 1 << endl;
	}

	rep(i, p+1) {
		rep(x, p) {
			cout << i * p + x + 1 << " ";
		}
		cout << p * p + p + 1 << endl;
	}

	system("PAUSE");
}


Measured memory_bytes: 640
cs = []
3.times do |i|
    cs[i] = gets.split.map(&:to_i)
end

[1, 2].each do |i|
    diff1 = [0, 1, 2].map do |j|
        cs[i][j] - cs[0][j]
    end
    diff2 = [0, 1, 2].map do |j|
        cs[j][i] - cs[j][0]
    end
    if diff1.uniq.length > 1 || diff2.uniq.length > 1
        puts 'No'
        exit
    end
end

puts 'Yes'

Measured memory_bytes: 1788
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int M, N; cin >> M >> N;
    int cnt[M]; bool found[M];
    int ans = 0;
    F0R(i, M) {
        cnt[i] = 0; found[i] = false;
    }
    int ans2 = 0;
    F0R(i, N) {
        int val; string S; cin >> val >> S; val--;
        if (S == "AC" && !found[val]) {
            found[val] = true; ans += cnt[val]; ans2++;
        } else {
            cnt[val]++;
        }
    }

    cout << ans2 << " " << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 768
#include<stdio.h>
#define SIZE 100

int main(void)
{
    int i, n, a[SIZE];
    
    scanf("%d", &n);
    for ( i=0; i<n; ++i)
        scanf("%d", &a[i]);

    for ( i=n-1; i>=0; --i) {
        printf("%d", a[i]);
        if ( i != 0)
            printf(" ");
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 2044
n = int(input())
a = []
s = []
for i in range(n):
  _a = int(input())
  a.append(_a)
  s.append([list(map(int, input().split())) for j in range(_a)])
bins = []
for i in range(2**n):
  binary = bin(i)[2:]
  binary = '0' * (n-len(binary)) + binary
  bins.append(list(map(int,list(binary))))

ans = 0
for binlist in bins:
  for i, p in enumerate(binlist):
    if p == 1:
      cnt = 0
      for state in s[i]:
        if binlist[state[0]-1] != state[1]:
          break
        else:
          cnt += 1
      if cnt < len(s[i]):
        break
  else:
    ans = max(ans, len(list(filter(lambda x: x==1, binlist))))
print(ans)

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

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

string str;
map<string,ll> cnt;

vector<string> vd;

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

	ll n,i;

	cin >> n;
	for(i=1;i<=n;++i)
	{
		cin >> str;
		cnt[str]++;
	}

	vd.pb("AC");
	vd.pb("WA");
	vd.pb("TLE");
	vd.pb("RE");

	for(auto v:vd)
		cout << v << " x " << cnt[v] << "\n";
}

Measured memory_bytes: 3672
#include <cstdio>
#include <cstring>
using namespace std;

int H, W;
int N;
int X[50], Y[50];
int vis[100][100];
void solve(int x, int y){
	if (x > W || y > H) return;
	for (int i = 1; i <= N; i++){
		if (x == X[i] && y == Y[i]) return;
	}
	vis[y][x]++;
	solve(x + 1, y);
	solve(x, y + 1);
}

int main(){
	
	while (1){
		memset(vis, 0, sizeof(vis));
		scanf("%d%d", &W, &H);
		if (W == 0){
			return 0;
		}
		scanf("%d", &N);
		for (int i = 1; i <= N; i++){
			scanf("%d%d", &X[i], &Y[i]);
		}
		solve(1, 1);
		printf("%d\n", vis[H][W]);
	}
}

Measured memory_bytes: 1076
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#ifdef ConanYu
#include "local.hpp"
#else
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

void Main() {
  int n; cin >> n;
  cout << (n - 1) / 2 << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
vector<int>primes[1000006];
void find_prime(){
	for (int i=2;i<=1e6;i++){
		if (!sz(primes[i]))
			for (int j=i;j<=1e6;j+=i)
				primes[j].pb(i);
	}
}
int n;
int used[1000006];
void func(int a){
	for (int i : primes[a])
		used[i]++;
}
void final(){
	int kind=0;
	for (int i=0;i<=1e6;i++){
	//	cout<<used[i]<<' ';
		if (used[i]==n)
			kind=2ll;
		if (used[i]>1)
			kind=max(kind,1ll);
	}
	if (!kind)
		cout<<"pairwise coprime";
	if (kind==1)
		cout<<"setwise coprime";
	if (kind==2)
		cout<<"not coprime";
}
signed main()
{
//	time_t a=clock();
	find_prime();
//	cout<<clock()-a;
	cin>>n;
	for (int i=0;i<n;i++){
		int a;
		cin>>a;
		func(a);
	}
	final();
	re 0;
}


Measured memory_bytes: 81440
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    map<string, long long> num;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        num[s]++;
    }
    long long res = 0;
    for (auto v : num) {
        long long n = v.second; // v.first が v.second 個
        res += n * (n-1) / 2;
    } 
    cout << res << endl;
}

Measured memory_bytes: 11420
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]
    As.sort()
    res = 1
    remain = sum(As)

    for i in range(N-1):
        temp = As[-1 * (i + 1)]
        remain -= temp

        if temp <= remain * 2:
            res += 1
        else:
            break

    print(res)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 20220
#include <iostream>
#include <map>
using namespace std;
int N;
int Array[100005];
map <int, int> M;
void Read()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> Array[i], M[Array[i]]++;
}

void Solve()
{
    int ans = 0;
    for(int i = 1; i <= N; i++)
    {
        if(M[Array[i]] >= Array[i])
        ans += M[Array[i]] - Array[i], M[Array[i]] = Array[i];
        else
            ans += M[Array[i]], M[Array[i]] = 0;
    }
    cout << ans << '\n';
}
int main()
{
    Read();
    Solve();
    return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int dt[4];
string ans;

bool func(int n,int pre,string s){
	if(n==4){
		if(pre==7){
			ans=s;
			return true;
		}else return false;
	}
	return func(n+1,pre+dt[n],s+'+') or func(n+1,pre-dt[n],s+'-');
}

int main(){
	string s;
	cin>>s;
	rep(i,4)dt[i]=(int)(s[i]-'0');
	func(1,dt[0],"");
	cout<<dt[0];
	rep(i,3)cout<<ans[i]<<dt[i+1];
	cout<<"=7"<<endl;
	return 0;
}

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

int main(){
  ll MOD = 1000000007;
  int n, m;
  cin >> n >> m;
  vi broken(n+1);
  vi a(n);
  rep(i,m){
    cin >> a[i];
    broken[a[i]] = 1;
  }
  vector<ll> dp(n+1);
  dp[0] = 1; 
  if(a[0] == 1) dp[1] = 0;
  else dp[1] = 1;
  for(ll i=2; i<=n; i++){
    if(broken[i] == 1) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i-1] + dp[i-2]) % MOD;
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 4748
n = int(input())

import math
import itertools
sosu = [0]*2 + [1]*(10**5)

for i, item in enumerate(sosu):
  if i > math.sqrt(len(sosu)):
    break
  if item:
    for j in range(2, len(sosu)//i):
      sosu[j*i] = 0

sosu_num = []
for i in range(len(sosu)):
  if sosu[i] and i % 5 == 1:
    sosu_num.append(i)

ans = sosu_num[:n]
for item in ans:
  print(item, end=" ")

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N;

  cin >> N ;

  string S;

  cin >> S ;

  vector<int> e(N+1,0),w(N+1,0);//s.at(0)=0になる。

  for(int i=0;i<N;i++){
    if(S.at(i)=='E') e.at(i+1)=e.at(i)+1;
    else e.at(i+1)=e.at(i);
  }//東向いてる人の1~iまででの合計人数

  for(int i=0;i<N;i++){
    if(S.at(i)=='W') w.at(i+1)=w.at(i)+1;
    else w.at(i+1)=w.at(i);
  }//西向いてる人の1~iまででの合計人数

  int ans=1000000;

  for(int i=0;i<N;i++){
    int Wn=w.at(i)-w.at(0);//リーダーより西でそっぽを向いている人(at(0)~at(i-1))
    int En=e.at(N)-e.at(i+1);////リーダーより西でそっぽを向いている人(at(i+1)~at(N-1))
    int m=Wn+En;
    if(m<ans) ans=m;
  }//リーダーの位置を動かして、リーダーより西で西を向いている人とリーダーより東で東を向いている人の和で最小となるものを探す。

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

Measured memory_bytes: 3076
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorders
{
	public class Program
	{
		static void Main(string[] args)
		{
			var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nm[0];
			int m = nm[1];
			
			var hash = new HashSet<int>();
			
			var uf = new UnionFindTree(m);
			for (int i = 0; i < n; i++) {
				var kl = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				int s = kl[0];
				for (int j = 1; j <= s - 1; j++) {
					uf.TryUnite(kl[j] - 1, kl[j + 1] - 1);
				}

				for (int j = 1; j <= s; j++) {
					hash.Add(kl[j] - 1);
				}
			}

			int parent = - 1;
			for (int i = 0; i < m; i++) {
				if (hash.Contains(i)) {
					if (parent == -1) {
						parent = uf.Find(i);
					} else {
						if (parent != uf.Find(i)) {
							Console.WriteLine("NO");
							return;
						}
					}
				}
			}

			Console.WriteLine("YES");
		}
	}

	public class UnionFindTree
	{
		private int[] sizes_;
		private int[] parent_;
		public int TreeCount { get; set; }

		public UnionFindTree(int n)
		{
			parent_ = new int[n];
			sizes_ = new int[n];
			for (int i = 0; i < n; i++) {
				parent_[i] = i;
				sizes_[i] = 1;
			}

			TreeCount = n;
		}

		public int Find(int x)
		{
			while (parent_[x] != x) {
				parent_[x] = parent_[parent_[x]];
				x = parent_[x];
			}

			return x;
		}

		public bool IsUnited(int x, int y)
		{
			return Find(x) == Find(y);
		}

		public void TryUnite(int x, int y)
		{
			int rootX = Find(x);
			int rootY = Find(y);
			if (rootX == rootY) {
				return;
			}

			int sizeX = sizes_[rootX];
			int sizeY = sizes_[rootY];
			if (sizeX < sizeY) {
				parent_[rootX] = rootY;
				sizes_[rootY] += sizeX;
			} else {
				parent_[rootY] = rootX;
				sizes_[rootX] += sizeY;
			}

			--TreeCount;
		}
	}
}

Measured memory_bytes: 26704
#include<iostream>
#include<algorithm>
#include<string>
#include<stdlib.h>
#define ll long long

using namespace std;

ll ans=0;
ll n=0;

int main(){
    cin>>n;
    for(int i=1;i<=n;++i){
        for(int j=i;j<=n;j+=i){
            ans+=j;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
package main

import "fmt"

func main() {
	var r, g, b int
	fmt.Scan(&r)
	fmt.Scan(&g)
	fmt.Scan(&b)
	if (r*100+g*10+b)%4 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long int dp[200][200],a,su[200];
int main(){
    cin>>a;
    for(int i=0;i<a;i++){cin>>su[i];}
    dp[su[0]][0]=1;
    for(int i=0;i<a-1;i++){
        for(int j=0;j<21;j++){
            if(dp[j][i]!=0){
                if(j+su[i+1]>20){}else{ dp[j+su[i+1]][i+1]+=dp[j][i]; }
                if(j-su[i+1]<0){}else{ dp[j-su[i+1]][i+1]+=dp[j][i]; }
                }
            }
        }
    cout<<dp[su[a-1]][a-2]<<endl;
    return 0;
}

Measured memory_bytes: 3112
import java.util.Scanner;
 
class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
 
        long S = stdIn.nextLong();
 
        long h = S/3600;
        long m = S%3600/60;
        long sec = S%60;
 
        System.out.println(h+":"+m+":"+sec);
    }
}

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

int main()
{
	int sum;
	int m,n;
	int mon;
	bool flag;
	while(cin >> sum){
		if(sum==0)
			break;
		flag = false;
		for(int i=0;i<12;i++){
			cin >> m >> n;
			sum -= (m-n);
			if(flag==false && sum<=0){
				flag = true;
				mon = i+1;
			}
		}
		if(flag==false)
			cout << "NA" << endl;
		else
			cout << mon << endl;
	}
	return 0;
}

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

using namespace std;
ll p = 1000000007ll;

int main(void)
{
  int n;
  cin >> n;
  cout << (n-1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 200010;
const int maxv = 1000002;
const int INF = LLONG_MAX/4;


int n;
int A[maxn];
int processed[maxv];
int ans[maxv];

int32_t main() {
	FAST
	cin >> n;
	for (int i =0;i<n;i++) cin >> A[i];	
	for (int i =0;i<n;i++) {
		int x = A[i];
		if (processed[x]) {
			ans[x] = 1;
			continue;
		}
		processed[x] = 1;
		
		for (int j =x*2;j<maxv;j += x) {
			ans[j] = 1;
		}
	}
	
	int rans = 0;
	for (int i =0;i<n;i++) {
		if (ans[A[i]] == 0) rans++;
	}
	cout << rans;
	
}









Measured memory_bytes: 20840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<vector<char>> S(N, vector<char>(10));
  for (int i = 0; i < N; i++) {
    cin >> S.at(i).at(0) >> S.at(i).at(1) >> S.at(i).at(2) >> S.at(i).at(3) >> S.at(i).at(4) >> S.at(i).at(5) >> S.at(i).at(6) >> S.at(i).at(7) >> S.at(i).at(8) >> S.at(i).at(9);
    sort(S.at(i).begin(), S.at(i).end());
  }
  sort(S.begin(), S.end());
  int64_t ans = 0;
  int64_t memo = 1;
  for (int i = 0; i < N - 1; i++) {
    if (S.at(i).at(0) == S.at(i + 1).at(0) && S.at(i).at(1) == S.at(i + 1).at(1) && S.at(i).at(2) == S.at(i + 1).at(2) && S.at(i).at(3) == S.at(i + 1).at(3) && S.at(i).at(4) == S.at(i + 1).at(4) && S.at(i).at(5) == S.at(i + 1).at(5) && S.at(i).at(6) == S.at(i + 1).at(6) && S.at(i).at(7) == S.at(i + 1).at(7) && S.at(i).at(8) == S.at(i + 1).at(8) && S.at(i).at(9) == S.at(i + 1).at(9)) {
      memo++;
    }
    else {
      ans += (memo * (memo - 1)) / 2;
      memo = 1;
    }
  }
  ans += (memo * (memo - 1)) / 2;
  cout << ans << endl;      
}

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

int main() {
	int H, W;
	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int h = 0; h < H; h++) {
			for (int w = 0; w < W; w++) {
				if(h==0||h==H-1)cout << "#";
				else {
					if(w==0||w==W-1)cout << "#";
					else cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  
  int ans = 0;
  if (n > 1) ans += n*(n-1)/2;
  if (m > 1) ans += m*(m-1)/2;
  
  cout << ans << endl;
  
  return 0;
}


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

using namespace std;

using ll = long long;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	vector<int> dp(n, 1000000001);
	dp[0] = 0;
	for (int i = 0; i < n - 1; i++) {
		if (i + 1 < n) dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
		if (i + 2 < n) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<string.h>
using namespace std;

int main() {
	int N, L;
	char S[105][105];
	char tmp[105];
	cin >> N >> L;
	for (int i = 0; i < N; i++)
		cin >> S[i];
	
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			if (strcmp(S[i], S[j]) > 0) {
				strcpy(tmp, S[j]);
				strcpy(S[j], S[i]);
				strcpy(S[i], tmp);		
			}
		}
	}

	for (int i = 0; i < N; i++)
		cout << S[i];
	cout << endl;
}

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


def solve(N: int, M: int, A: "List[int]"):
    return max(-1, N - sum(A))


# 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
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    print(solve(N, M, A))

if __name__ == '__main__':
    main()


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

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

int w, h, sx, sy, gx, gy;
int bd[20][20];

bool valid(int x, int y) {
    return 0 <= x && x < w && 0 <= y && y < h;
}

int dfs(int x, int y, int step = 1) {
    if (step > 10) return 11;
    int res = 11;
    for (int i=0; i<4; ++i) {
        int ny = y;
        int nx = x;
        while (valid(nx + dx[i], ny + dy[i]) && bd[ny + dy[i]][nx + dx[i]] != 1) {
            ny += dy[i];
            nx += dx[i];
            if (ny == gy && nx == gx) return step;
        }
        if (ny == y && nx == x) continue;
        if ( ! valid(nx + dx[i], ny + dy[i])) continue;
        bd[ny + dy[i]][nx + dx[i]] = 0;
        res = min(res, dfs(nx, ny, step + 1));
        bd[ny + dy[i]][nx + dx[i]] = 1;
    }
    return res;
}

int main() {
    while (cin >> w >> h) {
        if ( ! w) break;
        for (int i=0; i<h; ++i) {
            for (int j=0; j<w; ++j) {
                cin >> bd[i][j];
                if (bd[i][j] == 2) {
                    sy = i;
                    sx = j;
                } else if (bd[i][j] == 3) {
                    gy = i;
                    gx = j;
                }
            }
        }
        int res = dfs(sx, sy);
        cout << (res > 10 ? -1 : res) << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<windows.h>
using namespace std;
 
//#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
struct edge {int /*from,*/to,cost;};

signed main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    REP(i,a+1) REP(j,b+1) REP(k,c+1){
        if(i*500+j*100+k*50==x) ans++;
    }
    printf("%d\n",ans);

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
const static double PI = ::acos(-1);


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

    set<int> one;
    set<int> two;
    set<int> three;

    Rep(i, n)
    {
        int c = (int)(s[i] - '0');
        for (const int second : two)
        {
            three.insert(10 * second + c);
        }
        for (const int first : one)
        {
            two.insert(10 * first + c);
        }
        one.insert(c);
    }
    cout << three.size() << endl;



    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K; string S; cin >> N >> S >> K;

    char a = S[K-1];
    rep(i,N) if (S[i] != a) S[i] = '*';

    cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const ll MOD=1000000007;
const ll LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




int main(){
    bool f;cin >> f;
    cout << (not f) << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,m,cnt=0,ans=0,mn=100000;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cnt+=a[i];
        if(a[i]<mn)
        {
            mn=a[i];
        }
    }
    if(cnt<=m)
    {
        cout<<n+((m-cnt)/mn)<<NL;
    }
    else
    {
        SRT(a,n);
        int gu=0;
        for(int i=0;i<n;i++)
        {
            m-=a[i];
            if(m<0)
            {
                break;
            }
            gu++;
        }
        cout<<gu<<NL;
    }
    return 0;
}


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

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

using namespace std;

int main(){
  string s, t;cin>>s>>t;
  map<char, int>sm;
  rep(i, s.size())sm[s[i]]++;
  bool f=true;
  rep(i, t.size())if(sm[t[i]]==0)f=false;
  if(!f){ cout<<-1;return 0; }

  map<char, vector<ll>> sc;
  rep(i, s.size()){
    sc[s[i]].push_back(i+1);
  }

  ll s_count=0, s_index=0;
  rep(i, t.size()){
    // もし今見ている文字の位置情報を格納した配列の最後の値よりも
    // sの中を進んでいるインデックスが大きければ、次の連結されたsへ移動する
    if(s_index >= sc[t[i]][sc[t[i]].size()-1]){
      s_count++;
      s_index=0;
    }

    // get value from it
    s_index = *upper_bound(sc[t[i]].begin(), sc[t[i]].end(), s_index);
  }

  cout<<s.size()*s_count+s_index;

  return 0;
}


Measured memory_bytes: 1728