akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
class Main {
    static int N,M;
    static int[] visited, x,y,edges;
    static int[][] graph;
    static int ans;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        visited = new int[N+1];
        edges = new int[M];
        graph = new int[N+1][N+1];
        for(int i = 1; i<N+1; i++) visited[i] = -1;
        x = new int[M];
        y = new int[M];
        for(int i = 0; i<M; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            graph[x[i]][y[i]] = graph[y[i]][x[i]] = 1;
        }

        for(int i = 0; i<M; i++) {
            for(int j = 1; j<N+1; j++) visited[j] = -1;
            graph[x[i]][y[i]] = graph[y[i]][x[i]] = 0;
            dfs(1);
//            System.out.println();
//            for(int v: visited) System.out.print(v);
//            System.out.println();
            for(int j = 0; j<N+1; j++) {
                if(visited[j] == 1) continue;
                if(visited[j] == -1) {
                    ans++;
                    break;
                }
            }
            graph[x[i]][y[i]] = graph[y[i]][x[i]] = 1;
        }
        System.out.println(ans);
    }
    public static void dfs(int node) {
        if(visited[node]==1) return;
        //System.out.print(node+" ");
        if(visited[node] == -1) {
            visited[node] = 1;
        }
        for(int i = 0; i<N+1; i++) {
            if(graph[node][i] == 1) dfs(i);
        }
    }
}

Measured memory_bytes: 21844
#!/usr/bin/env python3 
# coding=utf_8

n = int(input())
adata = input().split()
data = list(map(int, adata))
count = 0

flag = True
while flag:
    flag = False
    for i in range(len(data)-1,0,-1):
        if data[i] < data[i-1]:
            tmp = data[i]
            data[i] = data[i-1]
            data[i-1] = tmp
            count +=1
            flag = True
ans = ""
for s in data:
    if ans != "":
        ans = ans+ " "
    ans = ans + str(s)



print(ans)
print(count)




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

