akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	LL h,w;
	cin >> h >> w;
	LL ans = INT64_MAX;

	// 縦に3分割
	ans = min(ans,w % 3 == 0 ? 0 : h);
	// 横に3分割
	ans = min(ans,h % 3 == 0 ? 0 : w);
	// 縦全探索->横半分
	for (LL i = 1; i < w; i++) {
		LL s1 = i * h;
		LL s2 = (w - i) * (h / 2);
		LL s3 = (w - i) * ((h / 2) + h % 2);
		ans = min(ans,max(max(abs(s1 - s2),abs(s2 - s3)),abs(s3 - s1)));
	}
	// 横全探索->縦半分
	for (LL i = 1; i < h; i++) {
		LL s1 = i * w;
		LL s2 = (h - i) * (w / 2);
		LL s3 = (h - i) * ((w / 2) + w % 2);
		ans = min(ans,max(max(abs(s1 - s2),abs(s2 - s3)),abs(s3 - s1)));
	}

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


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<class T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return 1; } return 0; }

int N, M, P;
vector<bool> visit;
vector<bool> seen;

void dfs(int v, const vector<vector<int>> &G) {
    if (seen[v]) return;
    visit[v] = true; seen[v] = true;
    for (auto u : G[v]) if (!seen[u]) dfs(u, G);
}

template<typename T>
pair<bool, vector<T>> bellmanford(const vector<vector<pair<int, T>>> &G, int s) {
    const T inf = numeric_limits<T>::max();
    int V = G.size();
    vector<T> dist(V, inf); dist[s] = 0;
    bool negative_cycle = false;
    
    for (int relax = 0; relax <= V; relax++) {
        for (int from = 0; from < V; from++) {
            for (const auto &e : G[from]) {
                int to; T cost; tie(to, cost) = e;
                if (dist[from] == inf) continue;
                if (dist[from] + cost < dist[to]) {
                    dist[to] = dist[from] + cost;
                    if (relax == V && visit[to]) negative_cycle = true;
                }
            }
        }
    }
    return {negative_cycle, dist};
}

int main() {
    cin >> N >> M >> P;
    vector<vector<pair<int, int>>> G(N);
    vector<vector<int>> H(N);
    seen.resize(N, false);
    visit.resize(N, false);
    for (int i = 0; i < M; i++) {
        int v, u, c; cin >> v >> u >> c; v--; u--;
        G[v].emplace_back(u, P-c);
        H[u].emplace_back(v);
    }
    
    dfs(N-1, H);
    
    bool neg; vector<int> dist;
    tie(neg, dist) = bellmanford(G, 0);
    
    int ans = max(0, -dist[N-1]);
    if (neg) ans = -1;
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n;
  long double m,c=0,c2=0;
  cin >> n >> m;
  long double a[n];
  for(int i=0;i<n;++i)cin >> a[i];
  for(int i=0;i<n;++i){
    c += a[i];
  }
  for(int i=0;i<n;++i){
    if(a[i]>=c/(4*m))c2++;
  }
  if(c2>=m){
    cout << "Yes"<<endl;
  }else{
    cout << "No"<<endl;
  }

  
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  
 public static void main(String args[]){
   int N=0;
   Scanner obj=new Scanner(System.in);
   N=obj.nextInt();
   int h[]=new int[N];
   for(int i=0;i<N;i++){
    h[i]=obj.nextInt();
   }
   int dp[]=new int[N];
	if(N==0)
      {
System.out.println(0);
return;
}
   if(N==1)
{     	
System.out.println(0);
return;
}
   if(N==2)
     {
System.out.println(Math.abs(h[0]-h[1]));
return;
}
   dp[0]=0;
   dp[1]=Math.abs(h[0]-h[1]);
   for(int i=2;i<N;i++){
    dp[i]= Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i] -h[i-2])+dp[i-2]);
   }
   System.out.println(dp[N-1]);
 }
}


Measured memory_bytes: 59140
a,b,c,d=map(int,input().split())
if a>=0 and c>=0:
    print(b*d)
if a>=0 and c<0:
    if d>=0:
        print(b*d)
    else:
        print(a*d)
if a<0 and c>=0:
    if b>=0:
        print(b*d)
    else:
        print(b*c)
if a<0 and c<0:
    if b>=0 and d>=0:
        print(max(a*c,b*d))
    else:
        print(a*c)

