akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	
		int b = tx - sx;
		int a = ty - sy;
		int countU = 0;
		int countD = 0;
		int countL = 0;
		int countR = 0;
		if (a < 0) {
			rep(i, abs(a)) {
				cout << "D" ;
				countD++;
			}
		}
		else {
			rep(i, a) {
				cout << "U" ;
				countU++;
			}
		}
		//cout << endl;
		if (b < 0) {
			rep(i, abs(b)) {
				cout << "L" ;
				countL++;
			}
		}
		else {
			rep(i, b) {
				cout << "R" ;
				countR++;
			}
		}
		//cout << endl;
		rep(i, countD) {
			cout << "U" ;
		}
		rep(i, countU) {
			cout << "D" ;
		}
		//cout << endl;
		rep(i, countR) {
			cout << "L" ;
		}
		rep(i, countL) {
			cout << "R" ;
		}
		//cout << endl;
		int i = 0;
		while (i < 2) {
			if (i > 0) {
				swap(countR, countL);
				swap(countD, countU);
			}
			if (countU>0) {
				cout << "D" ;
			}
			else {
				cout << "U";//<< endl;
			}
			//cout << endl;
			if (countR > 0) {
				rep(i, countR + 1) {
					cout << "R";// << endl;
				}
			}
			else if(countL>0) {
				rep(i, countL + 1) {
					cout << "L";//<< endl;
				}
			}
			//cout << endl;
			if (countU > 0) {
				rep(i, countU + 1) {
					cout << "U";// << endl;
				}
			}
			else if(countD>0) {
				rep(i, countD + 1) {
					cout << "D";// << endl;
				}
			}
			//cout << endl;
			if (countR>0) {
				cout << "L";// << endl;
			}
			else {
				cout << "R";// << endl;
			}
			//cout << endl;
			i++;
		}
	
}


Measured memory_bytes: 256
n=int(input())
a=[]
b=[]
for i in range(n):
  A=int(input())
  a.append(A)
  b.append(A)
b.sort()
max1=b[n-1]
max2=b[n-2]
for i in range(n):
  if a[i]==max1:
    print(max2)
  else:
    print(max1)

Measured memory_bytes: 14120
#include<stdio.h>
int main(void)
{
	int n,m;
	char a[1000],b[1000],c;
	int i,j;
	
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf(" %c %c",&a[i],&b[i]);
		}
		scanf("%d",&m);
		for(i=0;i<m;i++){
			scanf(" %c",&c);
			for(j=0;j<n;j++){
				if(c==a[j]){
					c=b[j];
					break;
				}
			
			}
			printf("%c",c);
		}
		printf("\n");
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1000
#include<stdio.h>

void trace(int A[], int N)
{
  int i;
  for(i=0; i<N; i++)
  {
    if(i>0)
      printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(void)
{
  int i,j,v,n;
  int array[100];
  scanf("%d\n", &n);

  for(i=0; i<n; i++)
  {
    scanf("%d", &array[i]);
  }
  for(i=0; i<n; i++)
  {
    printf("%d", array[i]);
    if(i!=n-1)
      printf(" ");
    else
      printf("\n");
  }

  for(i=1; i<n; i++)
  {
    v = array[i];
    j = i-1;
    while (j>=0 && array[j] > v)
    {   
      array[j+1] = array[j];
      j--;
    }   
    array[j+1] = v;
    trace(array, n); 
  }
}

Measured memory_bytes: 1032
import string

n = int(input())
strs = input()

ans = 0

for i in range(n):
    left = strs[:i]
    right = strs[i:]
    score = 0
    for a in string.ascii_lowercase:
        if a in left and a in right:
            score += 1
    
    if score > ans:
        ans = score
    
print(ans)

Measured memory_bytes: 3768
n,k = map(int,input().split())
s = [[i] for i in range(1,n+1)]
ans = 0

for i in s:
    x = i[0]
    c = 0
    while x < k:
        x *= 2
        c += 1
    s[i[0]-1].append(c)

for i in s:
    ans +=1/n*(1/2)**i[1]

print(ans)

Measured memory_bytes: 18036
#include <iostream>

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,c;
	int b[100],a,ans=0;
	cin>>n>>m>>c;
	for(int i=0;i<m;i++){
		cin>>b[i];
	}
	int d=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a;
			d+=b[j]*a;
		}
		if(d+c>0)
			ans++;
		d=0;
	}
	cout<<ans<<endl;
return(0);
}

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

namespace AtCoder
{
    class Modular
    {
        private const int M = 1000000007;
        private long value;