int main(){
	int N,Y;
	cin>>N>>Y;
	
	int A,x,y,z;
	double tz;
	for(int i=0;i<=N;i++){
		x=i;
		for(int j=0;j<=N;j++){
			y=j;
			A=10000*x+5000*y;
			z=(Y-A)/1000;
			tz=((double)Y-(double)A)/(double)1000;
			if(z==tz&&z<=N&&Y==10000*x+5000*y+1000*z&&N==x+y+z&&z>=0){
				cout<<x<<' '<<y<<' '<<z<<endl;
				return 0;
			}
		}
	}
	cout<<"-1"<<' '<<"-1"<<' '<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(raw_input())

if N == 3:
    print 2
    print 1, 3
    print 2, 3

elif N & 1:
    a = 0
    for i in range(1, N ):
        for j in range(i + 1, N):
            if i != N - j:
                a += 1
    
    for i in range(1, N):
        a += 1


    print a
    for i in range(1, N ):
        for j in range(i + 1, N):
            if i != N - j:
                print i, j
    
    for i in range(1, N):
        print i, N

else:
    a = 0
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            if i != N - j + 1:
                a += 1

    print a
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            if i != N - j + 1:
                a += 1
                print i, j
    


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

int main(){
  int N,K;
  cin >> N >> K;
  map<char,int> mp;
  for(int i = 0;i < K;i++){
    int d;
    cin >> d;
    mp[char(d + '0')] = 1;
  }

  for(int i = N;;i++){
    string s = to_string(i);
    bool flag = true;

    for(int j = 0;j < s.size();j++){
      if(mp[s[j]] == 1){
        flag = false;
        break;
      }
    }

    if(flag){
      cout << s << endl;
      return 0;
    }
  }


}


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


int main (){
    string S;
    cin>>S;
    int Longest =0;
    int Count =0;
    for(int i=0; i<S.size(); i++){
        if(S.at(i)=='A'||S.at(i)=='T'||S.at(i)=='C'||S.at(i)=='G'){
            Count ++;
        }
        else{
            Longest=max(Longest, Count);
            Count = 0;
        }
    }
    Longest=max(Longest, Count);
    cout<<Longest<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,a;
  cin>>h>>a;
  if(h<=a)cout<<1;
  else if(h>a){
    if(h%a==0)cout<<h/a;
  	else if(h%a!=0)cout<<h/a+1;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main(){

    ll A, B;
    cin >> A >> B;

    cout << (A * (A-1)) / 2 + (B * (B-1)) / 2 << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int i=0;
	while(a>0)
	{
		i++;
		a-=b;
	}
	cout<<i<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	char c, d = 'A' - 'a';
	while (cin.get(c)){
		if (c == '\n') break;
		if ('a' <= c && c <= 'z') c += d;
		cout << c;
	}
	cout << "\n";
	return 0;
}

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

int main() {
	vector<P>v;
	string s; cin >> s;
	if (s.size() <= 2) { puts("0"); return 0; }
	int cnt = 0; char back = s[0];
	for (char c : s) {
		if (c == back)cnt++;
		else {
			v.push_back(P(back, cnt));
			cnt = 1; back = c;
		}
	}
	v.push_back(P(back, cnt));
	int Max = 0;
	if (v.size() <= 2) { puts("0"); return 0; }
	rep(i, v.size() - 2) {
		if (v[i].first == 'J'&&v[i + 1].first == 'O'&&v[i + 2].first == 'I'&&v[i + 1].second <= v[i].second&&v[i + 1].second <= v[i + 2].second) {
			Max = max(Max, v[i + 1].second);
		}
	}
	cout << Max << endl;
	return 0;
}

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

#define SZ(v) ((int)(v).size())
using ll = long long;

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

	ll base  = 202;
	ll p = 1;
	ll mod = 2019;

	map<ll, int> cnt;
	string s;
	cin >> s;
	int n = SZ(s);
	cnt[0]++;
	ll ans(0);
	ll cur(0);
	for (int i = 0; i < n; ++i)
	{
		cur = (cur + (s[i]-'0')*p)%mod;
		ans += cnt[cur];
		cnt[cur]++;
		p = (p*base)%mod;
	}
	cout << ans << endl;
}


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

using namespace std;

set<char>s;

int main()
{
    int n;
    char c[101];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>c[i];
        s.insert(c[i]);
    }
    if(s.size()==3) cout<<"Three";
    else cout<<"Four";
    return 0;
}


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

using namespace std;

int main()
{
    int a[100010]={0},n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int s=-1,x;
    for(int i=0;i<n-1;i++)
    {
        if(s<a[i])
        {
            s=a[i];
            x=i;
        }
    }
    int flag=0;
    for(int i=x;i<n;i++)
    {
        if(s-a[i]>=2)
        {
            flag=1;
            break;
        }
    }
    if(flag==1)cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 640
type ball_t = {
  word : string;
  number : int;
}

let balls s_type t_type u =
  match s_type with {word = s_w; number = s_n}
    -> match t_type with {word = t_w; number = t_n}
      -> if s_w = u then (s_n - 1, t_n) else (s_n, t_n -1)

let s, t = Scanf.sscanf (read_line ()) "%s %s" (fun s t -> (s, t))
let a, b = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> (a, b))
let s_type = {word = s; number = a}
let t_type = {word = t; number = b}
let u = read_line ()

let () = let ans_s, ans_t = balls s_type t_type u in
  Printf.printf "%d %d\n" ans_s ans_t

Measured memory_bytes: 3844
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;
	ll min2 = min({ 8 * Q,4 * H,2 * S,D });
	ll res = (N / 2)*min2;
	if (N % 2) res += min({ 4 * Q, 2 * H, S });
	cout << res << "\n";

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	string s;
	cin >> s;
	int a[s.length()];
	int b=0,c=0,min=0;;
	
	for(int i=0;i<s.length();i++){
		for(int j=0;j<10;j++){
			if(s[i] == 48+j){
					a[i]=j;
			}
		}
		//cout << a[i] << endl;
	}
	
	for(int i=0;i<s.length()-2;i++){
		for(int j=i;j<i+3;j++){
			b += a[j]*pow(10,2-(j-i));
		}
		//cout << b << endl;
		c=(753-b)*(753-b);
		b=0;
		if(i==0){
			min=c;
		}else if(i>0){
			if(c<min)min=c;
		}
	}
	cout << sqrt(min) << endl;
	return 0;
}


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

ll n , x;
ll a[55], p[55]; ///バーガーの厚さと含まれるパティの数を入れる配列


ll dfs(ll N, ll X){
  if (N == 0) return 1;
  else if (X <= N) return 0;
  else if (X > 1 && X <= 1 + a[N-1]) return dfs(N-1, X-1);
  else if (X == 2 + a[N-1])  return p[N-1] + 1;
  else if (X > 2 + a[N-1] && X <= 2 + 2 * a[N-1]) {return p[N-1] + 1 + dfs(N-1, X-2-a[N-1]);}
  else if (X == 3 + 2 * a[N-1]) return 2 * p[N-1] + 1;
}

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

  a[0] = 1;
  p[0] = 1;
  rep(i, n) a[i + 1] = 2 * a[i] + 3;
  rep(i, n) p[i + 1] = 2 * p[i] + 1;
  ll ans = dfs(n, x);

  cout << ans << endl;


}


Measured memory_bytes: 3616
# inputを取得
A = []
for i in range(3):
  A.append(list(map(int, input().split())))
# A[0][0] A[0][1] A[0][2]
# A[1][0] A[1][1] A[1][2]
# A[2][0] A[2][1] A[2][2]

N = int(input())
b = []
for i in range(N):
  b.append(int(input()))

# bingoになる組み合わせを保持
C = []
C.append(A[0]) # 1行目
C.append(A[1]) # 2行目
C.append(A[2]) # 3行目
C.append([A[0][0], A[1][0], A[2][0]]) # 1列目
C.append([A[0][1], A[1][1], A[2][1]]) # 2列目
C.append([A[0][2], A[1][2], A[2][2]]) # 3列目
C.append([A[0][0], A[1][1], A[2][2]]) # 左上から斜め
C.append([A[0][2], A[1][1], A[2][0]]) # 右上から斜め

