akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

static const unsigned long long int MOD = 1000000007LL;

long long int a[100001];
int n;

int main()
{

    cin >> n;

    long long int dig = 1;
    long long int x = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        x += a[i] * dig;
        dig = dig * -1;
    }

    cout << x << " ";

    for (int i = 0; i < n - 1; i++)
    {
        x = 2 * a[i] - x;
        cout << x << " ";
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x;
    string y;
	cin >> x>> y;
    string ans;
    if(x<3200)ans="red";
    else ans = y;
      cout << ans << endl;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 x,a;
    cin >> x >> a;
    if(x < a){
        cout << "0\n";
    }else{
        cout << "10\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int a[10];

//B:=B?????????????????° C*=C?????????????????° cnt:=??????????????°??????
bool dfs(int B, int C, int cnt){
    if(cnt == 10){
        return true;
    }
    if(B < a[cnt]){
        return dfs(a[cnt], C, cnt + 1);
    }
    if(C < a[cnt]){
        return dfs(B, a[cnt], cnt + 1);
    }
    if(B > a[cnt] && C > a[cnt]){
        return false;
    }
}
int main(void){
    int n; cin >> n;
    for (int i = 0; i < n; ++i){
        rep(j, 10) cin >> a[j];
        if(dfs(0, 0, 0)) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

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

int main(void){
    
    string s;
    cin >> s;
    for(int i=0;i<3;i++){
        if(s[i] == '1'){
            s[i] = '9';
        }
        else{
            s[i] = '1';
        }
    }
    cout << s <<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
	int a,ans=0,n,m;
	cin >> n;
	m=n;
    while(1){
    	a=n%10;
    	ans=ans+a;
    	n=n/10;
    	if(n==0) break;
    }
    if(m%ans==0){
    	cout << "Yes" << endl;
    }
    else{
    	cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import numpy as np
N = int(input())

Number_to_divide = []
for i in range(1,int(np.sqrt(N))+1):
    if (N % i == 0)and((N / i) > (i + 1)):
        Number_to_divide.append((N / i) - 1)
print(int(sum(Number_to_divide)))



Measured memory_bytes: 21796
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cctype>
#include <ctime>
#include <vector>
#include <cstdlib>
#include <stack>
#define int long long
#define pll std::pair<int,int>
#define MP std::make_pair
#define fi first
#define se second
#define oo 2147483647
#define PI 3.141592653590
#define rint register int
#define F(i,num,b) for(rint i=num;i<=b;i++)
#define D(i,num,b) for(rint i=num;i>=b;i--)
#define G(i,num,b,c) for(rint num=head[b];num;num=c[num].next)

inline int _read () {int s = 0 , w = 1;char ch = getchar ();while ( ch > '9' || ch < '0' ) { if ( ch == '-' ) w = -1; ch = getchar ();}while ( ch >= '0' && ch <= '9' ) { s = s * 10 + ch - '0'; ch = getchar ();}return s * w;}
template < class T > inline void read ( T &x ) {T s = 0 , w = 1;char ch = getchar ();while ( ch > '9' || ch < '0' ) { if ( ch == '-' ) w = -1; ch = getchar ();}while ( ch >= '0' && ch <= '9' ) { s = s * 10 + ch - '0'; ch = getchar ();}x = s * w;return;}
template < class T , typename ...Argc > inline void read ( T &x , Argc &...Args ) {read ( x );read ( Args... );return;} 
template < class T > inline T max ( T x , T y ) {return x > y ? x : y;}
template < class T > inline T min ( T x , T y ) {return x < y ? x : y;}
template < class T > inline void abs ( T x ) {return x > 0 ? x : -x;}
template < typename T > void write ( T x ) {if ( x < 0 ) x = -x , putchar ( '-' );if ( x > 9 ) write ( x / 10 );putchar ( x % 10 + 48 );return;}
template < typename T > void writeln ( T x ) {write ( x ); printf ("\n"); }
template < class T > inline T gcd ( T x , T y ) {if ( x < y ) swap ( x , y );if ( !y ) return x;return gcd ( y , x % y );}
template < class T > inline T ksm ( T x , T y , T Mod ) {T tmp = 1;while ( y ) {if ( y % 2 == 1 ) tmp = ( tmp * x % Mod );x = ( x * x ) % Mod;y >>= 1;}return tmp;}	

/**********************************************************************************************************************************************************************************************************************************************************************/

const int N = 1e5 + 100;

int n,k,q,x;
int a[N];

signed main() {
    read ( n , k , q );
    for(int i = 1 ; i <= n ; i++)
		a[i] = k - q;
    while(q--) {
    	read ( x ); 
        a[x]++;
    }
    for(int i = 1 ; i <= n ; i++) {
        if(a[i] > 0) puts("Yes");
        else if(a[i] <= 0) puts("No");
    }
    return 0;
}


Measured memory_bytes: 1408
// C++ program to find the longest 
// path in the DAG 
  
#include <bits/stdc++.h> 
using namespace std; 
  
// Function to traverse the DAG 
// and apply Dynamic Programming 
// to find the longest path 
void dfs(int node, vector<int> adj[], int dp[], bool vis[]) 
{ 
    // Mark as visited 
    vis[node] = true; 
  
    // Traverse for all its children 
    for (int i = 0; i < adj[node].size(); i++) { 
  
        // If not visited 
        if (!vis[adj[node][i]]) 
            dfs(adj[node][i], adj, dp, vis); 
  
        // Store the max of the paths 
        dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
    } 
} 
  
// Function to add an edge 
void addEdge(vector<int> adj[], int u, int v) 
{ 
    adj[u].push_back(v); 
} 
  
// Function that returns the longest path 
int findLongestPath(vector<int> adj[], int n) 
{ 
    // Dp array 
    int dp[n + 1]; 
    memset(dp, 0, sizeof dp); 
  
    // Visited array to know if the node 
    // has been visited previously or not 
    bool vis[n + 1]; 
    memset(vis, false, sizeof vis); 
  
    // Call DFS for every unvisited vertex 
    for (int i = 1; i <= n; i++) { 
        if (!vis[i]) 
            dfs(i, adj, dp, vis); 
    } 
  
    int ans = 0; 
  
    // Traverse and find the maximum of all dp[i] 
    for (int i = 1; i <= n; i++) { 
        ans = max(ans, dp[i]); 
    } 
    return ans; 
} 
  
// Driver Code 
int main() 
{ 
    int n,m;
    cin>>n>>m; 
    vector<int> adj[n + 1]; 
  
    // Example-1 
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        addEdge(adj, a, b);
    } 
    
  
    cout << findLongestPath(adj, n)<<endl;; 
    return 0; 
} 


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , K;
  cin >> N;
  cin >> K;
  int Ans = 0;
  
  for (int i = 0; i < N; i++) {
    int x_i;
    cin >> x_i;
    if (x_i <= K - x_i) { 
      Ans = Ans + 2*x_i;
    }
    else {
      Ans = Ans + 2*(K-x_i);
    }
  }
  
    cout << Ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
	
int main(){
	long n,i,j,w,q,a,b,ans,sum;
	cin >> n >> w;
	vector<long> dp1(100001,w+1),dp2(100001,w+1);
	dp1[0]=0; dp2[0]=0; sum=0;
	
	for(i=0; i<n; i++){
		cin >> a >> b;
		for(j=0; j<=sum; j++){
			dp1[j+b]=min(dp1[j+b],dp2[j]+a);
		}
		sum+=b;
		
		dp2=dp1;
	}
	
	for(i=100000; i>=0; i--){
		if(dp1[i]<=w){
			cout << i << endl; return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b));
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  string ans = "";
  
  rep(i,S.size()){
    ans+="x";
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
"use strict";
function main(input) {
  const args = input.split("\n");
  const one = args[0].split(" ");

  const N = parseInt(one[0]);
  const K = parseInt(one[1]);
  const S = args[1];

  let S_first = S;
  let S_second = S;
  let S_third = S;

  let s = S_first.substr(K - 1, 1).toLowerCase();
  let ans = "";
  if(1 < K) {
      ans += S_second.substr(0, K - 1);
  }
  ans += s;
  if(K !== S.length) {
      ans += S_third.substr(K, S.length - 1);
  }

  console.log(ans);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
L = input()
l = len(L)
dp = [[0]*2 for _ in range(100005)]
# dp[i][smaller]: i桁目までみる　未満なら1
# dp[i][1] : i桁目までみて、a, bどちらもL未満
# dp[i][0] : i桁目までみて、a+b = L
dp[0][0] = 1
mod = 10**9+7

for i in range(l):
  n = L[i]
  # a + b = 0
  if n == "0":
    dp[i+1][0] = dp[i][0]
    dp[i+1][1] = dp[i][1]
  else: 
    dp[i+1][1] = (dp[i][0] + dp[i][1]) % mod

  # a + b = 1
  if n == "0": 
    dp[i+1][1] += dp[i][1] * 2 % mod
  else: 
    dp[i+1][0] += dp[i][0] * 2 % mod
    dp[i+1][1] += dp[i][1] * 2 % mod

print((dp[l][0]+dp[l][1])%mod)




Measured memory_bytes: 19700
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int X, Y, Z;
            string[] strABC = Console.ReadLine().Split(' ');
            Console.WriteLine($"{strABC[2]} {strABC[0]} {strABC[1]}");
        }
    }
}


Measured memory_bytes: 13140
package main

import (
	"fmt"
)

func reverse(s []int) []int {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	return s
}

func make_vl(v int) []int {
	vl := []int{0, 0, 0}
	i := 0
	for ; v > 0; v /= 10 {
		vl[i] = v % 10
		i++
	}
	return reverse(vl)
}

func main() {
	var n int
	var s string
	fmt.Scanf("%d\n", &n)
	fmt.Scanf("%s\n", &s)

	count := 0
	for v := 0; v < 1000; v++ {
		vl := make_vl(v)
		vi := 0
		for i := 0; i < len(s); i++ {
			if int(s[i]-'0') == vl[vi] {
				vi++
			}
			if vi == 3 {
				count++
				break
			}
		}
	}

	fmt.Printf("%v\n", count)
}


Measured memory_bytes: 896
object Main {
  def main(args: Array[String]): Unit = {
    val in = new java.util.Scanner(System.in)
    rec(in)
  }
  def rec(in: java.util.Scanner):Unit ={
    val a = in.nextInt
    val b = in.nextInt
    if(a == 0 && b == 0) return
    for(i <- 1 to a){
      for(j <- 1 to b){
        if((i+j)%2 == 0){
          printf("#")
        }else{
          printf(".")
        }
      }
      println("")
    }
    println("")
    rec(in)
  }
  
}

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

int main(void){
    int n,m,i,j,max=0,cnt=0;
    scanf("%d",&n);
    char s[n][11];
    for(i=0;i<n;i++){
        scanf("%s",s[i]);
    }
    scanf("%d",&m);
    char t[m][11];
    for(i=0;i<m;i++){
        scanf("%s",t[i]);
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(strcmp(s[i],s[j])==0){
                ++cnt;
            }
        }
        for(j=0;j<m;j++){
            if(strcmp(s[i],t[j])==0){
                --cnt;
            }
        }
        if(cnt>max){
            max=cnt;
        }
        cnt=0;
    }
    printf("%d\n",max);
    return 0;
}


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

int main(){

    int n;
    cin >> n;
    int ans;
    for(int i=1;i<=n;i++){
        if(pow(2,i)>n){
            ans=pow(2,i-1);
            break;
        }
    }

    cout << ans <<endl;

    return 0;
}

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

namespace ConsoleApplication
{
    class Program
    {
        static void Main()
        {
            new Solution().answer();
        }
    }

    class Solution
    {
        string N = "";
        //string[] M_split = new string[2];
        string T = "";

        public Solution()
        {
            N = Console.ReadLine();
            //M_split = N.Split(' ');
            int i = 0;
            int j = N.Length;
            for (i = 0; i <= j - 1; i++)
            {
                T = T + N.Substring(i, 1);
                i++;           
            }
        }

        public void answer()
        {
            Console.WriteLine(T);
        }
    }
}


Measured memory_bytes: 32724
#include<bits/stdc++.h>
#define ll long long int
#define vll vector<ll>
#define uset unordered_set<string>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n;
    cin >> n;
    
    uset x;
    while(n--){
        string s;
        cin >> s;
        x.insert(s);
    }
    
    cout << x.size() << endl;
    return 0;
}

Measured memory_bytes: 17708
#include <stdio.h>

int main (int argc, const char * argv[])
{
    int data[100];
	int i,j,k,c;
	
	for (i=0; i<100; i++) {
		data[i] = 0;
	}
	
	i=0;
	
	while (scanf("%d", &data[i]) != EOF) {
		i++;
	}
	
	for (j=0; j<i; j++) {
		for (k=j; k<i; k++) {
			if (data[j] > data[k]) {
				c = data[j];
				data[j] = data[k];
				data[k] = c;
			}
		}
	}
	
	k = 0;
	c = 0;
	
	for (j=0; j<i-1; j++) {
		if (data[j] == data[j+1]) {
			k++;
		}
		else {
			if (k >= c) {
				c = k;
			}
			k = 0;
		}
	}
	
	for (j=0; j<i-1; j++) {
		if (data[j] == data[j+1]) {
			k++;
		}
		else {
			if (k == c) {
				printf("%d\n", data[j]);
			}
			k = 0;
		}

	}
	
    return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define range(i,a,b) for(int i = (a);i <= (b);i++)
#define all(A) A.begin(),A.end()
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
#define vi vector<int>
#define vl vector<long long>
#define vd vector<double>
#define vp vector<pair<int,int> >
#define ll long long
#define pi pair<int,int>
#define popcnt(x) __builtin_popcountll(x)
#define LSOne(x) ((x) & (-(x)))
#define xx first
#define yy second
#define PQ priority_queue
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prp(p) cerr << "(" << (p).first << " ," << (p).second << ")";
#define prArr(A,n,t)  cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
#define what_is(x) cerr << #x << " is " << x << endl
#define bit_lg(x) (assert(x > 0),__builtin_ffsll(x) - 1)
const double PI = acos(-1);
using namespace std;

const int MAX = 1 << 20;
int f[MAX],dist[MAX],n,k;
vi G[MAX];
int ans;

int dfs(int u,int p) {
	if(G[u].empty()) return 0;
	int mx = 0;
	for(int v : G[u]) {
		int h = dfs(v,u);
		if(u != 1 && h + 1 == k) {
			ans++;
			h = -1;
//			cerr << "cur " << u << " " << v << endl;
		}
		mx = max(mx,h + 1);
	}
	if(u != 1 && mx == k) {
		ans ++;
		mx = 0;
//		cerr << "cut " << p << " " << u << endl;
	}
//	cerr << u << " " << mx << endl;
	return mx;
}


int main(){
	#ifdef HOME
		freopen("in.in", "r", stdin);
	#endif
	scanf("%d %d",&n,&k);
	range(i,1,n) scanf("%d",f + i);
	if(f[1] != 1) f[1] = 1,ans ++;
	range(i,2,n) G[f[i]].pb(i);
	dfs(1,0);

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


Measured memory_bytes: 34816
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    int N;
    cin >> N;
    int ans = 0;
    int a = INT_MAX, b = INT_MAX;
    REP (i, N - 1) {
        a = b;
        cin >> b;
        ans += min(a, b);
    }
    ans += b;

    cout << ans << endl;

    return 0;
}

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

int main(void){
    int D;
    cin>>D;
    switch(D){
        case 25:cout<<"Christmas"<<endl;break;
        case 24:cout<<"Christmas Eve"<<endl;break;
        case 23:cout<<"Christmas Eve Eve"<<endl;break;
        case 22:cout<<"Christmas Eve Eve Eve"<<endl;break;
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np
from scipy.spatial.distance import minkowski

n, m = map(int, input().split())
a = np.array([list(map(int, input().split())) for i in range(n)])
b = np.array([list(map(int, input().split())) for i in range(m)])

for i in range(n):
    c = np.array([minkowski(a[i], j , 1) for j in b], dtype=np.int64)
    ans = np.argmin(c) + 1
    print(ans)

Measured memory_bytes: 19368
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int main(){
  int X;
  cin >> X;
  int ans = 1;
  rep(i, 2, 32){
    int n = i * i;
    while(n <= X){
      ans = max(ans, n);
      n *= i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] N=sc.next().toCharArray();

        for (char c : N) {
            if(c=='7'){
                System.out.println("Yes");
                System.exit(0);
            }
        }
        System.out.println("No");
        sc.close();
    }
}

Measured memory_bytes: 35588
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N, M = LI()
H = LI()
AB = LRI(M)

HS = [True] * N
for a, b in AB:
    if H[a-1] < H[b-1]:
        HS[a-1] = False
    elif H[a-1] > H[b-1]:
        HS[b-1] = False
    if H[a-1] == H[b-1]:
        HS[a-1] = False
        HS[b-1] = False

ans = 0
for hs in HS:
    if hs:
        ans += 1

print(ans)


Measured memory_bytes: 90224
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

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

int main(){
  
  int i, N, a, cnt = 0;

  cin >> N;
  while(N--) {
    cin >> a;
    bool judge = false;
    for(i = 1; i * i < a; i++) {
      if((a - i) % (2 * i + 1) == 0) {
        judge = true;
        break;
      } 
      // cout << a << endl;
    }
    if(!judge) cnt++;
  }
  cout << cnt << endl;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){

  int n;
  cin >> n;
  vector<int> v(n+1);
  rep(i,n)cin >> v[i+1];
  vector<int> res;
  rep(times,n){
    for(int i = v.size()-1;i > 0;i--){
      if(i == v[i]){
        v.erase(v.begin()+i);
        res.push_back(i);
        break;
      }
    }
  }
  if(res.size() == n)for(int i = n-1;i >= 0;i--)cout << res[i] << endl;
  else cout << -1 << endl;
  


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  ll n; cin >> n;
  ll ans = 0;
  for(ll i = 2; i*i <= n; i++){
    if(n % i == 0){
      int c = 0;
      while(n % i == 0){
        c++;
        n /= i;
      }
      for(int j = 1; j <= c; j++){
        ans++;
        c -= j;
      }
    }
  }
  if(n != 1) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    rep(b, K+1, N+1) {
        ll n = N / b;
        ans += n * (b-K);
        ll m = N % b;
        if (m >= K) ans += m - K + 1;
        if (K == 0) ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=3010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN];
vector<int> G[MAXN];

bool dfs(int node, int par){
	bool res=0;
	for (int v:G[node]) if (v!=par && A[v]<A[node]) res|=!dfs(v, node);
	return res;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=1; i<=n; i++) cin>>A[i];
	for (int i=1; i<n; i++){
		cin>>u>>v;
		G[u].pb(v);
		G[v].pb(u);
	}
	for (int i=1; i<=n; i++) if (dfs(i, i)) cout<<i<<' ';
	
	return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
	public static int intersection(Circle c1, Circle c2){
		double dis1 = Math.pow(c2.x - c1.x,2) + Math.pow(c2.y - c1.y,2);
		double dis2 = Math.pow(c1.r + c2.r,2);
		double dis3 = Math.pow(c1.r - c2.r,2);
		if(dis1 > dis2)
			return 4;
		else if(dis1 == dis2)
			return 3;
		else if(dis1 > dis3)
			return 2;
		else if(dis1 == dis3)
			return 1;
		else
			return 0;
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Circle c1 = new Circle(sc.nextLong(),sc.nextLong(),sc.nextLong());
		Circle c2 = new Circle(sc.nextLong(),sc.nextLong(),sc.nextLong());
		System.out.println(intersection(c1,c2));
	}
}
class Circle{
	long x;
	long y;
	long r;
	Circle(long x, long y, long r){
		this.x = x;
		this.y = y;
		this.r = r;
	}
}


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

int main() {
    int n; cin >> n;
    map<string, int> nums;
    long long ans = 0;
    for (int i=0; i<n; ++i) {
        string s; cin >> s;
        sort(s.begin(), s.end());
        ans += nums[s];
        nums[s]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
//
//  main.cpp
//  AtCoder-B055-B
//
//  Created by Yuuki Tanaami on 2017/02/18.
//  Copyright © 2017年 Yuuki Tanaami. All rights reserved.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    long long ans;
    
    cin >> n;
    ans = 1;
    
    for (int i=1; i<=n; i++) {
        ans *= i;
        ans %= (10*10*10*10*10*10*10*10*10+7);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

string btn[3]={"ABC","DEF","GHI"};

bool dfs(string &str,int pos,P p) {
    if(str.size()==pos) return true;
    bool ret=false;
    rep(k,4) {
        int ny=p.fr+dy[k];
        int nx=p.sc+dx[k];
        if(ny<0||nx<0) continue;
        if(ny>=3||nx>=3) continue;
        if(str[pos]!=btn[ny][nx]) continue;
        ret |= dfs(str,pos+1,P(ny,nx));
    }

    return ret;
}

bool ok(string str) {
    P s;
    rep(y,3) rep(x,3) if(btn[y][x]==str[0]) s=P(y,x);

    return dfs(str,1,s);
}

int main() {
    int q=1000;
    while(q-->0) {
        string s;
        cin>>s;
        if(ok(s)) cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


int main() {
  rep(i,5){
    int a;cin>>a;
    if(a==0){
      cout<<i+1<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(void){
    char c; cin>>c;
    if(c=='A') cout<<'T'<<endl;
    if(c=='T') cout<<'A'<<endl;
    if(c=='C') cout<<'G'<<endl;
    if(c=='G') cout<<'C'<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
ll H, W, A, B;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    cin >> H >> W >> A >> B;
    // H times W
    //　右か下しかない
    // 下からA個いないかつ
    // 左からB個いないへは移動することができない
    ll ans = 0LL;
    ll bf = 0LL;
    COMinit();
    for(ll x = 0; x < W - B; x++) {
        ll tmp = COM(H - A - 1 + B + x, B + x);
        ll diff = tmp - bf + MOD;
        diff %= MOD;
        ans += diff * COM(A + W - 1 - B - x, A);
        bf = tmp;
        ans %= MOD;
    }

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

Measured memory_bytes: 12160
// https://atcoder.jp/contests/abc018/tasks/abc018_4

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e18;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
// int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int main() {

  int N; cin >> N;
  vector<int> A(N);
  vector<vector<int>> x(N), y(N);

  REP(i, N){
    cin >> A[i];
    REP(j, A[i]){
      int _x, _y;
      cin >> _x >> _y;
      _x--;
      x[i].push_back(_x);
      y[i].push_back(_y);
    }
  }

  vector<int> hito(N, 0);
  int _max = 0;
  int ans = 0;
  bool flag = true;

  // {0, 1, ..., n-1} の部分集合の全探索
  for (int bit = 0; bit < (1<<N); ++bit) {
      // vector<int> S;
      fill(hito.begin(), hito.end(), 0);
      _max = 0;
      flag = true;
      for (int i = 0; i < N; ++i) {
          if (bit & (1<<i)) { // 列挙に i が含まれるか
              // S.push_back(i);
              hito[i] = 1;
              _max++;
          }
      }
      REP(i, N){
        REP(j, A[i]){
          if(hito[i] == 1){
            if(hito[x[i][j]] != y[i][j]){
              // cout << hito[x[i][j]] << " " << y[i][j] << endl;
              flag = false;
            }
          }
        }
      }

      if(flag == true){
        ans = max(_max, ans);
      }

      // cout << bit << ": {";
      // for (int i = 0; i < (int)S.size(); ++i) {
      //     cout << S[i] << " ";
      // }
      // cout << "}" << endl;
  }

  cout << ans << endl;


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 256
import java.util.Scanner;

//https://atcoder.jp/contests/abc177/tasks/abc177_c

public class Main {
	static long modulo = 1000000000+7;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] nums = new int[N];
		long[] subSum = new long[N];
		for(int i = 0; i <  N; i++) {
			nums[i] = sc.nextInt();
		}
		subSum[N-1] = 0L;
		for(int i = N-2; i >=  0; i--) {
			subSum[i] = (subSum[i+1] + nums[i+1]) % modulo;
			//System.out.print(subSum[i] + " ");
		}
		//System.out.println();
		long res= 0;
		for(int i1 = 0 ; i1 <N-1; i1++) {
			//System.out.println("i1 "+ i1 + " nums[i1]*subSum[i1] " +nums[i1]*subSum[i1]);
			res = (res + (nums[i1]*subSum[i1]) % modulo)%modulo;
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 61980
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N;
    cin >> N;
    vector<int> h(N);
    REP(i, N) cin >> h[i];

    int ans = 0;
    int now = 0;
    FOR(i, 0, N) {
        if (now < h[i]) {
            ans += h[i] - now;
        }
        now = h[i];
    }
    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){

  ll K, N;
  cin >> N >> K;
  string str;
  cin >> str;
  str[K-1] = str[K-1] - ('A'-'a');
  cout << str << "\n";

  return 0;
}

Measured memory_bytes: 256
lines = $stdin.read
array = lines.split("\n")

N = array[0].to_i
K = array[1].to_i

#
# opA = * 2 of shown
# opB = + K of shown
# ------------------
# opA + opB = N times
#
# 1<=N, K<=10
#
def show_board(a, n, k)
  e = 1
  b = n - a

  1.upto(a) do |idx|
    e = e * 2
    # puts "x2 -> e = #{e}"
  end
  a.upto(n-1) do |idx|
    e = e + k
    # puts "+k -> e = #{e}"
  end
  e
end

#puts "N = #{N}, K = #{K}"

min = (1..N).map do |a|
  show_board(a, N, K)
end.to_a.min

puts min

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
int A[100000],n,p;
int partition(int [],int ,int);
int main(){
  int i,r,q;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  p=0;
 r=i-1;

 
  q=partition(A,p,r);

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

  return 0;
}
int partition(int A[],int p,int r){
  int i,j,tmp,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<= x){
      i=i+1;
      tmp=A[j];
      A[j]=A[i];
      A[i]=tmp;
    }
  }
    tmp=A[i+1];
    A[i+1]=A[r];
    A[r]=tmp;

 
  return i+1;
}

Measured memory_bytes: 988
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N;
void input() {
  cin>>N;
}
bool is_prime[MX+5];
vector<int> P;
void Eratosthenes(const int N) {
  for (int i = 2; i <= N; i++) {
    is_prime[i] = true;  // initialize.
  }
  for (int i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
}
int sm[MX+2];
void solve() {
  Eratosthenes(MX);
  sm[3] = 1;
  rep(i,4,MX - 1){
    if (is_prime[i] && is_prime[(i+1)/2]){
      sm[i]++;
    }
    sm[i] += sm[i-1];
  }
  rep(i,1,N){
    int a,b;
    cin>>a>>b;
    cout<<sm[b] - sm[a-1]<<endl;
  }

   ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 1664
/*
A1＝2(X2?X1)
B1＝2(Y2?Y1)
C1＝X12?X22＋Y12?Y22
A2＝2(X3?X1)
B2＝2(Y3?Y1)
C2＝X12?X32＋Y12?Y32

X＝(B1C2?B2C1)/(A1B2?A2B1)
Y＝(C1A2?C2A1)/(A1B2?A2B1)
*/
#include <fstream>
#include <iostream>
#include <math.h>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  // ifstream cin("../test.txt");
  int n;
  cin >> n;
  while (n--) {
    double x1,y1,x2,y2,x3,y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double a1 = 2 * (x2 - x1);
    double b1 = 2 * (y2 - y1);
    double c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
    double a2 = 2 * (x3 - x1);
    double b2 = 2 * (y3 - y1);
    double c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;

    double px = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
    double py = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);

    double r = sqrt((px - x1) * (px - x1) + (py - y1) * (py - y1));

    printf("%.3f %.3f %.3f\n", px, py, r);
  }
}

Measured memory_bytes: 1244
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNextLine()){
			Stack<Double> st=new Stack<Double>();
			String[] strs=sc.nextLine().split(" ");
			for(String str:strs){
				if("+".equals(str)){
					double op2=st.pop(),op1=st.pop();
					st.push(op1+op2);
				}else if("-".equals(str)){
					double op2=st.pop(),op1=st.pop();
					st.push(op1-op2);
				}else if("*".equals(str)){
					double op2=st.pop(),op1=st.pop();
					st.push(op1*op2);
				}else if("/".equals(str)){
					double op2=st.pop(),op1=st.pop();
					st.push(op1/op2);
				}else{
					st.push(Double.parseDouble(str));
				}
			}
			ln(st.pop());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

bool ok(char a) {
  if(a < '0') return false;
  if(a > '9') return false;
  return true;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
  int a, b;
  string s;
  cin >> a >> b >> s;
  for(int i = 0; i < a; i++) {
    if(!ok(s[i])) {
      cout << "No" << endl;
      return 0;
    }
  }
  if(s[a] != '-') {
    cout << "No" << endl;
    return 0;
  }
  for(int i = a + 1; i < s.size(); i++) {
        if(!ok(s[i])) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
using namespace std;
//  =========     /\       /|    |====/|
//      |        /  \       |    |   / |
//      |       /____\      |    |  /  |
//      |      /      \     |    | /   |
//  ========= /        \  =====  |/====|  
//  code

int main(){
    init;
    int n,i,j,k,l;
    cin>>n;
    int a[n+1][3],dp[n+1][3];
    for(i=1;i<=n;i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    int A = a[1][0];
    int B = a[1][1];
    int C = a[1][2];
    for(i=2;i<=n;i++){
        int AA=A,BB=B,CC=C;
        A = max(BB , CC) + a[i][0];
        B = max(AA , CC) + a[i][1];
        C = max(AA , BB) + a[i][2];
    }
    cout<<max(A ,max( B,C))<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
 
int main() {
    ios::sync_with_stdio(false);
	string s;
	cin >> s;
	for (int i = 0 ; i < (int)s.length() ; i += 2) {
		cout << s[i];
	}
}

Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    long long x,y,i,j,k,l,vmax=0,vsum=0,b;
    cin >>x;
cin>>y;
    int w[x],v[x],d[4],e[4];
    vector< vector<long long> >a;
    a.resize(4);
    for(int i=0;i<4;i++){
        a[i].resize(100);
d[i]=0;
    }
//入力
    for (i=0;i<x;i++){
        cin >> w[i];
cin >> v[i];
    }
//重さ振り分け
    for (i=0;i<x;i++){
        b =w[i]-w[0];
        a[b][i]=v[i];
        d[b]++;

    }
//価値の降順配列に変更
    for (i=0;i<4;i++){
        sort(a[i].begin(), a[i].end());
        reverse(a[i].begin(), a[i].end());
    }
//総当たり
    for (i=0;i<=d[0];i++){
    for (j=0;j<=d[1];j++){
    for (k=0;k<=d[2];k++){
    for (l=0;l<=d[3];l++){
        if ((i+j+k+l)*w[0]+j+2*k+3*l<=y){
            e[0] = accumulate(&a[0][0],&a[0][i],0);
            e[1] = accumulate(&a[1][0],&a[1][j],0);
            e[2] = accumulate(&a[2][0],&a[2][k],0);
            e[3] = accumulate(&a[3][0],&a[3][l],0);
            vsum = e[0]+e[1]+e[2]+e[3];
            vmax = max(vmax,vsum);
        }
    }}}}
    cout << vmax<<endl;
    return 0;
}

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

int main() {
    ll D, N;
    cin >> D >> N;

    ll MAX_VAL = 10000 * 100 * 10;
    ll ans;
    if (D == 0) {
        ll count = 0;
        for (ll i = 1; i <= MAX_VAL; i++) {
            if (i % 100 != 0) {
                count++;
                if (count == N) ans = i;
            }
        }
    } else if (D == 1) {
        ll count = 0;
        for (ll i = 1; i <= MAX_VAL; i++) {
            if (i % 100 == 0 && i % 10000 != 0) {
                count++;
                if (count == N) ans = i;
            }
        }
    } else if (D == 2) {
        ll count = 0;
        for (ll i = 1; i <= MAX_VAL; i++) {
            if (i % 10000 == 0 && i % 1000000 != 0) {
                count++;
                if (count == N) ans = i;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3540
#include<stdio.h>

int main(){
	int a[4]={0,0,0,0};
	for(int i=0;i<4;i++){
		int N;
		scanf("%d",&N);
		if(N==1)a[0]=1;
		if(N==9)a[1]=1;
		if(N==7)a[2]=1;
		if(N==4)a[3]=1;
	}
	if(a[0]*a[1]*a[2]*a[3]==1)printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
# GRL_1_C - All Pairs Shortest Path
def floyd_warshall(dist: "Array[Array[int]]") -> None:
    """
    Compute the shortest paths of all pairs.
    """
    V = len(dist)
    for i in range(V):  # intermediate point
        for j, c2 in enumerate(dist[j][i] for j in range(V)):  #  source
            for k, (c1, c3) in enumerate(zip(dist[j], dist[i])):  # target
                if c2 + c3 < c1:
                    dist[j][k] = c2 + c3


def detect_negative_cycle(dist: "Array[Array[int]]") -> bool:
    return any(d[i] < 0 for i, d in enumerate(dist))


def main():
    N, M, *E = map(int, open(0).read().split())
    dist = [[float("inf")] * N for _ in range(N)]
    for i in range(N):
        dist[i][i] = 0
    for v, u, c in zip(*[iter(E)] * 3):
        dist[v][u] = c
    floyd_warshall(dist)
    if detect_negative_cycle(dist):
        print("NEGATIVE CYCLE")
    else:
        for d in dist:
            cur = [i if i != float("inf") else "INF" for i in d]
            print(" ".join(map(str, cur)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 7776
N = int(input())
S = input()


#total = S.count('R') * S.count('G') * S.count('B')

r = g = b = 0
for s in range(N):
    if S[s] == 'R':
        r += 1
    elif S[s] == 'G':
        g += 1
    else:
        b += 1

total = r * g * b


for gap in range(1, N//2+1):
    for i in range(N - 2 * gap):
        j = i + gap
        k = j + gap
        if k >= N:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            total -= 1

print(total)


Measured memory_bytes: 9156
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 3e5 + 100;
const LL INF = 1e9;

VI st;

void update(int n, int b, int e, int i, int v)
{
    if(b == e)
    {
        if(b == i)
        {
            st[n] = max(st[n],v);
        }
        return;
    }

    if(b > i || e < i) return;

    int m = (b + e) / 2, l = n * 2, r = l + 1;
    update(l,b,m,i,v);
    update(r,m+1,e,i,v);

    st[n] = max(st[l],st[r]);
}

int query(int n, int b, int e, int i, int j)
{
    if(b > j || e < i) return 0;
    else if(i <= b && e <= j) return st[n];

    int m = (b + e) / 2, l = n * 2, r = l + 1;
    return max(query(l,b,m,i,j), query(r,m+1,e,i,j));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n, k;
    cin>>n>>k;
    int a[n], mx = 0;
    loop(i,0,n) {cin>>a[i]; mx = max(mx,a[i]);}

    st.resize(MX * 4,0);
    int ans = 0, c, l, r;
    loop(i,0,n)
    {
        l = max(0,a[i] - k); r = min(mx,a[i] + k);
        c = 1 + query(1,0,MX,l,r);
        ans = max(ans,c);
        update(1,0,MX,a[i],c);
    }

    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 8944
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int k = Integer.parseInt(sa[0]);
		int x = Integer.parseInt(sa[1]);
		br.close();

		if (500 * k >= x) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 19412
/**
 *    authur: Bao Trung <3
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define all(x) (x).begin(), (x).end()
#define set_vect(a,n); vector<int>a(n); for(auto &z : a)cin>>z;
const int mod = 1e9+7;
string s;
map <string,int> mp;
int res = 0;
void solve(){
	cin >> s;
	mp[s]++;
	if(mp[s] == 1) res++;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int t = 1; cin >> t;
	while(t--){solve();}
	cout << res;
	return 0;
}

// Code By CodeWar :3

Measured memory_bytes: 19212