        public Modular(long value) { this.value = value; }
        public static implicit operator Modular(long a) { return new Modular((a % M + M) % M); }
        public static Modular operator +(Modular a, Modular b) { return a.value + b.value; }
        public static Modular operator -(Modular a, Modular b) { return a.value - b.value; }
        public static Modular operator *(Modular a, Modular b) { return a.value * b.value; }
        public static Modular Pow(Modular a, int n)
        {
            switch (n)
            {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                var p = Pow(a, n / 2);
                return p * p * Pow(a, n % 2);
            }
        }
        public static Modular operator /(Modular a, Modular b) { return a * Pow(b, M - 2); }
        private static readonly List<int> facs = new List<int> { 1 };
        private static Modular Fac(int n)
        {
            for (int i = facs.Count; i <= n; ++i) { facs.Add((int)(Math.BigMul(facs.Last(), i) % M)); }
            return facs[n];
        }
        public static Modular Ncr(int n, int r)
        {
            return (n < r) ? 0
                 : (n == r) ? 1
                            : Fac(n) / (Fac(r) * Fac(n - r));
        }
        public static explicit operator int(Modular a) { return (int)a.value; }
    }

    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int N, Modular A, Modular B, Modular C)
        {
            Modular ans = 0;
            var a = A / (A + B);
            var b = B / (A + B);
            var c = C / 100;
            var alpha = Modular.Pow(a, N);
            var beta = Modular.Pow(b, N);
            for (int i = 0; i < N; ++i)
            {
                ans += (alpha * Modular.Pow(b, i) + beta * Modular.Pow(a, i)) * Modular.Ncr(N + i - 1, N - 1) * (N + i);
            }
            return (int)(ans / (1 - c));
        }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            Console.WriteLine(Solve(V[0], V[1], V[2], V[3]));
        }
    }
}


Measured memory_bytes: 16932
#include<bits/stdc++.h>
#define INFTY 10000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