Measured memory_bytes: 9200
def ans():
    n = int(input())
    nowt, nowa = 1,1
    for _ in range(n):
        t, a = map(int, input().split())
        c = max(nowt//t,nowa//a)
        if nowt > c * t or nowa > c * a:
            c += 1
        nowt, nowa = max(c*t,t), max(c*a,a)
    return int(nowa+nowt)

print(ans())


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
const ll mod=1e9+7;

const int N=100+1, W=2e5;
ll dp[W],n,p;



int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();
    
    cin>>n>>p;
    vector<ll> w(n),v(n);
    for(ll i=0;i<n;i++)
        cin>>w[i]>>v[i];
    for(ll j=n-1;j>=0;j--){
        for(ll i=p;i>=0;i--){
            dp[i+w[j]]=max(dp[i+w[j]],dp[i]+v[j]);
        }
    }
    ll ans=0;
    for(ll i=0;i<=p;i++)
        ans=max(ans, dp[i]);
    cout<<ans;




    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}

Measured memory_bytes: 5248
s = int(input())

a = [s]
idx = 1
while True:
    idx += 1

    if a[-1] % 2 == 0:
        a.append(a[-1] // 2)
    else:
        a.append(3*a[-1] + 1)
    
    if a[-1] in a[:-1]:
        break

print(idx)

Measured memory_bytes: 3060
/*By Mohan Abhyas V*/
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>  
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

ll mpow(ll a, ll b){
	if(b >= (MOD-1)) b %= (MOD-1);
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

ll mpow(ll a, ll b, ll p){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2,p);   t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}
ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}
ll range(ll l, ll r){
	return l + rand()%(r-l+1);
}

p64 hashFn(v64 vc)
{
    ll p1 = 31, p2 = 97;
    ll m1 = 1e9+9, m2 = 998244353;
    ll hsv1 = 0, hsv2 = 0, p_pow1 = 1, p_pow2 = 1;
    forn(i, vc.size())
    {
        hsv1 = ((hsv1 + vc[i] + 1) * p_pow1) % m1;
        p_pow1 = (p_pow1 * p1) % m1;

        hsv2 = ((hsv2 + vc[i] + 1) * p_pow2) % m2;
        p_pow2 = (p_pow2 * p2) % m2;
    }
    return mp(hsv1, hsv2);
}
     
void solve(){
   ld l;
   cin>>l;
   ld ans = l*l*l;
   ans /= 27.000;
   cout<<setprecision(15)<<ans<<ln; 
}
 
int main()
{
	fast_cin();
    ll t=1;
    //cin>>t;
    forn(i,t) {
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    }
    return 0;
}

/*
1) try dp
2) meet in the middle
3) correct complexity analysis
4) randomized algorithm
5) brute force

*/

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

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i,m) cin >> b[i];
    int ans = 0;
    rep(i,n){
        int sum = 0;
        rep(j,m){
            int a;
            cin >> a;
            sum += a*b[j];
        }
        if(sum + c > 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=2e5+50;
using namespace std;
int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
{
	int n;
	cin>>n;
	int tab[n];
	for(int i=0;i<n;i++)
	{
		cin>>tab[i];
	}
	int s=0;
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			s+=tab[i]*tab[j];
		}
	}
	cout<<s;
}


Measured memory_bytes: 256
#include <stdio.h>

#define min(a, b) ((a) < (b) ? (a) : (b))

int main(void)
{
	int A, B, C, ans = 0;
	scanf("%d %d %d", &A, &B, &C);

	ans = min(B / A , C);
	printf("%d\n", ans);
	return 0;
}


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

int main(){
  int sell=0,num=0;
  int a,b,count=0;
  while(scanf("%d,%d",&a,&b)!=EOF){
    count++;
    sell+=a*b;
    num+=b;
  }
  cout<<sell<<endl;
  cout<<(num+(count/2))/count<<endl;
}

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

int main() {
	int H,W,D,A,Q,L,R;
	cin >> H >> W >> D;
	vector<vector<int>> m(H, vector<int>(W,0));
	vector<P> p(H*W);

	rep(i,H)
		rep(j,W) {
			cin >> A;
			p.at(A-1) = P(i,j);
		}

	rep(i,D) {
		int x=i+D;
		while(x < H*W) {
			int sy=p.at(x-D).first, sx=p.at(x-D).second, ty=p.at(x).first, tx=p.at(x).second;
			m.at(ty).at(tx) = m.at(sy).at(sx) + abs(sy-ty) + abs(sx-tx);
			x += D;
		}
	}

	cin >> Q;
	rep(i,Q) {
		cin >> L >> R;
		--L, --R;
		cout << m.at(p.at(R).first).at(p.at(R).second) - m.at(p.at(L).first).at(p.at(L).second) << endl;
	}
}