# bingoか判定
flag = False
for c in C:
  # c = [1, 2, 3]
  # b = [1, 2, 3, 4, 5, …]
  # 重複する要素が3だったらbingo
  if len(list(set(c) & set(b))) == 3:
    flag = True
    # 1個でもbingoならチェック終了
    break

# 結果をoutput
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{

public static void main(String[] args) {
  Scanner scanner = new Scanner(System.in);
  String parm = scanner.next();
  
  int i = Integer.parseInt(parm)%10;
  
  if (i == 3) {
    System.out.print("bon");
  } else if(i == 0 || i == 1 || i == 6 || i == 8) {
    System.out.print("pon");
  } else {
    System.out.print("hon");
  }
}
}

  

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

int A[1000000], *G;

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

void shellSort(int n)
{
  int cnt = 0, m, i, j = 0;
  G = malloc(n * sizeof(int));
  for(i = 1;;)
    {
      if(i > n)
	{
	  break;
	}
      G[j] = i;
      j++;
      i = 3 * i + 1;
    }
  m = j;
  for(i = m - 1; i >= 0; i--)
    {
      insertionSort(n, G[i], &cnt);
    }
  printf("%d\n", m);
  for(i = m - 1; i >= 0; i--)
    {
      printf("%d", G[i]);
      if(i) printf(" ");
    }
  printf("\n%d\n", cnt);
  for(i = 0; i < n; i++)
    {
      printf("%d\n", A[i]);
    }
}

int main()
{
  int n, i;
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      scanf("%d", &A[i]);
    }
  shellSort(n);
  return 0;
}



Measured memory_bytes: 5616
n = int(input())
lis = []
for i in range(n):
  a,b = map(int,input().split())
  ke = a + b
  lis.append([a,b,ke])
lis.sort(key = lambda x:x[2],reverse = True)
takahashi = 0
aoki = 0
for i in range(n):
  if i % 2 == 0:takahashi += lis[i][0]
  else:aoki += lis[i][1]
print(takahashi -aoki)

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

const long long INF = 1e18;