int main(){
    int n,k;cin>>n>>k;
    int num[n][2];
    string s;cin>>s;
    int mx = 0;
    int ch=1;
    int cnt = 0;
    rep(i,n){
        if(s[i]=='0'){
           if(ch)num[cnt][0]=i;
           ch = 0;
           if(s[i+1]=='1'||i==n-1){
               num[cnt][1]=i;
               cnt++;
           }
        }
        if(s[i]=='1'){
            ch = 1;
        }
    }
   // rep(i,cnt)cout<<"n"<<num[i][0]<<num[i][1]<<endl;
    if(cnt<k){
        cout<<n<<endl;
        return 0;
    }
    mx =max(num[k][0]-1,mx);
    for (int i = 0; i < cnt; i++)
    {
       int r,l;
       if(i>0)l = num[i-1][1]+1;
       else l = 0;
       if(k+i<cnt){
           r = num[i+k][0]-1;
       }else{
           r = n-1;
       }
       //cout<<l<<r<<endl;
       mx = max(mx,r-l+1);
    }
    
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 896
#include<iostream>

using namespace std;


int main()
{
	int N, M;
	int a[50], b[50];
	int n[50];

	cin >> N >> M;

	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
	}

	for (int i = 0; i < N; i++) {
		n[i] = 0;
	}

	for (int i = 0; i < M; i++) {
		n[a[i] - 1]++;
		n[b[i] - 1]++;
	}

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

	return 0;
}

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

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

    map<string, ll> mp;
    REP(i, n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    
    ll cnt = 0;
    for (auto& kv : mp) {
        cnt += kv.second * (kv.second - 1) / 2;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int n,a[500],s;
int main(){
	cin>>n;
	for(int i=1;i<=2*n;i++) cin>>a[i];
	sort(a+1,a+1+n*2);
	for(int i=1;i<=2*n;i+=2) s+=a[i];
	cout<<s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

const int maxn=2e5+7;
LL a[maxn];
int n;
LL x;
int main()
{
    n=read();x=read();
    for(int i=1;i<=n;i++)a[i]=read()+a[i-1];
    LL ans=1e18;
    for(int k=1;k<=n;k++){
        LL now=3,res=0;
        for(int i=n;i>=1;i-=k){
            res+=(a[i]-a[max(0,i-k)])*max(now,5LL);now+=2;
            if(res>=ans)break;
        }
        res+=1LL*(k+n)*x;
        if(res<ans)ans=res;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
N,Y=map(int,input().split())
a=10000
b=5000
c=1000
x=Y//a+1
ans=['-1','-1','-1']
for i in range(x):
  if Y-i*a<0:
    break
  if ans!=['-1','-1','-1']:
    break
  jtmp=(Y-i*a)//5000+1
  for j in range(jtmp):
    k=(Y-a*i-b*j)//c
    if Y-a*i-b*j-c*k==0 and i+j+k==N:
      ans=[str(i),str(j),str(k)]
      break
print(' '.join(ans))

Measured memory_bytes: 40684
N,Y=map(int,input().split())
Y=Y/1000
ans=[-1,-1,-1]
for i in range(N+1):
    for j in range(N-i+1):
        if 10*i+5*j+N-i-j==Y:
                ans=[i,j,N-i-j]
                break
print(ans[0],ans[1],ans[2])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}
int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}
ll powermod(ll x, ll y, ll p)  
{  
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;  
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}
 
int main()
{
    ll x;
    cin>>x;
    if(x>=30)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
        
}


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

#define PI 3.14159265359

int main(){
  int N;
  cin >> N;
  for (int i = 1; i < N + 1; i++){
    int ans = 0;
    for (int j = 1; j < 59; j++){
      for (int k = j; k < 71; k++){
        for (int l = k; l < 100; l++){
          if (j * j + k * k + l * l + j * k + k * l + l * j == i){
            if (j == k && k == l) ans++;
            else if (j == k || k == l || l == j) ans += 3;
            else ans += 6;
          }
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3588
#include <stdio.h>
int GCD(int a,int b)
{
  int r=1;
  while(r!=0){
    r=a%b;
    a=b;
    b=r;
  }
  return a;
}
int main()
{
  int k;
  scanf("%d",&k);
  int gcdsum=0;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int m=1;m<=k;m++){
            gcdsum+=GCD(GCD(i,j),m);
      }
    }
  }
  printf("%d",gcdsum);
  return 0;
}

Measured memory_bytes: 1728
def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))

    # 式 f の末尾に "+" を追加するかしないかして次の数字を追加
    return dfs(i + 1, f + s[i + 1]) + \
           dfs(i + 1, f + "+" + s[i + 1])


s = input()
n = len(s)

print(dfs(0, s[0]))

Measured memory_bytes: 9188
#include<stdio.h>
int main()
{
  int i,j,k,l,cou,n;
  while(scanf("%d",&n)!=EOF){
    cou=0;
    for(i=0;i<=9;i++){
      for(j=0;j<=9;j++){
	for(k=0;k<=9;k++){
	  for(l=0;l<=9;l++){
	    if(i+j+k+l==n)cou++;
	  }
	}
      }
    }
    printf("%d\n",cou);
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    for (int i = 0; i <= N; ++i){
         for (int j = 0; j <= N; j++){
             int b = N - i * R - j * G;
             if (b >=0 ){
                 if (b % B == 0){
                     ans++;
                 }
             }
         }
    }
    cout << ans << endl;
}

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

void jump(int *p, int size, int num2)
{
    int i = 1, pre_ans = 0;
    for (; i <= size; i++)
    {
        pre_ans += p[i-1];
        if (pre_ans > num2)
        {
            break;
        }
    }

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

    return;
}

int main()
{
    int num1 = 0, num2 = 0, i = 0;
    char buf[256];
    fgets(buf, 256, stdin);
    sscanf(buf, "%d %d", &num1, &num2);

    int *p = (int*)malloc(num1);
    for (; i < num1; i++)
    {
        scanf("%d", &p[i]);
    }

    jump(p, num1, num2);

    return 0;
}

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

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

    int sum = 1;
    for (int i = 1; i < 1000; i++) {
        if (i % 3 == 0) {
            sum += 200;
        } else {
            sum += 195;
        }
    }

    while (n--) {
        int x, y, z;
        cin >> x >> y >> z;
        int s = 0;
        for (int i = 1; i < x; i++) {
            if (i % 3 == 0) s += 200;
            else s += 195;
        }
        for (int i = 1; i < y; i++) {
            if (x % 3 && i % 2 == 0) s += 19;
            else s += 20;
        }

        s += z;

        cout << sum - s << endl;
    }

    return 0;
}



Measured memory_bytes: 3092
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


H, W, K = MI()
C = [input() for _ in range(H)]

def count(red_x, red_y):
    cnt = 0
    for i in range(H):
        if i in red_x:
            continue
        for j in range(W):
            if j in red_y:
                continue
            if C[i][j] == '#':
                cnt += 1
    return cnt

ans = 0
for i in range(2 ** H):
    red_x = []
    for j in range(H):
        if (i >> j) & 1:
            red_x.append(j)
    for k in range(2 ** W):
        red_y = []
        for l in range(W):
            if (k >> l) & 1:
                red_y.append(l)
        if count(red_x, red_y) == K:
            ans += 1
print(ans)

Measured memory_bytes: 74192
a = int(input())
ar = list(map(int,input().split(" ")))
A = 0
B = 0
while True:
  A += max(ar)
  ar.remove(max(ar))
  if len(ar) == 0:
      break
  B += max(ar)
  ar.remove(max(ar))
  if len(ar) == 0:
      break
print(A - B)

Measured memory_bytes: 3064
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
N = listA[0]
V = listA[1]
C = listA[2]

sumValue = 0
for i in range(N[0]):
  if V[i] > C[i]:
    sumValue += V[i] - C[i]
print(sumValue)

Measured memory_bytes: 3064
#include<cstdio>
int main(){
    
    int a,b;
    scanf("%d %d", &a, &b);
    
    int d,r;
    double f;
    
    d = a / b;
    r = a % b;
    f = (double)a / b;
    
    printf("%d %d %f\n", d, r, f);
    
    return 0;
}


Measured memory_bytes: 2720
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include<bitset>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); ++i)
#define loops(i,f,n) for(int i = (f); i < (n); ++i)
#define INF 999999999
#define llint long long int
#define vec vector<int>
#define vec2 vector<vector<int>>

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	llint a, b, c, k;
	cin >> a >> b >> c >> k;
	cout << (k % 2 == 0 ? a - b : b - a) << endl;
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> x(N);
	vector<int> y(N);

	for (int i = 0; i < N; i++) {
		cin >> x.at(i);
		cin >> y.at(i);
	}

	double sum = 0.0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			sum += sqrt(((double)x.at(i) - x.at(j)) * (x.at(i) - x.at(j)) + (y.at(i) - y.at(j)) * (y.at(i) - y.at(j)));
		}
	}

	double n_kai = 1.0;
	for (int i = 1; i <= N; i++) {
		n_kai *= i;
	}

	double n_minus_1_kai = 1.0;
	for (int i = 1; i < N; i++) {
		n_minus_1_kai *= i;
	}

	printf("%.8f\n", (sum * n_minus_1_kai / n_kai));
}

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Control.Monad

