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

ll N;
string s;


int main(){
  cin>>s;
  N=s.size();
  ll ans=N*(N-1)/2;
  ll cnt[26]={};
  for(int i=0;i<N;i++)cnt[ s[i]-'a' ]++;

  for(int i=0;i<26;i++){
    ans-= cnt[i]*(cnt[i]-1)/2;
  }

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


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, K;
	long long X[100000], ans = 1000000000000000000;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> X[i];
	}
	for (int i = 0; i <= N - K; i++) {
		long long time;
		int l = i, r = i + K - 1;
		if (X[l] * X[r] >= 0) {
			time = max(abs(X[l]), abs(X[r]));
		}
		else {
			time = 2 * min(abs(X[l]), abs(X[r])) + max(abs(X[l]), abs(X[r]));
		}
		ans = min(ans, time);
	}
	cout << ans;
}

Measured memory_bytes: 1024
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;

void a(){
    string n; cin >> n;
    if(n.find_first_of("7")!=string::npos){
        cout << "Yes"<<endl;
    }else{
        cout << "No"<<endl;
    }
}

void b(){
    ll n; cin >> n;
    ll sum =0;
    for(ll i=1;i<=n;i++){
        if(i%3==0&&i%5==0) continue;
        else if(i%3==0) continue;
        else if(i%5==0) continue;
        else sum+=i; 
    }
    cout << sum << endl;
}

ll gcd(ll a,ll b){
    return (b==0)?a:gcd(b,a%b);
}

ll ggcd(ll a,ll b,ll c){
    return gcd(gcd(a,b),c);
}
void c(){
    int k;
    cin >> k;
    ll ans =0;
    for(int a=1;a<=k;a++)
        for(int b=1;b<=k;b++)
            for(int c=1;c<=k;c++){
                ans +=ggcd(a,b,c);
            }

    cout << ans << endl;
}

void d(){

}

void e(){

}

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

Measured memory_bytes: 3168
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int result = 0;
		ArrayList<Integer> h = new ArrayList<Integer>();
		for(int i = 0; i < N; i++) {
			h.add(sc.nextInt());
			if(h.get(i) >= K) {
				result++;
			}
		}
		System.out.println(result);
		sc.close();
	}
}


Measured memory_bytes: 62512
/*...Part - 01...*/

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <iterator>
#include <bitset>
#include <assert.h>
#include <new>
#include <sstream>
//#include <bits/stdc++.h>
using namespace std ;

/*...Part - 02...*/

typedef long long               ll ;
typedef long double             ld ;
typedef unsigned long long      ull ;
typedef pair<int,int>           pii ;
typedef pair<ll,ll>             pll ;
typedef vector<int>             vi ;
typedef vector<ll>              vll ;
typedef vector<vector<int>>     vvi ;

int Int(){int x ; scanf("%d",&x) ; return x ;}
ll Long(){ll x ; scanf("%lld",&x) ; return x ;}

/*...Part - 03...*/
/*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/*...Part - 04...*/
/*...Needed to change according to problem requirements...*/

const int N          = (int)3e3 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;

/*..........................................................*/
/*...Part - 05...*/

#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     Int         Int()
#define     Long        Long()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

/*...Part - 06...*/
/*...... ! Code start from here ! ......*/

bool vis[N][N] ;
double dp[N][N], a[N];
int n ;

double call(int p, int h){
	if(p == n){
		if(h > p - h)return 1.00 ;
		return 0.0 ;
	}
	if(vis[p][h])return dp[p][h] ;
	double& ret = dp[p][h] ;
	vis[p][h] = 1 ;
	ret += call(p + 1, h + 1) * a[p] ;
	ret += call(p + 1, h) * (1.0 - a[p]) ;
	return ret ;
}

int main(){
    int test = 1 , tc = 0 ;
    while(test--){
        n = Int ;
        for(int i = 0 ; i < n ; ++i)cin >> a[i] ;
        printf("%.10f\n",call(0,0));
    }
    return 0 ;
}

/*...Always look at the part - 04...*/
/*...............END................*/




Measured memory_bytes: 78080
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int a;
    string s;
    cin >> a >> s;
    if(a>=3200) cout << s << endl;
    else cout << "red" << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d%d", $H, $W);
echo str_repeat("#", $W + 2),"\n";
for($i = 0; $i < $H; $i++){
    echo "#".trim(fgets(STDIN))."#","\n";
}
echo str_repeat("#", $W + 2),"\n";


Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;cin>>a>>b>>c;
  string ans="NO";
  int sum=0;
  do{
    sum+=a;
    if(sum%b==c){ans="YES";break;}
  }while(sum%b!=0);
  cout<<ans;
}

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