long long dp[5001];
pair<int, int> a[5000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    for (int i=0; i<n; i++)
        cin >> a[i].first >> a[i].second;

    sort(a, a + n, [] (const pair<int, int> &pa, const pair<int, int> &pb) {
        return pa.first + pa.second < pb.first + pb.second;
    });

    memset(dp, 127, sizeof(dp));
    dp[0] = 0;
    for (int i=0; i<n; i++)
        for (int j=n-1; j>=0; j--)
            if (a[i].first >= dp[j])
                dp[j+1] = min(dp[j+1], dp[j] + a[i].second);

    for (int j=n; j>=0; j--)
        if (dp[j] < INF) {
            cout << j << "\n";
            break;
        }

    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
typedef long long ll;
int n,k,a[100002];
ll sum[100002];
const int INF = 1<<28;

void solve() {
  rep(i,n) cin>>a[i];
  sum[0]=0;
  rep(i,n) sum[i+1]=sum[i]+a[i];
  ll ans = -INF;
  //rep(i,n+1) cout<<sum[i]<<endl;
  for(int i=0; i+k<=n; ++i) {
    ans = max(ans, sum[i+k]-sum[i]);
  }
  cout<<ans<<endl;
}
int main() {
  while(cin>>n>>k,n) solve();
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1000100100;

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

    vector<ll> cnts(26, 0);
    REP(i, w.length()) {
        ll id = (ll)w[i] - (ll)'a';
        ++cnts[id];
    }

    REP(i, cnts.size()) {
        if(cnts[i] % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(){
  string str;
  cin>>str;
  stack <int> stk,sstk,h,ans;  
  int cnt=0,sum=0;
  str+='\\';
  for(int i=0;i<str.size();i++){
    if(str[i]=='\\')stk.push(i);
    if(stk.size()&&str[i]=='/')cnt+=i-stk.top(),stk.pop();
    if(str[i]=='\\'&&cnt){
      sum+=cnt;
      while(h.size()&&h.top()>stk.size())cnt+=sstk.top(),sstk.pop(),h.pop();
      sstk.push(cnt);
      h.push(stk.size());
      cnt=0;
    }
  }
  while(!sstk.empty())ans.push(sstk.top()),sstk.pop();
 
  cout <<sum<<endl<<ans.size();
  while(!ans.empty())cout <<" "<<ans.top(),ans.pop();
  cout <<endl;
}

Measured memory_bytes: 3252
if __name__ == '__main__':
    x, y, z = (int(_) for _ in input().split(' '))
    a = max((x, y, z))
    if a == x:
        b, c = y, z
    elif a == y:
        b, c = x, z
    elif a == z:
        b, c = x, y
    print(abs(a // 2 * b * c - (a - a // 2) * b * c))


Measured memory_bytes: 3064
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

def gcd(u, v):
    while v:
        u, v = v, u%v
    return u

def gcds(a, b, c):
    return gcd(a, gcd(b, c))
  
s = 0
k = ni()
for i in range(1, k+1):
    for j in range(1, k+1):
        for l in range(1, k+1):
            s += gcds(i, j, l)
print(s)


Measured memory_bytes: 69036
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a, b):
    return (a * b)//gcd(a,b)

N = int(input())
T = [int(input()) for i in range(N)]

ans = 1
for i in T:
    ans = lcm(ans,i)

print(ans)

Measured memory_bytes: 3060
n,m = (int(i) for i in input().split())
a = [int(input()) for i in range(m)]
mod = 1000000007
oks = [True for _ in range(n+1)]
for i in a:
    oks[i] = False
dp = [1,0]
dp[1] = 1 if oks[1] is True else 0
for i in range(2,n+1):
    if oks[i] is True:
        dp.append((dp[i-1]+dp[i-2])%mod)
    else:
        dp.append(0)
print(dp[n])


Measured memory_bytes: 8600
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m,f,r;	//??????????¨??????????????¨???????????¨?????????°
		StringBuilder sb = new StringBuilder();
		
		while (true) {
			m=sc.nextInt();
			f=sc.nextInt();
			r=sc.nextInt();
			
			//-1 -1 -1?????¨?????????
			if(m==-1 && f==-1 && r==-1){
				break;
			}
			
			//??????
			if(m==-1 || f==-1){
				//F
				System.out.println("F");
			}
			else if (m+f >= 80) {
				//A
				System.out.println("A");
			}
			else if (m+f >= 65 && m+f < 80) {
				//B
				System.out.println("B");
			}
			else if (m+f >= 50 && m+f < 65) {
				//C
				System.out.println("C");
			}
			else if (m+f >= 30 && m+f < 50) {
				if (r >= 50) {
					//C
					System.out.println("C");
				}
				else {
					//D
					System.out.println("D");
				}
			}
			else if (m+f < 30) {
				//F
				System.out.println("F");
			}
			
		}
	}
}

Measured memory_bytes: 19244
#include<bits/stdc++.h>
#define pi 3.141592653589793238463
using namespace std;

int main(){
  	int n,m;
  	cin>>n>>m;
  	int sum=0;
  	for(int i=0;i<m;i++){
  	    int x;
  	    cin>>x;
  	    n-=x;
  	}
  	if(n<0) cout<<-1;
  	else cout<<n;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  char s[101];
  for(int i=0; i<n; i++) {
    cin >> s[i];
    if(s[i]=='Y'){
      cout << "Four";
      return 0;
    }
  }
  cout << "Three";
  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, L;
  cin >> N >> L;
  string v[102];
  rep(i, 0, N) { cin >> v[i]; }
  sort(v, v + N);
  rep(i, 0, N) { cout << v[i]; }
  cout << endl;
  getchar();
}

Measured memory_bytes: 3676
#include<iostream>
#include<string>
using namespace std;
int main() {
	int p = 0, x = 0;
	string  s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
			for (int j = i; j < s.size(); j++) {
				if (s[j] == 'A' || s[j] == 'T' || s[j] == 'G' || s[j] == 'C')p++;
				else break;
			}
		}
		if (x < p)x = p;
		p = 0;
	}
		
		cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

    int i;
    int j;
    int width;
    int height;

    while(1) {
        scanf("%d %d", &height, &width);
        
        if(width == 0 && height == 0) {
            break;
        }

        for(i = 0; i < height; i++) {
            for(j = 0; j < width; j++) {
                putchar('#');
            }
            printf("\n");
        }
        
        printf("\n");
    } 

    return 0;
}

Measured memory_bytes: 576
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define P pair<ll,ll>

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repd(i,n) for(ll i = (n); i >= 0; i--)
#define FOR(i,t,n) for(ll i = (t); i < (n); i++)
#define FORD(i,t,n) for(ll i = (n); i >= t; i--)
#define ALL(x) x.begin(),x.end()
#define asort(x) sort(ALL(x))

int main() {
    int N, ans = 0;
    cin >> N;
    int a[101];
    rep(i,N) cin >> a[i];
    for(int i = 0; i < N; i+=2) {
        if(a[i] % 2 == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
int maxtime(int x) {
	return (x + 9) / 10 * 10;
}
int remtime(int x) {
	return maxtime(x) - x;
}
int main() {
	int A, B, C, D, E;
	cin >> A >> B >> C >> D >> E;
	int sum = maxtime(A) + maxtime(B) + maxtime(C) + maxtime(D) + maxtime(E);
	sum -= max({ remtime(A), remtime(B), remtime(C), remtime(D), remtime(E) });
	cout << sum << endl;
	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, m; cin >> n >> m;
    ll tot = 0;
    for (int i = 0; i < m; i++) {
        int ai; cin >> ai;
        tot += ai;
    }
    if (tot > n) {
        cout << -1 << '\n';
    }
    else cout << (n-tot) << '\n';
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

ll nCm_array[1000][1000]; // nCm_array[6][2]  = 6C2,  nCm_array[9][9] = 9C9
void nCm(void)
{
	ll i, j;
	for (i = 0; i < 1000; i++)
	{
		for (j = 0; j <= i; j++)
		{
			ll ans;
			if ((j == 0) || (j == i))
				ans = 1;
			else
				ans = nCm_array[i - 1][j] + nCm_array[i - 1][j - 1];
			nCm_array[i][j] = ans;
		}
	}
}

int main() {
	nCm();
	string N;
	cin >> N;
	int K;
	cin >> K;
	int Nlen = N.length();
	ll ans = 0;
	ll aa = 0;
	rep(i, Nlen) {
		if (N[i] != '0')
			aa++;
	}
	if (aa == K)
		ans++;
	int deccount = 0;
	rep(i, Nlen) {
		int n = (int)N[i] - (int)'0';
		rep(j, n) {
			if (j == 0) {
				if (K - deccount >= 0) {
					ll anstmp = nCm_array[Nlen - i - 1][K - deccount];
					rep(l, K - deccount)
						anstmp *= 9LL;
					ans += anstmp;
				}
			}
			else {
				if (K - deccount - 1 >= 0) {
					ll anstmp = nCm_array[Nlen - i - 1][K - deccount - 1];
					rep(l, K - deccount - 1)
						anstmp *= 9LL;
					ans += anstmp;
				}
			}
		}
		if (n != 0)
			deccount++;
	}
	cout << ans << endl;

	return 0;
}

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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) a.begin(), a.end()
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {	
	map<string,int> mp;
	int N,M;
	cin >> N;
	int mx = 0;
	for (int i = 0; i < N; ++i) {
		string s;
		cin >> s;
		mp[s]++;
	}

	cin >> M;
	for (int i = 0; i < M; ++i) {
		string s;
		cin >> s;
		mp[s]--;
	}

	for (auto x : mp) {
		mx = max(mx,x.second);
	}
	cout << mx << '\n';

}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////


Measured memory_bytes: 256
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

void IO(){
#ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
#endif 
}

int32_t main(){
   boost;
   IO();

   int N,X,T; cin>>N>>X>>T;
   cout << (int)ceil((ld)N/X)*T << endl;
	

   return 0;
}



Measured memory_bytes: 3648
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    bool flg = true;
    vector<int> t(n+1, 0);
    vector<int> x(n+1, 0);
    vector<int> y(n+1, 0);
    rep(i, n) cin >> t[i+1] >> x[i+1] >> y[i+1];
    rep(i, n) {
        if (abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]) > t[i+1] - t[i]) {
            flg = false;
        }
        else if ((abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]) - (t[i+1]-t[i]))%2 != 0) {
            flg = false;
        } 
    }
    cout << ((flg) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 4148
N,A,B,C = map(int,input().split())
l = [int(input()) for _ in range(N)]
INF = 10**10

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(c-C) -30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))