main :: IO ()
main = do
    s <- getLine
    t <- getLine
    let ss = cycle s
    let len = length s
    let rs = fmap (\i -> take len $ drop i ss) [0 .. length s - 1]
    if t `elem` rs
        then putStrLn "Yes"
        else putStrLn "No"

Measured memory_bytes: 508
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  int n, m;
  readf("%s %s\n", &n, &m);

  int d = max(n, m) - min(n, m);

  if (d > 1) {
    writeln("0");
    return;
  }

  long res = 1;
  foreach (i; 2..n+1) {
    res *= i;
    res %= 10^^9 + 7;
  }
  foreach (i; 2..m+1) {
    res *= i;
    res %= 10^^9 + 7;
  }

  if (d == 0) {
    res *= 2;
    res %= 10^^9 + 7;
  }

  res.writeln;
}


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

int main() {
  string s; cin >> s;
  vector<bool> a(26);
  for (auto e: s) {
    if (a.at(e - 'a')) {
      cout << "no" << endl;
      return 0;
    }
    a.at(e - 'a') = true;
  }
  cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i ++){
        cin >> a[i];
        
    }
    int count = 0;
    for(int i = 0; i < n; i ++){
        while(a[i] % 2 ==0){
            a[i] /= 2;
            count ++;
        }
    }
    
    cout << count;
    
    
}


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

int main(){
  char b;
  cin>>b;
  if(b=='A'){
    cout<<'T'<<endl;
  }else if(b=='T'){
    cout<<'A'<<endl;
  }else if(b=='G'){
    cout<<'C'<<endl;
  }else if(b=='C'){
    cout<<'G'<<endl;
  }
}

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

#define DIV 1000000007

long long N;
map<string, long long> dp[105]; //idxまできた時に最後の3文字のpatternとそれぞれの数

bool ok(string str){
	if(str.size() < 2){
		return true;
	}
	if(str.find("AGC") != std::string::npos){
		return false;
	}
	for(long long i = 0; i < str.size() - 1; i++){
		string s = str;
		swap(s[i], s[i+1]);
		if(s.find("AGC") != std::string::npos){
			return false;
		}
	}
	return true;
}

string trim(string str){
	if(str.size() <= 3){
		return str;
	}
	return str.substr(1, 3);
}

int main(){
	cin >> N;
	dp[0][""] = 1;

	for(long long i = 0; i < N; i++){
		for(auto item : dp[i]){
			string str = item.first;
			long long num = item.second;
			num %= DIV;
			if(ok(str + "A")){
				dp[i+1][trim(str+"A")] += num;
			}
			if(ok(str + "C")){
				dp[i+1][trim(str+"C")] += num;
			}
			if(ok(str + "G")){
				dp[i+1][trim(str+"G")] += num;
			}
			if(ok(str + "T")){
				dp[i+1][trim(str+"T")] += num;
			}
		}
	}

	long long ans = 0;
	for(auto item : dp[N]){
		long long num = item.second;
		ans += num;
		ans %= DIV;
	}
	cout << ans << endl;
}