int main() {
  int A, B;
  cin >> A;
  cin >> B;
  
  int count = 0;
  
  for(int i=A; i<=B; i++)
  {
    int n1 = i % 10;
    int n2 = (i % 100) / 10;
    int n3 = (i % 1000) / 100;
    int n4 = (i % 10000) / 1000;
    int n5 = (i % 100000) / 10000;
    
    if(n1 == n5 && n2 == n4) count++;
  }
  
  cout << count << endl;
  
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();

    ll a, v;
    cin >> a >> v;
    ll b, w;
    cin >> b >> w;
    ll t;
    cin >> t;
    if (a > b) {
        swap(a, b);
    }

    ll aa = a + v * t, bb = b + w * t;
    if (aa >= bb) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
//#define TASK "file"

#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long i64;
typedef long double dbl;
const dbl PI = acos(-1.0L);
const dbl EPS = 1e-12L;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

namespace task {
int a, b;

int main() {
  cin >> a >> b;
  for (int p = 0; p < 20000; ++p) {
    if (p * 8 / 100 == a && p / 10 == b) {
      cout << p << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
  return 0;
}
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(11);
  cout.setf(ios::fixed);
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#elif defined(TASK)
  freopen(TASK".in", "r", stdin);
  freopen(TASK".out", "w", stdout);
#endif
  return task::main();
}


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

int sum(int x){
    int res=0;
    while(x){
        res+=x%10;
        x/=10;
    }
    return res;
}
int main(){
    int n;
    cin>>n;
    int res=1e9;
    for(int a=1;a<n;a++){
        int b=n-a;
        res=min(sum(a)+sum(b),res);
    }    
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K;
string S,T;
ll ans;
ll x[1000000];
ll y[1000000];
ll a[1000000];
ll b[1000000];
ll c[1000000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
ll possible[10000000];
int main() {
	cin>>N;
	if(N==1){
		cout<<"Yes"<<endl;
		cout<<2<<endl;
		cout<<1<<" "<<1<<endl;
		cout<<1<<" "<<1<<endl;
		return 0;
	}
	rep(i,1,N){
		if(i*(i+1)>=10000000)break;
		possible[i*(i+1)]=i+1;
	}
	if(possible[N*2]==0){
		cout<<"No"<<endl;
	}else{
		ll num=possible[N*2];
		cout<<"Yes"<<endl;
		cout<<num<<endl;
		ll anstable[1000][1000];
		ll lastnum=0;
		for(int i=1;i<=num;++i){
			cout<<num-1;
			ll count=0;
			for(int j=1;j<i;++j){
				cout<<" "<<anstable[j][i-1];
				//anstable[i][j]=anstable[j][i-1];
				count++;
			}
			while(count<num-1){
				lastnum++;
				cout<<" "<<lastnum;
				count++;
				anstable[i][count]=lastnum;
			}
			cout<<endl;
		}
	}
	return 0;
}


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

namespace algorithm
{
	class Program
	{

		static void Main(string[] args)
		{
			//配列全てに処理(入力.分割,数値に変換)
			var nk = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
			var b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

			int ans=Math.Abs(nk[1]-b[0]);


			foreach (var tmp in b)
			{
				ans = Gcd(Math.Abs(tmp-nk[1]), ans);
			}

			Console.Write(ans);

		}
		public static int Gcd(int a, int b)
		{
			Func<int, int, int> gcd = null;
			gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
			return a > b ? gcd(a, b) : gcd(b, a);
		}
	}
}


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

template<class T = long long> constexpr T PINF(){ return std::numeric_limits<T>::max(); }
template<class T = long long> constexpr T MINF(){ return std::numeric_limits<T>::lowest(); }

template <typename T>
class RMQ{
private:
  vector<T> data;
  int n;
  const T UNDEF;

  T _query(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) return UNDEF;

    if(a <= l && r <= b){
      return data[k];
    }else{
      T left  = _query(a, b, 2 * k + 1, l, (l + r) / 2);
      T right = _query(a, b, 2 * k + 2, (l + r) / 2, r);
      return min(left, right);
    }
  }
public:
 
    RMQ(int n_, T UNDEF_):n(1),UNDEF(UNDEF_){
        while(n < n_) n *= 2;
        data = vector<T>(this->n * 2, UNDEF);
    }
 
    void update(int k, T a){
        k += n - 1;
        data[k] = a;
        while (k > 0)
        {
            k = (k - 1) / 2;
            data[k] = min(data[2 * k + 1], data[2 * k + 2]);
        }
    }

    T query(int a, int b) { return _query(a, b, 0, 0, n); }
};
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);

    int n,q;
    cin >> n >> q;
    RMQ<long long> rmq(n,(1LL<<31)-1);
    for(int i = 0; i < q; ++i){
      int a,b,c;
        cin >> a >> b >> c;
        if(a==0){
          rmq.update(b,c);
        }else{
          cout << rmq.query(b,c+1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define all(a) begin(a), end(a)
#define sz(a) (int)(a.size())
#define deb(a) cout << #a << ": " << a << ENDL
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;

int main()
{   _
    lli n, x, t; cin >> n >> x >> t;
    if(n % x == 0) n /= x;
    else n = (n - n %x + x) / x;
    cout << n * t << ENDL;
    return 0;
}


Measured memory_bytes: 3580
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		long sum = 1;
		boolean exceed = false;
		boolean zero = false;
		for(int i = 0; i < t; i++) {
			long curr = sum;
			long a = sc.nextLong();
			if(a == 0)
				zero = true;
			sum *= a;
			if(sum > (long)1e18 || curr > sum) {
				exceed = true;
			}
		}
		if(zero)
			System.out.println(0);
		else if(exceed)
			System.out.println(-1);
		else
			System.out.println(sum);
	}
}

Measured memory_bytes: 59956
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

set_random;

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll a , b , c , d;

ll get(ll x){
    return b / x - (a - 1) / x;
}

int main() {
    fast_io;

    cin >> a >> b >> c >> d;
    cout << b - a + 1 - get(c) - get(d) + get(c * d / __gcd(c , d)) << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int Par[100001],Rank[100001],Sum[100001],Ans[100001];

void init(int n)
{
	for(int i =0;i<n;i++)
	{
		Par[i] = i;
		Rank[i] = 0;
		Sum[i] = 1;
	}
}

int find(int x)
{
	if(Par[x]==x)return x;
	return x = find(Par[x]);
}

void unite(int x,int y)
{
	x = find(x);
	y = find(y);
	if(x==y)return;
	if(Rank[x]<Rank[y])
	{
		Par[x]=y;
		Sum[y] += Sum[x];
	}
	else
	{
		Par[y] = x;
		Sum[x] += Sum[y];
		if(Rank[x]==Rank[y])Rank[x]++;
	}
}

int main()
{
	int n,m,k;
	cin >> n >> m >> k;
	init(n);
	for(int i = 0;i<m;i++)
	{
		int x,y;
		cin >> x >> y;
		x--;y--;
		unite(x,y);
		Ans[x]--;
		Ans[y]--;
	}
	for(int i = 0;i<n;i++)
	{
		Ans[i] += Sum[find(i)]-1;
	}
	for(int i =0;i<k;i++)
	{
		int x,y;
		cin >> x >> y;
		x--;y--;
		if(find(x)==find(y))
		{
			Ans[x]--;
			Ans[y]--;
		}
	}
	for(int i =0;i<n;i++)
	{
		cout<<Ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2432
def main():
    n = int(input())
    a = list(map(int, input().split()))
    plus = []
    minus = []
    for i in a:
        if i > 0:
            plus.append(i)
        elif i < 0:
            minus.append(i)
        else:
            if len(minus) == 0:
                minus.append(i)
            else:
                plus.append(i)
    plus.sort(reverse=True)
    minus.sort()
    if len(minus) == 0:
        minus.append(plus.pop())
    elif len(plus) == 0:
        plus.append(minus.pop())
    print(sum(plus)-sum(minus))
    now = minus[-1]
    for i in range(len(plus) - 1):
        print(now, plus[i])
        now -= plus[i]
    print(plus[-1], now)
    now = plus[-1] - now
    for i in range(len(minus) - 1):
        print(now, minus[i])
        now -= minus[i]
main()

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

int main(){
 int n,x;
 while(true){
  cin>>n>>x;
  int count =0;
  if(n==0&&x==0) break;
  for(int i=1;i<=n;i++){
   for(int j=i+1; j<=n; j++){
    for(int k=j+1; k<=n; k++){
     if(i+j+k==x) count++;
    }
   }
  }
 cout << count << endl;
 }
}


Measured memory_bytes: 3136
X, K, D = map(int, input().split())
 
X = abs(X)
time = X//D
rest = K - time
 
if rest <= 0:
    print(X-K*D)
elif rest%2 == 0:
    print(min(X-time*D, abs(X-(time+2)*D)))
else:
    print(min(X-(time-1)*D, abs(X-(time+1)*D)))


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

using namespace std;
typedef long long ll;

ll sign(ll x) {
  return (x>0)-(x<0);
}

int main() {
  ll N; cin >> N;
  vector<ll> A(N);
  ll mc = 0;
  for (ll j=0; j < N; ++j){
    cin >> A[j];
    if (A[j] < 0) mc += 1;
  }
  ll ans = 0;
  if (mc % 2 == 0) {
    for (ll j=0; j < N; ++j) {
      ans += abs(A[j]);
    }
  } else {
    ll midx = 0, tmp = abs(A[0]);
    for (ll j=1; j < N; ++j) {
      if (tmp > abs(A[j])) {
        midx = j;
        tmp = abs(A[j]);
      }
    }
    for (ll j=0; j < N; ++j) {
      if (j != midx) ans += abs(A[j]);
    }
    ans -= abs(A[midx]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
#include<cstdio>
#include<algorithm>
int n,m;
long long x[1001],y[1001],z[1001];
long long t[1001];
long long ans=-2147483647;
long long sum=0;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld%lld",&x[i],&y[i],&z[i]);
	}
	for(int i=-1;i<=1;i+=2)for(int j=-1;j<=1;j+=2)for(int k=-1;k<=1;k+=2){
		for(int I=1;I<=n;I++){
			t[I]=1ll*i*x[I]+1ll*j*y[I]+1ll*k*z[I];
		}
		std::sort(t+1,t+n+1);
		for(int I=n;I>n-m;I--) sum+=t[I];
		if(sum>ans) ans=sum;
		sum=0;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())
a = list(map(int, input().split()))

a.sort(reverse=True)
sub = sum(a)
ans = 0
touhyou = sub * (1 / (4 * m))
for i in range(n):
    if a[i] >= touhyou:
        ans += 1

if ans >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
n,a,b,c=map(int,input().split())
s_=[input() for i in range(n)]
ans=""
for i in range(n):
    s1,s2=s_[i]
    if s2=="B":
        if i!=n-1:
            if s_[i+1]=="AC" and c==0 and a<=1:
                a,b,ans=(a+1,b-1,ans+"A")
            elif s_[i+1]=="BC" and c==0 and b<=1:
                a,b,ans=(a-1,b+1,ans+"B")
            else:
                a,b,ans=(a-1,b+1,ans+"B") if a>b else (a+1,b-1,ans+"A")
        else:
            a,b,ans=(a-1,b+1,ans+"B") if a>b else (a+1,b-1,ans+"A")
        if min(a,b)==-1:
            print("No")
            break
    elif s1=="A":
        if i!=n-1:
            if s_[i+1]=="AB" and b==0 and a<=1:
                a,c,ans=(a+1,c-1,ans+"A")
            elif s_[i+1]=="BC" and b==0 and c<=1:
                a,c,ans=(a-1,c+1,ans+"C")
            else:
                a,c,ans=(a-1,c+1,ans+"C") if a>c else (a+1,c-1,ans+"A")
        else:
            a,c,ans=(a-1,c+1,ans+"C") if a>c else (a+1,c-1,ans+"A")
        if min(a,c)==-1:
            print("No")
            break
    else:
        if i!=n-1:
            if s_[i+1]=="AB" and a==0 and b<=1:
                b,c,ans=(b+1,c-1,ans+"B")
            elif s_[i+1]=="AC" and a==0 and c<=1:
                b,c,ans=(b-1,c+1,ans+"C")
            else:
                b,c,ans=(b-1,c+1,ans+"C") if b>c else (b+1,c-1,ans+"B")
        else:
            b,c,ans=(b-1,c+1,ans+"C") if b>c else (b+1,c-1,ans+"B")
        if min(b,c)==-1:
            print("No")
            break
else:
    print("Yes")
    for j in range(n):
        print(ans[j])



Measured memory_bytes: 16412
n,m = map(int,input().split())

la = []
for i in range(n):
    la.append(input())

lb = []
for i  in range(m):
    lb.append(input())

for i in range(n-m+1):
    for j in range(n-m+1):

        f = True
        for k in range(m):
            for l in range(m):
                if la[i+k][j+l] !=lb[k][l]:
                    f = False
        if f:
            print("Yes")
            exit()

print("No")


Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arrA = sc.next().toCharArray();
		char[] arrB = sc.next().toCharArray();
		char[] arrC = sc.next().toCharArray();
		if (arrA[arrA.length - 1] == arrB[0] && arrB[arrB.length - 1] == arrC[0]) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 20820
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

d = onem()

c = l()

s = []
for i in range(d):
	s.append(l())
day = [0 for i in range(26)]

c = [[c[i],i] for i in range(26)]
c.sort(reverse = True)

for i in range(d):
	print(c[i%26][1]+1)

Measured memory_bytes: 68236
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


K = int(input())
cnt = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            L = [i,j,k]
            cnt += gcd(*L)
print(cnt)

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

class POINT{
  public:
  int X;
  int Y;
  void set(int x, int y){
    X=x;
    Y=y;
  }
};

int Distance(POINT a, POINT b){
  return abs(a.X-b.X)+abs(a.Y-b.Y);
}

int main() {
  int N, M;
  cin >> N >> M;
  POINT Person[N];
  POINT CheckPoint[M];
  for(int i=0 ; i<N ; i++){
    int a, b;
    cin >> a >> b;
    Person[i].set(a, b);
  }
  for(int i=0 ; i<M ; i++){
    int a, b;
    cin >> a >> b;
    CheckPoint[i].set(a, b);
  }
  
  for(int i=0 ; i<N ; i++){
    int min_dis=400000000, num;
    for(int j=0 ; j<M ; j++){
      //cout << "Dis=" << Distance(CheckPoint[j], Person[i]) << endl;
      if(min_dis>Distance(CheckPoint[j], Person[i])){
        num=j;
        min_dis=Distance(CheckPoint[j], Person[i]);
      }
    }
    cout << ++num << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,F;
  double D,E=99999.0;
  cin >> A;
  vector<int>S(A);
  cin >>B>>C;
  for(int i=0;i<A;i++)cin >> S[i];
  for(int i=0;i<A;i++){
    D=B-S[i]*0.006;
    D=C-D;
    if(D<0)D*=-1.0;
    if(E>D){
      E=D;
      F=i+1;
    }
  }
  cout << F << endl;
}


Measured memory_bytes: 256
import sys
import math

N = 1000000
primes = [1] * (N//2)
primes[0] = 0

for i in range(3,int(math.sqrt(N)),2):
    if primes[i//2]:
        primes[(i*i)//2::i] = [0] * len(primes[(i*i)//2::i])

for i in sys.stdin:
    n = int(i)
    if n == 1:
        print(0)
    elif n == 2:
        print(1)
    else:
        print(sum(primes[0:(n+1)//2])+1)

Measured memory_bytes: 17036
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;

int main()
{
    int n, q;
    cin >> n >> q;
    dsu d(n);
    rep(i,q)
    {
        int t, u, v;
        cin >> t >> u >> v;
        if(t) cout << d.same(u, v) << "\n";
        else d.merge(u, v);
    }
    return 0;
}

Measured memory_bytes: 4004
local mfl, mce = math.floor, math.ceil
local mmi, mma = math.min, math.max
local n = io.read("*n")
local t = {}
_u = io.read("*n")
for i = 1, n - 1 do
  t[i] = io.read("*n")
end
n = n - 1
local ret = 0
for i = 1, n do
  local c = 0
  for j = 1, n do
    if n % i == 0 then
      if n - i * j <= i * j then break end
    end
    if n - i * j < i then break end
    c = c + t[i * j] + t[n - i * j]
    ret = mma(ret, c)
  end
end
print(ret)


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll M;
	cin >> M;
	cout << (24-M) + 24 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 200200
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
struct Line{int u,v,w;}e[MAX<<1];
bool operator<(Line a,Line b){return a.w<b.w;}
int n,Q,m,v[MAX],f[MAX];long long ans=0;
int getf(int x){return x==f[x]?x:f[x]=getf(f[x]);}
int main()
{
	n=read();Q=read();memset(v,127,sizeof(v));
	while(Q--)
	{
		int A=read()+1,B=read()+1,C=read();
		e[++m]=(Line){A,B,C};
		v[A%n+1]=min(v[A%n+1],C+1);
		v[B%n+1]=min(v[B%n+1],C+2);
	}
	int pos=1;
	for(int i=2;i<=n;++i)if(v[i]<v[pos])pos=i;
	for(int i=pos%n+1,j=pos;i!=pos;j=i,i=i%n+1)v[i]=min(v[i],v[j]+2);
	for(int i=2;i<=n;++i)e[++m]=(Line){i-1,i,v[i]};
	e[++m]=(Line){1,n,v[1]};
	sort(&e[1],&e[m+1]);
	for(int i=1;i<=n;++i)f[i]=i;
	for(int i=1;i<=m;++i)
	{
		int u=getf(e[i].u),v=getf(e[i].v);
		if(u==v)continue;
		ans+=e[i].w;f[u]=v;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 9600
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a[5]=='0'&&(a[6]=='1'||a[6]=='2'||a[6]=='3'||a[6]=='4')){
		cout<<"Heisei"<<endl;
	}
	else{
		cout<<"TBD"<<endl;
	}
	return 0;
}

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

#pragma GCC optimize("O3")

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

int main() {
    int a, b;
    cin >> a >> b;
    string s_a, s_b;
    s_a = to_string(a);
    char const *c_a = s_a.c_str();
    s_b = to_string(b);
    char const *c_b = s_b.c_str();
    s_a = string(b, *c_a);
    s_b = string(a, *c_b);
    if(s_a >= s_b) cout << s_b;
    else cout << s_a;
    
    return 0;
}


Measured memory_bytes: 3688
#include<iostream>
#include <cstdio>
#include<vector>
#include<queue>
#include<algorithm>
 
using namespace std;
int main(void){
    int N, count = 0;
    long long result = 0;
    scanf("%d", &N);
    char tmp[11];
    vector<string> S(N);
    queue<long long> q;
 
    //入力してソート--O(N)
    for(int i = 0; i < N; i++){
        scanf("%s", tmp);
        S[i] = tmp;
        sort(S[i].begin(), S[i].end());//ソート--O(10log10)
    }
    sort(S.begin(), S.end());
 
    //キューに同じ組み合わせの文字列の数を追加--O(N)
    while (S.size() != 1){
        auto itr = S.end() - 1;
        if (*itr == *(itr - 1)){
            count++;
        }
        else{
        if(count != 0){
            q.push(count + 1);
            count = 0;
        }
        else
            count = 0;
        }
        S.pop_back();
    }
 
    if(count != 0){
        q.push(count + 1);
    }
 
    //キューに入った組み合わせの計算--O(N)
    while(!q.empty()){
        long long num = q.front();
        //numC2の計算
        result += num * (num - 1) / 2;
        q.pop();
    }
 
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 5888
# -*- coding: utf-8 -*-
def solve():
    N, T = map(int, input().split())
    min_c = 'TLE'
    for _ in range(N):
        c, t = map(int, input().split())
        if t <= T:
            if min_c=='TLE' or c<min_c:
                min_c = c
    res = min_c
    return str(res)

if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 3060
n=int(input())
sumt=1
suma=1
for i in range(n):
    t,a=map(int,input().split())
    check=0
    k=int(max(sumt//t,suma//a))
    while check==0:
        if sumt<=t*k and suma<=a*k:
            check+=1
            sumt=t*k
            suma=a*k
        k+=1
print(sumt+suma)    

Measured memory_bytes: 3060
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>

using namespace std;

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

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

int main()
{
    int n;
    cin >> n;
    int x[n] = {};
    int sortx[n] = {};
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
        sortx[i] = x[i];
    }
    sort(sortx, sortx + n);

    //less median, greater median
    int lm = sortx[(n / 2) - 1];
    int gm = sortx[n / 2];
    for (int i = 0; i < n; i++)
    {
        if (x[i] <= lm)
        {
            cout << gm << endl;
        }
        else
        {
            cout << lm << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3712
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,m,a[100111];
int b[100111],bn;
int main()
{
	getii(n,m);
	int cnt1=0;
	for(int i=1;i<=m;i++)geti(a[i]),cnt1+=a[i]&1;
	if(cnt1>2)
	{
		puts("Impossible");
		return 0;
	}
	for(int i=1;i<=m;i++)if(a[i]&1)
	{
		if(a[1]&1)swap(a[i],a[m]);
		else swap(a[i],a[1]);
	}
	if(m==1)
	{
		if(a[1]==1)
		{
			cout<<1<<endl<<1<<endl<<1<<endl;
			return 0;
		}
		else
		{
			cout<<a[1]<<endl;
			cout<<2<<endl;
			cout<<1<<" "<<a[1]-1<<endl;
			return 0;
		}
	}
	b[bn++]=a[1]+1;
	for(int i=2;i<m;i++)b[bn++]=a[i];
	if(a[m]!=1)b[bn++]=a[m]-1;
	for(int i=1;i<=m;i++)puti(a[i]);puts("");
	putsi(bn);
	for(int i=0;i<bn;i++)puti(b[i]);
	return 0;
}


Measured memory_bytes: 256
x=int(input())
if x<=99:
    print(0)
    exit()
if x<=105:
    print(1)
    exit()
dp=[0]*(x+1)
for i in range(100):
    dp[i]=0
for i in range(100,106):
    dp[i]=1
for i in range(106,x+1):
    if dp[i-100]==1 or dp[i-101]==1 or dp[i-102]==1 or dp[i-103]==1 or dp[i-104]==1 or dp[i-105]==1:
        dp[i]=1
print(dp[-1])

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m;
  long long int n,s=0;
  cin>>n>>m;
  long long int a;
  for(int i=0;i<m;i++){
    cin>>a;s+=a;
  }
  if(s<=n)cout<<n-s;
  else cout<<-1;
}


Measured memory_bytes: 3620
n = int(input())
s = list(input())

ans = 0
for i in range(n-1):
    x = s[:i+1]
    y = s[i+1:]
    tmp = 0
    subset = set()
    for string in x:
        if string in y and string not in subset:
            tmp += 1
            subset.add(string)
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;



int main () {

    int n,m; cin >>n>>m;
    vector<vector<bool> > adj(n, vector<bool>(n, false));
    for (int i = 0; i < m; i++) {
        int v; cin >> v; --v;
        int u; cin >> u; --u;
        adj[v][u] = true;
        adj[u][v] = true;
    }

    vector<vector<ll> > dp(1<<n, vector<ll>(n, 0));
    dp[1][0] = 1;

    for(int bit = 0; bit < (1<<n)-1; bit++){
        for(int k = 0; k < n; k++){
            for(int j = 0; j < n; j++){
                if(!(bit & (1 << k)) && (bit & (1 << j)) && adj[j][k]) {
                    dp[bit | (1<<k)][k] += dp[bit][j];
                }
            } 
        }
    }

    ll sum = 0;
    for (int i = 0; i < n; i++) {
        sum += dp[(1<<n) - 1][i];
    }
    cout << sum << endl;

    return 0;
}




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

int main() {
	int n, h, w, a, b;
	cin >> n >> h >> w;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (a >= h&&b >= w)cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    int n,x;
    while (scanf("%d",&n)!=EOF) {
        bool ans=true;
        for (int i=0;i<n;i++) {
            scanf("%d",&x);
            if (x%2==0) {
                if (x%3==0||x%5==0)
                    continue;
                else
                    ans=false;
            }

        }
        printf("%s\n",ans?"APPROVED":"DENIED");
    }
    return 0;
}


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

using namespace std;

typedef struct names {
	string en;
	int eby;
	int wy;
};

/*
void sort(names array[], int S) {
	int sorted, last;
	int i;
	names temp;

	sorted = S;
	while(sorted) {
		last = 0;
		for(i = 0; i < sorted - 1; i++) {
			if(array[i].wy > array[i + 1].wy) {
				temp = array[i];
				array[i] = array[i + 1];
				array[i + 1] = temp;
				last = i + 1;
			}
		}

		sorted = last;
	}
}
*/

bool comp(names A, names B) {
	return A.wy < B.wy;
}

int main(void) {
	int N, Q;
	names data[1024];
	int query;
	int next;

	while(cin >> N >> Q, N != 0 || Q != 0) {
		for(int i = 0; i < N; i++)
			cin >> data[i].en >> data[i].eby >> data[i].wy;
		sort(data, data + N, comp);
		
		for(int i = 0; i < Q; i++) {
			cin >> query;
			for(next = 0; query > data[next].wy && next < N; next++);
			if(next == N) {
				cout << "Unknown" << endl;
				continue;
			}

			if(data[next].eby + query - data[next].wy > 0)
				cout << data[next].en << " " << data[next].eby + query - data[next].wy << endl;
			else
				cout << "Unknown" << endl;
		}
	}
}

Measured memory_bytes: 1312
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	static final int INF = 2 << 28;
	static final long INF_L = 2L << 60;
	static final int  MOD = 1000000007;
	static final long MOD_L = 1000000007;
	public static void main(String[] args) {	
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int M = sc.nextInt();
		char[][] flag = new char[N][M];
		for(int i = 0; i < N; i++) {
			flag[i] = sc.next().toCharArray();
		}
		int MAX = INF;
		for(int i = 0; i < N-2; i++) {
			for(int j = i+1; j < N-1; j++) {
				int sum = 0;
				for(int k = 0; k <= i; k++) {
					for(int l = 0; l < M; l++) {
						if(flag[k][l] != 'W')sum++;
					}
				}
				for(int k = i+1; k <= j; k++) {
					for(int l = 0; l < M; l++) {
						if(flag[k][l] != 'B')sum++;
					}
				}
				for(int k = j+1; k < N; k++) {
					for(int l = 0; l < M; l++) {
						if(flag[k][l] != 'R')sum++;
					}
				}
				MAX = Math.min(MAX, sum);
			}
		}
		System.out.println(MAX);
	}
	
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
    	return (int)nextLong();
    }
}

Measured memory_bytes: 25432
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

struct Circle {
	int x, y, r, c;

	Circle(int _x, int _y, int _r, int _c) :x(_x), y(_y), r(_r), c(_c) {}
};

bool collision(Circle& c1, Circle& c2)
{
	return (c2.x - c1.x)*(c2.x - c1.x) + (c2.y - c1.y)*(c2.y - c1.y) < (c2.r + c1.r)*(c2.r + c1.r);
}

const int MAX = 24;

int n;
bool memo[1 << MAX];

void dfs(vector<Circle>& circles, int bit)
{
	memo[bit] = true;

	rep(i, n) {
		if ((bit >> i) % 2 == 0) {
			bool flag = true;

			//????????£?????????????????????
			rep(j, i) {
				if ((bit >> j) % 2 == 0) {
					if (collision(circles[i], circles[j]) == true) {
						flag = false;
					}
				}
			}

			if (flag == false) {
				continue;
			}

			for (int j = i + 1; j < n; j++) {
				if ((bit >> j) % 2 == 1) {
					continue;
				}

				if (circles[i].c != circles[j].c) {
					continue;
				}

				bool f = true;

				rep(k, j) {
					if ((bit >> k) % 2 == 0) {
						if (collision(circles[j], circles[k]) == true) {
							f = false;
						}
					}
				}

				if (f == false) {
					continue;
				}

				int b = bit;
				b = b | (1 << i);
				b = b | (1 << j);
				if (memo[b] == false) {
					dfs(circles, b);
				}
			}
		}
	}
}

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

		if (n == 0) {
			break;
		}

		vector<Circle> circles;

		rep(i, 1 << MAX) {
			memo[i] = false;
		}

		rep(i, n) {
			int x, y, r, c;

			cin >> x >> y >> r >> c;

			circles.push_back(Circle(x, y, r, c));
		}

		dfs(circles, 0);

		int ans = 0;

		rep(i, 1 << n) {
			int temp = 0;

			if (memo[i] == true) {
				rep(j, n) {
					if ((i >> j) % 2 == 1) {
						temp++;
					}
				}

				ans = max(ans, temp);
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 19476
s = list(map(int, input().split()))
dl = input()
stmp = [0] * 6

dr = {"N": [1, 5, 2, 3, 0, 4],
      "W": [2, 1, 5, 0, 4, 3],
      "S": [4, 0, 2, 3, 5, 1],
      "E": [3, 1, 0, 5, 4, 2]}
for d in dl:
    drs = dr[d]
    for i in range(6):
        stmp[i] = s[drs[i]]
    s = list(stmp)
    #print(s)
print(s[0])


Measured memory_bytes: 5600
L = list(input())
N = len(L)
mod = 10**9+7

S = [0]*(N+1)
for i in range(N):
    if L[i] == "1":
        S[i+1] = S[i] + 1
    else:
        S[i+1] = S[i]

ans = 0
for i in range(N):
    if S[i+1] > S[i]:
        ans += pow(3, N-i-1, mod)*pow(2, S[i], mod)
        ans %= mod

ans += pow(2, S[-1], mod)
print(ans%mod)

Measured memory_bytes: 7804
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int K;
  string S;
  cin  >>K>>S;
  
  int shupopopo =S.size();
  if(K >=shupopopo){cout<<S<<endl;}
  else{for(int i=0;i<K;i++){
 cout<<S.at(i);
  
  }
       cout<<"..."<<endl;
}
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {

    static long[] L = new long[90];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        L[0] = 2;
        L[1] = 1;
        System.out.println(lucas(n));
        sc.close();
    }

    public static long lucas(int n){
        if(L[n] != 0) return L[n];
        L[n] = lucas(n-1) + lucas(n-2);
        return L[n];
    }
}
 

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n + 1);
    rep0(i, n)cin >> a[i];
    a[n] = 0;
    ll cnt = 0,ans = 0;
    rep0(i, n + 1){
        if(a[i] == i + 1)++cnt;
        else{
            ans += (cnt + 1) / 2;
            cnt = 0;
        }
    }
    pf(ans);
    return 0;
}


Measured memory_bytes: 1024
x, n = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted([i for i in range(-102, 102)], reverse=True)

ans = {'diff':1000, 'ans':0}

for i in q:
    if not i in p:
        if abs(x-i) <= ans['diff']:
            ans['diff'] = abs(x-i)
            ans['ans'] = i

print(ans['ans'])


Measured memory_bytes: 9196