Measured memory_bytes: 3064
function*stdinIter(){const t=require("fs").readFileSync("/dev/stdin","utf-8").trim().split(/\n|\s/);yield*t}function readMany(t,e){const i=e||this.iter||(this.iter=stdinIter()),n=[];for(let e=0;e<t;e+=1)n.push(i.next().value);return n};

(() => {
    // 鶴亀算を忘却した顔

    const [ x, y ] = readMany(2).map(it => parseInt(it))

    if (2 * x <= y && y <= 4 * x && y % 2 == 0) {
        console.log('Yes')
    } else {
        console.log('No')
    }
})()


Measured memory_bytes: 29692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

void dfs(int s,int p,int d,vector<int> &dist,vector<int> &parent,vector<vector<int> > &G){
    parent[s]=p;
    dist[s]=d;
    for(auto v:G[s]){
        if(v!=p) dfs(v,s,d+1,dist,parent,G);
    }
}

int rec(int s,vector<int> &num,vector<int> &parent,vector<vector<int>> &G){
    if(num[s]!=-1)return num[s];
    else {
        int tmp=1;
        for(auto v:G[s]){
            if(v!=parent[s])tmp+=rec(v,num,parent,G);
        }
        num[s]=tmp;return num[s];
    }
}

int main(){
    int N;cin>>N;
    vector<vector<int> > G(N);
    int a,b;
    REP(i,N-1){
        cin>>a>>b;a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> parent(N);
    vector<int> dist(N),num(N,-1);    
    dfs(0,-1,0,dist,parent,G);
    int u=N-1;
    REP(i,(dist[N-1]+1)/2-1)u=parent[u];
    cout<<(rec(u,num,parent,G)>=(N%2==0?N/2:N/2+1)?"Snuke":"Fennec")<<endl;
    return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if((a == 1 || a== 2) && (b == 1 || b== 2) ){
    cout << 3;
  }else if((a == 2 || a== 3) && (b == 2 || b== 3)){
    cout << 1;
  }else{
    cout << 2;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);

      int numFriends = sc.nextInt();

      int cent = sc.nextInt();

      int yes = 0;

      for(int i = 0; i < numFriends; i++) {
          int height = sc.nextInt();
          if (height >= cent) {
            yes++;
          }
      }

      System.out.print(yes);


    }
}

