akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<double,double> P;
double D(P a, P b){return sqrt((a.F-b.F)*(a.F-b.F)+(a.S-b.S)*(a.S-b.S));}
 
int main() {
  int n,tt=1;
  while(cin>>n&&n) {
    P a[n][2];
    for(int i=0; i<n; i++) {
      for(int j=0; j<2; j++) cin >> a[i][j].F >> a[i][j].S;
    }
    double dp[1<<n][n][2];
    for(int t=0;t<(1<<n);t++)for(int i=0;i<n;i++)for(int j=0;j<2;j++)dp[t][i][j]=1<<29;
    for(int i=0; i<n; i++) {
      for(int j=0; j<2; j++) dp[1<<i][i][j]=D(a[i][0],a[i][1]);
    }
    for(int t=0; t<(1<<n); t++) {
      for(int i=0; i<n; i++) {
        if(!(t&(1<<i))) continue;
        for(int j=0; j<2; j++) {
          for(int k=0; k<n; k++) {
            if(t&(1<<k)) continue;
            for(int l=0; l<2; l++) {
              dp[t|(1<<k)][k][l^1]=min(dp[t|(1<<k)][k][l^1],dp[t][i][j]+D(a[i][j],a[k][l])+D(a[k][0],a[k][1]));
            }
          }
        }
      }
    }
    double ans=1<<29;
    for(int i=0; i<n; i++)for(int j=0; j<2; j++) ans=min(ans,dp[(1<<n)-1][i][j]);
    cout<<"Case "<<tt++<<": ";
    printf("%.10f\n",ans);
  }
  return 0;
}


Measured memory_bytes: 6756
#include<bits/stdc++.h>
using namespace std;
#define N 200000 + 5
#define inf 123456789
#define Inf 10000000000000000
#define Mod 1000000007
#define base 1331
#define rep(i, l, r) for(register int i = l; i <= r; ++i)
#define dep(i, l, r) for(register int i = r; i >= l; --i)
#define Next(i, u) for(register int i = h[u]; i; i = e[i].next)
#define mem(f, x) memset(f, x, sizeof(f))
#define file(a) freopen(#a".in","r",stdin); freopen(#a".out","w",stdout);
typedef long long ll;
typedef double D;
int n, tot, Max, ans[N];
ll Hash;
bool book[N];
map <string, int> M;
string a[N];
int read(){
	char c; int x = 0, f = 1;
	c = getchar();
	while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9'){ x = (x << 3) + (x << 1) + c - '0'; c = getchar();}
	return x * f;
}
int Mul(int a, int b) { return 1ll * a * b % Mod; }
int Inc(int a, int b) { return (a += b) >= Mod ? a - Mod : a; }
int Dec(int a, int b) { return (a -= b) < 0 ? a + Mod : a; }
bool cmp(int x, int y){ return a[x] < a[y];}
signed main(){
	//file(data);
	n = read();
    rep(i, 1, n){
        cin >> a[i];
        M[a[i]] += 1;
        if(M[a[i]] > Max) Max = M[a[i]], mem(book, 0), book[i] = 1;
        else if(M[a[i]] == Max) book[i] = 1;
    }
    rep(i, 1, n) if(book[i]) ans[++tot] = i;
    sort(ans + 1, ans + tot + 1, cmp);
    rep(i, 1, tot) cout << a[ans[i]] << endl;
	return 0;
}

Measured memory_bytes: 28800
use std::io::stdin;
use std::io::BufRead;

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    let buf = buf.split_whitespace().map(|x| { x.parse::<u64>().unwrap() }).collect::<Vec<_>>();

    let n = *buf.get(0).unwrap();
    let m = *buf.get(1).unwrap();
    let l = *buf.get(2).unwrap();

    let mut A: Vec<Vec<u64>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        stdin.read_line(&mut buf);

        A.push(buf.split_whitespace().map(|x| { x.parse::<u64>().unwrap() }).collect::<Vec<_>>());
    }

    let mut B: Vec<Vec<u64>> = Vec::new();
    for _ in 0..m {
        let mut buf = String::new();
        stdin.read_line(&mut buf);

        B.push(buf.split_whitespace().map(|x| { x.parse::<u64>().unwrap() }).collect::<Vec<_>>());
    }

    let mut C: Vec<Vec<u64>> = Vec::new();
    for i in 0..n {
        let mut row_res: Vec<u64> = Vec::new();
        for j in 0..l {
            let mut element_res = 0;
            for k in 0..m {
                element_res += A.get(i as usize).unwrap().get(k as usize).unwrap() * B.get(k as usize).unwrap().get(j as usize).unwrap();
            }
            row_res.push(element_res);
        }
        C.push(row_res);
    }

    for row in C {
        println!("{}", row.iter().map(u64::to_string).collect::<Vec<_>>().join(" "));
    }
}


