akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<endl;
#define ll long long int
#define pb push_back
#define in insert
#define mp make_pair
#define F first
#define S second
#define N 1000000
#define mod 1000000007
#define PI acos(-1)
int main()
{
	IOS
	int n,m;
	cin>>n>>m;
	char a[n+1][m+1];
	int i,j;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		cin>>a[i][j];
	}
	int dp[n+2][m+2];
	memset(dp,0,sizeof(dp));
	dp[1][1]=1;
	for(i=1;i<=n;i++)
	{
		if(i==1)
		j=2;
		else
		j=1;
		for(;j<=m;j++)
		{
			if(a[i][j]=='#')
			continue;
			dp[i][j]=(dp[i][j-1]%mod+dp[i-1][j]%mod)%mod;
		}
	}
	cout<<dp[n][m];
}

Measured memory_bytes: 5120
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

string A;
ll cnt[26];

int main(){
    cin>>A;

    rep(i,A.size()){
        cnt[A[i]-'a']++;
    }

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

    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

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

	ll cnt = 0;
	
	for (int i = 0; i < n - 1;i++) {
		if (a[i] > x) {
			cnt += a[i]-x;
			a[i] = x;
		}
		ll s = a[i] + a[i + 1];
		if (s > x) {
			cnt += s - x;
			a[i + 1] -= (s - x);
			
		}
	}

	cout << cnt << endl;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
typedef double ld;
typedef pair<int,int> p2;
typedef pair<p2,int> p3;
typedef vector<ll> vi;
const ll Mod = 7 + 1e9;
const ll INF32 = 5 + 2e9;
const ll INF64 = 5 + 1e18;
const ll MAX = 5+ 1e5;

int N,W,w[105],v[105];
ll dp[105][MAX];
int main()
{
    cin >> N >> W;
    for(int i=1; i<=N; i++)
        cin >> w[i] >> v[i];
    for(int i=1; i<=1e5; i++)
        dp[0][i] = INF64;

    for(int i=1; i<=N; i++)
        for(int j=0; j<=1e5; j++)
        {
            dp[i][j] = dp[i-1][j];
            if( j - v[i] >= 0 )
                dp[i][j] = min( dp[i][j] , w[i] + dp[i - 1][j - v[i]] );
        }
    int ans = 0;
    for(int i=1e5; i>=0; i--)
        if( dp[N][i] <= W )
        {
            ans = i;
            break;
        }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 80128
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;
//printf("%.10f\n", n);

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}

ll test[1234][1234];
signed main() {
	vector<vector<ll>> abc(27, vector<ll>(2));
	ll D, c, s; cin >> D;
	for (int h = 1; h <= 26; h++) {
		cin >> abc[h][0]; abc[h][1] = h;
	}
	sort(abc.begin() + 1, abc.end());
	for (int i = 0; i < D; i++) {
		for (int h = 0; h < 26; h++) {
			cin >> test[i][h];
		}
	}
	for (int h = 0; h < 14; h++) {
		vector<vector<ll>> v(676, vector<ll>(3)); ll uio = 0;
		for (int i = 0; i < 26; i++) {//26*h+i
			for (int j = 0; j < 26; j++) {
				v[uio][0] = test[26 * h + i][j];
				v[uio][1] = i; v[uio][2] = j; uio++;
			}
		}
		sort(v.begin(), v.end()); reverse(v.begin(), v.end());
		vector<ll> ok1(26), ok2(26), ans(26); ll jkl = 0;
		for (int h = 0; h < 676; h++) {
			if (ok1[v[h][1]] == 0 && ok2[v[h][2]] == 0) {
				ok1[v[h][1]]++; ok2[v[h][2]]++;
				ans[v[h][1]] = v[h][2]; jkl++;
			}
		}
		for (int h = 0; h < 26; h++) {
			cout << ans[h] + 1 << endl;
		}
	}
	cout << abc[26][1] << endl;
	return 0;
}

Measured memory_bytes: 5200
#include<iostream>
using namespace std;
int main(){
  	int n,x,i,j,s=0,b=-1;
  	int a[110];
  	cin >> n >> x;
  	for(i=0;i<n;i++){
    	cin >> a[i];
      	s+=a[i];
      	if(s>x && b==-1){
        	b=i+1;
        }
    }
    if(b==-1)
    	b=n+1;
  	cout << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> win[100005];
int played[100005], dp[100005];
void dfs(int x, int d) {
  vector<int> v;
  for (auto y : win[x]) {
    dfs(y, d);
    v.push_back(dp[y]);
  }
  sort(v.rbegin(), v.rend());
  for (int i = 0; i < v.size(); i++) {
    dp[x] = max(dp[x], v[i] + i + 1);
  }
}
int main() {
  int n, x;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> x;
    played[i]++;
    played[x]++;
    win[x].push_back(i);
  }
  dfs(1, 0);
  cout << dp[1] << endl;
  return 0;
}


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

int main() {
  int n, l;
  cin >> n >> l;
  vector<string> s(n);

  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
  }

  sort(s.begin(), s.end());

  string ans;

  for (int i = 0; i < n; i++) {
    ans += s.at(i);
  }

  cout << ans;
}