Measured memory_bytes: 48420
#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;cin>>s;
  map<char, int> logger;
  for(char c='a';c<='z';c++)logger[c]=-1;

  rep(i, s.size()){
    char c = s[s.size()-1-i];
    if(logger[c]>=0)continue;

    int counter=i;
    for(int j=s.size()-1-i;j>=0;j--){
//cout<<c<<s[j]<<i<<j<<counter<<endl;
      if(s[j]==c){
        logger[c] = max(logger[c], counter);
        counter=0;
      }else{
        counter++;
      }
    }
    logger[c] = max(logger[c], counter);
  }

  int result=1000000;
  for(auto p:logger){
//cout<<p.first<<' '<<p.second<<endl;
    if(p.second<0)continue;
    result = min(result, p.second);
  }

  cout<<result;

  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

def how_long(aabb, ccdd):
    return abs(aabb[0]-ccdd[0])+abs(aabb[1]-ccdd[1])

for stu in ab:
    r = [how_long(stu,cd[i]) for i in range(m)]
    print(r.index(min(r))+1)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <cmath>
#include <ccomplex>
using namespace std;

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

	int dp[50];
	dp[0] = 1;
	dp[1] = 1;

	for (int i = 2; i < 45; i++) {
		dp[i] = dp[i - 1] + dp[i - 2];
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 3024
from sys import stdin
import math
from itertools import groupby

n = int(stdin.readline().rstrip())
total = math.factorial(n)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

li = prime_factorize(total)
lin = []
for key, value in groupby(li):
    lin.append(len(list(value)))

point = 1

for i in lin:
    point *= i+1
    point %= 10**9+7

print(point)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define ALL(i) (i).begin(),(i).end()
#define RALL(i) (i).begin(),(i).end(),greater<int>()
using namespace std;
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }
 
typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
#define TENFIVE2 200005
 
// #define int long long
 
signed main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  A +=B;
  C+=D;
  if(A==C)print("Balanced");
  if(A>C)print("Left");
  if(A<C)print("Right");
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 0; i < (1 << n); i++){
			Vector<Integer> va = new Vector<Integer>();
			for(int j = 0; j < n; j++){
				if((i & (1 << j)) != 0) va.add(j);
			}
			System.out.print(i + ":");
			for(int j = 0; j < va.size(); j++){
				System.out.print(" " + va.get(j));
			}
			System.out.print("\n");
		}
	}
}



Measured memory_bytes: 68876
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  long double radH = 2 * M_PI * (H + M / 60.0) / 12;
  long double radM = 2 * M_PI * M / 60.0;
  long double ans = A * A + B * B - 2 * A * B * cosl(radH - radM);
  ans = sqrtl(ans);
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 4100
#include <iostream>
#include <string>
#include <vector>
#include <valarray>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
	int s, ans = 1;
	cin >> s;
	vector<bool>d(s * 3 + 1, false);
	auto f = [](int x) {
		if (x % 2 == 0) {
			return x / 2;
		}
		else {
			return 3 * x + 1;
		}
	};
	auto c = [&d](int x) {
		if (d[x] == true) {
			return false;
		}
		else {
			d[x] = true;
			return true;
		}
	};
	while (c(s)) {
		s = f(s);
		ans++;
		if (d.size() <= s) {
			d.resize(s + 1, false);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
long long R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]||N[H[a]]==N[H[b]]&&H[a]%2==1?1:0;
}
//挿入関数
void hin(long long a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  long long n,a[200010],b[200010],i,lb=0,bf,ans=0,ra,j,r,l;
  scanf("%lld",&n);
  for(i=0;i<n;i++)scanf("%lld %lld",&a[i],&b[i]);
  if(n%2==0){
    for(i=0;i<n;i++)hin(a[i]*2);
    for(i=0;i<n/2;i++)j=N[hout()];
    l=(N[H[1]]+j)/2;
    R=C=1;
    for(i=0;i<n;i++)hin(b[i]*2);
    for(i=0;i<n/2;i++)j=N[hout()];
    r=(N[H[1]]+j)/2;//printf("%lld %lld\n",l,r);
    printf("%lld\n",r-l+1);
  }
  else{
    for(i=0;i<n;i++)hin(a[i]);
    for(i=0;i<n/2;i++)hout();
    l=N[H[1]];
    R=C=1;
    for(i=0;i<n;i++)hin(b[i]);
    for(i=0;i<n/2;i++)hout();
    r=N[H[1]];
    printf("%lld\n",r-l+1);
  }
  return 0;
}
    


Measured memory_bytes: 7980
N=int(input())
s=sorted([str(sorted(input())) for i in range(N)])+[""]
ans=c=0
j=s[0]
for i in s[1:]:
    if i==j:
        c+=1
    else:
        j=i
        ans+=c*(c+1)//2
        c=0