Measured memory_bytes: 5060
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.ABC161
{
    /// <summary>
    /// 
    /// </summary>
    static class B
    {
        static void Main(string[] args)
        {
            var n = NextInt();
            var m = NextInt();
            var aas = ReadIntArray();

            var sum = aas.Sum();
            Console.WriteLine(aas.Count(a => a >= (double)sum / (4 * m)) >= m ? "Yes" : "No");
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      String S =sc.next();
      
 if( S.charAt(2)==S.charAt(3)&&S.charAt(4)==S.charAt(5)){
   System.out.println("Yes");
 }else{
   System.out.println("No");
     }
    }
}
     

Measured memory_bytes: 22740
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> prime = new ArrayList<Integer>();
        ArrayList<Integer> fmod1 = new ArrayList<Integer>();
        for(int i = 3; i <= 55555; i++){
            boolean chk = true;
            for(int p : prime){
                if(i % p == 0){
                    chk = false;
                    break;
                }
            }
            if(chk){
                prime.add(i);
                if(i % 5 == 1){
                    fmod1.add(i);
                }
            }
        }
        for(int i = 0; i < n; i++){
            System.out.print(fmod1.get(i) + " ");
        }
        System.out.println();
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

bool is_need(vector<int>& A, int ix, int N ,int K)
{
  vector<vector<bool>> dp(N + 5, vector<bool>(K + 5, false));
  dp[0][0] = true;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= K; ++j) {
      dp[i + 1][j] = dp[i][j];
      if (i != ix and j - A[i] >= 0) {
        dp[i + 1][j] = dp[i + 1][j] or dp[i][j - A[i]];
      }
    }
  }
  for (int i = max(0, K - A[ix]); i < K; ++i) {
    if (dp[N][i]) { return true; }
  }
  return false;
}

int main()
{
  int N, K; scanf("%d %d", &N, &K);
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }
  sort(A.begin(), A.end(), greater<int>());

  int high = N, low = -1;
  while (high - low > 1) {
    int mid = (high + low) / 2;
    if (is_need(A, mid, N, K)) {
      low = mid;
    }
    else {
      high = mid;
    }
  }

  int ans = N - low - 1;
  printf("%d\n", ans);
  return 0;
}


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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            if (a >= 13)
                Console.WriteLine(b);
            if (a >= 6 && a <= 12)
                Console.WriteLine(b / 2);
            if (a <= 5)
                Console.WriteLine(0);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    int N;
    cin >> N;
    cout << N*800 - (N/15) * 200 << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define DOW(i,b,a) for (int i = (b); i >= (a); i--)
#define pb(a) push_back(a)
#define ALL(a) (a).begin(),(a).end()
#define fi first
#define se second

template<typename T>
void print_array(T* arr, int num) {
   FOR(i, 0, num) cout << arr[i] << ' ';
   cout << endl;
}

template<typename T> 
void print_vector(vector<T> vec) {
   FOR(i,0,vec.size()) cout << vec[i] << ' ';
   cout << endl;
}

int n,m,x,y;
set<int> st,ed;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    //freopen("test.txt", "r", stdin);
    cin >> n >> m;
    FOR(i,0,m) {
    	cin >> x >> y;
    	if (x == 1) st.insert(y);
    	if (y == n) ed.insert(x);
    }
    for(int a: st) {
    	if (ed.find(a) != ed.end()) {
    		cout << "POSSIBLE";
    		return 0;
    	}
    }
    cout << "IMPOSSIBLE";
}

Measured memory_bytes: 9600
N=int(input())
A,B  = list(map(int, input().split()))
lis = list(map(int, input().split()))
lis_1=[]
lis_2=[]
lis_3=[]
for i in lis:
    if i <= A:
       lis_1.append(i)
    elif i > A and i <=B:
       lis_2.append(i)
    else:
       lis_3.append(i)

print(min([len(lis_1),len(lis_2),len(lis_3)]))