Measured memory_bytes: 256
using System;

class Program
{
    public static void Main(string[] args)
    {
        string input = Console.ReadLine();

        char temp1 = input[0];
        int temp1Num = 1;
        char temp2 = 'z';
        int temp2Num = 0;

        for (int i = 1; i < input.Length; i++)
        {
            if (input[i] == temp1)
            {
                temp1Num++;
            }
            else if (input[i] != temp1 && temp2 == 'z')
            {
                temp2 = input[i];
            }
        }

        for (int i = 0; i < input.Length; i++)
        {
            if (input[i] == temp2)
            {
                temp2Num++;
            }
        }

        if (temp1Num == 2 && temp2Num == 2)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
import math
def main():
    N = int(input())
    min_sum_xy = N + 1
    for x in range(2, math.floor(N**(1/2))+1):
        if N % x == 0:
            y = N // x
            min_sum_xy = min(x + y, min_sum_xy)
    print(min_sum_xy - 2)
main()

Measured memory_bytes: 9380
using System;

namespace abc055
{
    public class Program
    {
        public static void Main(string[] args)
        {
            ulong modulo = (ulong) Math.Pow(10, 9) + 7;
 
            int n = Convert.ToInt32(Console.ReadLine());
            ulong p = 1;

            for (int i =1; i <= n; i++)
            {
                p = p * (ulong) i;
                p %= modulo;
            }
            Console.WriteLine(p);
        }
    }
}

Measured memory_bytes: 11220
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b):
    g = gcd(a,b)
    return (a * b) // g

N = int(input())

result = 1
for i in range(N):
    result = lcm(result,int(input()))

print(result)


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

int main() {
	string s;
	cin>>s;
	if(s == "SUN")
		cout<<7;
	else if(s == "SAT")
		cout<<1;
	else if(s == "FRI")
		cout<<2;
	else if(s == "THU")
		cout<<3;
	else if(s == "WED")
		cout<<4;
	else if(s == "TUE")
		cout<<5;
	else if(s == "MON")
		cout<<6;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a, b;
int main () {
	cin >> a >> b;
	if (a==b){
		cout << "Draw" << endl;
	} else if (a==1){
		cout << "Alice" << endl;
	} else if (b==1){
		cout << "Bob" << endl;
	} else if (a<b){
		cout << "Bob" << endl;
	} else if (b<a){
		cout << "Alice" << endl;
	}
}


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

using namespace std;

int main() {
	string input;
	int a=0;
	bool b;
	cin >> input;
	for (int i = 0; i < input.length(); i++) a += input[i] - '0';
	if (stoi(input) % a == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
using namespace std;
#define pb push_back
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int x,k,d;cin >> x >> k >> d;
	if(x==0){
		if(k&1)	cout << d;
		else	cout << 0;
		return 0;
	}
	x=abs(x);
	int a=x%d;int b=x/d;
	if(b>=k){
		int ans=x;
		ans-=(k*d);
		cout << abs(ans);
		return 0;
	}
	k-=b;
	if(k&1)	cout << abs(d-a);
	else	cout << abs(a);


	return 0;
}


Measured memory_bytes: 3596
words = gets.chomp.split.map(&:downcase)
word_freq_hash = Hash.new(0)

words.each do |word|
  word_freq_hash[word] += 1
end

most_freq_word = word_freq_hash.max_by { |_, val| val }[0]
longest_word = word_freq_hash.max_by { |key, _| key.length }[0]

puts "#{most_freq_word} #{longest_word}"

Measured memory_bytes: 8580
S = list(input())[::-1]
T = list(input())[::-1]


for i in range(len(S) - len(T) + 1):
    for index, char in enumerate(S[i:i + len(T)], 0):
        if char != "?" and char != T[index]:
            break
    else:
        print("".join((S[:i] + T + S[i + len(T):])[::-1]).replace("?", "a"))
        break
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3060
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> lobo(n);

    for (int i = 0; i < n; ++i) {
        int x, l; cin >> x >> l;
        int st = x - l;
        int en = x + l;
        lobo[i] = make_pair(en, st);
    }

    int ans = 0;
    int now = INT_MIN;
    sort(lobo.begin(), lobo.end());
    for (int i = 0; i < n; ++i) {
        if (now <= lobo[i].second) {
            ans++;
            now = lobo[i].first;
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
S = input()

def solve(S):
    if S[0] != "A":
        return False
    s = S[1:]        
    if not "C" in s[1:-1]:
        return False
    i = s[1:-1].find("C") + 1
    s = s[:i] + s[i+1:]
    for c in s:
        if c < "a" or c > "z":
            return False
    return True

if solve(S):
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3064
n = input()
l = len(n)
ls = [4**int(x) for x in range(l)]
ls.sort(reverse=True)

cnt = 0
for i in range(4**l):
    can = []
    for j in range(l):
        if i//ls[j]==3:
            can.append("7")
            i = int(i-ls[j]*3)
        elif i//ls[j]==2:
            can.append("5")
            i = int(i-ls[j]*2)
        elif i//ls[j]==1:
            can.append("3")
            i = int(i-ls[j])
        else:
            can.append("0")
    can = int("".join(can))
    can = list(str(can))
    if len(set(can)&{"0"})==0 and len({"3","5","7"}-set(can))==0:
        pass
    else:
        continue
    can = int("".join(can))
    if int(n)>=can:
        cnt+=1
    else:
        pass

print(cnt)

Measured memory_bytes: 43996
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
#define rREP(i,b,n) for(int i = n; i >= b; i--)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const string lowercase = "abcdefghijklmnopqrstuvwxyz";
const string uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int gcd(int a, int b){return b ? gcd(b, a % b): a;}

int main()
{
    int n, m;
    vi x, d;
    cin >> n >> m;

    REP(i,0,m){
        int xi;
        cin >> xi;
        x.push_back(xi);
    }

    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }

    sort(x.begin(), x.end());

    int ans = x[m-1] - x[0];
    REP(i,1,m){
        d.push_back(x[i] - x[i-1]);
    }
    sort(d.begin(), d.end(), greater<int>());

    REP(i,0,n-1){
        ans -= d[i];
    }
    cout << ans << endl;
    return 0;
}


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

namespace Atcoder
{
    class AtCodeeeeeeeeeeeeeeeeeeeer
    {
        static void Main(string[] args)
        {
            string A = Console.ReadLine();
            string B = Console.ReadLine();
            string ans = "EQUAL";
            if (A.Length==B.Length)
            {
                for (int i = 0; i < A.Length; i++)
                {
                    int a = A[i];
                    int b = B[i];
                    if (a>b)
                    {
                        ans = "GREATER";
                        break;
                    }
                    else if (a<b)
                    {
                        ans = "LESS";
                        break;
                    }
                }
            }
            else
            {
                if (A.Length > B.Length)
                {
                    ans = "GREATER";
                }
                else if (A.Length <B.Length)
                {
                    ans = "LESS";
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

		String ans ="";
		switch(b){
			case "A":
				ans = "T";
				break;
			case "C":
				ans = "G";
				break;
			case "G":
				ans = "C";
				break;
			case "T":
				ans = "A";
				break;
		}

        System.out.println(ans);


	}

}



Measured memory_bytes: 20820
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	int n;
	cin >> n;

	double sum = 0;
	for (int i = 0; i < n; i++) {
		double x;
		string u;
		cin >> x >> u;
		if (u == "JPY") {
			sum += x;
		}
		else {
			sum += x * 380000.0;
		}
	}

	COUT(setprecision(10) << sum);


	return 0;
}


Measured memory_bytes: 256
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/15/20 20:19:02
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  ll x,k,d; cin>>x>>k>>d;
  x = abs(x);
  ll ans;
  if (x/d > k) {
    ans = x-k*d;
  } else {
    ll f = x%d;
    ll c = x/d;
    if (c%2 == k%2) {
      ans = f;
    } else {
      ans = d-f;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int H = ty - sy;
    int W = tx - sx;
    for (int h = 0; h < H; h++){
        cout << 'U';
    }
    for (int w = 0; w < W; w++){
        cout << 'R';
    }
    for (int h = 0; h < H; h++){
        cout << 'D';
    }
    for (int w = 0; w < W + 1; w++){
        cout << 'L';
    }
    for (int h = 0; h < H + 1; h++){
        cout << 'U';
    }
    for (int w = 0; w < W + 1; w++){
        cout << 'R';
    }
    cout << 'D' << 'R';
    for (int h = 0; h < H + 1; h++){
        cout << 'D';
    }
    for (int w = 0; w < W + 1; w++){
        cout << 'L';
    }
    cout << 'U' << endl;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        int ans = 0;
        for(int i = 0; i <= n-3; i++)
        {
            if (s.Substring(i,3) == "ABC")
            {
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
S = raw_input()
S1, S2 = [], []

ans = pool = 0
for i in xrange(len(S)):
    if S[i] == "/" and len(S1) > 0:
        j = S1.pop()
        ans += i - j
        a = i - j
        while (len(S2) > 0 and S2[-1][0] > j):
            a += S2.pop()[1]
        S2.append([j, a])
    if S[i] == "\\":
        S1.append(i)
print ans
if len(S2) > 0:
    print len(S2), " ".join(map(str, [a for j, a in S2]))
else:
    print 0

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

int main() {
  int x, y,s;
  cin >> x>> y >> s;
  //cin >> y;

  if (x*y < s) 
      {
        cout << x*y << endl;
      }

   else if (x*y > s) //(x%500 > y)
         {
          cout << s << endl;
        }
   else 
   {
    cout << s << endl;
   }
   //else 
   //{
    //cout << "Yes" << endl;
   //}
   return 0;
    //else
        //{
         // cout << "No" << endl;
       // }
  

  //cout << "終了" << endl;
}



Measured memory_bytes: 256
import collections

h, w, n = [int(i) for i in input().split()]
s = [tuple(int(i) for i in input().split()) for j in range(n)]

def dictadd(d, si):
    dc = d
    for i in range(si[0]-2, si[0]+1):
        if 1 <= i <= h-2:
            for j in range(si[1]-2, si[1]+1):
                if 1 <= j <= w-2:
                    dc[(i, j)] += 1
    return dc


d = collections.defaultdict(lambda: 0)
dc = d

for i in s:
    dc = dictadd(dc, i)

dcv = list(dc.values())
ans = collections.defaultdict(lambda: 0)
tot = 0

for i in range(1, 10):
    ans[i] += dcv.count(i)
    tot += dcv.count(i)

ans[0] = (w-2)*(h-2)-tot


for i in range(0, 10):
    print(ans[i])

Measured memory_bytes: 169248
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <locale>
using namespace std;

int main()
{
  int n, k;
  string str;
  cin >> n >> k;
  cin >> str;
  string str2 = str;
  std::transform(str.begin() + k - 1, str.begin() + k, str2.begin() + k - 1, ::tolower);
  
  cout << str2 << endl;
 
  return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for(int i =0, j = s.size()-1; i<j; i++,j--){
        if(s[i] != s[j]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[505][505];
char r[505][505], b[505][505];
int main(){
	int h, w;
	scanf("%d%d", &h, &w);
	for(int i=1;i<=h;i++) scanf("%s", s[i]+1);
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			r[i][j] = '.';
			b[i][j] = '.';
			if(j == 1 || (i%2 == 1 && j != w)) r[i][j] = '#';
			else if(j == w || (i%2 == 0 && j != 1)) b[i][j] = '#';
			if(s[i][j] == '#') r[i][j] = '#', b[i][j] = '#';
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++) printf("%c", r[i][j]);
		printf("\n");
	}
	printf("\n");
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++) printf("%c", b[i][j]);
		printf("\n");
	}
}

Measured memory_bytes: 1536
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;

int main()
{
	vector<int> a,b;
  	int i, nmax;
	int n;
	cin >> n;
	for (i = 0; i < n; i++)
  	{
		int x;
		cin >> x;
		b.push_back(x);
	}
    nmax = 0;
	for (i = 0; i < n; i++)
    {
      if (i == 0)
      {
		nmax += b[i];
      }
      else if (i == n - 1)
      {
        nmax += b[i - 1];
      }
	  else
  	  {
        nmax += ((b[i] - b[i - 1]) > 0 ? b[i - 1] : b[i]);
  	  }
    }
  	cout << nmax;
 	 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

char str0[105];
char str1[105];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    scanf("%s%s", str0, str1);

    int i,j;
    for(i=0; i<n; i++) {
        if(strncmp(str0+i, str1, n-i)==0) {
            break;
        }
    }
    printf("%d\n", i+n);



    return 0;
}


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

k = []
s = []
ans = 0

for _ in range(m):
    a = list(map(int , input().split()))
    k.append(a[0])
    s.append(a[1:])

p = list(map(int , input().split()))

for bit in range(1<<n):
    for i in range(m):
        cnt = 0
        for sw in s[i]:
            if bit & 1<<(sw-1):
                cnt += 1
        if cnt % 2 != p[i]:
            break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 39792
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

T1,T2,A1,A2,B1,B2 = map(int,read().split())

# 一人止める

def F(T1,T2,A1,A2):
    if A1 == 0:
        return 'infinity'
    if A1 < 0:
        A1 = -A1
        A2 = -A2
    if A2 >= 0:
        return 0
    R = T1 * A1
    L = T2 * (-A2)
    dx = R - L
    if dx == 0:
        return 'infinity'
    if dx > 0:
        return 0
    dx = -dx
    ret = 2 * (R//dx) + 1
    if R % dx == 0:
        ret -= 1
    return ret

answer = F(T1,T2,A1-B1,A2-B2)
print(answer)

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,a; cin >> n;
  map<ll,ll> m;
  for (ll i = 0; i < n; ++i) {
    cin >> a; m[a] += 1;
  }
  if (m.size() == 1) {
    if (m.begin()->first == 0) puts("Yes"); else puts("No");
  }
  else if (m.size() == 2) {
    if (m.begin()->first == 0 && n%3 == 0 && m.begin()->second == n/3)
      puts("Yes"); else puts("No");
  }
  else if (m.size() == 3) {
    vector<ll> keys(3); ll pos = 0, x = 0;
    for (auto itr = m.begin(); itr != m.end(); ++itr) { 
      keys[pos] = itr->first; pos += 1;
      x ^= itr->first;
    }
    bool b1 = (x == 0);
    bool b2 = (m[keys[0]] == m[keys[1]] && m[keys[1]] == m[keys[2]]);
    if (b1&&b2) puts("Yes"); else puts("No");
  }
  else puts("No");
  return 0;
}


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

int main(){
	int N=0;
  cin>>N;
  
  if(N==1){
    cout<<"Hello World"<<endl;
    
    return 0;
    
  }else{
    int B,C;
    
    cin>>B>>C;
    
    
    cout<<B+C<<endl;
    
  }
  
  
}

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

struct vec{
    double x,y;
};

double inner_product(vec& a, vec& b){
    return a.x*b.x+a.y*b.y;
}

int main(void){
    vec p1,p2,p,p12;
    int q;
    cin >> p1.x >> p1.y >> p2.x >> p2.y;
    p12.x=p2.x-p1.x; p12.y=p2.y-p1.y;
    cin >> q;
    cout.precision(10);
    cout.setf(std::ios::showpoint);
    for(int i=0;i<q;i++){
        cin >> p.x >> p.y;
        p.x-=p1.x; p.y-=p1.y;
        double k=2*inner_product(p,p12)/inner_product(p12,p12);
        cout << fixed << p1.x+k*p12.x-p.x << " " << p1.y+k*p12.y-p.y << endl;
    }
    return 0;
}

Measured memory_bytes: 3244
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  int N;
  cin >> N;
  cout << N / 3 << LF;

  return 0;
}



Measured memory_bytes: 256
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

K = int(input())

d = defaultdict(int)
dd = set()
num = 7
cnt = 1
if K == 7:
    print(1)
    exit()
while num % K != 0:
    num = num*10 + 7
    num %= K
    if num in dd:
        print(-1)
        exit()
    dd.add(num)
    cnt += 1
    # print(dd)
print(cnt)

Measured memory_bytes: 158316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    int a,b,c,d,e; cin >>a >>b>>c>>d>>e;
    if(a == 0) {AA(1);}
    else if(b == 0) {AA(2);}
    else if(c == 0) {AA(3);}
    else if(d == 0) {AA(4);}
    else  AA(5);
    return 0;
}

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

int main() {
  int Tc;
  cin >> Tc;
  while(Tc--) {
    pair<int,int> d, p(0,0);
    pair<int,pair<int,int> > maxi(0, make_pair(0,0));
    while(cin >> d.first >> d.second && (d.first|d.second)) {
      p.first += d.first;
      p.second += d.second;
      maxi = max(maxi, make_pair(p.first*p.first+p.second*p.second, p));
    }
    cout << maxi.second.first << " " << maxi.second.second << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <cstdio>

int r,c;

int main(){
	scanf("%d %d", &r, &c);
	int f[r][c];
	for(int i=0; i<r; ++i){
		for(int j=0; j<c; ++j){
			scanf("%d", &f[i][j]);
		}
	}
	int k[r+1][c+1];
	
	int rss =0;
	for(int i=0; i<r; ++i){
		int rs=0;
		for(int j=0; j<c; ++j){
			rs += f[i][j];
		}
		k[i][c]=rs;
		rss += rs;
	}
	
	for(int j=0; j<c; ++j){
		int cs =0;
		for(int i=0; i<r; ++i){
			cs += f[i][j];
		}
		k[r][j]=cs;
	}
	
	for(int i=0; i<=r; ++i){
		if(i!=r){
			for(int j=0; j<=c; ++j){
				if(j!=c){
					printf("%d ", f[i][j]);
				}else{
					printf("%d\n", k[i][c]);
				}
			}
			
		}else{
			for(int l=0; l<c; ++l){
				printf("%d ", k[r][l]);
			}
			printf("%d\n", rss);
		}
	}
	
}


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

int main(){
  string s;
  int cnt =0;
  cin >> s;
  rep(i,s.size()){
    if(s.at(i)=='1') cnt++;
  }
  
  cout << cnt << endl;
  
}
    

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

int n, m;
vector<int> adj[100001];
bool vis[100001];

void dfs(int vtx){
	vis[vtx] = true;
	for(int i : adj[vtx])
		if(!vis[i]) dfs(i);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	int ans = -1;
	for(int i = 1; i <= n; i++)
		if(!vis[i])
			dfs(i), ans++;
	cout << ans << '\n';
	return 0;
}

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

int main(){
    int N,M,X,Y,x[100],y[100];
    cin >> N >> M >> X >> Y;
    int tmp;
    for(int i=0; i<N; i++)
    cin >>x[i];
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            if(x[i]>x[j]){
                tmp=x[j];
                x[j]=x[i];
                x[i]=tmp;
            }
        }
    }
    for(int i=0; i<M; i++)
    cin >>y[i];
    for(int i=0; i<M; i++){
        for(int j=i+1; j<M; j++){
            if(y[i]>y[j]){
                tmp=y[j];
                y[j]=y[i];
                y[i]=tmp;
            }
        }
    }
    if(x[N-1]<y[0] && X<y[0] && x[N-1]<Y && X<Y)
        cout << "No War" << endl;
    else
    cout <<"War" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
   
int main(){
    string N;
    cin >> N;
    for(int i = 0; i < 3; i++){
        if(N[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define irep(i,a,b) for(typeof(i) i = (a); i < (b); ++i)
#define itrep(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)

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

	ll A,B,C,K;
	cin >> A >> B >> C >> K;

	if (K <= A) {
		cout << K << endl;
	}
	else if(K <= A+B) {
		cout << A << endl;
	}
	else {
		cout << A - (K - (A + B)) << endl;
	}
	return(0);
}


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

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define pb push_back
#define mp make_pair

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

bool comparef(pii a,pii b){
	if(a.fi == b.fi){
		return a.se > b.se;
	}else{
		return a.fi < b.fi;
	}
}
void solve(){
	int N;
	cin >> N;
	vector<pii> v(N*3);
	long long a = 0;
	long long b = 0;
	long long c = 0;
	rep(i,3){
		rep(j,N){
			int tn;
			cin >> tn;
			v[i*N+j] = mp(tn,i);
		}
	}
	sort(v.begin(),v.end(),comparef);
	// rep(i,3){
	// 	rep(j,N){
	// 		cout << v[i*N+j].fi << "," << v[i*N+j].se<<endl;
	// 	}

	// }
	rep(i,3*N){
		switch(v[i].se){
			case 0:
				a++;
			break;
			case 1:
				b+=a;
			break;
			case 2:
				c+=b;
			break;
		}
	}
	cout << c << endl;
}

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

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

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a.at(i);
  }
  if (h <= sum) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

}
  
      
      

Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toInt() }
    val q = sc.nextInt()
    val bc = (0 until q).map { sc.next().toInt() to sc.next().toInt() }
    println(problem171d(n, a, q, bc))
}

fun problem171d(
    n: Int,
    a: List<Int>,
    q: Int,
    bc: List<Pair<Int, Int>>
): String {
    val ans = mutableListOf<Long>()
    var sum = 0L
    for (i in 0 until n) {
        sum += a[i]
    }
    ans.add(sum)
    val counts = mutableMapOf<Int, Int>()
    for (i in 0 until n) {
        val ai = a[i]
        if (counts[ai] == null) {
            counts[ai] = 0
        }
        counts[ai] = counts[ai]!!.plus(1)
    }
   for (i in 0 until q) {
       val (b, c) = bc[i]
       if (counts[b] == null) {
           ans.add(ans.last())
           continue
       }
       val bC = counts[b]!!
       val cC = counts[c]
       counts[c] = (cC ?: 0) + bC
       counts[b] = 0
       var s = ans.last()
       s -= b.toLong() * bC
       s += c.toLong() * bC
       ans.add(s)
   }
    return ans.drop(1).joinToString("\n")
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    //sの各要素をR:0 G:1 B:2に置き換えたもの
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        if(s[i] == 'R') a[i] = 0;
        if(s[i] == 'G') a[i] = 1;
        if(s[i] == 'B') a[i] = 2;
    }
    vector<ll> cnt(3);
    for(int i = 0;i < n;i++){
        cnt[a[i]]++;
    }
    ll ans = 1;
    for(int i = 0;i < 3;i++) ans *= cnt[i];
    for(int j = 0;j < n;j++){
        for(int i = 0;i < j;i++){
            int k = j + (j-i);
            if(k < n){
                if(a[i] == a[j]) continue;
                if(a[k] == a[j]) continue;
                if(a[i] == a[k]) continue;
                ans--;
            }
        }
    }
    cout << ans << endl;
}

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

const ll INF = 1LL << 60;

ll N;
vector<ll> A;
int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];

    vector<ll> sum(N + 1);

    rep(i, N) {
        sum[i + 1] = sum[i] + A[i]; 
        // cout << sum[i] << " " << A[i];
        // cout << endl;
    }

    ll total = 0;
    rep(i, N) {
        total += A[i];
    }
    // cout << total << endl;
    ll ans = INF;
    for (int i = 1; i <= N; i++) {
        // cout << sum[i] << endl;
        ll left = sum[i];
        ll right = total - left; 
        ll tmp = left -right;
        // cout << left << " " << right << endl;
        if (tmp < 0) tmp = -tmp;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    long long int t,n,i,j,k,l,sum,sum1,cnt,cnt1,flag,flag1,m,x,y,a,b,c,d,mid;
      cin>>k>>i>>j;
      flag=0;
      for(l=i;l<=j;l++)
      {
          if(l%k==0)
          {
              flag=1;
              break;
          }
      }
      if(flag==1)
      {
          cout<<"OK"<<endl;
      }
      else
      {
                cout<<"NG"<<endl;

      }
     return 0;

}




Measured memory_bytes: 3596
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define INF 10000000

using namespace std;

typedef pair<int,int> P;

int main(){
    int h,w,d[1005][1005];
    
    queue <P>que;
    cin>>h>>w;
  rep(i,h)rep(j,w)d[i][j]=INF;
    rep(i,h)rep(j,w){
        char a;
        cin>>a;
        if(a=='#'){
            que.push(P(i,j));
            d[i][j]=0;
            }
    }
    int ans=0;
    int dx[4]={-1,1,0,0};
    int dy[4]={0,0,-1,1};
    while(que.size()){
        P q=que.front();
        ans=max(ans,d[q.first][q.second]);
        que.pop();
        rep(i,4){
            int nx=q.first+dx[i];
            int ny=q.second+dy[i];
            if(0<=ny&&ny<w&&0<=nx&&nx<h&&d[nx][ny]==INF){
                d[nx][ny]=ans+1;
                que.push(P(nx,ny));
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12304
#include<stdio.h>

int main(){
  long n,i,j;
  long y;
  scanf("%ld %ld",&n,&y);
  for(i=0;i<=n;i++){
    for(j=0;i+j<=n;j++){
      if(i*10000+j*5000+(n-i-j)*1000==y){
        printf("%ld %ld %ld\n",i,j,n-i-j);
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
}

Measured memory_bytes: 128
d = {}
for i in range(26):
    d[i] = 0
s = input()
n = len(s)
for i in range(n):
    x = s[i]
    y = ord(x) - 97
    d[y] += 1
ans = 0
for i in range(26):
    ans += d[i]*(n-d[i])
ans = ans // 2 + 1
print(ans)

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


int N;
tpl blocks[1010];
ll dp[1010][10100];


ll rec(int pos, int weight){
    if(dp[pos][weight] >= 0) return dp[pos][weight];
    ll res = 0;
    if(pos == N){
        res = 0;
    }
    else{
        if(get<0>(blocks[pos]) >= weight){
            res = max(res, rec(pos + 1, min(10010, weight + get<1>(blocks[pos]))) + get<2>(blocks[pos]));
        }
        // 積まない
        res = max(res, rec(pos + 1, weight));
    }
    return dp[pos][weight] = res;
}

int main(){

    cin >> N;
    for(int i = 0; i < N; i++){
        int w, s, v;
        cin >> w >> s >> v;
        blocks[i] = tpl(s, w, v);
        
    }

    // sの小さい順番にソートしておく
    sort(blocks, blocks + N,
         [&](tpl t1, tpl t2) {
             int s1 = get<0>(t1);
             int w1 = get<1>(t1);
             int s2 = get<0>(t2);
             int w2 = get<1>(t2);
             return s1 + w1 < s2 + w2;
         });

    memset(dp, -1, sizeof(dp));
    cout << rec(0, 0) << endl;

    return 0;
}


Measured memory_bytes: 80000
import sys


n,m = map(int, input().split())
steps = [True] * (n+1)
for i in range(m):
    steps[int(input())] = False



dp = [0] * (n+1)
dp[0] = 1
dp[1] = 1
if n >= 2:
    dp[2] = 2

## 散弾未満の時
if n == 1:
    if not steps[1]:
        print(0)
    else:
        print(1)
    exit()
elif n == 2:
    if not steps[2]:
        print(0)
        exit()
    else:
        if not steps[1]:
            print(1)
        else:
            print(2)
        exit()


ans = 1

l = 0
r = 0
idx = 0
finished = 2
while l < len(steps):

    if idx >= len(steps):
        if r-l > finished:
            for i in range(finished+1, r-l+1):
                dp[i] = dp[i-2] + dp[i-1]
                finished = i
        ans *= dp[r-l]
        break

    if steps[idx]:
        r = idx
    else:
        # idx段目が壊れてる
        #次も壊れてるなら終わり
        if steps[idx+1] == False:
            print(0)
            exit()
        else: 
            if r-l > finished:
                for i in range(finished+1, r-l+1):
                    dp[i] = dp[i-2] + dp[i-1]
                    finished = i
            ans *= dp[r-l]
            l = idx+1
            r = idx+1
    idx += 1

print(ans%(10**9+7))

Measured memory_bytes: 460916
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 2000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

vector <int> a1,a2;

int main()
{
	int n; cin>>n;
	if(n==3) printf("2\n1 3\n2 3\n");
	else
	{
		if(n%2==0)
		{
			for(int i=1;i<=n;i++)
			{
				for(int j=i+1;j<=n;j++)
				{
					if(i+j!=n+1) a1.pb(i),a2.pb(j);
				}
			}
		}
		else
		{
			n--;
			for(int i=1;i<=n;i++)
			{
				for(int j=i+1;j<=n;j++)
				{
					if(i+j!=n+1) a1.pb(i),a2.pb(j);
				}
			}
			rep(i,1,n) a1.pb(i),a2.pb(n+1);
		}
		cout<<a1.size()<<endl;
		rep(i,0,(int)a1.size()-1) printf("%d %d\n",a1[i],a2[i]);
	}
	return 0;
}

Measured memory_bytes: 3736
times = readlines.map(&:to_i)

times.sort! do |a,b|
  t = b % 10
  t == 0 ? -1 : a % 10 <=> b % 10
end

last = times.shift
total = 0
times.each do |t|
  total += t.quo(10).ceil * 10
end
total += last

puts total


Measured memory_bytes: 1788
#include<iostream>
#include<queue>
#define N 1 << 9
using namespace std;

int main(){
    int n;
    queue<int> qu;
    while(cin >>n){
        for(int i = 1; i <= N; i = i << 1){
            if((n & i) != 0){
                qu.push(i);
            }
        }
        while(qu.empty() != 1){
            cout <<qu.front();
            if(qu.size() != 1){
                cout <<" ";
            }
            qu.pop();
        }
        cout <<endl;
    }
    return 0;

}

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

using vi = vector<int>;
using vll = vector<long long>;

constexpr long long mod = 1000000007;

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

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

    string s;
    cin >> s;

    bool b = false;
    rep(i, s.size()) {
        if(s[i]=='7'){
            b = true;
        }
    }

    if(b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3648
#include<stdio.h>
int main(void){
  int a,b=0;
  char op;
  while(1){
  scanf("%d %c %d",&a,&op,&b);
  if(op=='?')break;
  switch(op){
  case '+' :printf("%d\n",a+b);break;
  case '-' :printf("%d\n",a-b);break;
  case '*' :printf("%d\n",a*b);break;
  case '/' :printf("%d\n",a/b);break;
  }
}
  return 0;
}



Measured memory_bytes: 2036
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll a,b;
cin>>a>>b;
if(b<10&&a<10){
    cout<<a*b<<endl;
}
else{
    cout<<"-1"<<endl;
}
}









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

using namespace std;

int main(){
	int N; cin>>N;
  	set<int> se;
  	int tmp=N,ans=2;
  	se.insert(N);
  	while(1){
      	if(tmp%2==0) tmp/=2;
      	else tmp=tmp*3+1;
      	
      	if(se.count(tmp)==1) break;
    	se.insert(tmp);
      	ans++;
    }
  printf("%d",ans);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=min((a), (b))

const int MOD=1000000007;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

bool a[30], b[30];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	cin>>n>>s;
	int ans=0;
	REP(i, n-1){
		REP(j, 26){
			a[j]=false;
			b[j]=false;
		}
		int tmp=0;
		REP(j, i+1) a[s[j]-'a']=true;
		FOR(j, i+1, n) b[s[j]-'a']=true;
		REP(j, 26){
			if(a[j] && b[j]) ++tmp;
		}
		ans=max(ans, tmp);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn main() {
    input! {
        a: usize,
    }

    echo!(a + a * a + a * a * a);
}


Measured memory_bytes: 2124
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val c = sc.nextInt()
  val k = sc.nextInt()
  val t = (1..n).map { sc.nextInt() }.sorted()


  var ki = t[0] + k
  var count = 0
  var ans = 1
  for (ti in t) {
    if (count == c || ti > ki) {
      count = 1
      ans++
      ki = ti + k
      continue
    }
    count++
  }

  println(ans)
}

Measured memory_bytes: 63224
#include<stdio.h>
int main(void){
    int n,m;
    scanf("%d%d",&n,&m);
    int a[m];
    for(int i=0;m>i;++i)
    scanf("%d",&a[i]);
    int sum=0;
    for(int i=0;m>i;++i){
        sum+=a[i];
    }
    if(n-sum<0)
    printf("-1");
    else
    {
        printf("%d",n-sum);
    }
    return 0;
}

Measured memory_bytes: 1728
from fractions import gcd

# input
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

if len(x) == 1:
    print(abs(X - x[0]))
else:
    k = [
        abs(X - p)
        if i == 0
        else
        abs(p - x[i - 1])
        for i, p in enumerate(x)
    ]
    D = gcd(k[0], k[1])
    for n in range(2, N):
        D = gcd(D, k[n])
    
    print(D)

Measured memory_bytes: 16296
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define For(i,n) for(ll i = 1 ; i < n ; i++)

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  ll a,b;cin>>a>>b;
  bool found = false;
  For(i,10000){
    if((i*8)/100 == a && (i*10)/100 == b){cout<<i;found = true;break;}
  }
  if(!found)cout<<-1;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    A = LI()
    c = Counter(A)
    if N % 2 != 0 and c[0] != 1:
        print(0)
        exit()
        
    for i in range(1,(N + 1) // 2):
        if c[i*2-(N%2==0)] != 2:
            print(0)
            exit()
    print(pow(2,N//2,mod))
if __name__ == '__main__':
    main()


Measured memory_bytes: 55896