print(ans)

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

void solver() {
  long long x;
  cin >> x;

  for (int i = 0; i <= 100000; i++) {
    for (int j = 0; j <= 100000; j++) {
      long long a = 1;
      long long b = 1;
      long long arev = 1;
      long long brev = 1;
      long long amin = 1;
      long long bmin = 1;
      long long aminrev = 1;
      long long bminrev = 1;
      for (int k = 0; k < 5; k++) {
        a *= i;
        b *= j;
        arev *= j;
        brev *= i;
        amin *= -i;
        bmin *= -j;
        aminrev *= -j;
        bminrev *= -i;
      }

      if (x == a - b) {
        cout << i << " " << j << "\n";
        return;
      }

      if (x == arev - brev) {
        cout << j << " " << i << "\n";
        return;
      }

      if (x == amin - bmin) {
        cout << -i << " " << -j << "\n";
        return;
      }

      if (x == aminrev - bminrev) {
        cout << -j << " " << -i << "\n";
        return;
      }

      if (x == a - bmin) {
        cout << i << " " << -j << "\n";
        return;
      }

      if (x == amin - b) {
        cout << -i << " " << j << "\n";
        return;
      }

      if (x == arev - bminrev) {
        cout << j << " " << -i << "\n";
        return;
      }

      if (x == aminrev - brev) {
        cout << -j << " " << i << "\n";
        return;
      }
    }
  }
}

int main() {
  solver();
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define stdi(in) freopen(in, "r", stdin)
#define stdo(out) freopen(out, "w", stdout)
#define stdio(in, out) stdi(in); stdo(out)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define MAX 100007
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<pair<int, int> , null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update>

//const ll modd = 998244353;
const ll inf = 1e18;

ll arr[51][51], k;
ll M[51][51];
ll tmp[51][51];
int n;

void mult(ll A[51][51], ll B[51][51]){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            tmp[i][j]=0;

            for(int k=0;k<n;k++){
                tmp[i][j] = (tmp[i][j]+(A[i][k]*B[k][j])%MOD)%MOD;
            }
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            A[i][j] = tmp[i][j];
        }
    }
}

void power(ll y){
    if(y==1){
        return;
    }

    power(y/2);
    mult(arr, arr);

    if(y&1){
        mult(arr, M);
    }

}

int main(){
    /*#ifndef ONLINE_JUDGE
        stdio("in", "out");
    #endif*/
    fast;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>arr[i][j];
            M[i][j] = arr[i][j];
        }
    }

    power(k);

    ll ans = 0;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            ans = (ans+arr[i][j]);
            if(ans>=MOD) ans-=MOD;
        }
    }

    cout<<ans<<'\n';

    return 0;
}



Measured memory_bytes: 384
def resolve():
    '''
    code here
    '''
    num_S, num_c  = [int(item) for item in input().split()]

    delta = num_c - num_S *2
    scc = 0
    if num_S != 0:
        if num_c // 2 <= num_S :
            scc = num_c//2
        else:
            scc = num_S
            scc += delta//4
    else:
        scc = num_c//4

    print(scc)

if __name__ == "__main__":
    resolve()


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

using namespace std;

#define int long long

const int N = (int)3e5, MOD = (int)1e9 + 7, INF = (int)3e18;

main() {
    ios :: sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    map <string ,int> mp;
    for (int i = 1; i <= n; ++i) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << mp.size();
    return 0;  
}

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

using namespace std;
int main(){
    long long N; cin >> N;

    long long sum = 0;

    for(long long i=1; i*i < N; i++){
        if(N%i == 0){
            long long a = i;
            long long M = N/i - 1;
            if(M <= a){
                continue;
            }
            sum += M;
        }
    }
    cout << sum << endl;;
}

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


int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  
  int sig=1;
  for(int i=0; i<N; i++){
    if(A.at(i)==sig){
      sig++;
    }
  }
  
  if(sig==1){
    cout << -1 << endl;
    return 0;
  }
  
  cout << N-sig+1 << endl;
  
}

// int型の2次元配列(3×4要素の)の宣言
  //vector<vector<int>> data(3, vector<int>(4));

  // 入力 (2重ループを用いる)
  //for (int i = 0; i < 3; i++) {
    //for (int j = 0; j < 4; j++) {
      //cin >> data.at(i).at(j);
    //}
  //}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef pair<int,int> pi;

int n;
vector<pi> arr;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	for(int i=0; i<n; i++) {
		int x;
		cin >> x;
		arr.emplace_back(x,i+1);
	}
	sort(arr.begin(), arr.end());
	for(auto x : arr) cout << x.se << " "; cout << endl;
	return 0;
}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n, m;
    cin >> n >> m;

    vector<pair<int, int>> input_list;
    map<int, vector<int>> city;
    rep(i, m){
        int y, p;
        cin >> p >> y;
        if(city.find(p) == city.end()){
            city.emplace(p, vector<int>());
        }
        city[p].emplace_back(y);
        input_list.emplace_back(y, p);
    }

    repi(i, 1, n+1){
        sort(all(city[i]));
    }

    rep(i, m){
        int p = input_list[i].second;
        auto point = lower_bound(all(city[p]), input_list[i].first);
        printf("%06d%06d\n", input_list[i].second, (int)(point - city[p].begin()) + 1);
    }
}