Measured memory_bytes: 896
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int H, W;
string s[2000];
int l[2000][2000], r[2000][2000], u[2000][2000], b[2000][2000];

int brightArea(int i, int j)
{
    if (i < 0 || H <= i || j < 0 || W <= j || s[i][j] == '#')
        return 0;
    int ret = 1;
    FOR (k, 1, H) {
        if (i+k >= H || s[i+k][j] == '#') break;
        ret++;
    }
    FOR (k, 1, H) {
        if (i-k < 0 || s[i-k][j] == '#') break;
        ret++;
    }
    FOR (k, 1, W) {
        if (j+k >= W || s[i][j+k] == '#') break;
        ret++;
    }
    FOR (k, 1, W) {
        if (j-k < 0 || s[i][j-k] == '#') break;
        ret++;
    }
    return ret;
}

void solve()
{
    REP (i, H) {
        FOR (j, 1, W) {
            l[i][j] = (s[i][j-1] == '#' ? 0 : l[i][j-1]+1);
        }
    }
    REP (i, H) {
        REPR (j, W-2) {
            r[i][j] = (s[i][j+1] == '#' ? 0 : r[i][j+1]+1);
        }
    }
    FOR (i, 1, H) {
        REP (j, W) {
            u[i][j] = (s[i-1][j] == '#' ? 0 : u[i-1][j]+1);
        }
    }
    REPR (i, H-2) {
        REP (j, W) {
            b[i][j] = (s[i+1][j] == '#' ? 0 : b[i+1][j]+1);
        }
    }

    int ans = 0;
    REP (i, H) {
        REP (j, W) {
            if (s[i][j] != '#') {
                ans = max(ans, l[i][j]+r[i][j]+u[i][j]+b[i][j]+1);
            }
        }
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    REP(i, H) cin >> s[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 67072
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1'000'000'007;
constexpr ll mod = 998244353;
const double PI = 3.14159265358;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S,T;
  cin >> S >> T;
  vector<int> sum_S(S.size()+1,0);
  for(int i=0; i<S.size(); i++){
    if(S[i] == 'A'){
      sum_S[i+1] = sum_S[i] + 1;
    }else{
      sum_S[i+1] = sum_S[i] + 2;
    }
  }
  vector<int> sum_T(T.size()+1,0);
  for(int i=0; i<T.size(); i++){
    if(T[i] == 'A'){
      sum_T[i+1] = sum_T[i] + 1;
    }else{
      sum_T[i+1] = sum_T[i] + 2;
    }
  }
  int Q;
  cin >> Q;
  for(int i=0; i<Q; i++){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    a--;c--;
    if((sum_S[b]-sum_S[a])%3 == (sum_T[d]-sum_T[c])%3){
      cout << "YES\n";
    }else{
      cout << "NO\n";
    }
  }
  return 0;
}

Measured memory_bytes: 4264
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i,j;
  int n,m;
  cin>>n>>m;
  vi v(n,0);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    v[a]++;
    v[b]++;
  }
  rep(i,n)
    cout<<v[i]<<endl;
 
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program {
  static void Main() {
    var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    var a = arr[0];
    var b = arr[1];
    Console.WriteLine(Math.Max(a + b, Math.Max(a - b, a * b)));
  }
}

Measured memory_bytes: 13268
import math
while True:
	d,w,h = map(int,input().split())
	if d == 0:
		break
	n = int(input())
	dist = [math.sqrt(d**2+w**2), math.sqrt(d**2+h**2), math.sqrt(w**2+h**2)]
	leng = min(dist)
	for i in range(n):
		if 2*int(input())-leng > 0:
			print('OK')
		else:
			print('NA')

Measured memory_bytes: 7760
b = int(input())
a = b % 10

if a == 2 or a == 4 or a == 5 or a == 7 or a == 9 :
  print("hon")
elif a == 0 or a == 1 or a == 6 or a == 8 :
  print("pon")
elif a == 3 :
  print("bon")

Measured memory_bytes: 61872
n=input()
n=(int(n))
for i in range(1,n+1):
    if i%3==0:
        print(" {}".format(i),end='')
    elif i%10==3:
        print(" {}".format(i),end='')
    elif (i//10)%10==3:
        print(" {}".format(i),end='')
    elif (i//100)%10==3:
        print(" {}".format(i),end='')
    elif (i//1000)%10==3:
        print(" {}".format(i),end='')
print("")


Measured memory_bytes: 5872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

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

    cout << 3*n*n << endl;
    return 0;

}


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

int ctoi(char c){
    switch (c){
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default: return 0;
    }
}

int main(){
    string N;
    cin >> N;
    int len = N.size();
    int S_N = 0;
    for (int i = 0; i < len; i++){
        S_N += ctoi(N.at(i));
    }
    int X = stoi(N);
    if (X % S_N == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>
#include <iomanip>

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

// typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


// LRUD
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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

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

bool pairCompare(const P& firstElof, const P& secondElof){
    // return firstElof.second > secondElof.second;
    return firstElof.second < secondElof.second;
}

int main(int argc, char**argv){
    int n, m;
    cin >> n >> m;

    vector<pair<pair<int, int>, int> > py;
    for (int i = 0; i < m; i++){
        int p, y;
        cin >> p >> y;
        py.push_back(make_pair(make_pair(p, y), i));
    }

    sort(py.begin(), py.end());

    int former_p = -1;
    int year_counter = 1;
    for (int i = 0; i < m; i++){
        int pref = py[i].first.first;
        int year = py[i].first.second;
        if (former_p == pref){
            year_counter++;
        }else{
            former_p = pref;
            year_counter = 1;
        }
        py[i].first.second = year_counter;
    }

    sort(py.begin(), py.end(), pairCompare);

    for (int i = 0; i < m; i++){
        int fi = py[i].first.first;
        int se = py[i].first.second;
        cout << setw(6) << setfill('0') << fi;
        cout << setw(6) << setfill('0') << se;
        cout << endl;
    }

    return 0;
}

















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

int main() {
  int n, k, ridable = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    if (h >= k) ridable++;
  }
  cout << ridable << endl;
}

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

int main() {
    ll n;
    cin >> n;
    vector<ll> num(n);
    for (int i = 0; i < n; ++i) cin >> num.at(i);
    int ans = 1;
    int minimum = num.at(0);
    for (ll j = 1; j < n; ++j) {
        if (num.at(j) < minimum) {
            ans++;
            minimum = num.at(j);
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" );
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+9, LINF = 1e18;


int main()
{
    ll a,b,x=1;
    cin>>a>>b;
    rep(i,a)x*=100;
    b+=(b==100);
    cout<<x*b<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979323846;

// 素因数分解(素因数とその指数を返す)
map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i=2; i*i<=n; i++) {
    while (n%i==0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n!=1) ret[n] = 1;
  return ret;
}

int main() {
  ll N;
  cin >> N;
  map<ll, int> dict; // N!の素因数分解
  for (ll i=2; i<=N; i++) {
    map<ll, int> dict2 = prime_factor(i);
    for (auto p: dict2) {
      auto key = p.first;
      auto value = p.second;
      if (dict.count(key)) dict[key] += value;
      else dict[key] = value;
    }
  }
  ll res = 1;
  for (auto p: dict) {
    auto value = p.second;
    res = res*(value+1)%MOD;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

int A;
int N[200005];
signed main(){
    scanf("%lld",&A);
    rep(i,A)scanf("%lld",&N[i]);
    sort(N,N+A);
    rep(i,A-1){
        if(N[i]==N[i+1]){
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>

void trace(int A[],int N){
	int i;
	for(i=0;i<N;i++){
		if(i>0)printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

void sort(int A[],int N){
	int i,j,v;
	for(i=1;i<N;i++){
		v=A[i];
		j=i-1;
		while(j>=0 && A[j]>v){
			A[j+1]=A[j];
			j--;
		}
			A[j+1]=v;
		trace(A,N);
	}
}

int main(void){
	int A[100];
	int N,i,j;
	
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%d",&A[i]);
	
	trace(A,N);
	sort(A,N);
	
	return 0;
}

Measured memory_bytes: 604
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define srch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    string a,b;
    while(cin>>a)
    {
        s=c=0;
        c=INT_MAX;
        for(i=0;i<a.sz-2;i++)
        {
            x=0;
            x=a.at(i)-48;
            x=x*10+a.at(i+1)-48;
            x=x*10+a.at(i+2)-48;
            x=abs(753-x);
            if(x<c)
            {
                c=x;
            }
        }
        cout<<c<<en;
    }
}



Measured memory_bytes: 256
//30
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    string f[10];
    int w[10],s[10];
    for(int i=0;i<n;i++){
      cin>>f[i]>>w[i]>>s[i];
    }
    int x[]={0,1,2,3,4,5,6,7,8,9};
    int ans[10];
    double g=1<<30;
    do{
      bool f=true;
      for(int i=0;i<n;i++){
	int ws=0;
	for(int j=i+1;j<n;j++){
	  ws+=w[x[j]];
	}
	f&=s[x[i]]>=ws;
      }
      if(f){
	double ww=0;
	double ws=0;
	for(int i=0;i<n;i++){
	  ww+=(i+1)*w[x[i]];
	  ws+=w[i];
	}
	if(ww/ws<g){
	  g=ww/ws;
	  copy(x,x+n,ans);
	}
      }
    }while(next_permutation(x,x+n));
    for(int i=0;i<n;i++){
      cout<<f[ans[i]]<<endl;
    }
  }
  return 0;
}

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

typedef long long ll;

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

    int n; cin >> n;
    map<int,int> mp;
    for(int i=0;i<n;i++){
        int d;
        cin >> d;
        mp[d]++;
    }
    int m; cin >> m;
    vector<int> t(m);
    for(int i=0;i<m;i++) cin >> t[i];
    for(int i=0;i<m;i++){
        if(mp[t[i]]<1){
            cout << "NO" << endl;
            return 0;
        }else mp[t[i]]--;
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <algorithm>
using namespace std;
int n, ans;
string a[305];

int chk() {
	int i, j;
	for(i=0; i<n; i++) for(j=i+1; j<n; j++) if(a[i][j] != a[j][i]) return 0;
	return 1;
}

int main() {
	int i, j;
	cin>>n;
	for(i=0; i<n; i++) cin>>a[i];
	for(i=0; i<n; i++) {
		ans += chk();
		for(j=0; j<n; j++) rotate(a[j].begin(), a[j].begin()+1, a[j].end());
	}
	cout<<ans*n;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include "cpp/Solution.h"

using namespace std;


int main() {
    int Z = 'Z';
    int a = 'a';

    char in;

    cin >> in;

    if(in >= a){
        cout << 'a';
    }else{
        cout << 'A';
    }

    return 0;
}





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

using namespace std;

int main(void) {
	cin.tie(nullptr); ios::sync_with_stdio(false);
	int Km, N; cin >> Km >> N;

	vector<int> HOME; HOME.resize(N);

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

	int dis_min = HOME[N - 1] - HOME[0];
	for (int i = 1; i < N; i++) {
		int comparison;
		comparison = HOME[N - 1] - HOME[i];
		if (comparison < dis_min) {
			comparison += HOME[i-1] + Km - HOME[N - 1];
			if (comparison < dis_min) {
				dis_min = comparison;
			}
		}
	}
	
	cout << dis_min << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    ll h,w;
    cin >> h >> w;

    ll ans = 1LL<<60;
    if (h % 3 != 0 && w % 3 != 0) {
        REP(_,2) {
            ll s1,s2,s3,s;
            FOR(i,1,h) {
                s1 = i * w;
                s2 = (h - i) * (w / 2);
                s3 = (h - i) * (w - w / 2);
                s = max(s1,max(s2,s3)) - min(s1,min(s2,s3));
                ans = min(ans,s);
                
                ll h2 = h - i;
                s2 = (h2 / 2) * w;
                s3 = (h2 - h2 / 2) * w;
                s = max(s1,max(s2,s3)) - min(s1,min(s2,s3));
                ans = min(ans,s);
            }
            swap(h,w);
        }
    } else {
        ans = 0;
    }

    cout << ans << endl;

    return 0;
}

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

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var answer = 0;
            var dict = new Dictionary<int, int>();
            for (var i = 0; i < A.Length; i++)
            {
                if (dict.ContainsKey(A[i])) dict[A[i]]++;
                else dict[A[i]] = 1;
            }

            foreach (var val in dict.Keys)
            {
                var tmp = dict[val];
                tmp += dict.ContainsKey(val - 1) ? dict[val - 1] : 0;
                tmp += dict.ContainsKey(val + 1) ? dict[val + 1] : 0;
                answer = Math.Max(answer, tmp);
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 37472
#include <stdio.h>
int main (void)
{int  a[114],b[514],m,n;
 scanf("%d %d %d",&a[1],&a[2],&a[3]);
 for(n=1;n<3;n++){
 	for(m=1;m<3;m++){
 		if(a[m]>a[m+1]){
 		b[m]=a[m];
 		b[m+1]=a[m+1];
 		a[m]=b[m+1];
 		a[m+1]=b[m];

}

}
 
}
printf("%d %d %d\n",a[1],a[2],a[3]);

return 0;
}

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

#define task "D" //ABC132
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (ll i = (r); i >= (l); --i)
#define pb push_back
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;

// Limit
const ll mod=1e9+7;
// Struct

// Variables
ll n,k,gt[2004],igt[2004];
// Function
ll power(ll x,ll y,ll mod)
{
    ll res=1;
    x%=mod;
    while (y)
    {
        if (y&1) res=res*x%mod;
        x=x*x%mod;
        y>>=1;
    }
    return res;
}
int main()
{
	//freopen(task".in","r",stdin);
	//freopen(task".out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	cin >> n >> k;
	gt[0]=1;
	ll mx=max(k,n-k+2);
	rep(i,1,mx+1) gt[i]=gt[i-1]*i%mod;
	igt[mx+1]=power(gt[mx+1],mod-2,mod);
	Rep(i,mx,0) igt[i]=igt[i+1]*(i+1)%mod;
	rep(i,1,k)
	{
	    if (i>n-k+1) cout << "0\n";
	    else
        {
            cout << ((((((gt[k-1]*igt[i-1]%mod)*igt[k-i])%mod)*gt[n-k+1])%mod)*igt[i]%mod*igt[n-k-i+1])%mod << '\n';
        }
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

bool solve(ll K, ll X, const vector<ll>& v){
  ll mn = 100000000000000000LL;
  ll sum = 0;
  int s = 0, t = 0;
  while(true){
    while(t<v.size() && X+sum < K){
      sum += v[t];
      t++;
    }
    if(X+sum >= K) mn = min(mn, X+sum);
    if(t == v.size()) break;
    if(X+sum < K) break;
    if(s >= v.size()) break;
    sum -= v[s];
    s++;
  }

  if(mn-X >= K) return true;
  return false;
}


int main(){
  int N;
  ll K;
  vector<ll> v;
  cin >> N >> K;

  ll sum = 0;
  rep(i,N){
    ll x;
    cin >> x;
    v.push_back(x);
    sum += x;
  }

  ll ret = 0;
  vector<ll> w(N-1);
  rep(i,v.size()){
    int cnt = 0;
    rep(j,v.size()){
      if(i==j) continue;
      w[cnt++] = v[j];
    }
    sort(ALLOF(w));
    if(solve(K, v[i], w)) ret++;
  }

  cout << ret << endl;
  
  return 0;
}


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

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    int * a = new int[n];
    int * b = new int[m];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < m; i++)
        cin >> b[i];
    int idxA = 0, idxB = 0, rest = k;
    while (a[idxA] <= rest && idxA < n)
    {
        rest -= a[idxA];
        idxA++;
    }
    while (b[idxB] <= rest && idxB < m)
    {
        rest -= b[idxB];
        idxB++;
    }
    int max = idxA + idxB;
    while (idxA > 0)
    {
        rest += a[idxA - 1];
        while (b[idxB] <= rest && idxB < m)
        {
            rest -= b[idxB];
            idxB++;
        }
        idxA--;
        if (idxA + idxB > max)
            max = idxA + idxB;
    }
    cout << max << endl;
}


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

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

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int main() {
    int a = iin(), b = iin(), c = iin();
    stout(((a + b == c) || (b + c == a) || (c + a == b)) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
    int dice[7], i, j, k, above, front, right[25], question;
    int side[5]={2,3,5,4,2};
    char order[7][3] = {"","","N","W","E","S","NN"};
    
    for(i=1; i<=6; i++){
        scanf("%d", &dice[i]);
    }
    scanf("%d", &question);
    
    for(i=0; i<question; i++){
        scanf("%d %d", &above, &front);
        
        //上面を見つける
        for(j=1; dice[j]!=above; j++);
        
        //回転させて上面を合わせる
        for(k=0; order[j][k]!='\0'; k++){
            
            dice[0]=dice[1];
            switch(order[j][k]){
                case 'E' :  dice[1]=dice[4];
                            dice[4]=dice[6];
                            dice[6]=dice[3];
                            dice[3]=dice[0];
                            break;
                case 'N' :  dice[1]=dice[2];
                            dice[2]=dice[6];
                            dice[6]=dice[5];
                            dice[5]=dice[0];
                            break;;
                case 'S' :  dice[1]=dice[5];
                            dice[5]=dice[6];
                            dice[6]=dice[2];
                            dice[2]=dice[0];
                            break;
                case 'W' :  dice[1]=dice[3];
                            dice[3]=dice[6];
                            dice[6]=dice[4];
                            dice[4]=dice[0];
                            break;
            }
        }
        for(j=0; front!=dice[side[j]]; j++);
        right[i]=dice[side[j+1]];
    }
    
    for(i=0; i<question; i++)
    printf("%d\n", right[i]);
    
    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '1')
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384