Measured memory_bytes: 2176
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

ll n,a[200005] = {};

int main(){
    IN n;
    inrep(n,a);

    rep(i,0,n-1){
        a[i+1] += a[i];
    }
    
    map<ll,ll> m;
    rep(i,0,n)m[a[i]] ++;

    ll ans = m[0];
    for(auto ite: m)if(ite.sd >= 2)ans += (ite.sd * (ite.sd-1) /2);
    P(ans);
    
	return  0;
}

Measured memory_bytes: 14336
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    char b[1000];
    char a[1000];
    char c[1000];
    char d[1000];
    int m=0;
    int n=0;
    while(~scanf("%s%s",a,b))
    {
        int j=strlen(a);
        int k=strlen(b);
        for(int i=0; i<j; i++)
        {
            c[m]=a[i];
            m++;
        }
        for(int i=k-1; i>=0; i--)
        {
            d[n]=b[i];
            n++;
        }
        if(strcmp(c,d))
            printf("NO\n");
        else
            printf("YES\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
     cout.tie(0);   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n;
   cin>>n;
   if(n==2)
   {
      cout<<1;
      return 0;
   }
   unordered_set<int>s;
   for(int i=2;i*i<=n;i++)
   {
      if(n%i==0)
      {
         s.insert(i);
         s.insert(n/i);
      }
   }
   s.insert(n);
   unordered_set<int>ans;

   for(auto i:s)
   {
      int z=i;
      int x=n;
      while (x%i==0)
      {
         x/=i;
      }
            
      if((x-1)%i==0)
      {
         ans.insert(i);
      }
   }
   n--;
   for(int i=2;i*i<=n;i++)
   {
      if(n%i==0)
      {
         ans.insert(i);
         ans.insert(n/i);
      }
   }

   ans.insert(n);

   cout<<ans.size();

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int m1,d1,m2,d2;
        m1=scan.nextInt();
        d1=scan.nextInt();
        m2=scan.nextInt();
        d2=scan.nextInt();
        if(m1!=m2) System.out.println(1);
        else System.out.println(0);
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,i;
  int64_t s;
  cin>>n;
  s=0;
  for(i=1;i<=n;i++) if (i%3>0 && i%5>0) s+=i;
  cout<<s<<endl;
}

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

int main(void) {
    string S;
    cin >> S;
    cout << S;
    if (S[S.length() - 1] == 's') {
        printf("es\n");
    } else {
        printf("s\n");
    }
    return 0;
}


Measured memory_bytes: 3624
//
//  main.cpp
//  190113
//

#include <iostream>
#include <regex>

std::string parts(std::string s,int sta,int fin){
    std::string ret="";
    for(int i=sta;i<fin;i++){
        ret+=s[i];
    }
    return ret;
}

int main(int argc, const char * argv[]) {
    // insert code here...
//    //std::string str[3] = {"int", "double[4]", "char[32]"}; // 対象文字列
//    std::string str[3] = {"inta", "Uint", "inxt"}; // 対象文字列
//    //std::regex re("(int|double|char)(\\[(\\d+)\\])?"); // 正規表現
//    std::string reStr=R"((^in))";
//    std::cout<<reStr;
//    //std::regex re(R"((^in))");
//    std::regex re(reStr);
//    std::smatch match; // string型の文字列に対するマッチング結果を格納するのがstd::smatch型
//
//    for( int i = 0; i < 3; ++i ){
//        if(regex_search(str[i], match, re)){ // regex_match()は正規表現にマッチすると1を返す
//            std::cout << "matched: " ;
//            for ( int j = 0; j < match.size(); ++j ){ // match.size()はサブグループの数+1を返す
//                std::cout << match[j] << ":";
//            }
//            std::cout << std::endl;
//        }
//    }
    
    std::string a="keyence";

    
    std::string S;
    std::cin>>S;
    
    //std::cout<<S<<std::endl;
    
    bool isYes=false;
    std::smatch match;
    
    std::string wilds="";
    for(int i=0;i<S.size()-a.size();i++){
        wilds+="\\w";
    }
    
    for(int i=0;i<7+1;i++){
        for(int j=0;j<i;j++){
            std::string reStr="(";
            reStr+=parts(a, 0, j);
            reStr+=wilds;
            reStr+=parts(a, j, 7);
            reStr+=")";
            std::regex re(reStr);
            
            //std::cout<<reStr<<std::endl;
            if(regex_match(S, match, re)){
                isYes=true;
            }
        }
    }
    
    if(isYes){
        std::cout<<"YES\n";
    }else{
        std::cout<<"NO\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
  int N;
  char S[100001];
  scanf("%d",&N);
  scanf("%s",S);
  int i;
  int ans=N;
  for(i=0;i<N;i++){
    if(S[i]==S[i+1]){
      ans=ans-1;
    }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define fs first
#define sc second
#define pb push_back
using namespace std;
 
typedef pair<int,int> P;
struct edge{int u,v,cost;};
bool comp(const edge& e1, const edge& e2){return e1.cost<e2.cost;}
 
int n,m;
int s,t,c;
edge e[10100];
vector<int> sp;
vector<P> g[1010];
bool use[1010],h[10100];
 
int dfs(int pos){
  if(use[pos])return 0;
  use[pos] = true;
  int res = 1;
  for(int i=0;i<g[pos].size();i++){
    if(h[g[pos][i].sc])continue;
    res += dfs(g[pos][i].fs);
  }
  return res;
}
 
int main(){
  while(cin >> n >> m,n||m){
    for(int i=0;i<m;i++){
      sp.clear();
      cin >> s >> t >> c;
      s--; t--;
      e[i].u = s;
      e[i].v = t;
      e[i].cost = c;
    }
 
    sort(e,e+m,comp);
    sp.clear();    
 
    for(int i=0;i<n;i++)g[i].clear();
    
    for(int i=0;i<m;i++){
      g[e[i].u].pb(P(e[i].v,i));
      g[e[i].v].pb(P(e[i].u,i));
      h[i] = false;
    }
 
    for(int i=m-1;i>=0;i--){
      for(int j=0;j<n;j++)use[j] = false;
      h[i] = true;
      if(dfs(0) != n){
	h[i] = false;
	sp.pb(e[i].cost);
      }
    }
        
    sort(sp.begin(),sp.end());
    cout << sp[n/2-1] << endl;
  }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
    int s;
    cin>> s;
    vll v;
    rep(i, 3, s + 2)
        v.pb(i);
    int n = v.size();
    vll dp(s + 2, 1);
    dp[0] = 0, dp[1] = 0, dp[2] = 0;
    rep(i, 0, s + 2){
        rep(j, 0, n){
            int gg = i - v[j];
            if(gg < 3)
                continue;
            dp[i] += dp[gg];
            dp[i] %= mod;
        }
    }
    cout<< dp[s]<< "\n";
    return 0;
}
//Counting problems: Sometimes easier to find complement of the answer
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


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

int main()
{
  int A, B; cin >> A >> B;
  int ans = A - 2 * B;
  if (ans > 0) {
    cout << ans << endl;
  }
  else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
def main():
    n, m, d = map(int, input().split())

    if n - 2 * d - 1 >= 0:
        p1 = (n-2*d) / n
        p2 = 1 - p1
    else:
        p1 = 0
        p2 = 2 * d / n
    if d == 0:
        ans = p1 * 1 / n + p2 / n
        ans *= (m - 1)
    else:
        ans = p1 * 2 / n + p2 / n
        ans *= (m-1)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n = 3;
  int c[n][n];
  REP(i, 0, n) {
    REP(j, 0, n) { cin >> c[i][j]; }
  }
  bool ok = 1;
  REP(j, 1, n) {
    int cand = c[0][j]-c[0][0];
    REP(i,1,n){
      if(cand!=c[i][j]-c[i][0])ok=0;
    }
  }
  Yes(ok);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;

int N;

int main() {
    cin >> N;
    long long sum = 0;
    int mn = 1e9;
    bool flag = false;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        if (a != b) flag = true;
        if (a > b && mn > b) {
            mn = b;
        }
        sum += b;
    }
    if (flag) {
        sum -= mn;
    } else {
        sum = 0;
    }
    
    cout << sum << endl;
}

Measured memory_bytes: 256
def main():
    n, s = map(int, input().split())
    a = sorted([int(i) for i in input().split()])
    mod = 998244353
    dp = [[0] * (s + 1) for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(n):
        ai = a[i]
        for j in range(s + 1):
            if j < ai:
                dp[i + 1][j] = dp[i][j] * 2 % mod
            else:
                dp[i + 1][j] = (dp[i][j] * 2 % mod + dp[i][j - ai]) % mod
    print(dp[n][s])

if __name__ == '__main__':
    main()

Measured memory_bytes: 132120
#include <iostream>

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

using namespace std;

int main()
{
	int N;
	while(cin>>N,N)
	{
		int max = 0, min = 1<<16;
		REP(i,N)
		{
			int sum = 0;
			REP(j,5)
			{
				int s;
				cin>>s;
				sum += s;
			}
			if (max < sum) max = sum;
			if (sum < min) min = sum;
		}
		cout << max << " " << min << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
char s[1000];
int n,k;
scanf("%d %d",&n,&k);
scanf("%s",s);
s[k-1]=s[k-1]+0x20;
printf("%s",s);
return 0;
}

Measured memory_bytes: 128
// Problem : B - ... (Triple Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int k;
		cin>>k;
		string s;
		cin>>s;
		int n = s.size();
		if(n>k)
		{
			cout<<s.substr(0,k)<<"...";
		}
		else
		cout<<s;    	
    }
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int s[200003];
int n,t,k;
int main()
{
  scanf("%d%d",&n,&k);
  for (int i=1;i<=n;i++)
  {
    scanf("%d",&t);
    s[t]--;
  }
  sort(s+1,s+n+1);
  for (int i=1;i<=k;i++)
  {
    n+=s[i];
  }
  printf("%d\n",n);
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
using namespace std;
int input();
string IntToString(int);

int main() {
  int A,B;
  cin>>A>>B;
  if(A%2==0||B%2==0){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
  
  
  
  

  


}
int input(){
  int x;
  cin>>x;
  return x;
}


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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
vector<pii> v[N];
void solve(){
    ll n;
    cin>>n;
    ll a,b;
    rep(i,1,n-1){
        cin>>a>>b;
        v[a].pb({b,i});
        v[b].pb({a,i});
    }
    vi ans(n,0);
    ll maxx=0;
    rep(i,1,n){
        ll fk=1;
        // set<ll> ss;
        mii mm;
        for(auto j:v[i]){
            if(ans[j.S]!=0) mm[ans[j.S]]++;
        }
        for(auto j:v[i]){
            // cout<<fk<<endl;
            while(mm[fk]!=0) fk++;
            if(ans[j.S]==0) {ans[j.S]=fk;
            mm[fk]=1;}
            // cout<<fk<<" ";
            // ss.insert(fk);
        }
        // cout<<endl; 
    }
    rep(i,1,n-1) maxx=max(maxx,ans[i]);
    cout<<maxx<<endl;
    rep(i,1,n-1) cout<<ans[i]<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 9076
//2018-6-2
//miaowey
//
#include <bits/stdc++.h>
using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)

int Calc(int a){
	int ret = 0;
	while(a){
		ret += a % 10; a/= 10;
	}
	return ret;
}

int main(){
	int n, ans = 100000;

	scanf("%d", &n);
	For(a, 1, n - 1) ans = min(ans, Calc(a) + Calc(n - a));
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,i,j,k;
int x[200005];
int y[200005];
main()
{
	scanf("%d",&a);
	for(i=1;i<=a;i++)
	{
		scanf("%d",&x[i]);
		y[i]=x[i];
	}
	sort(x,x+a+1);
	for(i=1;i<=a;i++)
	{	//printf("%d")
		if(y[i]>x[a/2])
		{
			printf("%d\n",x[a/2]);
		}
		else
		{
			printf("%d\n",x[a/2+1]);
		}
	}
}

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

using namespace std;
using ll=long long;

char c[27]= {'0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
string ans;

ll genCharNum(ll num){
    if(num<=26) {
        ans += c[num];
        // cout << num << endl;
        return num;
        }
    else if(num % 26 ==0){
        ans += c[26];
        // cout << 26 << endl;
        return genCharNum((num-1)/26);
    }
    else{
        // cout << num%26 << endl;
        ans += c[num%26];
        return genCharNum(num/26);
    } 
}



int main(){
    ll num;
    cin >> num;
    genCharNum(num);
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const int N = ;
int n, mx, g, a, k;

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n >> k;
	for(int i = 1; i <= n; i++ ) {
		cin >> a;
		mx = max(a, mx);
		g = __gcd(g, a);
	}

	if(mx >= k &&k % g == 0) cout << "POSSIBLE\n";
	else cout << "IMPOSSIBLE\n";
}	

	

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int inf = 0x3f3f3f3f;
const int maxn = 2e3 + 10;
const int mod = 1e9 + 7;

typedef long long ll;

int n, k;
ll dp[maxn][maxn];

int read()
{
	int x;
	scanf("%d", &x);
	return x;
}

int main()
{
	n = read(), k = read();
	dp[0][0] = 1;	
	for(int i = 1; i <= 2000; i ++)
	{
		for(int j = 1; j <= 2000; j ++)
		{
			dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];
			dp[i][j] %= mod;
		}
	}
	for(int i = 1; i <= k; i ++)
	{
		ll ans = dp[k][i]*(dp[n-k][i]+dp[n-k][i]+dp[n-k][i+1]+dp[n-k][i-1]);
		cout << ans % mod << endl;
	}
}

Measured memory_bytes: 31616
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N,W;
    cin >> N >> W;
    ll maxv=100000;
    ll dp[N+1][maxv+1];
    ll i,j;
    dp[0][0]=0;
    for(j=1;j<=maxv;j++){
      dp[0][j]=W+1;
    }
    ll w,v;
    for(i=1;i<=N;i++){
      cin >> w >> v;
      for(j=0;j<=maxv;j++){
        dp[i][j]=dp[i-1][j];
          if(j-v>=0 && dp[i][j]>dp[i-1][j-v]+w)dp[i][j]=dp[i-1][j-v]+w;
      }
    }
    for(j=maxv;j>=0;j--){
      if(dp[N][j]<=W){
        cout << j;
        return 0;
      }
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

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

int main(){
	//input
	ll N,K,Q; cin>>N>>K>>Q;
	vector<ll> A(Q);
	vector<ll> truee(N+1,0);
	vector<ll> ans(N+1,false);
	rep(i,Q) cin>>A[i];
	rep(i,Q){
		truee[A[i]]++;
	}
	rep1(i,N){
		if(Q-truee[i]<K) ans[i]=true;
	}
	rep1(i,N){
		if(ans[i]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
using namespace std;
int head = 0;
int tail = 0;

struct mission
{
	char name[100];
	int time;
};

mission A[100000],B[100000];

void EnQueue(mission mis) {
	A[head++] = mis;
	if (head>= 100000) {
		head = 0;
	}
}

void DeQueue() {
	tail++;
	if (tail >= 100000) {
		tail = 0;
	}
}

bool isEmpty() {
	if (tail == head) { return true; }
	return false;
}

int main() 
{
	int n,times;
	cin >> n>>times;
	for (int i = 0; i < n; i++) {
		mission temp;
		cin >> temp.name >> temp.time;
		EnQueue(temp);
	}
	int time= 0;
	while (!isEmpty()) {
		if (A[tail].time > times) {
			A[tail].time -= times;
			EnQueue(A[tail]);
			DeQueue();
			time += times;
		}
		else {
			time += A[tail].time;
			cout << A[tail].name << " " << time<< endl;
			DeQueue();
		}
	}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string S;
    cin>>S;

    int N=S.size();
    int dl[N+1]{};
    int dr[N+1]{};
    dl[0]=0;
    dr[N]=0;
    int r=0,l=0;
    rep(i,N){
        if(S[i]=='<')l++;
        else l=0;
        dl[i+1]=l;
    }
    for(int i=N-1;i>=0;i--){
        if(S[i]=='>')r++;
        else r=0;
        dr[i]=r;
    }
    int ans=0;
    rep(i,N+1){
        //cout << max(dl[i],dr[i]) <<" ";
        ans+=max(dl[i],dr[i]);
    }
    cout<<ans<<endl;



}


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

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    int ans[4] ={0};
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;

        if(s == "AC") ans[0]++;
        if(s == "WA") ans[1]++;
        if(s == "TLE") ans[2]++;
        if(s == "RE") ans[3]++;
    }

    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;

    return 0;
}

Measured memory_bytes: 3632
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& STL DEBUGGER &&&&&&&&&&&&&&&&&&&&&&&&&&&

//#define _GLIBCXX_DEBUG       // Iterator safety; out-of-bounds access for Containers, etc.
//#pragma GCC optimize "trapv" // abort() on (signed) integer overflow.

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& LIBRARIES &&&&&&&&&&&&&&&&&&&&&&&&&&&

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

/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; 
*/
// find_by_order(), order_of_key() 

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEFINES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#define int long long int 
#define ld long double
#define X first
#define Y second
#define all(i) i.begin(), i.end()
#define sz(a) (int)a.size()
 
const ld PI  = 3.141592653589793238463;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEBUG &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define XOX
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}
 
void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
 
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CODE &&&&&&&&&&&&&&&&&&&&&&&&&&&
	

void solve(){
	int k, a, b;
	cin >> k >> a >> b;
	for(int i = a; i <= b; ++i){
		if( i % k == 0){
			cout << "OK\n";
			return;
		}
	}
	cout << "NG\n";
}

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    int T = 1; 
    //cin >> T;
    for(int tc = 1; tc <= T; ++tc){
		//cout << "Case #"<< tc <<": ";
        solve();
    }
    return 0;
}
/*
Sample inp
*/

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

int n;
int a[200000];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  
  map<int, int> his;
  long sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += his[a[i]];
    ++his[a[i]];
  }
  
  for (int i = 0; i < n; ++i) {
    long k = his[a[i]];
    long diff = k * (k - 1) / 2 - (k - 1) * (k - 2) / 2;
    cout << sum - diff << endl;
  }
}

Measured memory_bytes: 8320
h, w = map(int, input().split())
s = [input() for _ in range(h)]
for i in range(h):
    l = ''
    for j in range(w):
        if s[i][j] == '#': l += '#'
        else:
            l += str(sum([ss[max(0, j-1):min(w, j+2)].count('#') for ss in s[max(0, i-1):min(h, i+2)]]))
    print(l)


Measured memory_bytes: 3316
//dp[i][j][k] = i枚目までのカードでj枚選んで合計がkである組合せ
//カードを選ばない　dp[i + 1][j][k] += dp[i][j][k]
//カードを選ぶ　　　dp[i + 1][j + 1][k + x[i]] += dp[i][j][k]

#include<stdio.h>
long long int dp[51][51][2510] = { { { 1 } } };
int main() {
	int N, A;
	scanf("%d%d", &N, &A);
	int *X = (int *)malloc(sizeof(int)*N);
	for (int i = 1; i <= N; i++)
	{
		scanf("%d", &X[i]);
	}

	for (int i = 1; i <= N; i++)
	{
		for (int j = 0; j <= N; j++)
		{
			for (int k = 0; k <= 2500; k++)//
			{
				if (k < X[i]) {
					dp[i][j][k] = dp[i - 1][j][k];
				}
				else if (j >= 1) {
					dp[i][j][k] = dp[i - 1][j - 1][k - X[i]] + dp[i - 1][j][k];
				}
			}
		}
	}
		long long int ans = 0;
		for (int j = 1; j <= N; j++) {
			ans += dp[N][j][j*A];
		}
		printf("%lld\n", ans);
		return 0;
	}

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

int main() {
  int n; cin >> n;
  int a[n], pref[n+1];
  for (int i = 1; i <= n; i++) cin >> a[i];
  pref[0] = 0;
  for (int i = 1; i <= n; i++) pref[i] = pref[i-1] + a[i];
  int s1 = a[1], s2 = pref[n]-pref[1], sum;
  sum = abs(s2-s1);
  for (int i = 2; i < n; i++) 
  {
    int st1 = 1, en1 = i, st2 = i+1, en2 = n;
    s1 = pref[en1] - pref[st1-1];
    s2 = pref[en2] - pref[st2-1];
    sum = min(sum, abs(s2-s1));
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int inf=1e18;
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int a,b,n;
    cin >> a >> b >> n;
    int x=min(n,b-1);
    cout << (a*x)/b-a*(x/b);
}

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

using namespace std;

#define M 1000000007
int main()
{
    int n,m;
    cin>>n>>m;
    int dp[n+1][m+1];
    char key[n+1][m+1];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>key[i][j];
        }
    }
    dp[1][1]=1;

    for(int i=2;i<=n;i++)
    {
        if(key[i][1]=='#')
        {
            dp[i][1]=0;
        }
        else{
        dp[i][1]=dp[i-1][1];
        dp[i][1]=(dp[i][1]%M);
        }
    }
    for(int i=2;i<=m;i++)
    {
        if(key[1][i]=='#')
        {
            dp[1][i]=0;
        }
        else{
        dp[1][i]=dp[1][i-1];
        dp[1][i]=(dp[1][i]%M);
        }
    }

    for(int i=2;i<=n;i++)
    {
        for(int j=2;j<=m;j++)
        {
              if(key[i][j]=='#')
              {
                  dp[i][j]=0;
                  continue;
              }
              dp[i][j]=dp[i-1][j]+dp[i][j-1];
              dp[i][j]=(dp[i][j]%M);
        }
    }
    cout<<dp[n][m]<<endl;
}


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main()
{
    int n;
    cin >> n;
    
    int x[n];
    int l[n];
    vector<pair<int, int>> range(n);
    for (auto i =0 ; i < n; i ++)
    {
        cin >> x[i] >> l[i];
        range[i] = make_pair(x[i] - l[i], x[i] + l[i]);
    }

    // sort
    sort(range.begin(), range.end());

    int maxRange = range[0].second;
    int ans = 0;
    for (auto i = 1; i < n; i ++)
    {
        if (maxRange > range[i].first)
        {
            ans++;
            if (maxRange > range[i].second)
            {
                maxRange = range[i].second;
            }
        }
        else
        {
            maxRange = range[i].second;
        }
    }
    cout << n - ans << endl;
    return 0;
}


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

using namespace std;

int main() {
  int ans = 0;
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    s[i] == '+' ? ans++ : ans--;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue

n, a, b = list(map(int, input().split()))

ll = [[-1 for i in range(401)] for j in range(401)]

# queue = Queue()
ll[0][0] = 0
for i in range(n):
    ap, bp, price = list(map(int, input().split()))
    #    next = Queue()
    #    for q in queue:
    #        ll[q[0] + ap][q[1] + bp] = min(ll[q[0]][q[1]] + price, ll[q[0] + ap][q[1] + bp])
    #        next.put_nowait([q[0] + ap, q[1] + bp])
    for aa in reversed(range(390)):
        for bb in reversed(range(390)):
            if ll[aa][bb] >= 0:
                if ll[aa + ap][bb + bp] < 0:
                    ll[aa + ap][bb + bp] = 99999
                ll[aa + ap][bb + bp] = min(ll[aa + ap][bb + bp], ll[aa][bb] + price)
              #  print(aa+ap,bb+bp,ll[aa+ap][bb+bp])
ret = 9999999
for aa in range(401):
    for bb in range(1, 401):
        if abs(float(aa) / bb - float(a) / b) < 0.001 and ll[aa][bb] > 0:
            ret = min(ret, ll[aa][bb])
if ret > 900000:
    print('-1')
else:
    print(ret)

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

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

int main() {
    ll a, b, n, ans = -1;

    cin >> a >> b >> n;
    ll x = n, cnt = 0;

    if (b <= n) {
        x = b;
        if (b != n)ans = max(ans, a * (x + 1) / b - a * ((x + 1) / b));
        ans = max(ans, a * (x - 1) / b - a * ((x - 1) / b));
    }else{
        ans = a * n / b - a * (n / b);
    }

    /*
    x = n;
    while (x) {
        cout << "x = " << x << " " << a * x / b - a * (x / b) << endl;
        ans = max(ans, a * x / b - a * (x / b));
        x--;
        if (cnt > 1e+7) break;
        cnt++;
    }
*/

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
x,y = map(int, raw_input().split())
ret = 10**9 + 7
if x <= y:
    ret = min(ret, y - x)
if -x <= y:
    ret = min(ret, y + x + 1)
if x <= -y:
    ret = min(ret, -y - x + 1)
if -x <= -y:
    ret = min(ret, -y + x + 2)
print ret


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

using namespace std;

typedef long long ll;

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

	ll x;
	cin>>x;

	ll res = x;

	for(int i=0;i<n-1;i++)
	{
		cin>>x;
		res=__gcd(x,res);
	}

	cout<<res<<'\n';
	return 0;	
}

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

int main(){
    int i,n,x,y,a=0,b = 0;
    string T,H;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>T>>H;
        if(T==H){
            a+=1;
            b+=1;
        }else if(T<H){b+=3;
        }
        else if(T>H){a+=3;
        }
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin>>n;
  vector<int> ans(1000010,0);

  rep(i,1,110){
    rep(j,1,110){
      rep(k,1,110){
        int now = i*i+j*j+k*k+i*j+j*k+i*k;
        ++ans[now];
      }
    }
  }
  rep(i,1,n+1) cout<<ans[i]<<'\n';
  return 0;
}

Measured memory_bytes: 11096