Measured memory_bytes: 13172
N,M = map(int,input().split())
pat = [[int(i) for i in input().split()] for _ in range(M)]
Graph = [[0 for i in range(N)] for _ in range(N)]
for i,j in pat:
    Graph[i-1][j-1] = 1
    Graph[j-1][i-1] = 1

def dfs(v,N,visit_list):

    all_visit = True

    for i in range(N):
        if visit_list[i] == False:
            all_visit = False
    
    if all_visit:
        return 1

    ret = 0

    for k in range(N):
        if Graph[v][k] == False:
            continue
        if visit_list[k] :
            continue
        
        visit_list[k] = True
        ret += dfs(k,N,visit_list)
        visit_list[k] = False
    return ret

visit_list = [False for i in range(N)]
visit_list[0] = True
print(dfs(0,N,visit_list))
    



Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main{

    static int value[];
    
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

	int n=Integer.parseInt(br.readLine());
	value=new int[n+1];
	System.out.println(fib(n));
    }

    static int fib(int i){
	if(value[i]!=0)
	    return value[i];

	if(i<=1)
	    return 1;
	return value[i]=fib(i-1)+fib(i-2);
    }
}



Measured memory_bytes: 24220
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;
const int inf = 1e9;
int update(int h, int p, int n){
    h |= 1<<p;
    int res = 0;
    for(int y=0; y<n; y++){
        for(int x=0; x<n; x++){
            int pos = y*n+x;
            if(pos == p) continue;
            int count = 0;
            for(int dy=-1; dy<=1; dy++){
                for(int dx=-1; dx<=1; dx++){
                    if(dy==0 && dx==0) continue;
                    if(y+dy<0 || n<=y+dy || x+dx<0 || n<=x+dx) continue;
                    int adj = pos +dy*n +dx;
                    if((h & 1<<adj) != 0) count++;
                }
            }
            if((h & 1<<pos) != 0){
                if(count==2 || count==3) res |= 1<<pos;
            }else{
                if(count == 3) res |= 1<<pos;
            }
        }
    }
    return res;
}

struct info{
    int h,p,s;
    info(int h, int p, int s):h(h),p(p),s(s){}
    info();
    bool operator<(const info &a) const{
        return (h!=a.h)? h<a.h: p<a.p;
    }
};

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        int p;
        int hash=0;
        for(int i=0; i<n*n; i++){
            char c;
            cin >> c;
            if(c=='@') p = i;
            if(c=='#') hash |= 1<<i;
        }

        set<info> used;
        used.insert(info(hash, p, 0));
        queue<info> wait;
        wait.push(info(hash, p, 0));
        int ans = -1;
        while(!wait.empty()){
            int h = wait.front().h;
            int p = wait.front().p;
            int s = wait.front().s;
            wait.pop();
            if(h == 0){
                ans = s;
                break;
            }
            int y = p/n;
            int x = p%n;
            for(int dy=-1; dy<=1; dy++){
                for(int dx=-1; dx<=1; dx++){
                    if(dy==0 && dx==0) continue;
                    if(y+dy<0 || n<=y+dy || x+dx<0 || n<=x+dx) continue;
                    int np = (y+dy)*n +(x+dx);
                    if((h & 1<<np) != 0) continue;
                    int nh = update(h, np, n);
                    info next(nh, np, s+1);
                    if(used.find(next) == used.end()){
                        used.insert(next);
                        wait.push(next);
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 4420
#include <stdio.h>
#define MAX_N 101

double t[MAX_N], v[MAX_N];

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

double min(double a, double b)
{
    return a < b? a: b;
}

int main(void)
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%lf", &t[i]);
    for (int i = 0; i < n; i++)
        scanf("%lf", &v[i]);
    double cur = 0.0;
    double ans = 0.0;
    for (int i = 0; i < n; i++) {
        double inc, kep, dec;
        double lim = 1.0E10;
        double tmp = 0.0;
        for (int j = i + 1; j <= n; j++) {
            lim = min(lim, v[j] + tmp);
            tmp += t[j];
        }
        inc = min(v[i] - cur, (lim + t[i] - cur) * 0.5);
        inc = min(inc, t[i]);
        dec = max(0.0, cur + inc - lim);
        kep = t[i] - inc - dec;
        ans += 0.5 * (cur * 2.0 + inc) * inc;
        ans += (cur + inc) * kep;
        ans += 0.5 * ((cur + inc) * 2.0 - dec) * dec;
        cur += inc;
        cur -= dec;
    }
    printf("%f\n", ans);
    return 0;
}


Measured memory_bytes: 128