Measured memory_bytes: 3064
#include <iostream>
#include <cassert>
#define REP(i,l,n) for(int i=l;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define MAX 1000000
int n,cou,digit;
char target,current;
char a[MAX],ans[MAX];
using namespace std;
int main() {
  while(1){
    cin >> n;
    if(n==0) return 0;
    cin >> a;
    rep(i,n){
      cou = 0;
      digit = 0;
      rep(j,MAX){
        //cout << i << " <-i,j-> " << j << " , " << a << " <-a,ans-> " << ans << endl;                                                                                                                                                                                                                                                   
        current = a[j];
        if(cou==0||target==current){
          cou++;
          target = current;
        }else{
          if(cou >= 100) ans[digit++] = (char)(cou/100 + '0');
          if(cou >= 10) ans[digit++] = (char)(cou/10%10 + '0');
          ans[digit++] = (char)(cou%10 + '0');
          ans[digit++] = target;
          cou = 1;
          target = current;
        }
        if(current == '\0'){
          ans[digit++] = '\0';
          break;
        }
      }
      rep(i,digit) a[i] = ans[i];
    }
    cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define newl '\n'

bool isprime(ll a)
{
    if(a<=1)
        return false;
    if(a==2||a==3)
        return true;
    if(a%2==0||a%3==0)
        return false;
    for(ll i=5;i*i<=a;i=i+6)
    {
        if(a%i==0||a%(i+2)==0)
            return false;
    }
    return true;

}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    string s;
    cin>>s;
    int count=0; int ans =0;
    for(int i=0;i<s.size();i++)
    {
       
       
            if(s[i]=='R')
            {
                count+=1;
                ans=max(ans,count);
            }
            else 
            {
                
                count=0;
                
            }
       
       
    }
    cout<<ans;
    
    return 0;
}


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

int main(){
    int f = 0, s = 0;
    for(int i = 0; i<3; i++){
        int a;
        cin >> a;
        if(a == 5) f++;
        else if(a == 7) s++; 
    }
    if(f == 2 && s == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
N = int(input())
A = [int(x) for x in input().split()]
if N%2==0:
    queue = deque()
    for i in range(0, N, 2):
        queue.append(A[i])
        queue.appendleft(A[i+1])
else:
    queue = deque([A[0]])
    for i in range(1, N, 2):
        queue.append(A[i])
        queue.appendleft(A[i+1])
 
print(*queue)

Measured memory_bytes: 25412
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    string s_front = s.substr(0,2);
    string s_back = s.substr(2,2);
    if("01" <= s_front && s_front <= "12" && "01" <= s_back && s_back <= "12") {
        cout << "AMBIGUOUS" << endl;
    }else if("01" <= s_front && s_front <= "12") {
        cout << "MMYY" << endl;
    }else if("01" <= s_back && s_back <= "12") {
        cout << "YYMM" << endl;
    }else {
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    k=I()
    s=""
    for i in range(k):
        s+="ACL"
    print(s)
    








if __name__=="__main__":
    main()



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

int bubbleSort(int A[], int N){
  int i, j;
  bool flag = true;
  int sw = 0;
  for(i = 0; flag; i++){
    flag = false;
    for(j = N - 1; j >= i + 1; j--){
      if(A[j] < A[j - 1]){
        swap(A[j], A[j - 1]);
        flag = true;
        sw++;
      }
    }
  }
  return sw;
}


int main(){
  
  int N;
  cin >> N;
  int A[100];
  for(int i = 0; i < N; i++)
    cin >> A[i];

  int sw;
  sw = bubbleSort(A,N);

  for(int i = 0; i < N; i++){
    if(i) cout << ' ';
    cout << A[i];
   }
    
   cout << endl;
   cout << sw << endl;

  return 0; 
}


Measured memory_bytes: 3096
#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() {
  string s;
  cin >> s;
  deque<char> q;
  for (char c : s) q.push_back(c);
  bool flip = false;
  int Q;
  cin >> Q;
  rep(qi,Q) {
    int ty;
    cin >> ty;
    if (ty == 1) {
      flip = !flip;
    } else {
      int f; char c;
      cin >> f >> c;
      if (flip) f = 3-f;
      if (f == 1) {
        q.push_front(c);
      } else {
        q.push_back(c);
      }
    }
  }
  if (flip) reverse(q.begin(), q.end());
  string ans;
  for (char c : q) ans += c;
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    cout << (c-a) * 60 + d-b - e << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3656
P, Q, R = map(int, input().split())

list_m = [P+Q,R+Q,P+R,Q+R,R+P,Q+P]

min = 200
for i in range(0,len(list_m)):
    if min > int(list_m[i]):
        min = list_m[i]

print(min)


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

string is_seven(int N)
{
  int reminder;
  while(N)
  {
    reminder = N%10;
    if(reminder == 7)
    {
      return "Yes";
      break;
    }
    N=N/10;
  }
  return "No";
}

int main()
{
  int N;
  cin >> N;
  cout << is_seven(N);
  return 0;
}

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

int main(){

	int i,j,n;
	int a[100] = {}, b[100] = {};
	cin >> n;

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

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

	for(j=0;j<n-1;j++){
	cout << b[j] << " "; 
	}cout << b[n-1] << endl;
	
	return 0;
}

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

int main()
{
    int N;cin >> N;
    int k=0;
    bool can=false;
    for (k=0;k<1000;k++)
    {
        if (k*(k-1)/2==N)
        {
            can=true;
            break;
        }
    }
    if (!can) cout << "No" <<endl;
    else
    {
        cout << "Yes" << endl;
        cout << k << endl;
        vector<vector<int>> sets(k,vector<int>(k-1,0));
        for (int i=0;i<k-1;i++)
        {
            for (int j=0;j<k-1-i;j++)
            {
                if (i!=0)
                {
                    sets[i][i+j]=1+j+sets[i-1][k-2];
                    sets[i+j+1][i]=1+j+sets[i-1][k-2];
                }
                else
                {
                    sets[i][i+j]=i+j+1;
                    sets[i+j+1][i]=i+j+1;
                }
            }
        }
        for (int i=0;i<k;i++)
        {
            cout << k-1 << " ";
            for (int j=0;j<k-1;j++)
            {
                cout << sets[i][j] << " ";
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using plpii = std::pair<long long, std::pair<int, int>>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

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

	int k, a, b;
	cin >> k >> a >> b;
	int i = 1;
	while (i * k <= b) {
		if (i*k >= a) {
			cout << "OK" << "\n";
			return 0;
		}

		++i;
	}

	cout << "NG" << "\n";

	return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,n) for(ll i=0;i<n;i++)
#define forne(i,n) for(ll i=1;i<=n;i++)
#define forse(i,s,e) for(ll i=s;i<e;i++)
#define all(v) v.begin(),v.end()
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
	// cin>>t;
	while(t--){
		char c;
		cin>>c;
		cout<<char(c+'b'-'a')<<endl;
	}
}

Measured memory_bytes: 256
//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;

ull a,b,n;
ll f(ll x) {
  return floor(a*x/b) - a*floor(x/b);
}


int main() {
  fastio;
  cin >> a >> b >> n;
  ll lo = -1;
  ull hi = min(n,b);
  while(hi - lo > 1) {
    ll mid = (hi + lo) >> 1;
    if (f(mid) > f(mid + 1)) {
      hi = mid;
    }
    else {
      lo = mid;
    }
  }
  cout << f(lo + 1) << endl;
  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


Measured memory_bytes: 3632
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,random
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
AA = inpl()

cnt = 0
plus_min = INF
mins_max = -INF
ans = 0

for a in AA:
    if a < 0:
        cnt += 1
        mins_max = max(mins_max,a)
        ans -= a
    else:
        plus_min = min(plus_min,a)
        ans += a

if cnt%2 == 0 :
    print(ans)
else:
    ans = max( ans + mins_max*2 , ans - plus_min*2 )
    print(ans)


Measured memory_bytes: 16380
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), true);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.flush();
		out.close();
	}
}

class Pair<A, B> {
	A first;
	B second;

	Pair(A first, B second) {
		this.first = first;
		this.second = second;
	}

}

class TaskB {
	int INF = (int) 1e3 + 5;
	long mod = (long) 1e9 + 7;

	public void solve(int testNumber, InputReader in, PrintWriter pw) {
		int N = in.nextInt();
		long arr[] = new long[N];
		for (int i = 0; i < N; i++) {
			arr[i] = in.nextLong();
		}
		long dp[][] = new long[N][N];
		for (int i = N - 1; i >= 0; i--) {
			for (int j = i; j < N; j++) {
				if (i == j) {
					dp[i][j] = arr[i];
				} else {
					dp[i][j] = Math.max(arr[i] - dp[i + 1][j], arr[j] - dp[i][j - 1]);
				}
			}
		}
		pw.println(dp[0][N - 1]);
	}

	boolean FirstRow_Col(Pair<Integer, Integer> pair) {
		return pair.first == 0 || pair.second == 0;
	}

	int __gcd(int a, int b) {
		if (b == 0)
			return a;
		return __gcd(b, a % b);

	}

	public int getInt(int num) {
		int ret = -1;
		switch (num) {
		case 0:
			ret = 6;
			break;
		case 1:
			ret = 2;
			break;
		case 2:
			ret = 5;
			break;
		case 3:
			ret = 5;
			break;
		case 4:
			ret = 4;
			break;
		case 5:
			ret = 5;
			break;
		case 6:
			ret = 6;
			break;
		case 7:
			ret = 3;
			break;
		case 8:
			ret = 7;
			break;
		case 9:
			ret = 6;
			break;
		}
		return ret;
	}

	public int isPow(long num) {
		int count = 0;
		while (num > 0) {
			num /= 2;
			count++;
		}
		return count;
	}
}

class InputReader {
	BufferedReader br;
	StringTokenizer st;

	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 97208
#include <stdio.h>
#include <algorithm>
#include <queue>
using namespace std;

const long long mod = 1000000007;
long long inv[100100]={0,1},fact[100100]={1,1},ifact[100100]={1,1};
int N,P[100100],D[100100],L[100100],G[100100],X[100100],S[200200];
queue<int> Q;

int main()
{
	scanf ("%d",&N);
	for (int i=1;i<=N;i++) scanf ("%d",&P[i]), D[P[i]]++;
	for (int i=1;i<=N;i++){
		if (D[i] >= 3){
			puts("0");
			return 0;
		}
		if (D[i] == 0) Q.push(i);
	}

	while (!Q.empty()){
		int x = Q.front(); Q.pop();

		if (L[P[x]]){
			puts("0");
			return 0;
		}
		L[P[x]] = L[x] + 1;
		if (--D[P[x]] == 0) Q.push(P[x]);
	}
	
	long long ans = 1;
	for (int i=1;i<=N;i++) if (D[i] == 1){
		int x = i, c = 0;
		while (D[x] == 1){
			X[c] = x;
			S[c] = (L[x] > 0);
			c++;

			D[x] = 0;
			x = P[x];
		}
		reverse(X,X+c);
		reverse(S,S+c);
		for (int i=0;i<c;i++) S[i+c] = S[i];
		for (int i=1;i<c*2;i++) S[i] += S[i-1];

		if (S[c-1] == 0) G[c]++;
		else{
			for (int i=0;i<c;i++){
				int x = X[i], v = 0;
				if (L[x]){
					if (L[x] <= c && S[i+L[x]-1] - S[i] == 0) v++;
					if (L[x] <= c-1 && S[i+L[x]] - S[i] == 0) v++;
					ans = ans * v % mod;
				}
			}
		}
	}

	for (int i=2;i<=N;i++){
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
		fact[i] = fact[i-1] * i % mod;
		ifact[i] = ifact[i-1] * inv[i] % mod;
	}

	for (int i=1;i<=N;i++) if (G[i]){
		long long coeff = (i % 2 == 1 && i > 1 ? 2 : 1);
		long long sum = 0, now = 1;
		for (int j=0;j<G[i];j++) now = now * coeff % mod;
		for (int j=0;j<=G[i]/2;j++){
			sum = (sum + now * fact[G[i]] % mod * ifact[j*2] % mod * ifact[G[i]-j*2]) % mod;
			now = now * (j * 2 + 1) % mod;
			now = now * i % mod;
			now = now * inv[coeff] % mod;
			now = now * inv[coeff] % mod;
		}
		ans = ans * sum % mod;
	}

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

	return 0;
}

Measured memory_bytes: 4608
M,D = map(int,input().split())
c = 0
for m in range(1,M+1):
    for d in range(1,D+1):
        d1 = d%10
        d10 = int((d-d1)/10)

        if d1 >= 2 and d10 >= 2 and d1*d10 == m:
            c+=1
print(c)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007ll
using namespace std;
ll mem[2003][2003], s;
ll dp(int sum, int tot)
{
    if(sum>s)return 0;
    if(tot>=s)return (tot==s);
    if(mem[sum][tot]!=-1)return mem[sum][tot];
    mem[sum][tot]= dp(sum+1, tot);
    mem[sum][tot]+= dp(3, tot+sum);
    return mem[sum][tot]%= mod;
}
int main()
{
    scanf("%lld", &s);
    memset(mem, -1, sizeof mem);
    printf("%lld\n", dp(3, 0));
    return 0;
}


Measured memory_bytes: 35232
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
int n, a[20], l[20], k;
bool b[20];
void f(int i) {
	if (i < 0) {
		int r = 0;
		for (int p = 0; p < k; p++) if (b[p]) r += a[p];
		cout << r << ':';
		for (int p = 0; p < k; p++)if (b[p])cout << ' ' << l[p];
		cout << endl;
		return;
	}
	b[i] = 0;
	f(i - 1);
	b[i] = 1;
	f(i - 1);
	return;
}
signed main() {
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		a[i] = 1;
		cin >> l[i];
		for (int j = 0; j < l[i]; j++)a[i] *= 2;
	}
	sort(a, a + k);
	f(k - 1);
}


Measured memory_bytes: 3104
use std::cmp::min;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let h: Vec<i32> = (0..n).map(|_| read()).collect();

    let mut dp = vec![1 << 30; n];
    dp[0] = 0;
    dp[1] = (h[1] - h[0]).abs();

    for i in 2..n {
        dp[i] = min(dp[i], dp[i - 1] + (h[i] - h[i - 1]).abs());
        dp[i] = min(dp[i], dp[i - 2] + (h[i] - h[i - 2]).abs());
    }
    println!("{}", dp[n - 1]);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
a_list = tuple(map(int, input().split()))
b_list = tuple(map(int, input().split()))
mod = 10 ** 9 + 7
a_set = set(a_list)
b_set = set(b_list)

if len(a_set) < N or len(b_set) < M:
    print(0)
    exit()

a_list = sorted(a_list, reverse=True)
b_list = sorted(b_list, reverse=True)
a_list.append(-1)
b_list.append(-1)
ans = 1
a_i = 0
b_i = 0
for i in range(N*M, 0, -1):
    if i == a_list[a_i] and i == b_list[b_i]:
        a_i += 1
        b_i += 1
    elif i == a_list[a_i]:
        a_i += 1
        ans *= b_i
        ans %= mod
    elif i == b_list[b_i]:
        b_i += 1
        ans *= a_i
        ans %= mod
    else:
        ans *= (a_i*b_i - (N * M - i))
        ans %= mod
print(ans % mod)



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

int n;

#define N 1005

string s[N], X;
int t[N];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i ++) cin >> s[i] >> t[i];
    cin >> X;
    int pos = -1;
    for (int i = 1; i <= n; i ++) if (s[i] == X) pos = i;
    int ans = 0;
    for (int i = pos+1; i <= n; i ++) ans += t[i];
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

using ll = long long;
const ll INF  = 1e9;
const ll MOD =  1e9 + 7;
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    for(int r = 0; r <= N; r++){
        for(int g = 0; g <= N; g++){
            if((N - r * R - g * G) % B == 0 && (N - r * R - g * G) >= 0){
                ans ++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define vint vector<signed>
#define pint pair<signed,signed>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");

signed main(){
  int n;
  cin>>n;
  int a[n+2]={0};
  for(int i=1;i<=n;++i)cin>>a[i];
  int sum=0;
  for(int i=1;i<n+2;++i)sum+=abs(a[i]-a[i-1]);
  for(int i=1;i<=n;++i){
    int res,part1,part2,part3;
    part1=abs(a[i-1]-a[i]);
    part2=abs(a[i]-a[i+1]);
    part3=abs(a[i-1]-a[i+1]);
    res=sum-part1-part2+part3;
    cout<<res<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  for(int i=0;i<N;i++){
    int a; cin >> a;
    if(a%2==0){
      if(a%3!=0 && a%5!=0){
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 100000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double PI = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;


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

	ll a, b, c;
	cin >> a >> b >> c;
	if (c <= a + b)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
n,k = map(int, input().split())
a = list(map(int, input().split()))
gki = sum(a[0:k])
tmp = gki
rng = k
for i in range(k,n):
  tmp = tmp-a[i-k]+a[i]
  if tmp>gki:
    gki = tmp
    rng = i+1
  
E = 0
for i in a[rng-k:rng]:
  E += (i+1)/2
print(E) 

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;

const ll mod = 1000000007;

bool ok(const char* c, int size) {
	for (int i = 0; i < size / 2; i++) {
		if (c[i] != c[size - 1 - i]) {
			return false;
		}
	}
	return true;
}

int main(void)
{
	int h, w, k;
	std::cin >> h >> w >> k;
	vector<string> grid(h);
	rep(i, h) {
		std::cin >> grid[i];
	}
	ll u = 1LL << (h - 1);
	ll sum = INF;
	rep(bits, u) {
		int p = 0;
		map<int, int> ms;
		for (int i = 0; i < h; i++) {
			ms[i] = p;
			if (bits & (1 << i)) {
				p++;
			}
		}
		vector<int> prev(h, 0);
		vector<int> now(h, 0);
		bool ng = false;
		ll ss = p;
		for (int j = 0; j < w; j++) {
			now.assign(h, 0);
			for (int i = 0; i < h; i++) {
				if (grid[i][j] == '1') {
					now[ms[i]]++;
				}
			}
			bool div = false;
			for (int i = 0; i < h; i++) {
				if (now[ms[i]] > k) {
					ng = true;
					break;
				}
				auto c = now[ms[i]] + prev[ms[i]];
				if (c > k) {
					div = true;
					break;
				}
			}
			if (ng) break;
			if (div) {
				ss++;
				rep(i, h) {
					prev[i] = now[i];
				}
			}
			else {
				rep(i, h) {
					prev[i] += now[i];
				}
			}
		}
		if (ng) continue;
		if (sum > ss) {
			sum = ss;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	string s;
	int n,k;
	cin>>s; cin>>k;
	n = s.size();
	string t;
	t = s;
	for(int i=0;i<n;i++){
		t.pb(s[i]);
	}
	int good = -1;
	for(int i=0;i<n-1;i++){
		if( s[i] != s[n-1] ){ good = i; break; }
	}
	if( good == -1 ){
		int ans = n*k/2;
		cout<<ans<<endl;
		return 0;
	}
	int cur = 0, cnt = 0;
	for(int i=good;i<good+n;i++){
		if( cur == 0 )cur++;
		else{
			if( t[i] == t[i-1] )cur++;
			else{
				cnt += cur/2;
				cur = 1;
			}
		}
	}
	cnt += cur/2;
	int ans = 0;
	ans += cnt * (k-1);
	cur = 0, cnt = 0;
	for(int i=good;i<n;i++){
		if( cur == 0 )cur++;
		else{
			if( t[i] == t[i-1] )cur++;
			else{
				cnt += cur/2;
				cur = 1;
			}
		}
	}
	cnt += cur/2;
	ans += cnt;
	cout<<ans+good/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=20005;
int fl[N],pri[N];
int v1[N],v2[N],n;
void init(){
	For(i,2,N-1) For(j,2,(N-1)/i) fl[i*j]=1;
	For(i,2,N-1) if (!fl[i]&&*pri<=2*n+6) pri[++*pri]=i;
	//printf("%d %d\n",*pri,pri[*pri]);
}
int main(){
	scanf("%d",&n); init();
	For(i,0,n+n+2) v1[i]=v2[i]=1;
	For(i,0,n+1){
		int v=i;
		if (v%2==0) v1[v]=pri[(*pri)--];
		if ((v+n+1)%2==0) v2[v]=pri[(*pri)--];
		v=n+n+2-i;
		if (v%2==0) v1[v]=pri[(*pri)--];
		if ((v+n+1)%2==0) v2[v]=pri[(*pri)--];
	}
	/*printf("%d %d %d\n",v1[n],v1[n+1],v1[n+2]);
	printf("%d %d %d\n",v2[n],v2[n+1],v2[n+2]);
	printf("%d\n",*pri);
	return 0;*/
	//printf("%d\n",*pri);
	For(i,1,n) For(j,1,n)
		if ((i+j)%2==0) printf("%lld%c",1ll*v1[i+j]*v2[i+n-j+1],j==n?'\n':' ');
		else printf("%lld%c",1ll*v1[i+j-1]*v1[i+j+1]*v2[i+n-j]*v2[i+n-j+2]+1,j==n?'\n':' ');
}

Measured memory_bytes: 3072
#include <stdio.h>

int main(void)
{
	int n, i;
	int a[1001];

	scanf("%d", &n);

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

	for (i = 0; i < n; i++) {
		if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0) {
			printf("DENIED\n");
			return 0;
		}
	}

	printf("APPROVED\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstring>
#include <set>
using namespace std;

int main(){
	int n;
	cin>>n;
	set<string> S;
	while(n--){
		string x;
		cin>>x;
		S.insert(x);
	}
	cout<<S.size()<<endl;;
	return 0;
}


Measured memory_bytes: 15648
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 1*1e5 +5 ;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
ll binomialCoeff(ll n, ll k) 
{ 
    ll C[n + 1][k + 1]; 
    ll i, j; 


    for (i = 0; i <= n; i++) 
    { 
        for (j = 0; j <= min(i, k); j++) 
        { 
            
            if (j == 0 || j == i) 
                C[i][j] = 1; 

            else
                C[i][j] = (C[i - 1][j - 1] + 
                                        C[i - 1][j])%MOD; 
        } 
    } 

    return C[n][k]; 
}
bool compare(const string &a , const string&b){
    //set<pair<int,int> , decltype(&compare)>s(&compare) ;
}

// struct compare{
//     // for priority_queue
//     bool operator()(const int &a , const int&b){
//         return a<b ;
//     }
// };
vector<int>g[N] ;

vector<bool>vis(N) ;
void dfs(int ver){
    vis[ver] = 1 ;
    for(auto node : g[ver]){
        if(!vis[node]){
            dfs(node) ;
        }
    }
}
void solve()
{
    int n , m ; 
    cin>>n>>m;
    rep(i , m){
        int x , y , z ;
        cin>>x>>y>>z ;
        g[x].pb(y) ;
        g[y].pb(x) ;
    }
    int cost = 0 ;
    repu(i , 1  , n){
        if(!vis[i]){
            dfs(i) ;
            cost++;
        }
    }
    cout<<cost<<endl;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 12248
answer = 0
mod = 10**9 + 7
a,b = (int(n) for n in input().split(" "))
if abs(a-b) <= 1:
    temp1 = 1
    for i in range(1,a+1):
        temp1 = (temp1 * i) % mod
    temp2 = 1
    for i in range(1,b+1):
        temp2 = (temp2 * i) % mod
    answer += (temp1 * temp2) % mod
    if (a + b) % 2 == 0:
        answer = (answer * 2) % mod
    print(answer)
else:
    print(0)


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

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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

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

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

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

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

ll bin(ll n, ll i) {
	if (i == 0) { return n % 2; }
	else { return bin(n / 2, i - 1); }
}

	
int main() {

	ll n;
	cin >> n;
	string s;
	cin >> s;

	ll ans = 0;

	rep(i, n - 1) {

		ll v = 0;

		for (char c = 'a'; c <= 'z'; c++) {
			ll b = 0;

			for (ll j = 0; j <= i; j++) {
				if (s[j] == c) { b++; break; }
			}

			for (ll j = i + 1; j < n; j++) {
				if (s[j] == c) { b++; break; }
			}

			if (b == 2) { v++; }

		}

		ans = max(v, ans);

	}

	cout << ans;

	system("PAUSE");
}

Measured memory_bytes: 504
#include <stdint.h>
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <string>
#include <vector>

int cost[10];
int dist[10][10];
int expanded[10];

void djkInit() {
  for (int i = 0; i < 10; i++) {
    cost[i] = 0xfffffff;
  }
  cost[1] = 0;
}

void djkExpand(int n) {
  for (int i = 0; i < 10; i++) {
    int tmp = cost[n] + dist[i][n];
    if (cost[i] > tmp) {
      cost[i] = tmp;
    }
  }
  expanded[n] = 1;
}

void djk() {
  djkExpand(1);
  for (;;) {
    int min = 0xfffffff, minIndex;
    for (int i = 0; i < 10; i++) {
      if (expanded[i]) continue;
      if (min > cost[i]) {
        min = cost[i];
        minIndex = i;
      }
    }
    if (min == 0xfffffff) {
      break;
    }
    djkExpand(minIndex);
  }
}

int main(int argc, char *argv[]) {
  int H, W;
  std::cin >> H >> W;
  int A[H][W];
  for (int y = 0; y < 10; y++) {
    for (int x = 0; x < 10; x++) {
      std::cin >> dist[y][x];
    }
  }
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      std::cin >> A[y][x];
    }
  }
  djkInit();
  djk();
  int sum = 0;
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (A[y][x] != -1) {
        sum += cost[A[y][x]];
      }
    }
  }
  std::cout << sum << std::endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<string>
#include<sstream>
#include<iomanip>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string first,second;
        cin>>first;
        cin>>second;
        int carry=0;
        ostringstream sout;
        sout<<setfill('0')<<setw(max(first.length(),second.length()))<<first;
        first=sout.str();
        sout.str("");
        sout<<setfill('0')<<setw(max(first.length(),second.length()))<<second;
        second=sout.str();
        string ans="";
        for(int j=first.length()-1;j>=0;j--){
           int d1,d2;
           d1=first[j]-'0';
           d2=second[j]-'0';
           int sum=d1+d2+carry;
           carry=sum/10;
           char d3=sum%10+'0';
           ans=d3+ans;
        }
        if(carry==1)ans='1'+ans;
        if(ans.length()<=80)cout<<ans<<endl;
        else cout<<"overflow"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3128
//	Author : amnptl 
//	   Godbless
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define NeedForSpeed() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD (1000000007); // 1e9+7
int main()
{
	NeedForSpeed();
	ll n,k; cin>>n>>k; int a[n+1], ans[n+1];
	for(int i=1; i<=n; i++) cin>>a[i], ans[i] = -1;
	int curtown = 1; int cnt = 0;
	while(ans[curtown]==-1)
	{
		ans[curtown] = cnt++; 
		curtown = a[curtown];
	}
	int fin = ans[curtown]; int clen = cnt - fin;
	for(int i=1; i<=n; i++)
	{
		if(ans[i]==-1) continue;
		if((k<fin && ans[i]==k )|| (k>=fin && ans[i]>=fin && ans[i]%clen==k%clen))
		{
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	const int dr[] = { 0, -1, 0, 1, 0 };
	int h, w;
	cin >>h >>w;
	vector<string> ba(h);
	rep(i, h) cin >>ba[i];
	
	rep(i, h) rep(j,w) if(ba[i][j]=='#'){
		bool ok = false;
		rep(k, 4){
			int ny=i+dr[k], nx=j+dr[k+1];
			if(ny<0 ||ny>=h ||nx<0 || nx>=w) continue;
			if(ba[ny][nx]=='#') ok=true;
		}
		if(!ok){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main(void){
    int n,d;cin>>n>>d;
    cout<<(n+2*d)/(2*d+1)<<endl;
}

Measured memory_bytes: 764